Refactor and import cleanup (Excluding network PR changed files)
This commit is contained in:
parent
a36a0e6f4a
commit
c4ef977f16
165 changed files with 1572 additions and 1625 deletions
|
@ -38,10 +38,9 @@ import reborncore.common.util.RebornInventory;
|
|||
|
||||
/**
|
||||
* @author drcrazy
|
||||
*
|
||||
*/
|
||||
public abstract class GenericMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||
implements IToolDrop, InventoryProvider, IRecipeCrafterProvider{
|
||||
implements IToolDrop, InventoryProvider, IRecipeCrafterProvider {
|
||||
|
||||
public String name;
|
||||
public int maxInput;
|
||||
|
@ -50,12 +49,12 @@ public abstract class GenericMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
public int energySlot;
|
||||
public RebornInventory<?> inventory;
|
||||
public RecipeCrafter crafter;
|
||||
|
||||
|
||||
/**
|
||||
* @param name String Name for a blockEntity. Do we need it at all?
|
||||
* @param maxInput int Maximum energy input, value in EU
|
||||
* @param maxEnergy int Maximum energy buffer, value in EU
|
||||
* @param toolDrop Block Block to drop with wrench
|
||||
* @param name String Name for a blockEntity. Do we need it at all?
|
||||
* @param maxInput int Maximum energy input, value in EU
|
||||
* @param maxEnergy int Maximum energy buffer, value in EU
|
||||
* @param toolDrop Block Block to drop with wrench
|
||||
* @param energySlot int Energy slot to use to charge machine from battery
|
||||
*/
|
||||
public GenericMachineBlockEntity(BlockEntityType<?> blockEntityType, String name, int maxInput, int maxEnergy, Block toolDrop, int energySlot) {
|
||||
|
@ -67,7 +66,7 @@ public abstract class GenericMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
this.energySlot = energySlot;
|
||||
checkTier();
|
||||
}
|
||||
|
||||
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter != null && crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
|
@ -83,7 +82,7 @@ public abstract class GenericMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
charge(energySlot);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return maxEnergy;
|
||||
|
@ -108,19 +107,19 @@ public abstract class GenericMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
public double getBaseMaxInput() {
|
||||
return maxInput;
|
||||
}
|
||||
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(PlayerEntity p0) {
|
||||
return new ItemStack(toolDrop, 1);
|
||||
}
|
||||
|
||||
|
||||
// InventoryProvider
|
||||
@Override
|
||||
public RebornInventory<?> getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
|
||||
// IRecipeCrafterProvider
|
||||
@Override
|
||||
public RecipeCrafter getRecipeCrafter() {
|
||||
|
|
|
@ -57,9 +57,10 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
|
|||
this.totalCookingTime = (int) (200 / TechRebornConfig.cookingScale);
|
||||
this.toolDrop = toolDrop;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks that we have all inputs and can put output into slot
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract boolean canSmelt();
|
||||
|
@ -73,6 +74,7 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
|
|||
/**
|
||||
* Returns the number of ticks that the supplied fuel item will keep the
|
||||
* furnace burning, or 0 if the item isn't fuel
|
||||
*
|
||||
* @param stack Itemstack of fuel
|
||||
* @return Integer Number of ticks
|
||||
*/
|
||||
|
@ -82,11 +84,12 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
|
|||
}
|
||||
return (int) (AbstractFurnaceBlockEntity.createFuelTimeMap().getOrDefault(stack.getItem(), 0) * TechRebornConfig.fuelScale);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns remaining fraction of fuel burn time
|
||||
* Returns remaining fraction of fuel burn time
|
||||
*
|
||||
* @param scale Scale to use for burn time
|
||||
* @return int scaled remaining fuel burn time
|
||||
* @return int scaled remaining fuel burn time
|
||||
*/
|
||||
public int getBurnTimeRemainingScaled(int scale) {
|
||||
if (totalBurnTime == 0) {
|
||||
|
@ -95,11 +98,12 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
|
|||
|
||||
return burnTime * scale / totalBurnTime;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns crafting progress
|
||||
* Returns crafting progress
|
||||
*
|
||||
* @param scale Scale to use for crafting progress
|
||||
* @return int Scaled crafting progress
|
||||
* @return int Scaled crafting progress
|
||||
*/
|
||||
public int getProgressScaled(int scale) {
|
||||
if (totalCookingTime > 0) {
|
||||
|
@ -110,6 +114,7 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
|
|||
|
||||
/**
|
||||
* Returns true if Iron Machine is burning fuel thus can do work
|
||||
*
|
||||
* @return Boolean True if machine is burning
|
||||
*/
|
||||
public boolean isBurning() {
|
||||
|
@ -136,24 +141,24 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
|
|||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag compoundTag) {
|
||||
super.toTag(compoundTag);
|
||||
compoundTag.putInt("BurnTime", burnTime);
|
||||
compoundTag.putInt("TotalBurnTime", totalBurnTime);
|
||||
compoundTag.putInt("Progress", progress);
|
||||
return compoundTag;
|
||||
super.toTag(compoundTag);
|
||||
compoundTag.putInt("BurnTime", burnTime);
|
||||
compoundTag.putInt("TotalBurnTime", totalBurnTime);
|
||||
compoundTag.putInt("Progress", progress);
|
||||
return compoundTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if(world.isClient){
|
||||
if (world.isClient) {
|
||||
return;
|
||||
}
|
||||
boolean isBurning = isBurning();
|
||||
if (isBurning) {
|
||||
--burnTime;
|
||||
}
|
||||
|
||||
|
||||
if (!isBurning && canSmelt()) {
|
||||
burnTime = totalBurnTime = getItemBurnTime(inventory.getStack(fuelSlot));
|
||||
if (burnTime > 0) {
|
||||
|
@ -168,17 +173,17 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isBurning() && canSmelt()) {
|
||||
++progress;
|
||||
if (progress == totalCookingTime) {
|
||||
progress = 0;
|
||||
smelt();
|
||||
}
|
||||
} else if(!canSmelt()) {
|
||||
} else if (!canSmelt()) {
|
||||
progress = 0;
|
||||
}
|
||||
|
||||
|
||||
if (isBurning != isBurning()) {
|
||||
inventory.setChanged();
|
||||
updateState();
|
||||
|
@ -198,7 +203,7 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
|
|||
public RebornInventory<?> getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(PlayerEntity entityPlayer) {
|
||||
|
@ -220,7 +225,7 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
|
|||
public void setTotalBurnTime(int totalBurnTime) {
|
||||
this.totalBurnTime = totalBurnTime;
|
||||
}
|
||||
|
||||
|
||||
public int getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ import techreborn.init.ModRecipes;
|
|||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.init.TRContent;
|
||||
|
||||
public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity implements BuiltScreenHandlerProvider {
|
||||
public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity implements BuiltScreenHandlerProvider {
|
||||
|
||||
int input1 = 0;
|
||||
int input2 = 1;
|
||||
|
@ -84,7 +84,7 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
|
|||
if (!inventory.getStack(output).isItemEqualIgnoreDamage(itemstack))
|
||||
return false;
|
||||
int result = inventory.getStack(output).getCount() + itemstack.getCount();
|
||||
return result <= inventory.getStackLimit() && result <= inventory.getStack(output).getMaxCount();
|
||||
return result <= inventory.getStackLimit() && result <= inventory.getStack(output).getMaxCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -121,28 +121,28 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||
return new ScreenHandlerBuilder("alloyfurnace").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().blockEntity(this)
|
||||
.slot(0, 47, 17)
|
||||
.slot(1, 65, 17)
|
||||
.outputSlot(2, 116, 35).fuelSlot(3, 56, 53)
|
||||
.sync(this::getBurnTime, this::setBurnTime)
|
||||
.sync(this::getProgress, this::setProgress)
|
||||
.sync(this::getTotalBurnTime, this::setTotalBurnTime)
|
||||
.addInventory().create(this, syncID);
|
||||
.addInventory().blockEntity(this)
|
||||
.slot(0, 47, 17)
|
||||
.slot(1, 65, 17)
|
||||
.outputSlot(2, 116, 35).fuelSlot(3, 56, 53)
|
||||
.sync(this::getBurnTime, this::setBurnTime)
|
||||
.sync(this::getProgress, this::setProgress)
|
||||
.sync(this::getTotalBurnTime, this::setTotalBurnTime)
|
||||
.addInventory().create(this, syncID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStackValid(int slotID, ItemStack stack) {
|
||||
return ModRecipes.ALLOY_SMELTER.getRecipes(world).stream()
|
||||
.anyMatch(rebornRecipe -> rebornRecipe.getRebornIngredients().stream()
|
||||
.anyMatch(rebornIngredient -> rebornIngredient.test(stack))
|
||||
);
|
||||
.anyMatch(rebornRecipe -> rebornRecipe.getRebornIngredients().stream()
|
||||
.anyMatch(rebornIngredient -> rebornIngredient.test(stack))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -47,12 +47,12 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
|
|||
int inputSlot = 0;
|
||||
int outputSlot = 1;
|
||||
public float experience;
|
||||
|
||||
|
||||
public IronFurnaceBlockEntity() {
|
||||
super(TRBlockEntities.IRON_FURNACE, 2, TRContent.Machine.IRON_FURNACE.block);
|
||||
this.inventory = new RebornInventory<>(3, "IronFurnaceBlockEntity", 64, this);
|
||||
}
|
||||
|
||||
|
||||
public void handleGuiInputFromClient(PlayerEntity playerIn) {
|
||||
if (playerIn instanceof ServerPlayerEntity) {
|
||||
ServerPlayerEntity player = (ServerPlayerEntity) playerIn;
|
||||
|
@ -65,7 +65,7 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
|
|||
}
|
||||
experience = 0;
|
||||
}
|
||||
|
||||
|
||||
private ItemStack getResultFor(ItemStack stack) {
|
||||
ItemStack result = RecipeUtils.getMatchingRecipes(world, RecipeType.SMELTING, stack);
|
||||
if (!result.isEmpty()) {
|
||||
|
@ -81,7 +81,7 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// AbstractIronMachineBlockEntity
|
||||
@Override
|
||||
protected void smelt() {
|
||||
|
@ -90,7 +90,7 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
|
|||
}
|
||||
ItemStack inputStack = inventory.getStack(inputSlot);
|
||||
ItemStack resultStack = getResultFor(inputStack);
|
||||
|
||||
|
||||
if (inventory.getStack(outputSlot).isEmpty()) {
|
||||
inventory.setStack(outputSlot, resultStack.copy());
|
||||
} else if (inventory.getStack(outputSlot).isItemEqualIgnoreDamage(resultStack)) {
|
||||
|
@ -103,12 +103,12 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
|
|||
inventory.setStack(inputSlot, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean canSmelt() {
|
||||
if (inventory.getStack(inputSlot).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ItemStack outputStack = getResultFor(inventory.getStack(inputSlot));
|
||||
if (outputStack.isEmpty())
|
||||
return false;
|
||||
|
@ -130,19 +130,19 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
|
|||
super.fromTag(blockState, compoundTag);
|
||||
experience = compoundTag.getFloat("Experience");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag compoundTag) {
|
||||
super.toTag(compoundTag);
|
||||
compoundTag.putFloat("Experience", experience);
|
||||
return compoundTag;
|
||||
super.toTag(compoundTag);
|
||||
compoundTag.putFloat("Experience", experience);
|
||||
return compoundTag;
|
||||
}
|
||||
|
||||
// IContainerProvider
|
||||
public float getExperience() {
|
||||
return experience;
|
||||
}
|
||||
|
||||
|
||||
public void setExperience(float experience) {
|
||||
this.experience = experience;
|
||||
}
|
||||
|
|
|
@ -42,30 +42,30 @@ import techreborn.init.TRContent;
|
|||
import techreborn.utils.MessageIDs;
|
||||
|
||||
public class AlarmBlockEntity extends BlockEntity
|
||||
implements Tickable, IToolDrop {
|
||||
implements Tickable, IToolDrop {
|
||||
private int selectedSound = 1;
|
||||
|
||||
public AlarmBlockEntity() {
|
||||
super(TRBlockEntities.ALARM);
|
||||
}
|
||||
|
||||
public void rightClick() {
|
||||
if (world.isClient) {
|
||||
return;
|
||||
}
|
||||
public void rightClick() {
|
||||
if (world.isClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedSound < 3) {
|
||||
selectedSound++;
|
||||
} else {
|
||||
selectedSound = 1;
|
||||
}
|
||||
if (selectedSound < 3) {
|
||||
selectedSound++;
|
||||
} else {
|
||||
selectedSound = 1;
|
||||
}
|
||||
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.alarmID, new TranslatableText("techreborn.message.alarm")
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.alarmID, new TranslatableText("techreborn.message.alarm")
|
||||
.formatted(Formatting.GRAY)
|
||||
.append(" Alarm ")
|
||||
.append(String.valueOf(selectedSound)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// BlockEntity
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag compound) {
|
||||
|
@ -87,12 +87,12 @@ public class AlarmBlockEntity extends BlockEntity
|
|||
// ITickable
|
||||
@Override
|
||||
public void tick() {
|
||||
if (world.isClient()){
|
||||
return;
|
||||
}
|
||||
if (world.getTime() % 25 != 0) {
|
||||
return;
|
||||
}
|
||||
if (world.isClient()) {
|
||||
return;
|
||||
}
|
||||
if (world.getTime() % 25 != 0) {
|
||||
return;
|
||||
}
|
||||
if (world.isReceivingRedstonePower(getPos())) {
|
||||
BlockAlarm.setActive(true, world, pos);
|
||||
switch (selectedSound) {
|
||||
|
@ -106,7 +106,7 @@ public class AlarmBlockEntity extends BlockEntity
|
|||
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM_3, SoundCategory.BLOCKS, 4F, 1F);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
BlockAlarm.setActive(false, world, pos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ import techreborn.init.TRBlockEntities;
|
|||
import techreborn.init.TRContent;
|
||||
|
||||
public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
|
||||
implements IToolDrop, InventoryProvider, BuiltScreenHandlerProvider {
|
||||
implements IToolDrop, InventoryProvider, BuiltScreenHandlerProvider {
|
||||
|
||||
public RebornInventory<ChargeOMatBlockEntity> inventory = new RebornInventory<>(6, "ChargeOMatBlockEntity", 64, this);
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
|
|||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
if(world.isClient){
|
||||
if (world.isClient) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < 6; i++) {
|
||||
|
@ -61,11 +61,11 @@ public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
|
|||
|
||||
if (Energy.valid(stack)) {
|
||||
Energy.of(this)
|
||||
.into(
|
||||
Energy
|
||||
.of(stack)
|
||||
)
|
||||
.move();
|
||||
.into(
|
||||
Energy
|
||||
.of(stack)
|
||||
)
|
||||
.move();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
|
|||
public double getBaseMaxInput() {
|
||||
return TechRebornConfig.chargeOMatBMaxInput;
|
||||
}
|
||||
|
||||
|
||||
// TileMachineBase
|
||||
@Override
|
||||
public boolean canBeUpgraded() {
|
||||
|
@ -117,7 +117,7 @@ public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
|
|||
@Override
|
||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||
return new ScreenHandlerBuilder("chargebench").player(player.inventory).inventory().hotbar().addInventory()
|
||||
.blockEntity(this).energySlot(0, 62, 25).energySlot(1, 98, 25).energySlot(2, 62, 45).energySlot(3, 98, 45)
|
||||
.energySlot(4, 62, 65).energySlot(5, 98, 65).syncEnergyValue().addInventory().create(this, syncID);
|
||||
.blockEntity(this).energySlot(0, 62, 25).energySlot(1, 98, 25).energySlot(2, 62, 45).energySlot(3, 98, 45)
|
||||
.energySlot(4, 62, 65).energySlot(5, 98, 65).syncEnergyValue().addInventory().create(this, syncID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class DrainBlockEntity extends MachineBaseBlockEntity {
|
|||
|
||||
protected Tank internalTank = new Tank("tank", FluidValue.BUCKET, this);
|
||||
|
||||
public DrainBlockEntity(){
|
||||
public DrainBlockEntity() {
|
||||
this(TRBlockEntities.DRAIN);
|
||||
}
|
||||
|
||||
|
@ -54,13 +54,13 @@ public class DrainBlockEntity extends MachineBaseBlockEntity {
|
|||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if(world.isClient){
|
||||
if (world.isClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (world.getTime() % 10 == 0) {
|
||||
|
||||
if(internalTank.isEmpty()) {
|
||||
if (internalTank.isEmpty()) {
|
||||
tryDrain();
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class DrainBlockEntity extends MachineBaseBlockEntity {
|
|||
return internalTank;
|
||||
}
|
||||
|
||||
private void tryDrain(){
|
||||
private void tryDrain() {
|
||||
// Position above drain
|
||||
BlockPos above = this.getPos().up();
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class DistillationTowerBlockEntity extends GenericMachineBlockEntity impl
|
|||
|
||||
@Override
|
||||
public void writeMultiblock(MultiblockWriter writer) {
|
||||
writer .translate(1, 0, -1)
|
||||
writer.translate(1, 0, -1)
|
||||
.fill(0, 0, 0, 3, 1, 3, TRContent.MachineBlocks.BASIC.getCasing().getDefaultState())
|
||||
.ringWithAir(Direction.Axis.Y, 3, 1, 3, TRContent.MachineBlocks.INDUSTRIAL.getCasing().getDefaultState())
|
||||
.ringWithAir(Direction.Axis.Y, 3, 2, 3, TRContent.MachineBlocks.BASIC.getCasing().getDefaultState())
|
||||
|
|
|
@ -65,7 +65,7 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
|
|||
@Override
|
||||
public void writeMultiblock(MultiblockWriter writer) {
|
||||
BlockState state = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
||||
writer .translate(1, 0, -1)
|
||||
writer.translate(1, 0, -1)
|
||||
.ring(Direction.Axis.Y, 3, 0, 3, (v, p) -> v.getBlockState(p) == state, state, null, null);
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
|
|||
|
||||
@Override
|
||||
public RecipeCrafter getRecipeCrafter() {
|
||||
return (RecipeCrafter) crafter;
|
||||
return crafter;
|
||||
}
|
||||
|
||||
// TilePowerAcceptor
|
||||
|
|
|
@ -51,7 +51,7 @@ public class ImplosionCompressorBlockEntity extends GenericMachineBlockEntity im
|
|||
|
||||
@Override
|
||||
public void writeMultiblock(MultiblockWriter writer) {
|
||||
writer .translate(-1, -3, -1)
|
||||
writer.translate(-1, -3, -1)
|
||||
.fill(0, 0, 0, 3, 1, 3, TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState())
|
||||
.ringWithAir(Direction.Axis.Y, 3, 1, 3, TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState())
|
||||
.fill(0, 2, 0, 3, 3, 3, TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState());
|
||||
|
|
|
@ -79,7 +79,7 @@ public class IndustrialBlastFurnaceBlockEntity extends GenericMachineBlockEntity
|
|||
return state == lava || state.getBlock() == Blocks.AIR;
|
||||
};
|
||||
|
||||
writer .translate(1, 0, -1)
|
||||
writer.translate(1, 0, -1)
|
||||
.fill(0, 0, 0, 3, 1, 3, casing, basic)
|
||||
.ring(Direction.Axis.Y, 3, 1, 3, casing, basic, maybeLava, lava)
|
||||
.ring(Direction.Axis.Y, 3, 2, 3, casing, basic, maybeLava, lava)
|
||||
|
|
|
@ -67,7 +67,7 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl
|
|||
public void writeMultiblock(MultiblockWriter writer) {
|
||||
BlockState basic = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState();
|
||||
BlockState advanced = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
||||
writer .translate(1, -1, -1)
|
||||
writer.translate(1, -1, -1)
|
||||
.fill(0, 0, 0, 3, 1, 3, basic)
|
||||
.ring(Direction.Axis.Y, 3, 1, 3, (view, pos) -> view.getBlockState(pos) == advanced, advanced, (view, pos) -> view.getBlockState(pos).getMaterial() == Material.WATER, Blocks.WATER.getDefaultState())
|
||||
.fill(0, 2, 0, 3, 3, 3, basic);
|
||||
|
|
|
@ -67,7 +67,7 @@ public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity impl
|
|||
public void writeMultiblock(MultiblockWriter writer) {
|
||||
BlockState basic = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState();
|
||||
BlockState advanced = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
||||
writer .translate(1, -1, -1)
|
||||
writer.translate(1, -1, -1)
|
||||
.fill(0, 0, 0, 3, 1, 3, basic)
|
||||
.ring(Direction.Axis.Y, 3, 1, 3, (view, pos) -> view.getBlockState(pos) == advanced, advanced, (view, pos) -> view.getBlockState(pos).getMaterial() == Material.WATER, Blocks.WATER.getDefaultState())
|
||||
.fill(0, 2, 0, 3, 3, 3, basic);
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
package techreborn.blockentity.machine.multiblock;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||
|
@ -56,7 +55,7 @@ public class VacuumFreezerBlockEntity extends GenericMachineBlockEntity implemen
|
|||
BlockState advanced = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState();
|
||||
BlockState industrial = TRContent.MachineBlocks.INDUSTRIAL.getCasing().getDefaultState();
|
||||
|
||||
writer .translate(-1, -3, -1)
|
||||
writer.translate(-1, -3, -1)
|
||||
.fill(0, 0, 0, 3, 1, 3, advanced)
|
||||
.ringWithAir(Direction.Axis.Y, 3, 1, 3, industrial)
|
||||
.fill(0, 2, 0, 3, 3, 3, advanced);
|
||||
|
|
|
@ -40,8 +40,8 @@ public class AlloySmelterBlockEntity extends GenericMachineBlockEntity implement
|
|||
|
||||
public AlloySmelterBlockEntity() {
|
||||
super(TRBlockEntities.ALLOY_SMELTER, "AlloySmelter", TechRebornConfig.alloySmelterMaxInput, TechRebornConfig.alloySmelterMaxEnergy, TRContent.Machine.ALLOY_SMELTER.block, 3);
|
||||
final int[] inputs = new int[] { 0, 1 };
|
||||
final int[] outputs = new int[] { 2 };
|
||||
final int[] inputs = new int[]{0, 1};
|
||||
final int[] outputs = new int[]{2};
|
||||
this.inventory = new RebornInventory<>(4, "AlloySmelterBlockEntity", 64, this);
|
||||
this.crafter = new RecipeCrafter(ModRecipes.ALLOY_SMELTER, this, 2, 1, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
@ -50,10 +50,10 @@ public class AlloySmelterBlockEntity extends GenericMachineBlockEntity implement
|
|||
@Override
|
||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||
return new ScreenHandlerBuilder("alloysmelter").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().blockEntity(this)
|
||||
.slot(0, 34, 47)
|
||||
.slot(1, 126, 47)
|
||||
.outputSlot(2, 80, 47).energySlot(3, 8, 72).syncEnergyValue().syncCrafterValue().addInventory()
|
||||
.create(this, syncID);
|
||||
.addInventory().blockEntity(this)
|
||||
.slot(0, 34, 47)
|
||||
.slot(1, 126, 47)
|
||||
.outputSlot(2, 80, 47).energySlot(3, 8, 72).syncEnergyValue().syncCrafterValue().addInventory()
|
||||
.create(this, syncID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,17 +40,17 @@ public class AssemblingMachineBlockEntity extends GenericMachineBlockEntity impl
|
|||
|
||||
public AssemblingMachineBlockEntity() {
|
||||
super(TRBlockEntities.ASSEMBLY_MACHINE, "AssemblingMachine", TechRebornConfig.assemblingMachineMaxInput, TechRebornConfig.assemblingMachineMaxEnergy, TRContent.Machine.ASSEMBLY_MACHINE.block, 3);
|
||||
final int[] inputs = new int[] { 0, 1 };
|
||||
final int[] outputs = new int[] { 2 };
|
||||
final int[] inputs = new int[]{0, 1};
|
||||
final int[] outputs = new int[]{2};
|
||||
this.inventory = new RebornInventory<>(4, "AssemblingMachineBlockEntity", 64, this);
|
||||
this.crafter = new RecipeCrafter(ModRecipes.ASSEMBLING_MACHINE, this, 2, 2, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
||||
// IContainerProvider
|
||||
@Override
|
||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||
return new ScreenHandlerBuilder("assemblingmachine").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().blockEntity(this).slot(0, 55, 35).slot(1, 55, 55).outputSlot(2, 101, 45).energySlot(3, 8, 72)
|
||||
.syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
|
||||
.addInventory().blockEntity(this).slot(0, 55, 35).slot(1, 55, 55).outputSlot(2, 101, 45).energySlot(3, 8, 72)
|
||||
.syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
if (ingredient != Ingredient.EMPTY) {
|
||||
boolean foundIngredient = false;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if(checkedSlots.contains(i)) {
|
||||
if (checkedSlots.contains(i)) {
|
||||
continue;
|
||||
}
|
||||
ItemStack stack = inventory.getStack(i);
|
||||
|
@ -150,9 +150,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
}
|
||||
if (!missingOutput) {
|
||||
if (hasOutputSpace(recipe.getOutput(), 9)) {
|
||||
return true;
|
||||
}
|
||||
return hasOutputSpace(recipe.getOutput(), 9);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -173,9 +171,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
return true;
|
||||
}
|
||||
if (ItemUtils.isItemEqual(stack, output, true, true)) {
|
||||
if (stack.getMaxCount() > stack.getCount() + output.getCount()) {
|
||||
return true;
|
||||
}
|
||||
return stack.getMaxCount() > stack.getCount() + output.getCount();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -191,7 +187,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
ItemStack bestSlot = inventory.getStack(i);
|
||||
if (ingredient.test(bestSlot)) {
|
||||
ItemStack remainderStack = getRemainderItem(bestSlot);
|
||||
if(remainderStack.isEmpty()) {
|
||||
if (remainderStack.isEmpty()) {
|
||||
bestSlot.decrement(1);
|
||||
} else {
|
||||
inventory.setStack(i, remainderStack);
|
||||
|
@ -202,7 +198,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
ItemStack stack = inventory.getStack(j);
|
||||
if (ingredient.test(stack)) {
|
||||
ItemStack remainderStack = getRemainderItem(stack);
|
||||
if(remainderStack.isEmpty()) {
|
||||
if (remainderStack.isEmpty()) {
|
||||
stack.decrement(1);
|
||||
} else {
|
||||
inventory.setStack(j, remainderStack);
|
||||
|
@ -223,7 +219,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
|
||||
private ItemStack getRemainderItem(ItemStack stack) {
|
||||
if(stack.getItem() instanceof ExtendedRecipeRemainder) {
|
||||
if (stack.getItem() instanceof ExtendedRecipeRemainder) {
|
||||
return ((ExtendedRecipeRemainder) stack.getItem()).getRemainderStack(stack);
|
||||
|
||||
} else if (stack.getItem().hasRecipeRemainder()) {
|
||||
|
@ -310,7 +306,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
List<Integer> possibleSlots = new ArrayList<>();
|
||||
for (int s = 0; s < currentRecipe.getPreviewInputs().size(); s++) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if(possibleSlots.contains(i)) {
|
||||
if (possibleSlots.contains(i)) {
|
||||
continue;
|
||||
}
|
||||
ItemStack stackInSlot = inventory.getStack(i);
|
||||
|
@ -325,8 +321,8 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
|
||||
}
|
||||
|
||||
if(!possibleSlots.isEmpty()){
|
||||
int totalItems = possibleSlots.stream()
|
||||
if (!possibleSlots.isEmpty()) {
|
||||
int totalItems = possibleSlots.stream()
|
||||
.mapToInt(value -> inventory.getStack(value).getCount()).sum();
|
||||
int slots = possibleSlots.size();
|
||||
|
||||
|
@ -334,11 +330,11 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
int[] split = new int[slots];
|
||||
int remainder = totalItems % slots;
|
||||
Arrays.fill(split, totalItems / slots);
|
||||
while (remainder > 0){
|
||||
while (remainder > 0) {
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
if(remainder > 0){
|
||||
split[i] +=1;
|
||||
remainder --;
|
||||
if (remainder > 0) {
|
||||
split[i] += 1;
|
||||
remainder--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -350,7 +346,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
boolean needsBalance = false;
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
int required = split[i];
|
||||
if(slotEnvTyperubution.contains(required)){
|
||||
if (slotEnvTyperubution.contains(required)) {
|
||||
//We need to remove the int, not at the int, this seems to work around that
|
||||
slotEnvTyperubution.remove(new Integer(required));
|
||||
} else {
|
||||
|
|
|
@ -40,8 +40,8 @@ public class ChemicalReactorBlockEntity extends GenericMachineBlockEntity implem
|
|||
|
||||
public ChemicalReactorBlockEntity() {
|
||||
super(TRBlockEntities.CHEMICAL_REACTOR, "ChemicalReactor", TechRebornConfig.chemicalReactorMaxInput, TechRebornConfig.chemicalReactorMaxEnergy, TRContent.Machine.CHEMICAL_REACTOR.block, 3);
|
||||
final int[] inputs = new int[] { 0, 1 };
|
||||
final int[] outputs = new int[] { 2 };
|
||||
final int[] inputs = new int[]{0, 1};
|
||||
final int[] outputs = new int[]{2};
|
||||
this.inventory = new RebornInventory<>(4, "ChemicalReactorBlockEntity", 64, this);
|
||||
this.crafter = new RecipeCrafter(ModRecipes.CHEMICAL_REACTOR, this, 2, 2, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class ChemicalReactorBlockEntity extends GenericMachineBlockEntity implem
|
|||
@Override
|
||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||
return new ScreenHandlerBuilder("chemicalreactor").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().blockEntity(this).slot(0, 34, 47).slot(1, 126, 47).outputSlot(2, 80, 47).energySlot(3, 8, 72)
|
||||
.syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
|
||||
.addInventory().blockEntity(this).slot(0, 34, 47).slot(1, 126, 47).outputSlot(2, 80, 47).energySlot(3, 8, 72)
|
||||
.syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
|
||||
}
|
||||
}
|
|
@ -40,12 +40,12 @@ public class CompressorBlockEntity extends GenericMachineBlockEntity implements
|
|||
|
||||
public CompressorBlockEntity() {
|
||||
super(TRBlockEntities.COMPRESSOR, "Compressor", TechRebornConfig.compressorMaxInput, TechRebornConfig.compressorMaxEnergy, TRContent.Machine.COMPRESSOR.block, 2);
|
||||
final int[] inputs = new int[] { 0 };
|
||||
final int[] outputs = new int[] { 1 };
|
||||
final int[] inputs = new int[]{0};
|
||||
final int[] outputs = new int[]{1};
|
||||
this.inventory = new RebornInventory<>(3, "CompressorBlockEntity", 64, this);
|
||||
this.crafter = new RecipeCrafter(ModRecipes.COMPRESSOR, this, 2, 1, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
||||
// IContainerProvider
|
||||
@Override
|
||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||
|
|
|
@ -58,19 +58,19 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
|||
private int cookTimeTotal;
|
||||
// Energy cost per tick of cooking
|
||||
final int EnergyPerTick = 1;
|
||||
|
||||
|
||||
public ElectricFurnaceBlockEntity() {
|
||||
super(TRBlockEntities.ELECTRIC_FURNACE );
|
||||
super(TRBlockEntities.ELECTRIC_FURNACE);
|
||||
}
|
||||
|
||||
|
||||
private void setInvDirty(boolean isDirty) {
|
||||
inventory.setChanged(isDirty);
|
||||
}
|
||||
|
||||
|
||||
private boolean isInvDirty() {
|
||||
return inventory.hasChanged();
|
||||
}
|
||||
|
||||
|
||||
private void updateCurrentRecipe() {
|
||||
if (inventory.getStack(inputSlot).isEmpty()) {
|
||||
resetCrafter();
|
||||
|
@ -99,11 +99,11 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
|||
return true;
|
||||
}
|
||||
if (ItemUtils.isItemEqual(inventory.getStack(slot), recipeOutput, true, true)) {
|
||||
return recipeOutput.getCount() + inventory.getStack(slot).getCount() <= recipeOutput.getMaxCount();
|
||||
return recipeOutput.getCount() + inventory.getStack(slot).getCount() <= recipeOutput.getMaxCount();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean canCraftAgain() {
|
||||
if (inventory.getStack(inputSlot).isEmpty()) {
|
||||
return false;
|
||||
|
@ -114,16 +114,16 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
|||
if (!canAcceptOutput(currentRecipe, outputSlot)) {
|
||||
return false;
|
||||
}
|
||||
return !(getEnergy() < currentRecipe.getCookTime() * getEuPerTick(EnergyPerTick));
|
||||
}
|
||||
|
||||
return !(getEnergy() < currentRecipe.getCookTime() * getEuPerTick(EnergyPerTick));
|
||||
}
|
||||
|
||||
private void resetCrafter() {
|
||||
currentRecipe = null;
|
||||
cookTime = 0;
|
||||
cookTimeTotal = 0;
|
||||
updateState();
|
||||
}
|
||||
|
||||
|
||||
private void updateState() {
|
||||
Block furnaceBlock = getWorld().getBlockState(pos).getBlock();
|
||||
|
||||
|
@ -134,7 +134,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
world.updateListeners(pos, world.getBlockState(pos), world.getBlockState(pos), 3);
|
||||
}
|
||||
|
||||
|
||||
private boolean hasAllInputs(SmeltingRecipe recipe) {
|
||||
if (recipe == null) {
|
||||
return false;
|
||||
|
@ -143,9 +143,9 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
|||
return false;
|
||||
}
|
||||
|
||||
return recipe.matches(inventory, world);
|
||||
}
|
||||
|
||||
return recipe.matches(inventory, world);
|
||||
}
|
||||
|
||||
private void craftRecipe(SmeltingRecipe recipe) {
|
||||
if (recipe == null) {
|
||||
return;
|
||||
|
@ -156,22 +156,21 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
|||
ItemStack outputStack = inventory.getStack(outputSlot);
|
||||
if (outputStack.isEmpty()) {
|
||||
inventory.setStack(outputSlot, recipe.getOutput().copy());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Just increment. We already checked stack match and stack size
|
||||
outputStack.increment(1);
|
||||
}
|
||||
|
||||
|
||||
inventory.getStack(inputSlot).decrement(1);
|
||||
}
|
||||
|
||||
|
||||
public int getProgressScaled(int scale) {
|
||||
if (cookTimeTotal != 0) {
|
||||
return cookTime * scale / cookTimeTotal;
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public int getCookTime() {
|
||||
return cookTime;
|
||||
}
|
||||
|
@ -179,7 +178,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
|||
public void setCookTime(int cookTime) {
|
||||
this.cookTime = cookTime;
|
||||
}
|
||||
|
||||
|
||||
public int getCookTimeTotal() {
|
||||
return cookTimeTotal;
|
||||
}
|
||||
|
@ -187,12 +186,13 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
|||
public void setCookTimeTotal(int cookTimeTotal) {
|
||||
this.cookTimeTotal = cookTimeTotal;
|
||||
}
|
||||
|
||||
// TilePowerAcceptor
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
charge(2);
|
||||
|
||||
|
||||
if (world.isClient) {
|
||||
return;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
|||
|
||||
if (isInvDirty()) {
|
||||
if (currentRecipe == null) {
|
||||
updateCurrentRecipe();
|
||||
updateCurrentRecipe();
|
||||
}
|
||||
if (currentRecipe != null && (!hasAllInputs(currentRecipe) || !canAcceptOutput(currentRecipe, outputSlot))) {
|
||||
resetCrafter();
|
||||
|
|
|
@ -40,12 +40,12 @@ public class ExtractorBlockEntity extends GenericMachineBlockEntity implements B
|
|||
|
||||
public ExtractorBlockEntity() {
|
||||
super(TRBlockEntities.EXTRACTOR, "Extractor", TechRebornConfig.extractorMaxInput, TechRebornConfig.extractorMaxEnergy, TRContent.Machine.EXTRACTOR.block, 2);
|
||||
final int[] inputs = new int[] { 0 };
|
||||
final int[] outputs = new int[] { 1 };
|
||||
final int[] inputs = new int[]{0};
|
||||
final int[] outputs = new int[]{1};
|
||||
this.inventory = new RebornInventory<>(3, "ExtractorBlockEntity", 64, this);
|
||||
this.crafter = new RecipeCrafter(ModRecipes.EXTRACTOR, this, 2, 1, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
||||
// IContainerProvider
|
||||
@Override
|
||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||
|
|
|
@ -42,20 +42,20 @@ public class IndustrialElectrolyzerBlockEntity extends GenericMachineBlockEntity
|
|||
|
||||
public IndustrialElectrolyzerBlockEntity() {
|
||||
super(TRBlockEntities.INDUSTRIAL_ELECTROLYZER, "IndustrialElectrolyzer", TechRebornConfig.industrialElectrolyzerMaxInput, TechRebornConfig.industrialElectrolyzerMaxEnergy, TRContent.Machine.INDUSTRIAL_ELECTROLYZER.block, 6);
|
||||
final int[] inputs = new int[] { 0, 1 };
|
||||
final int[] outputs = new int[] { 2, 3, 4, 5 };
|
||||
final int[] inputs = new int[]{0, 1};
|
||||
final int[] outputs = new int[]{2, 3, 4, 5};
|
||||
this.inventory = new RebornInventory<>(7, "IndustrialElectrolyzerBlockEntity", 64, this);
|
||||
this.crafter = new RecipeCrafter(ModRecipes.INDUSTRIAL_ELECTROLYZER, this, 2, 4, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
||||
// IContainerProvider
|
||||
@Override
|
||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||
return new ScreenHandlerBuilder("industrialelectrolyzer").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().blockEntity(this)
|
||||
.filterSlot(1, 47, 72, stack -> ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
|
||||
.filterSlot(0, 81, 72, stack -> !ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
|
||||
.outputSlot(2, 51, 24).outputSlot(3, 71, 24).outputSlot(4, 91, 24).outputSlot(5, 111, 24)
|
||||
.energySlot(6, 8, 72).syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
|
||||
.addInventory().blockEntity(this)
|
||||
.filterSlot(1, 47, 72, stack -> ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
|
||||
.filterSlot(0, 81, 72, stack -> !ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
|
||||
.outputSlot(2, 51, 24).outputSlot(3, 71, 24).outputSlot(4, 91, 24).outputSlot(5, 111, 24)
|
||||
.energySlot(6, 8, 72).syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
|
||||
}
|
||||
}
|
|
@ -47,7 +47,7 @@ public class PlayerDectectorBlockEntity extends PowerAcceptorBlockEntity impleme
|
|||
public PlayerDectectorBlockEntity() {
|
||||
super(TRBlockEntities.PLAYER_DETECTOR);
|
||||
}
|
||||
|
||||
|
||||
public boolean isProvidingPower() {
|
||||
return redstone;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class PlayerDectectorBlockEntity extends PowerAcceptorBlockEntity impleme
|
|||
boolean lastRedstone = redstone;
|
||||
redstone = false;
|
||||
if (canUseEnergy(TechRebornConfig.playerDetectorEuPerTick)) {
|
||||
for(PlayerEntity player : world.getPlayers()){
|
||||
for (PlayerEntity player : world.getPlayers()) {
|
||||
if (player.distanceTo(player) <= 256.0D) {
|
||||
PlayerDetectorType type = world.getBlockState(pos).get(BlockPlayerDetector.TYPE);
|
||||
if (type == PlayerDetectorType.ALL) {// ALL
|
||||
|
@ -84,7 +84,7 @@ public class PlayerDectectorBlockEntity extends PowerAcceptorBlockEntity impleme
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return TechRebornConfig.playerDetectorMaxEnergy;
|
||||
|
|
|
@ -61,7 +61,7 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
|
|||
public int gaugeProgressScaled(int scale) {
|
||||
return progress * scale / time;
|
||||
}
|
||||
|
||||
|
||||
public int getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
|
|||
public void setProgress(int progress) {
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
|
||||
public void recycleItems() {
|
||||
ItemStack itemstack = TRContent.Parts.SCRAP.getStack();
|
||||
final int randomchance = this.world.random.nextInt(chance);
|
||||
|
@ -77,8 +77,7 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
|
|||
if (randomchance == 1) {
|
||||
if (inventory.getStack(1).isEmpty()) {
|
||||
inventory.setStack(1, itemstack.copy());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
inventory.getStack(1).increment(itemstack.getCount());
|
||||
}
|
||||
}
|
||||
|
@ -86,16 +85,13 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
|
||||
public boolean canRecycle() {
|
||||
return !inventory.getStack(0) .isEmpty() && hasSlotGotSpace(1);
|
||||
return !inventory.getStack(0).isEmpty() && hasSlotGotSpace(1);
|
||||
}
|
||||
|
||||
public boolean hasSlotGotSpace(int slot) {
|
||||
if (inventory.getStack(slot).isEmpty()) {
|
||||
return true;
|
||||
} else if (inventory.getStack(slot).getCount() < inventory.getStack(slot).getMaxCount()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else return inventory.getStack(slot).getCount() < inventory.getStack(slot).getMaxCount();
|
||||
}
|
||||
|
||||
public boolean isBurning() {
|
||||
|
@ -129,13 +125,12 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
|
|||
boolean updateInventory = false;
|
||||
if (canRecycle() && !isBurning() && getEnergy() != 0) {
|
||||
setBurning(true);
|
||||
}
|
||||
else if (isBurning()) {
|
||||
} else if (isBurning()) {
|
||||
if (useEnergy(getEuPerTick(cost)) != getEuPerTick(cost)) {
|
||||
this.setBurning(false);
|
||||
}
|
||||
progress++;
|
||||
if (progress >= Math.max((int) (time* (1.0 - getSpeedMultiplier())), 1)) {
|
||||
if (progress >= Math.max((int) (time * (1.0 - getSpeedMultiplier())), 1)) {
|
||||
progress = 0;
|
||||
recycleItems();
|
||||
updateInventory = true;
|
||||
|
@ -144,7 +139,7 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
|
||||
updateState();
|
||||
|
||||
|
||||
if (updateInventory) {
|
||||
markDirty();
|
||||
}
|
||||
|
@ -174,13 +169,13 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
|
|||
public double getBaseMaxInput() {
|
||||
return TechRebornConfig.recyclerMaxInput;
|
||||
}
|
||||
|
||||
|
||||
// TileMachineBase
|
||||
@Override
|
||||
public boolean canBeUpgraded() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(PlayerEntity entityPlayer) {
|
||||
|
|
|
@ -153,7 +153,7 @@ public class ResinBasinBlockEntity extends MachineBaseBlockEntity {
|
|||
|
||||
this.isFull = blockState.get(ResinBasinBlock.FULL);
|
||||
|
||||
if(blockState.get(ResinBasinBlock.POURING)){
|
||||
if (blockState.get(ResinBasinBlock.POURING)) {
|
||||
this.isPouring = true;
|
||||
pouringTimer = TechRebornConfig.sapTimeTicks;
|
||||
}
|
||||
|
|
|
@ -59,9 +59,9 @@ import java.util.stream.Collectors;
|
|||
//TODO add tick and power bars.
|
||||
|
||||
public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||
implements IToolDrop, InventoryProvider, BuiltScreenHandlerProvider {
|
||||
implements IToolDrop, InventoryProvider, BuiltScreenHandlerProvider {
|
||||
|
||||
public int[] craftingSlots = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||
public int[] craftingSlots = new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8};
|
||||
private CraftingInventory craftCache;
|
||||
public RebornInventory<RollingMachineBlockEntity> inventory = new RebornInventory<>(12, "RollingMachineBlockEntity", 64, this);
|
||||
public boolean isRunning;
|
||||
|
@ -69,7 +69,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
@Nonnull
|
||||
public ItemStack currentRecipeOutput;
|
||||
public RollingMachineRecipe currentRecipe;
|
||||
private int outputSlot;
|
||||
private final int outputSlot;
|
||||
public boolean locked = false;
|
||||
public int balanceSlot = 0;
|
||||
|
||||
|
@ -177,12 +177,12 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
|
||||
public void setIsActive(boolean active) {
|
||||
if (active == isRunning){
|
||||
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 blockMachineBase = (BlockMachineBase) this.getWorld().getBlockState(this.getPos()).getBlock();
|
||||
blockMachineBase.setActive(active, this.getWorld(), this.getPos());
|
||||
}
|
||||
this.getWorld().updateListeners(this.getPos(), this.getWorld().getBlockState(this.getPos()), this.getWorld().getBlockState(this.getPos()), 3);
|
||||
|
@ -213,7 +213,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
List<Integer> possibleSlots = new ArrayList<>();
|
||||
for (int s = 0; s < currentRecipe.getPreviewInputs().size(); s++) {
|
||||
ItemStack stackInSlot = inventory.getStack(s);
|
||||
Ingredient ingredient = (Ingredient) currentRecipe.getPreviewInputs().get(s);
|
||||
Ingredient ingredient = currentRecipe.getPreviewInputs().get(s);
|
||||
if (ingredient != Ingredient.EMPTY && ingredient.test(sourceStack)) {
|
||||
if (stackInSlot.isEmpty()) {
|
||||
possibleSlots.add(s);
|
||||
|
@ -223,32 +223,32 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
}
|
||||
|
||||
if(!possibleSlots.isEmpty()){
|
||||
int totalItems = possibleSlots.stream()
|
||||
.mapToInt(value -> inventory.getStack(value).getCount()).sum();
|
||||
if (!possibleSlots.isEmpty()) {
|
||||
int totalItems = possibleSlots.stream()
|
||||
.mapToInt(value -> inventory.getStack(value).getCount()).sum();
|
||||
int slots = possibleSlots.size();
|
||||
|
||||
//This makes an array of ints with the best possible slot EnvTyperibution
|
||||
int[] split = new int[slots];
|
||||
int remainder = totalItems % slots;
|
||||
Arrays.fill(split, totalItems / slots);
|
||||
while (remainder > 0){
|
||||
while (remainder > 0) {
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
if(remainder > 0){
|
||||
split[i] +=1;
|
||||
remainder --;
|
||||
if (remainder > 0) {
|
||||
split[i] += 1;
|
||||
remainder--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Integer> slotEnvTyperubution = possibleSlots.stream()
|
||||
.mapToInt(value -> inventory.getStack(value).getCount())
|
||||
.boxed().collect(Collectors.toList());
|
||||
.mapToInt(value -> inventory.getStack(value).getCount())
|
||||
.boxed().collect(Collectors.toList());
|
||||
|
||||
boolean needsBalance = false;
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
int required = split[i];
|
||||
if(slotEnvTyperubution.contains(required)){
|
||||
if (slotEnvTyperubution.contains(required)) {
|
||||
//We need to remove the int, not at the int, this seems to work around that
|
||||
slotEnvTyperubution.remove(new Integer(required));
|
||||
} else {
|
||||
|
@ -276,10 +276,10 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
}
|
||||
if (bestSlot == null
|
||||
|| bestSlot.getLeft() == balanceSlot
|
||||
|| bestSlot.getRight() == sourceStack.getCount()
|
||||
|| inventory.getStack(bestSlot.getLeft()).isEmpty()
|
||||
|| !ItemUtils.isItemEqual(sourceStack, inventory.getStack(bestSlot.getLeft()), true, true)) {
|
||||
|| bestSlot.getLeft() == balanceSlot
|
||||
|| bestSlot.getRight() == sourceStack.getCount()
|
||||
|| inventory.getStack(bestSlot.getLeft()).isEmpty()
|
||||
|| !ItemUtils.isItemEqual(sourceStack, inventory.getStack(bestSlot.getLeft()), true, true)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
sourceStack.decrement(1);
|
||||
|
@ -322,13 +322,13 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
return ItemUtils.isItemEqual(stack, output, true, true);
|
||||
}
|
||||
|
||||
public List<RollingMachineRecipe> getAllRecipe(World world){
|
||||
public List<RollingMachineRecipe> getAllRecipe(World world) {
|
||||
return ModRecipes.ROLLING_MACHINE.getRecipes(world);
|
||||
}
|
||||
|
||||
public ItemStack findMatchingRecipeOutput(CraftingInventory inv, World world) {
|
||||
RollingMachineRecipe recipe = findMatchingRecipe(inv, world);
|
||||
if(recipe == null){
|
||||
if (recipe == null) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return recipe.getOutput();
|
||||
|
@ -342,7 +342,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getToolDrop(final PlayerEntity entityPlayer) {
|
||||
return TRContent.Machine.ROLLING_MACHINE.getStack();
|
||||
|
@ -379,24 +379,24 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
|
||||
public int getBurnTimeRemainingScaled(final int scale) {
|
||||
if (tickTime == 0 || Math.max((int) (TechRebornConfig.rollingMachineRunTime* (1.0 - getSpeedMultiplier())), 1) == 0) {
|
||||
if (tickTime == 0 || Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1) == 0) {
|
||||
return 0;
|
||||
}
|
||||
return tickTime * scale / Math.max((int) (TechRebornConfig.rollingMachineRunTime* (1.0 - getSpeedMultiplier())), 1);
|
||||
return tickTime * scale / Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||
return new ScreenHandlerBuilder("rollingmachine").player(player.inventory)
|
||||
.inventory().hotbar()
|
||||
.addInventory().blockEntity(this)
|
||||
.slot(0, 30, 22).slot(1, 48, 22).slot(2, 66, 22)
|
||||
.slot(3, 30, 40).slot(4, 48, 40).slot(5, 66, 40)
|
||||
.slot(6, 30, 58).slot(7, 48, 58).slot(8, 66, 58)
|
||||
.onCraft(inv -> this.inventory.setStack(1, findMatchingRecipeOutput(getCraftingMatrix(), this.world)))
|
||||
.outputSlot(9, 124, 40)
|
||||
.energySlot(10, 8, 70)
|
||||
.syncEnergyValue().sync(this::getBurnTime, this::setBurnTime).sync(this::getLockedInt, this::setLockedInt).addInventory().create(this, syncID);
|
||||
.inventory().hotbar()
|
||||
.addInventory().blockEntity(this)
|
||||
.slot(0, 30, 22).slot(1, 48, 22).slot(2, 66, 22)
|
||||
.slot(3, 30, 40).slot(4, 48, 40).slot(5, 66, 40)
|
||||
.slot(6, 30, 58).slot(7, 48, 58).slot(8, 66, 58)
|
||||
.onCraft(inv -> this.inventory.setStack(1, findMatchingRecipeOutput(getCraftingMatrix(), this.world)))
|
||||
.outputSlot(9, 124, 40)
|
||||
.energySlot(10, 8, 70)
|
||||
.syncEnergyValue().sync(this::getBurnTime, this::setBurnTime).sync(this::getLockedInt, this::setLockedInt).addInventory().create(this, syncID);
|
||||
}
|
||||
|
||||
//Easyest way to sync back to the client
|
||||
|
@ -409,8 +409,8 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
|
||||
public int getProgressScaled(final int scale) {
|
||||
if (tickTime != 0 && Math.max((int) (TechRebornConfig.rollingMachineRunTime* (1.0 - getSpeedMultiplier())), 1) != 0) {
|
||||
return tickTime * scale / Math.max((int) (TechRebornConfig.rollingMachineRunTime* (1.0 - getSpeedMultiplier())), 1);
|
||||
if (tickTime != 0 && Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1) != 0) {
|
||||
return tickTime * scale / Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -39,12 +39,12 @@ public class ScrapboxinatorBlockEntity extends GenericMachineBlockEntity impleme
|
|||
|
||||
public ScrapboxinatorBlockEntity() {
|
||||
super(TRBlockEntities.SCRAPBOXINATOR, "Scrapboxinator", TechRebornConfig.scrapboxinatorMaxInput, TechRebornConfig.scrapboxinatorMaxEnergy, TRContent.Machine.SCRAPBOXINATOR.block, 2);
|
||||
final int[] inputs = new int[] { 0 };
|
||||
final int[] outputs = new int[] { 1 };
|
||||
final int[] inputs = new int[]{0};
|
||||
final int[] outputs = new int[]{1};
|
||||
this.inventory = new RebornInventory<>(3, "ScrapboxinatorBlockEntity", 64, this);
|
||||
this.crafter = new ScrapboxRecipeCrafter(this, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
||||
// TileMachineBase
|
||||
@Override
|
||||
public boolean canBeUpgraded() {
|
||||
|
|
|
@ -40,8 +40,8 @@ public class SoildCanningMachineBlockEntity extends GenericMachineBlockEntity im
|
|||
|
||||
public SoildCanningMachineBlockEntity() {
|
||||
super(TRBlockEntities.SOLID_CANNING_MACHINE, "SolidCanningMachine", TechRebornConfig.solidCanningMachineMaxInput, TechRebornConfig.solidCanningMachineMaxEnergy, TRContent.Machine.SOLID_CANNING_MACHINE.block, 3);
|
||||
final int[] inputs = new int[] { 0, 1 };
|
||||
final int[] outputs = new int[] { 2 };
|
||||
final int[] inputs = new int[]{0, 1};
|
||||
final int[] outputs = new int[]{2};
|
||||
this.inventory = new RebornInventory<>(4, "SolidCanningMachineBlockEntity", 64, this);
|
||||
this.crafter = new RecipeCrafter(ModRecipes.SOLID_CANNING_MACHINE, this, 2, 1, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
@ -50,10 +50,10 @@ public class SoildCanningMachineBlockEntity extends GenericMachineBlockEntity im
|
|||
@Override
|
||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||
return new ScreenHandlerBuilder("solidcanningmachine").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().blockEntity(this)
|
||||
.slot(0, 34, 47)
|
||||
.slot(1, 126, 47)
|
||||
.outputSlot(2, 80, 47).energySlot(3, 8, 72).syncEnergyValue().syncCrafterValue().addInventory()
|
||||
.create(this, syncID);
|
||||
.addInventory().blockEntity(this)
|
||||
.slot(0, 34, 47)
|
||||
.slot(1, 126, 47)
|
||||
.outputSlot(2, 80, 47).energySlot(3, 8, 72).syncEnergyValue().syncCrafterValue().addInventory()
|
||||
.create(this, syncID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@ public class WireMillBlockEntity extends GenericMachineBlockEntity implements Bu
|
|||
|
||||
public WireMillBlockEntity() {
|
||||
super(TRBlockEntities.WIRE_MILL, "WireMill", 32, 1000, TRContent.Machine.WIRE_MILL.block, 2);
|
||||
final int[] inputs = new int[] { 0 };
|
||||
final int[] outputs = new int[] { 1 };
|
||||
final int[] inputs = new int[]{0};
|
||||
final int[] outputs = new int[]{1};
|
||||
this.inventory = new RebornInventory<>(3, "WireMillBlockEntity", 64, this);
|
||||
this.crafter = new RecipeCrafter(ModRecipes.WIRE_MILL, this, 1, 1, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
@ -49,13 +49,13 @@ public class WireMillBlockEntity extends GenericMachineBlockEntity implements Bu
|
|||
@Override
|
||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||
return new ScreenHandlerBuilder("wiremill").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().blockEntity(this)
|
||||
.slot(0, 55, 45)
|
||||
.outputSlot(1, 101, 45)
|
||||
.energySlot(2, 8, 72)
|
||||
.syncEnergyValue()
|
||||
.syncCrafterValue()
|
||||
.addInventory()
|
||||
.create(this, syncID);
|
||||
.addInventory().blockEntity(this)
|
||||
.slot(0, 55, 45)
|
||||
.outputSlot(1, 101, 45)
|
||||
.energySlot(2, 8, 72)
|
||||
.syncEnergyValue()
|
||||
.syncCrafterValue()
|
||||
.addInventory()
|
||||
.create(this, syncID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,10 +55,10 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
|
|||
private String ownerUdid;
|
||||
|
||||
public ChunkLoaderBlockEntity() {
|
||||
super(TRBlockEntities.CHUNK_LOADER );
|
||||
super(TRBlockEntities.CHUNK_LOADER);
|
||||
this.radius = 1;
|
||||
}
|
||||
|
||||
|
||||
public void handleGuiInputFromClient(int buttonID, @Nullable PlayerEntity playerEntity) {
|
||||
radius += buttonID;
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
|
|||
|
||||
reload();
|
||||
|
||||
if(playerEntity != null){
|
||||
if (playerEntity != null) {
|
||||
ChunkLoaderManager manager = ChunkLoaderManager.get(getWorld());
|
||||
manager.syncChunkLoaderToClient((ServerPlayerEntity) playerEntity, getPos());
|
||||
}
|
||||
|
@ -82,20 +82,20 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
|
|||
return TRContent.Machine.CHUNK_LOADER.getStack();
|
||||
}
|
||||
|
||||
private void reload(){
|
||||
private void reload() {
|
||||
unloadAll();
|
||||
load();
|
||||
}
|
||||
|
||||
private void load(){
|
||||
private void load() {
|
||||
ChunkLoaderManager manager = ChunkLoaderManager.get(getWorld());
|
||||
ChunkPos rootPos = getChunkPos();
|
||||
int loadRadius = radius -1;
|
||||
int loadRadius = radius - 1;
|
||||
for (int i = -loadRadius; i <= loadRadius; i++) {
|
||||
for (int j = -loadRadius; j <= loadRadius; j++) {
|
||||
ChunkPos loadPos = new ChunkPos(rootPos.x + i, rootPos.z + j);
|
||||
|
||||
if(!manager.isChunkLoaded(getWorld(), loadPos, getPos())){
|
||||
if (!manager.isChunkLoaded(getWorld(), loadPos, getPos())) {
|
||||
manager.loadChunk(getWorld(), loadPos, getPos(), ownerUdid);
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
|
|||
|
||||
@Override
|
||||
public void onBreak(World world, PlayerEntity playerEntity, BlockPos blockPos, BlockState blockState) {
|
||||
if(world.isClient){
|
||||
if (world.isClient) {
|
||||
return;
|
||||
}
|
||||
unloadAll();
|
||||
|
@ -114,19 +114,19 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
|
|||
|
||||
@Override
|
||||
public void onPlace(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
|
||||
if(world.isClient){
|
||||
if (world.isClient) {
|
||||
return;
|
||||
}
|
||||
ownerUdid = placer.getUuidAsString();
|
||||
reload();
|
||||
}
|
||||
|
||||
private void unloadAll(){
|
||||
private void unloadAll() {
|
||||
ChunkLoaderManager manager = ChunkLoaderManager.get(world);
|
||||
manager.unloadChunkLoader(world, getPos());
|
||||
}
|
||||
|
||||
public ChunkPos getChunkPos(){
|
||||
public ChunkPos getChunkPos() {
|
||||
return new ChunkPos(getPos());
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
|
|||
super.fromTag(blockState, nbttagcompound);
|
||||
this.radius = nbttagcompound.getInt("radius");
|
||||
this.ownerUdid = nbttagcompound.getString("ownerUdid");
|
||||
if(!StringUtils.isBlank(ownerUdid)){
|
||||
if (!StringUtils.isBlank(ownerUdid)) {
|
||||
nbttagcompound.putString("ownerUdid", this.ownerUdid);
|
||||
}
|
||||
inventory.read(nbttagcompound);
|
||||
|
@ -158,7 +158,7 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
|
|||
public int getRadius() {
|
||||
return radius;
|
||||
}
|
||||
|
||||
|
||||
public void setRadius(int radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
|
|
@ -48,29 +48,29 @@ public class IndustrialCentrifugeBlockEntity extends GenericMachineBlockEntity i
|
|||
|
||||
public IndustrialCentrifugeBlockEntity() {
|
||||
super(TRBlockEntities.INDUSTRIAL_CENTRIFUGE, "IndustrialCentrifuge", TechRebornConfig.industrialCentrifugeMaxInput, TechRebornConfig.industrialCentrifugeMaxEnergy, TRContent.Machine.INDUSTRIAL_CENTRIFUGE.block, 6);
|
||||
final int[] inputs = new int[] { 0, 1 };
|
||||
final int[] outputs = new int[] { 2, 3, 4, 5 };
|
||||
final int[] inputs = new int[]{0, 1};
|
||||
final int[] outputs = new int[]{2, 3, 4, 5};
|
||||
this.inventory = new RebornInventory<>(7, "IndustrialCentrifugeBlockEntity", 64, this);
|
||||
this.crafter = new RecipeCrafter(ModRecipes.CENTRIFUGE, this, 2, 4, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
|
||||
// IContainerProvider
|
||||
@Override
|
||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||
return new ScreenHandlerBuilder("centrifuge").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().blockEntity(this)
|
||||
.filterSlot(1, 40, 54, stack -> ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
|
||||
.filterSlot(0, 40, 34, stack -> !ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
|
||||
.outputSlot(2, 82, 44).outputSlot(3, 101, 25)
|
||||
.outputSlot(4, 120, 44).outputSlot(5, 101, 63).energySlot(6, 8, 72).syncEnergyValue()
|
||||
.syncCrafterValue().addInventory().create(this, syncID);
|
||||
.addInventory().blockEntity(this)
|
||||
.filterSlot(1, 40, 54, stack -> ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
|
||||
.filterSlot(0, 40, 34, stack -> !ItemUtils.isItemEqual(stack, DynamicCellItem.getEmptyCell(1), true, true))
|
||||
.outputSlot(2, 82, 44).outputSlot(3, 101, 25)
|
||||
.outputSlot(4, 120, 44).outputSlot(5, 101, 63).energySlot(6, 8, 72).syncEnergyValue()
|
||||
.syncCrafterValue().addInventory().create(this, syncID);
|
||||
}
|
||||
|
||||
|
||||
// IListInfoProvider
|
||||
@Override
|
||||
public void addInfo(final List<Text> info, final boolean isReal, boolean hasData) {
|
||||
super.addInfo(info, isReal, hasData);
|
||||
if(Screen.hasControlDown()) {
|
||||
if (Screen.hasControlDown()) {
|
||||
info.add(new LiteralText("Round and round it goes"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
|
|||
private int amplifier = 0;
|
||||
|
||||
public MatterFabricatorBlockEntity() {
|
||||
super(TRBlockEntities.MATTER_FABRICATOR );
|
||||
super(TRBlockEntities.MATTER_FABRICATOR);
|
||||
}
|
||||
|
||||
private boolean spaceForOutput() {
|
||||
|
@ -61,7 +61,7 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
|
|||
private boolean spaceForOutput(int slot) {
|
||||
return inventory.getStack(slot).isEmpty()
|
||||
|| ItemUtils.isItemEqual(inventory.getStack(slot), TRContent.Parts.UU_MATTER.getStack(), true, true)
|
||||
&& inventory.getStack(slot).getCount() < 64;
|
||||
&& inventory.getStack(slot).getCount() < 64;
|
||||
}
|
||||
|
||||
private void addOutputProducts() {
|
||||
|
@ -76,8 +76,7 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
|
|||
private void addOutputProducts(int slot) {
|
||||
if (inventory.getStack(slot).isEmpty()) {
|
||||
inventory.setStack(slot, TRContent.Parts.UU_MATTER.getStack());
|
||||
}
|
||||
else if (ItemUtils.isItemEqual(this.inventory.getStack(slot), TRContent.Parts.UU_MATTER.getStack(), true, true)) {
|
||||
} else if (ItemUtils.isItemEqual(this.inventory.getStack(slot), TRContent.Parts.UU_MATTER.getStack(), true, true)) {
|
||||
inventory.getStack(slot).setCount((Math.min(64, 1 + inventory.getStack(slot).getCount())));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue