Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…y.git into 1.20
  • Loading branch information
khjxiaogu committed Jan 24, 2025
2 parents be75b20 + 57df6c6 commit 2dff659
Show file tree
Hide file tree
Showing 17 changed files with 790 additions and 629 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/publish_snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Publish Snapshots

on:
push:
branches: [ "1.20" ]
workflow_dispatch:
jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4
- name: Set up JDK 20
uses: actions/setup-java@v4
with:
java-version: '20'
distribution: 'temurin'

# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582
- name: Modify permission settings
run: chmod +x ./gradlew
- name: Read mod version from properties
id: read_property
uses: christian-draeger/[email protected]
with:
path: './gradle.properties'
properties: 'mod_version'
- name: Run data generation
run: ./gradlew runData -Pmod_version="${{steps.read_property.outputs.mod_version}}-snapshot${{github.run_number}}"
- name: Run build jar
run: ./gradlew jar -Pmod_version="${{steps.read_property.outputs.mod_version}}-snapshot${{github.run_number}}"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-binary
path: build/libs/*.jar
if-no-files-found: error
overwrite: true
- name: Download cosmaven from github
run: wget https://github.com/TeamMoegMC/CosMavenProxy/releases/latest/download/cosmavenproxy.jar
- name: Publish to cos maven
shell: bash
env:
COS_KEY: ${{ secrets.COS_SECRETKEY }}
COS_ID: ${{ secrets.COS_SECRETID }}
run: |
java -DCOS_SECRETID="$COS_ID" -DCOS_SECRETKEY="$COS_KEY" -Dport=9999 -jar cosmavenproxy.jar &
./gradlew publishMavenJavaPublicationToCOSRepository -Pmod_version="${{steps.read_property.outputs.mod_version}}-snapshot${{github.run_number}}"
dependency-submission:

runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: Set up JDK 20
uses: actions/setup-java@v4
with:
java-version: '20'
distribution: 'temurin'

# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class CarKilnRecipe extends IESerializableRecipe {
public final int tickEnergy;
public int maxProcess;

public CarKilnRecipe(ResourceLocation id, ItemStack[] output, IngredientWithSize[] inputs, FluidTagInput input_fluid, int time, int tickEnergy) {
public CarKilnRecipe (ResourceLocation id, ItemStack[] output, IngredientWithSize[] inputs, FluidTagInput input_fluid, int time, int tickEnergy) {
super(Lazy.of(()->output[0]), IIRecipes.CAR_KILN, id);
this.output = output;
this.inputs = inputs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package com.teammoeg.immersiveindustry.content.carkiln;

import blusunrize.immersiveengineering.api.ApiUtils;
import blusunrize.immersiveengineering.api.crafting.FluidTagInput;
import blusunrize.immersiveengineering.api.crafting.IERecipeSerializer;
import blusunrize.immersiveengineering.api.crafting.IngredientWithSize;
Expand All @@ -32,12 +31,8 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.crafting.conditions.ICondition.IContext;
import net.minecraftforge.fluids.FluidStack;

import java.util.ArrayList;

import javax.annotation.Nullable;

public class CarKilnRecipeSerializer extends IERecipeSerializer<CarKilnRecipe> {
@Override
public ItemStack getIcon() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public CrucibleContainer(MenuType<CrucibleContainer> type, int windowId, Invento
super(type, windowId,inventoryPlayer.player,6);
CrucibleState state=te.mbContext().getState();
process.bind(()->state.recipe.getProgressRatio());
fuelProcess.bind(()->state.burnTime*1f/state.burnTimeMax);
temperature.bind(()->state.temperature/100);
fuelProcess.bind(state::getBurnProgress);
temperature.bind(()->state.temperature);
tank=state.tank;
tankSlot.bind(()->tank.getFluid());
hasPreheater.bind(()->state.hasPreheater);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import blusunrize.immersiveengineering.common.util.sound.MultiblockSound;
import com.teammoeg.immersiveindustry.IIConfig;
import com.teammoeg.immersiveindustry.IIContent.IIMultiblocks;
import com.teammoeg.immersiveindustry.content.carkiln.CarKilnLogic;
import com.teammoeg.immersiveindustry.content.carkiln.CarKilnState;
import com.teammoeg.immersiveindustry.util.CapabilityFacing;
import com.teammoeg.immersiveindustry.util.ChangeDetectedItemHandler;
import com.teammoeg.immersiveindustry.util.IIUtil;
Expand Down Expand Up @@ -51,6 +49,12 @@

public class CrucibleLogic implements IClientTickableComponent<CrucibleState>, IMultiblockLogic<CrucibleState>, IServerTickableComponent<CrucibleState> {

public static final int MAX_TEMP = 1700;
public static final int TEMP_ABOVE_WHICH_REQUIRES_FANS = 1000;
public static final BlockPos FRONT_PREHEATER_REL_POS = new BlockPos(1, 0, -1);
public static final BlockPos BACK_PREHEATER_REL_POS = new BlockPos(1, 0, 3);
public static final int DEFAULT_ACTIVE_FAN_SPEED = 64;

public CrucibleLogic() {

}
Expand All @@ -65,6 +69,7 @@ public void ensureBurntime(IMultiblockContext<CrucibleState> context) {
if (totalTime > 0) {
// burnTime = IIConfig.COMMON.coke.get();
state.burnTime = totalTime;
state.burnTimeMax = totalTime;
ItemStack origin = inventory.getStackInSlot(4);
if (origin.getCount() == 1)
inventory.setStackInSlotNoChange(4, ItemStack.EMPTY);
Expand Down Expand Up @@ -96,17 +101,18 @@ public void tickServer(IMultiblockContext<CrucibleState> context) {
// new heating mechanism
ensureBurntime(context);
if (state.burnTime > 0) {
double coefficient = getFanSpeed(context) < 64 ? 0 : Math.sqrt(getFanSpeed(context)) / 8;
int fanspeed = getFanSpeed(context);
double coefficient = fanspeed < DEFAULT_ACTIVE_FAN_SPEED ? 0 : Math.sqrt(fanspeed) / 8;
if (coefficient == 0) {// Speed < 64, no boost
if (state.temperature > 1000) {
if (state.temperature > TEMP_ABOVE_WHICH_REQUIRES_FANS) {
state.temperature--;
} else {
state.active = true;
state.burnTime--;
state.temperature++;
}
} else {// Speed >= 64, higher temperature and faster speed up
if (state.temperature < 1700) {
if (state.temperature < MAX_TEMP) {
state.active = true;
state.burnTime--;
state.temperature++;
Expand Down Expand Up @@ -298,12 +304,12 @@ else if (position.side() == RelativeBlockFace.UP)
public void onEntityCollision(IMultiblockContext<CrucibleState> ctx, BlockPos posInMultiblock, Entity collided) {
if (posInMultiblock.getY() >= 2) {
if (!(collided instanceof ItemEntity)) {
if (collided instanceof LivingEntity col && ctx.getState().active)
if (collided instanceof LivingEntity col && ctx.getState().temperature>100)
col.hurt(ctx.getLevel().getRawLevel().damageSources().hotFloor(), 4);
return;
}
ItemEntity itemEntity = (ItemEntity) collided;
ItemStack insertItem = ItemHandlerHelper.insertItem(ctx.getState().inventory, itemEntity.getItem().copy(), false);
ItemStack insertItem = ItemHandlerHelper.insertItem(ctx.getState().inputHandler.getValue(), itemEntity.getItem().copy(), false);
if (insertItem.isEmpty()) {
itemEntity.remove(RemovalReason.DISCARDED);
return;
Expand All @@ -319,25 +325,31 @@ public boolean tryOutput(IMultiblockContext<CrucibleState> context) {
return update;
}

public <V> V getFromPreheater(IMultiblockContext<CrucibleState> context, Function<BlastFurnacePreheaterBlockEntity, V> getter, V orElse) {
return getBlast(context).map(getter).orElse(orElse);
}

public Optional<BlastFurnacePreheaterBlockEntity> getBlast(IMultiblockContext<CrucibleState> context) {
BlockEntity te = context.getLevel().getBlockEntity(new BlockPos(1, 0, 2));
if (te instanceof BlastFurnacePreheaterBlockEntity && ((BlastFurnacePreheaterBlockEntity) te).getFacing().equals(context.getLevel().getOrientation().front().getOpposite()))
return Optional.of((BlastFurnacePreheaterBlockEntity) te);
return Optional.empty();
public int getFromPreheater(IMultiblockContext<CrucibleState> context, Function<BlastFurnacePreheaterBlockEntity, Integer> getter, int orElse) {
Optional<BlastFurnacePreheaterBlockEntity> preheater1 = Optional.empty();
Optional<BlastFurnacePreheaterBlockEntity> preheater2 = Optional.empty();
BlockEntity te1 = context.getLevel().getBlockEntity(FRONT_PREHEATER_REL_POS);
BlockEntity te2 = context.getLevel().getBlockEntity(BACK_PREHEATER_REL_POS);
if (te1 instanceof BlastFurnacePreheaterBlockEntity && ((BlastFurnacePreheaterBlockEntity) te1).getFacing().equals(context.getLevel().getOrientation().front().getOpposite()))
preheater1 = Optional.of((BlastFurnacePreheaterBlockEntity) te1);
if (te2 instanceof BlastFurnacePreheaterBlockEntity && ((BlastFurnacePreheaterBlockEntity) te2).getFacing().equals(context.getLevel().getOrientation().front()))
preheater2 = Optional.of((BlastFurnacePreheaterBlockEntity) te2);
int result1 = preheater1.map(getter).orElse(orElse);
int result2 = preheater2.map(getter).orElse(orElse);
return result1 + result2;
}

public int getFanSpeed(IMultiblockContext<CrucibleState> context) {
boolean preheaterval = getFromPreheater(context, BlastFurnacePreheaterBlockEntity::doSpeedup, 0) > 0;
if (preheaterval != context.getState().hasPreheater) {
context.getState().hasPreheater = true;
boolean hasPreheater = getFromPreheater(context, BlastFurnacePreheaterBlockEntity::doSpeedup, 0) > 0;
int fanSpeed = 0;
if (hasPreheater) {
fanSpeed = DEFAULT_ACTIVE_FAN_SPEED;
}
if (hasPreheater != context.getState().hasPreheater) {
context.getState().hasPreheater = hasPreheater;
context.markDirtyAndSync();
return 64;
}
return 0;
return fanSpeed;
}
@Override
public void dropExtraItems(CrucibleState state, Consumer<ItemStack> drop) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

public class CrucibleScreen extends IEContainerScreen<CrucibleContainer> {
private static final ResourceLocation TEXTURE = new ResourceLocation(IIMain.MODID, "textures/gui/crucible.png");
public static final int ROOM_TEMPERATURE_KELVIN = 300;

public CrucibleScreen(CrucibleContainer container, Inventory inv, Component title) {
super(container, inv, title,TEXTURE);
Expand All @@ -57,7 +58,7 @@ protected void gatherAdditionalTooltips(int mouseX, int mouseY, Consumer<Compone
super.gatherAdditionalTooltips(mouseX, mouseY, addLine, addGray);
if (mouseX >= this.leftPos + 10 && mouseX < this.leftPos + 19 && mouseY > this.topPos + 10 && mouseY < this.topPos + 67) {
//Temperature in kelvins
int k = menu.temperature.getValue() *100 + 300;
int k = menu.temperature.getValue() + ROOM_TEMPERATURE_KELVIN;
addLine.accept(Component.translatable("gui.immersiveindustry.crucible.temperature_in_kelvin", k));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public CrucibleState(IInitialMultiblockContext<CrucibleState> capabilitySource)
outputFluidCap=CrucibleLogic.fluidout.getFacingCapability(capabilitySource, ForgeCapabilities.FLUID_HANDLER);
}

public float getBurnProgress() {
return burnTimeMax == 0 ? 0 : burnTime / (float) burnTimeMax;
}

@Override
public void writeSaveNBT(CompoundTag nbt) {
nbt.put("inv", inventory.serializeNBT());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,89 @@ public ItemStack quickMoveStack(Player playerIn, int index) {

@Override
public boolean moveItemStackTo(ItemStack pStack, int pStartIndex, int pEndIndex, boolean pReverseDirection) {
return super.moveItemStackTo(pStack, pStartIndex, pEndIndex, pReverseDirection);
boolean flag = false;
int i = pStartIndex;
if (pReverseDirection) {
i = pEndIndex - 1;
}

if (pStack.isStackable()) {
while (!pStack.isEmpty()) {
if (pReverseDirection) {
if (i < pStartIndex) {
break;
}
} else if (i >= pEndIndex) {
break;
}

Slot slot = this.slots.get(i);
ItemStack itemstack = slot.getItem();
if(slot.mayPlace(pStack))
if (!itemstack.isEmpty() && ItemStack.isSameItemSameTags(pStack, itemstack)) {
int j = itemstack.getCount() + pStack.getCount();
int maxSize = Math.min(slot.getMaxStackSize(), pStack.getMaxStackSize());
if (j <= maxSize) {
pStack.setCount(0);
itemstack.setCount(j);
slot.setChanged();
flag = true;
} else if (itemstack.getCount() < maxSize) {
pStack.shrink(maxSize - itemstack.getCount());
itemstack.setCount(maxSize);
slot.setChanged();
flag = true;
}
}

if (pReverseDirection) {
--i;
} else {
++i;
}
}
}

if (!pStack.isEmpty()) {
if (pReverseDirection) {
i = pEndIndex - 1;
} else {
i = pStartIndex;
}

while (true) {
if (pReverseDirection) {
if (i < pStartIndex) {
break;
}
} else if (i >= pEndIndex) {
break;
}

Slot slot1 = this.slots.get(i);
ItemStack itemstack1 = slot1.getItem();
if (itemstack1.isEmpty() && slot1.mayPlace(pStack)) {
if (pStack.getCount() > slot1.getMaxStackSize()) {
slot1.setByPlayer(pStack.split(slot1.getMaxStackSize()));
} else {
slot1.setByPlayer(pStack.split(pStack.getCount()));
}

slot1.setChanged();
flag = true;
break;
}

if (pReverseDirection) {
--i;
} else {
++i;
}
}
}

return flag;

}
public void receiveMessage(short btnId,int state) {

Expand Down
7 changes: 2 additions & 5 deletions src/main/java/com/teammoeg/immersiveindustry/util/IIUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@

public class IIUtil {

public IIUtil() {
// TODO Auto-generated constructor stub
}
public static boolean outputItem(IItemHandlerModifiable inventory,CapabilityReference<IItemHandler> outputCap,int slot) {
ItemStack stack = inventory.getStackInSlot(3);
ItemStack stack = inventory.getStackInSlot(slot);
if(!stack.isEmpty())
{
ItemStack nstack = Utils.insertStackIntoInventory(outputCap, stack, false);
if(nstack.getCount()!=stack.getCount()) {
inventory.setStackInSlot(3, nstack);
inventory.setStackInSlot(slot, nstack);
return true;
}

Expand Down
Loading

0 comments on commit 2dff659

Please sign in to comment.