Merge remote-tracking branch 'origin/1.12' into 1.12

This commit is contained in:
modmuss50 2019-03-17 15:08:03 +00:00
commit ee0d72223a

View file

@ -35,6 +35,7 @@ import net.minecraft.util.EnumFacing;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import reborncore.api.IToolDrop; import reborncore.api.IToolDrop;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.registration.RebornRegistry; import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry; import reborncore.common.registration.impl.ConfigRegistry;
@ -119,6 +120,7 @@ public class TileRollingMachine extends TilePowerAcceptor
InventoryCrafting craftMatrix = getCraftingMatrix(); InventoryCrafting craftMatrix = getCraftingMatrix();
currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, world); currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, world);
if (currentRecipe != null) { if (currentRecipe != null) {
setIsActive(true);
if (world.getTotalWorldTime() % 2 == 0) { if (world.getTotalWorldTime() % 2 == 0) {
Optional<InventoryCrafting> balanceResult = balanceRecipe(craftMatrix); Optional<InventoryCrafting> balanceResult = balanceRecipe(craftMatrix);
if (balanceResult.isPresent()) { if (balanceResult.isPresent()) {
@ -147,6 +149,8 @@ public class TileRollingMachine extends TilePowerAcceptor
inventory.setInventorySlotContents(outputSlot, stack); inventory.setInventorySlotContents(outputSlot, stack);
tickTime = 0; tickTime = 0;
hasCrafted = true; hasCrafted = true;
} else {
setIsActive(false);
} }
} }
if (hasCrafted) { if (hasCrafted) {
@ -167,13 +171,27 @@ public class TileRollingMachine extends TilePowerAcceptor
&& canMake(craftMatrix)) { && canMake(craftMatrix)) {
useEnergy(getEuPerTick(energyPerTick)); useEnergy(getEuPerTick(energyPerTick));
tickTime++; tickTime++;
} else {
setIsActive(false);
} }
} }
if (currentRecipeOutput.isEmpty()) { if (currentRecipeOutput.isEmpty()) {
tickTime = 0; tickTime = 0;
currentRecipe = null; currentRecipe = null;
setIsActive(canMake(getCraftingMatrix()));
} }
}
public void setIsActive(boolean active) {
if (active == isRunning){
return;
}
isRunning = active;
if (this.getWorld().getBlockState(this.getPos()).getBlock() instanceof BlockMachineBase) {
BlockMachineBase blockMachineBase = (BlockMachineBase)this.getWorld().getBlockState(this.getPos()).getBlock();
blockMachineBase.setActive(active, this.getWorld(), this.getPos());
}
this.getWorld().notifyBlockUpdate(this.getPos(), this.getWorld().getBlockState(this.getPos()), this.getWorld().getBlockState(this.getPos()), 3);
} }
public Optional<InventoryCrafting> balanceRecipe(InventoryCrafting craftCache) { public Optional<InventoryCrafting> balanceRecipe(InventoryCrafting craftCache) {