Refactor and import cleanup (Excluding network PR changed files)

This commit is contained in:
Justin Vitale 2020-07-09 23:04:42 +10:00
parent a36a0e6f4a
commit c4ef977f16
165 changed files with 1572 additions and 1625 deletions

View file

@ -36,7 +36,7 @@ public enum EFluidGenerator {
@Nonnull
private final String recipeID;
private EFluidGenerator(@Nonnull String recipeID) {
EFluidGenerator(@Nonnull String recipeID) {
this.recipeID = recipeID;
}

View file

@ -54,7 +54,7 @@ public class FluidGeneratorRecipe {
@Override
public String toString() {
return "FluidGeneratorRecipe [generatorType=" + generatorType + ", fluid=" + fluid + ", energyPerMb="
+ energyPerMb + "]";
+ energyPerMb + "]";
}
@Override
@ -83,8 +83,6 @@ public class FluidGeneratorRecipe {
return false;
} else if (!FluidUtils.fluidEquals(other.fluid, fluid))
return false;
if (generatorType != other.generatorType)
return false;
return true;
return generatorType == other.generatorType;
}
}

View file

@ -83,10 +83,7 @@ public class FluidGeneratorRecipeList {
return false;
FluidGeneratorRecipeList other = (FluidGeneratorRecipeList) obj;
if (recipes == null) {
if (other.recipes != null)
return false;
} else if (!recipes.equals(other.recipes))
return false;
return true;
return other.recipes == null;
} else return recipes.equals(other.recipes);
}
}

View file

@ -25,7 +25,6 @@
package techreborn.api.generator;
import net.minecraft.fluid.Fluid;
import java.util.EnumMap;
@ -39,17 +38,17 @@ public class GeneratorRecipeHelper {
* FluidGeneratorRecipe.
*/
public static EnumMap<EFluidGenerator, FluidGeneratorRecipeList> fluidRecipes = new EnumMap<>(
EFluidGenerator.class);
EFluidGenerator.class);
/**
* Register a Fluid energy recipe.
*
* @param generatorType A value of the EFluidGenerator type in which the fluid is
* allowed to be consumed.
* allowed to be consumed.
* @param fluidType
* @param energyPerMb Represent the energy / MILLI_BUCKET the fluid will produce.
* Some generators use this value to alter their fluid decay
* speed to match their maximum energy output.
* @param energyPerMb Represent the energy / MILLI_BUCKET the fluid will produce.
* Some generators use this value to alter their fluid decay
* speed to match their maximum energy output.
*/
public static void registerFluidRecipe(EFluidGenerator generatorType, Fluid fluidType, int energyPerMb) {
fluidRecipes.putIfAbsent(generatorType, new FluidGeneratorRecipeList());
@ -58,7 +57,7 @@ public class GeneratorRecipeHelper {
/**
* @param generatorType A value of the EFluidGenerator type in which the fluid is
* allowed to be consumed.
* allowed to be consumed.
* @return An object holding a set of availables recipes for this type of
* FluidGenerator.
*/
@ -67,10 +66,10 @@ public class GeneratorRecipeHelper {
}
/**
* Removes recipe
* Removes recipe
*
* @param generatorType A value of the EFluidGenerator type for which we should remove recipe
* @param fluidType Fluid to remove from generator recipes
* @param fluidType Fluid to remove from generator recipes
*/
public static void removeFluidRecipe(EFluidGenerator generatorType, Fluid fluidType) {
FluidGeneratorRecipeList recipeList = getFluidRecipesForGenerator(generatorType);

View file

@ -34,14 +34,13 @@ import java.util.List;
/**
* @author drcrazy
*
*/
public class ScrapboxRecipeCrafter extends RecipeCrafter {
/**
* @param parent Tile having this crafter
* @param inventory Inventory from parent blockEntity
* @param inputSlots Slot IDs for input
* @param parent Tile having this crafter
* @param inventory Inventory from parent blockEntity
* @param inputSlots Slot IDs for input
* @param outputSlots Slot IDs for output
*/
public ScrapboxRecipeCrafter(BlockEntity parent, RebornInventory<?> inventory, int[] inputSlots, int[] outputSlots) {
@ -49,9 +48,9 @@ public class ScrapboxRecipeCrafter extends RecipeCrafter {
}
@Override
public void updateCurrentRecipe(){
public void updateCurrentRecipe() {
List<RebornRecipe> scrapboxRecipeList = ModRecipes.SCRAPBOX.getRecipes(blockEntity.getWorld());
if(scrapboxRecipeList.isEmpty()){
if (scrapboxRecipeList.isEmpty()) {
setCurrentRecipe(null);
return;
}
@ -62,4 +61,4 @@ public class ScrapboxRecipeCrafter extends RecipeCrafter {
this.currentTickTime = 0;
setIsActive();
}
}
}

View file

@ -37,7 +37,6 @@ import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntit
/**
* @author drcrazy
*
*/
public class FusionReactorRecipe extends RebornRecipe {
@ -54,7 +53,7 @@ public class FusionReactorRecipe extends RebornRecipe {
this.minSize = minSize;
}
public int getStartEnergy () {
public int getStartEnergy() {
return startE;
}

View file

@ -58,7 +58,7 @@ public class RollingMachineRecipe extends RebornRecipe {
@Override
public void deserialize(JsonObject jsonObject) {
if(jsonObject.has("shaped")) {
if (jsonObject.has("shaped")) {
JsonObject json = JsonHelper.getObject(jsonObject, "shaped");
shapedRecipe = RecipeSerializer.SHAPED.read(getId(), json);
} else {

View file

@ -63,13 +63,13 @@ public class DataDrivenBEProvider extends BlockEntityType<DataDrivenBEProvider.D
private final List<DataDrivenSlot> slots;
public static DataDrivenBEProvider create(Block block, Identifier identifier){
public static DataDrivenBEProvider create(Block block, Identifier identifier) {
String location = String.format("%s/machines/%s.json", identifier.getNamespace(), identifier.getPath());
JsonObject jsonObject;
try {
jsonObject = SerializationUtil.GSON.fromJson(IOUtils.toString(FabricLauncherBase.getLauncher().getResourceAsStream(location), StandardCharsets.UTF_8), JsonObject.class);
} catch (Exception e) {
throw new RuntimeException("failed to read json: " + location, e);
throw new RuntimeException("failed to read json: " + location, e);
}
Identifier id = new Identifier(JsonHelper.getString(jsonObject, "name"));
DataDrivenBEProvider provider = new DataDrivenBEProvider(block, jsonObject);
@ -95,7 +95,7 @@ public class DataDrivenBEProvider extends BlockEntityType<DataDrivenBEProvider.D
public BuiltScreenHandler createScreenHandler(DataDrivenBlockEntity blockEntity, int syncID, PlayerEntity player) {
BlockEntityScreenHandlerBuilder builder = new ScreenHandlerBuilder(identifier.getPath()).player(player.inventory)
.inventory().hotbar().addInventory().blockEntity(blockEntity);
.inventory().hotbar().addInventory().blockEntity(blockEntity);
slots.forEach(dataDrivenSlot -> dataDrivenSlot.add(builder));
@ -127,7 +127,7 @@ public class DataDrivenBEProvider extends BlockEntityType<DataDrivenBEProvider.D
@Override
public BuiltScreenHandler createScreenHandler(int syncID, PlayerEntity player) {
return provider.createScreenHandler(this,syncID, player);
return provider.createScreenHandler(this, syncID, player);
}
public DataDrivenBEProvider getProvider() {
@ -139,24 +139,24 @@ public class DataDrivenBEProvider extends BlockEntityType<DataDrivenBEProvider.D
return slots.stream().filter(slot -> slot.getType() == SlotType.ENERGY).findFirst().orElse(null).getId();
}
private int countOfSlotType(SlotType type){
private int countOfSlotType(SlotType type) {
return (int) slots.stream()
.filter(slot -> slot.getType() == type)
.count();
.filter(slot -> slot.getType() == type)
.count();
}
private int[] slotIds(SlotType type){
private int[] slotIds(SlotType type) {
return slots.stream()
.filter(slot -> slot.getType() == type)
.mapToInt(DataDrivenSlot::getId)
.toArray();
.filter(slot -> slot.getType() == type)
.mapToInt(DataDrivenSlot::getId)
.toArray();
}
public List<DataDrivenSlot> getSlots() {
return Collections.unmodifiableList(slots);
}
private String getSimpleName(){
private String getSimpleName() {
return WordUtils.capitalize(identifier.getPath());
}
}

View file

@ -41,12 +41,12 @@ import java.util.stream.Collectors;
public class DataDrivenSlot {
public static List<DataDrivenSlot> read(JsonArray jsonArray){
public static List<DataDrivenSlot> read(JsonArray jsonArray) {
AtomicInteger idCount = new AtomicInteger();
return SerializationUtil.stream(jsonArray)
.map(JsonElement::getAsJsonObject)
.map(json -> new DataDrivenSlot(idCount.getAndIncrement(), JsonHelper.getInt(json, "x"), JsonHelper.getInt(json, "y"), SlotType.fromString(JsonHelper.getString(json, "type"))))
.collect(Collectors.toList());
.map(JsonElement::getAsJsonObject)
.map(json -> new DataDrivenSlot(idCount.getAndIncrement(), JsonHelper.getInt(json, "x"), JsonHelper.getInt(json, "y"), SlotType.fromString(JsonHelper.getString(json, "type"))))
.collect(Collectors.toList());
}
private final int id;
@ -78,14 +78,14 @@ public class DataDrivenSlot {
return type;
}
public void add(BlockEntityScreenHandlerBuilder inventoryBuilder){
public void add(BlockEntityScreenHandlerBuilder inventoryBuilder) {
type.getSlotBiConsumer().accept(inventoryBuilder, this);
}
@Environment(EnvType.CLIENT)
public void draw(MatrixStack matrixStack, GuiBase<?> guiBase, GuiBase.Layer layer){
public void draw(MatrixStack matrixStack, GuiBase<?> guiBase, GuiBase.Layer layer) {
//TODO find a better way to do this
if(getType() == SlotType.OUTPUT){
if (getType() == SlotType.OUTPUT) {
guiBase.drawOutputSlot(matrixStack, getX(), getY(), layer);
} else {
guiBase.drawSlot(matrixStack, getX(), getY(), layer);

View file

@ -41,14 +41,14 @@ public enum SlotType {
builder.energySlot(slot.getId(), slot.getX(), slot.getY());
});
public static SlotType fromString(String string){
public static SlotType fromString(String string) {
return Arrays.stream(values())
.filter(slotType -> slotType.name().equalsIgnoreCase(string))
.findFirst()
.orElse(null);
.filter(slotType -> slotType.name().equalsIgnoreCase(string))
.findFirst()
.orElse(null);
}
private BiConsumer<BlockEntityScreenHandlerBuilder, DataDrivenSlot> slotBiConsumer;
private final BiConsumer<BlockEntityScreenHandlerBuilder, DataDrivenSlot> slotBiConsumer;
SlotType(BiConsumer<BlockEntityScreenHandlerBuilder, DataDrivenSlot> slotBiConsumer) {
this.slotBiConsumer = slotBiConsumer;

View file

@ -79,7 +79,7 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
super.tick();
ticksSinceLastChange++;
if(world.isClient){
if (world.isClient) {
return;
}
@ -89,8 +89,7 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
if (!inputStack.isEmpty()) {
if (FluidUtils.isContainerEmpty(inputStack) && !tank.getFluidAmount().isEmpty()) {
FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluid());
}
else if (inputStack.getItem() instanceof ItemFluidInfo && getRecipes().getRecipeForFluid(((ItemFluidInfo) inputStack.getItem()).getFluid(inputStack)).isPresent()) {
} else if (inputStack.getItem() instanceof ItemFluidInfo && getRecipes().getRecipeForFluid(((ItemFluidInfo) inputStack.getItem()).getFluid(inputStack)).isPresent()) {
FluidUtils.drainContainers(tank, inventory, 0, 1);
}
}
@ -118,14 +117,13 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
if (world.getTime() - lastOutput < 30 && !isActive()) {
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, true));
}
else if (world.getTime() - lastOutput > 30 && isActive()) {
} else if (world.getTime() - lastOutput > 30 && isActive()) {
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, false));
}
}
public int getProgressScaled(int scale) {
if (isActive()){
if (isActive()) {
return ticksSinceLastChange * scale;
}
return 0;
@ -207,11 +205,11 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
this.ticksSinceLastChange = ticksSinceLastChange;
}
public FluidValue getTankAmount(){
public FluidValue getTankAmount() {
return tank.getFluidAmount();
}
public void setTankAmount(FluidValue amount){
public void setTankAmount(FluidValue amount) {
tank.setFluidAmount(amount);
}

View file

@ -54,10 +54,12 @@ public class LightningRodBlockEntity extends PowerAcceptorBlockEntity implements
public void tick() {
super.tick();
if (onStatusHoldTicks > 0) { --onStatusHoldTicks; }
if (onStatusHoldTicks > 0) {
--onStatusHoldTicks;
}
Block BEBlock = getCachedState().getBlock();
if (! (BEBlock instanceof BlockMachineBase)) {
if (!(BEBlock instanceof BlockMachineBase)) {
return;
}
@ -83,7 +85,7 @@ public class LightningRodBlockEntity extends PowerAcceptorBlockEntity implements
lightningBolt.method_29495(Vec3d.ofBottomCenter(world.getTopPosition(Heightmap.Type.MOTION_BLOCKING, getPos())));
if (!world.isClient) {
((ServerWorld) world).spawnEntity(lightningBolt);
world.spawnEntity(lightningBolt);
}
addEnergy(TechRebornConfig.lightningRodBaseEnergyStrike * (0.3F + weatherStrength));
machineBaseBlock.setActive(true, world, pos);
@ -110,10 +112,7 @@ public class LightningRodBlockEntity extends PowerAcceptorBlockEntity implements
public boolean isValidIronFence(int y) {
Block block = this.world.getBlockState(new BlockPos(pos.getX(), y, pos.getZ())).getBlock();
if(block == TRContent.REFINED_IRON_FENCE){
return true;
}
return false;
return block == TRContent.REFINED_IRON_FENCE;
}
@Override

View file

@ -60,10 +60,10 @@ public class PlasmaGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity im
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("plasmagenerator").player(player.inventory).inventory().hotbar().addInventory()
.blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
.sync(this::getTankAmount, this::setTankAmount)
.sync(tank)
.addInventory().create(this, syncID);
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
.sync(this::getTankAmount, this::setTankAmount)
.sync(tank)
.addInventory().create(this, syncID);
}
}

View file

@ -26,7 +26,6 @@ package techreborn.blockentity.generator;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
@ -151,7 +150,7 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
public void tick() {
super.tick();
if (world == null){
if (world == null) {
return;
}
@ -191,7 +190,7 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
@Override
public double getBaseMaxOutput() {
if (getPanel() == TRContent.SolarPanels.CREATIVE){
if (getPanel() == TRContent.SolarPanels.CREATIVE) {
return EnergyTier.INSANE.getMaxOutput();
}
// Solar panel output will only be limited by the cables the users use
@ -231,22 +230,22 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
info.add(
new TranslatableText("reborncore.tooltip.energy.maxEnergy")
.formatted(Formatting.GRAY)
.append(": ")
.append(
new LiteralText(PowerSystem.getLocaliszedPowerFormatted(getMaxPower()))
.formatted(Formatting.GOLD)
)
.formatted(Formatting.GRAY)
.append(": ")
.append(
new LiteralText(PowerSystem.getLocaliszedPowerFormatted(getMaxPower()))
.formatted(Formatting.GOLD)
)
);
info.add(
new TranslatableText("techreborn.tooltip.generationRate.day")
.formatted(Formatting.GRAY)
.append(": ")
.append(
new LiteralText(PowerSystem.getLocaliszedPowerFormatted(panel.generationRateD))
.formatted(Formatting.GOLD)
)
.formatted(Formatting.GRAY)
.append(": ")
.append(
new LiteralText(PowerSystem.getLocaliszedPowerFormatted(panel.generationRateD))
.formatted(Formatting.GOLD)
)
);
info.add(

View file

@ -60,10 +60,10 @@ public class DieselGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity im
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("dieselgenerator").player(player.inventory).inventory().hotbar()
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
.sync(this::getTankAmount, this::setTankAmount)
.sync(tank)
.addInventory().create(this, syncID);
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
.sync(this::getTankAmount, this::setTankAmount)
.sync(tank)
.addInventory().create(this, syncID);
}
}

View file

@ -39,7 +39,7 @@ import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
public class DragonEggSyphonBlockEntity extends PowerAcceptorBlockEntity
implements IToolDrop, InventoryProvider {
implements IToolDrop, InventoryProvider {
public RebornInventory<DragonEggSyphonBlockEntity> inventory = new RebornInventory<>(3, "DragonEggSyphonBlockEntity", 64, this);
private long lastOutput = 0;

View file

@ -60,10 +60,10 @@ public class GasTurbineBlockEntity extends BaseFluidGeneratorBlockEntity impleme
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("gasturbine").player(player.inventory).inventory().hotbar()
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
.sync(this::getTankAmount, this::setTankAmount)
.sync(tank)
.addInventory().create(this, syncID);
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
.sync(this::getTankAmount, this::setTankAmount)
.sync(tank)
.addInventory().create(this, syncID);
}
}

View file

@ -60,10 +60,10 @@ public class SemiFluidGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("semifluidgenerator").player(player.inventory).inventory().hotbar()
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
.sync(this::getTankAmount, this::setTankAmount)
.sync(tank)
.addInventory().create(this, syncID);
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
.sync(this::getTankAmount, this::setTankAmount)
.sync(tank)
.addInventory().create(this, syncID);
}
}

View file

@ -60,10 +60,10 @@ public class ThermalGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity i
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("thermalgenerator").player(player.inventory).inventory().hotbar()
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
.sync(this::getTankAmount, this::setTankAmount)
.sync(tank)
.addInventory().create(this, syncID);
.addInventory().blockEntity(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue()
.sync(this::getTicksSinceLastChange, this::setTicksSinceLastChange)
.sync(this::getTankAmount, this::setTankAmount)
.sync(tank)
.addInventory().create(this, syncID);
}
}

View file

@ -64,11 +64,11 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
}
public static int getItemBurnTime(@Nonnull ItemStack stack) {
if (stack.isEmpty()){
return 0;
}
if (stack.isEmpty()) {
return 0;
}
Map<Item, Integer> burnMap = AbstractFurnaceBlockEntity.createFuelTimeMap();
if(burnMap.containsKey(stack.getItem())){
if (burnMap.containsKey(stack.getItem())) {
return burnMap.get(stack.getItem()) / 4;
}
return 0;
@ -183,9 +183,9 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("generator").player(player.inventory).inventory().hotbar().addInventory()
.blockEntity(this).fuelSlot(0, 80, 54).energySlot(1, 8, 72).syncEnergyValue()
.sync(this::getBurnTime, this::setBurnTime)
.sync(this::getTotalBurnTime, this::setTotalBurnTime).addInventory().create(this, syncID);
.blockEntity(this).fuelSlot(0, 80, 54).energySlot(1, 8, 72).syncEnergyValue()
.sync(this::getBurnTime, this::setBurnTime)
.sync(this::getTotalBurnTime, this::setTotalBurnTime).addInventory().create(this, syncID);
}
@Override

View file

@ -55,8 +55,7 @@ public class WaterMillBlockEntity extends PowerAcceptorBlockEntity implements IT
if (waterblocks > 0) {
addEnergy(waterblocks * TechRebornConfig.waterMillEnergyMultiplier);
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, true));
}
else {
} else {
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, false));
}
}

View file

@ -52,7 +52,7 @@ public class WindMillBlockEntity extends PowerAcceptorBlockEntity implements ITo
boolean generating = pos.getY() > 64;
if(world.isClient) {
if (world.isClient) {
bladeAngle += spinSpeed;
if (generating) {

View file

@ -35,9 +35,9 @@ import techreborn.blocks.lighting.BlockLamp;
import techreborn.init.TRBlockEntities;
public class LampBlockEntity extends PowerAcceptorBlockEntity
implements IToolDrop {
implements IToolDrop {
private static int capacity = 33;
private static final int capacity = 33;
public LampBlockEntity() {
super(TRBlockEntities.LAMP);

View file

@ -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;
@ -52,10 +51,10 @@ public abstract class GenericMachineBlockEntity extends PowerAcceptorBlockEntity
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) {

View file

@ -60,6 +60,7 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
/**
* 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
*/
@ -85,6 +87,7 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
/**
* Returns remaining fraction of fuel burn time
*
* @param scale Scale to use for burn time
* @return int scaled remaining fuel burn time
*/
@ -98,6 +101,7 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
/**
* Returns crafting progress
*
* @param scale Scale to use for crafting progress
* @return int Scaled crafting progress
*/
@ -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,17 +141,17 @@ 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();
@ -175,7 +180,7 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
progress = 0;
smelt();
}
} else if(!canSmelt()) {
} else if (!canSmelt()) {
progress = 0;
}

View file

@ -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;
@ -127,22 +127,22 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
@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

View file

@ -133,9 +133,9 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
@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

View file

@ -42,29 +42,29 @@ 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
@ -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);
}
}

View file

@ -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();
}
}
}
@ -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);
}
}

View file

@ -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();

View file

@ -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())

View file

@ -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

View file

@ -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());

View file

@ -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)

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);
}
}

View file

@ -40,8 +40,8 @@ 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);
}
@ -50,7 +50,7 @@ public class AssemblingMachineBlockEntity extends GenericMachineBlockEntity impl
@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);
}
}

View file

@ -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 {

View file

@ -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);
}
}

View file

@ -40,8 +40,8 @@ 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);
}

View file

@ -60,7 +60,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
final int EnergyPerTick = 1;
public ElectricFurnaceBlockEntity() {
super(TRBlockEntities.ELECTRIC_FURNACE );
super(TRBlockEntities.ELECTRIC_FURNACE);
}
private void setInvDirty(boolean isDirty) {
@ -99,7 +99,7 @@ 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;
}
@ -114,8 +114,8 @@ 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;
@ -143,8 +143,8 @@ 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) {
@ -156,8 +156,7 @@ 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);
}
@ -187,6 +186,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
public void setCookTimeTotal(int cookTimeTotal) {
this.cookTimeTotal = cookTimeTotal;
}
// TilePowerAcceptor
@Override
public void tick() {

View file

@ -40,8 +40,8 @@ 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);
}

View file

@ -42,8 +42,8 @@ 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);
}
@ -52,10 +52,10 @@ public class IndustrialElectrolyzerBlockEntity extends GenericMachineBlockEntity
@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);
}
}

View file

@ -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

View file

@ -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;

View file

@ -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;
}

View file

@ -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();
@ -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;
}

View file

@ -39,8 +39,8 @@ 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);
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -55,7 +55,7 @@ public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IT
private String ownerUdid;
public ChunkLoaderBlockEntity() {
super(TRBlockEntities.CHUNK_LOADER );
super(TRBlockEntities.CHUNK_LOADER);
this.radius = 1;
}
@ -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);

View file

@ -48,8 +48,8 @@ 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);
}
@ -58,19 +58,19 @@ public class IndustrialCentrifugeBlockEntity extends GenericMachineBlockEntity i
@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"));
}
}

View file

@ -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())));
}
}

View file

@ -49,19 +49,19 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
super(TRBlockEntities.ADJUSTABLE_SU, "ADJUSTABLE_SU", 4, TRContent.Machine.ADJUSTABLE_SU.block, EnergyTier.INSANE, TechRebornConfig.aesuMaxEnergy);
}
public int getMaxConfigOutput(){
public int getMaxConfigOutput() {
int extra = 0;
if(superconductors > 0){
if (superconductors > 0) {
extra = (int) Math.pow(2, (superconductors + 2)) * maxOutput;
}
return maxOutput + extra;
}
public void handleGuiInputFromClient(int id, boolean shift, boolean ctrl) {
if(shift){
if (shift) {
id *= 4;
}
if(ctrl){
if (ctrl) {
id *= 8;
}
@ -88,14 +88,14 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
@Override
public void tick() {
super.tick();
if (world == null){
if (world == null) {
return;
}
if (OUTPUT > getMaxConfigOutput()) {
OUTPUT = getMaxConfigOutput();
}
if(world.getTime() % 20 == 0){
if (world.getTime() % 20 == 0) {
checkTier();
}
}
@ -118,7 +118,7 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
@Override
public double getBaseMaxInput() {
//If we have super conductors increase the max input of the machine
if(getMaxConfigOutput() > maxOutput){
if (getMaxConfigOutput() > maxOutput) {
return getMaxConfigOutput();
}
return maxInput;

View file

@ -113,13 +113,15 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity
// MachineBaseBlockEntity
@Override
public void setFacing(Direction enumFacing) {
if (world == null) { return; }
if (world == null) {
return;
}
world.setBlockState(pos, world.getBlockState(pos).with(EnergyStorageBlock.FACING, enumFacing));
}
@Override
public Direction getFacingEnum() {
if(world == null){
if (world == null) {
return null;
}
Block block = world.getBlockState(pos).getBlock();

View file

@ -34,12 +34,11 @@ import techreborn.init.TRContent;
/**
* Created by modmuss50 on 14/03/2016.
*
*/
public class HighVoltageSUBlockEntity extends EnergyStorageBlockEntity implements BuiltScreenHandlerProvider {
/**
* MFSU should store 4M Energy with 512 E/t I/O
* MFSU should store 4M Energy with 512 E/t I/O
*/
public HighVoltageSUBlockEntity() {
super(TRBlockEntities.HIGH_VOLTAGE_SU, "HIGH_VOLTAGE_SU", 2, TRContent.Machine.HIGH_VOLTAGE_SU.block, EnergyTier.HIGH, 4_000_000);
@ -48,7 +47,7 @@ public class HighVoltageSUBlockEntity extends EnergyStorageBlockEntity implement
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("mfsu").player(player.inventory).inventory().hotbar().armor()
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
.syncEnergyValue().addInventory().create(this, syncID);
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
.syncEnergyValue().addInventory().create(this, syncID);
}
}

View file

@ -44,6 +44,6 @@ public class LowVoltageSUBlockEntity extends EnergyStorageBlockEntity implements
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("batbox").player(player.inventory).inventory().hotbar().addInventory()
.blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45).syncEnergyValue().addInventory().create(this, syncID);
.blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45).syncEnergyValue().addInventory().create(this, syncID);
}
}

View file

@ -34,12 +34,11 @@ import techreborn.init.TRContent;
/**
* Created by modmuss50 on 14/03/2016.
*
*/
public class MediumVoltageSUBlockEntity extends EnergyStorageBlockEntity implements BuiltScreenHandlerProvider {
/**
* MFE should store 300k energy with 128 E/t I/O
* MFE should store 300k energy with 128 E/t I/O
*/
public MediumVoltageSUBlockEntity() {
super(TRBlockEntities.MEDIUM_VOLTAGE_SU, "MEDIUM_VOLTAGE_SU", 2, TRContent.Machine.MEDIUM_VOLTAGE_SU.block, EnergyTier.MEDIUM, 300_000);
@ -48,8 +47,8 @@ public class MediumVoltageSUBlockEntity extends EnergyStorageBlockEntity impleme
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("mfe").player(player.inventory).inventory().hotbar().armor()
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
.syncEnergyValue().addInventory().create(this, syncID);
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
.syncEnergyValue().addInventory().create(this, syncID);
}
}

View file

@ -42,11 +42,11 @@ public class IDSUManager extends PersistentState {
}
@Nonnull
public static IDSUPlayer getPlayer(World world, String uuid){
public static IDSUPlayer getPlayer(World world, String uuid) {
return get(world).getPlayer(uuid);
}
public static IDSUManager get(World world){
public static IDSUManager get(World world) {
ServerWorld serverWorld = (ServerWorld) world;
return serverWorld.getPersistentStateManager().getOrCreate(IDSUManager::new, KEY);
}
@ -54,13 +54,13 @@ public class IDSUManager extends PersistentState {
private final HashMap<String, IDSUPlayer> playerHashMap = new HashMap<>();
@Nonnull
public IDSUPlayer getPlayer(String uuid){
public IDSUPlayer getPlayer(String uuid) {
return playerHashMap.computeIfAbsent(uuid, s -> new IDSUPlayer());
}
@Override
public void fromTag(CompoundTag tag) {
for(String uuid : tag.getKeys()){
for (String uuid : tag.getKeys()) {
playerHashMap.put(uuid, new IDSUPlayer(tag.getCompound(uuid)));
}
}
@ -78,7 +78,7 @@ public class IDSUManager extends PersistentState {
private IDSUPlayer() {
}
private IDSUPlayer(CompoundTag compoundTag){
private IDSUPlayer(CompoundTag compoundTag) {
read(compoundTag);
}

View file

@ -54,7 +54,7 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
if (ownerUdid == null || ownerUdid.isEmpty()) {
return 0.0;
}
if(world.isClient){
if (world.isClient) {
return clientEnergy;
}
return IDSUManager.getPlayer(world, ownerUdid).getEnergy();
@ -65,7 +65,7 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
if (ownerUdid == null || ownerUdid.isEmpty()) {
return;
}
if(world.isClient){
if (world.isClient) {
clientEnergy = energy;
} else {
IDSUManager.getPlayer(world, ownerUdid).setEnergy(energy);
@ -77,7 +77,7 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
if (ownerUdid == null || ownerUdid.isEmpty()) {
return 0.0;
}
if(world.isClient){
if (world.isClient) {
throw new UnsupportedOperationException("cannot set energy on the client!");
}
double energy = IDSUManager.getPlayer(world, ownerUdid).getEnergy();
@ -95,7 +95,7 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
if (ownerUdid == null || ownerUdid.isEmpty()) {
return false;
}
if(world.isClient){
if (world.isClient) {
throw new UnsupportedOperationException("cannot set energy on the client!");
}
return input <= IDSUManager.getPlayer(world, ownerUdid).getEnergy();
@ -120,8 +120,8 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("idsu").player(player.inventory).inventory().hotbar().armor()
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
.syncEnergyValue().addInventory().create(this, syncID);
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
.syncEnergyValue().addInventory().create(this, syncID);
}
@Override

View file

@ -36,7 +36,7 @@ import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
public class LSUStorageBlockEntity extends MachineBaseBlockEntity
implements IToolDrop {
implements IToolDrop {
public LesuNetwork network;
@ -93,7 +93,7 @@ public class LSUStorageBlockEntity extends MachineBaseBlockEntity
} else {
if (network.master != null
&& network.master.getWorld().getBlockEntity(new BlockPos(network.master.getPos().getX(),
network.master.getPos().getY(), network.master.getPos().getZ())) != network.master) {
network.master.getPos().getY(), network.master.getPos().getZ())) != network.master) {
network.master = null;
}
}

View file

@ -43,7 +43,7 @@ import java.util.ArrayList;
public class LapotronicSUBlockEntity extends EnergyStorageBlockEntity implements BuiltScreenHandlerProvider {
private int connectedBlocks = 0;
private ArrayList<LesuNetwork> countedNetworks = new ArrayList<>();
private final ArrayList<LesuNetwork> countedNetworks = new ArrayList<>();
public LapotronicSUBlockEntity() {
super(TRBlockEntities.LAPOTRONIC_SU, "LESU", 2, TRContent.Machine.LAPOTRONIC_SU.block, EnergyTier.LOW, TechRebornConfig.lesuStoragePerBlock);
@ -51,22 +51,20 @@ public class LapotronicSUBlockEntity extends EnergyStorageBlockEntity implements
this.maxOutput = TechRebornConfig.lesuBaseOutput;
}
private void setMaxStorage(){
maxStorage = (connectedBlocks + 1) * TechRebornConfig.lesuStoragePerBlock;
private void setMaxStorage() {
maxStorage = (connectedBlocks + 1) * TechRebornConfig.lesuStoragePerBlock;
if (maxStorage < 0 || maxStorage > Integer.MAX_VALUE) {
maxStorage = Integer.MAX_VALUE;
}
}
private void setIORate(){
maxOutput = TechRebornConfig.lesuBaseOutput + (connectedBlocks * TechRebornConfig.lesuExtraIOPerBlock);
private void setIORate() {
maxOutput = TechRebornConfig.lesuBaseOutput + (connectedBlocks * TechRebornConfig.lesuExtraIOPerBlock);
if (connectedBlocks < 32) {
return;
}
else if (connectedBlocks < 128) {
} else if (connectedBlocks < 128) {
maxInput = EnergyTier.MEDIUM.getMaxInput();
}
else {
} else {
maxInput = EnergyTier.HIGH.getMaxInput();
}
}

View file

@ -25,7 +25,6 @@
package techreborn.blockentity.storage.fluid;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
@ -81,7 +80,7 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
}
if (FluidUtils.drainContainers(tank, inventory, 0, 1)
|| FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluid())) {
|| FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluid())) {
if (type == TRContent.TankUnit.CREATIVE) {
if (!tank.isEmpty() && !tank.isFull()) {
@ -137,8 +136,8 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
if (!this.tank.getFluidInstance().isEmpty()) {
info.add(
new LiteralText(String.valueOf(this.tank.getFluidAmount()))
.append(new TranslatableText("techreborn.tooltip.unit.divider"))
.append(WordUtils.capitalize(FluidUtil.getFluidName(this.tank.getFluid())))
.append(new TranslatableText("techreborn.tooltip.unit.divider"))
.append(WordUtils.capitalize(FluidUtil.getFluidName(this.tank.getFluid())))
);
} else {
info.add(new TranslatableText("techreborn.tooltip.unit.empty"));
@ -146,14 +145,14 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
}
info.add(
new TranslatableText("techreborn.tooltip.unit.capacity")
.formatted(Formatting.GRAY)
.append(
new LiteralText(String.valueOf(this.tank.getCapacity()))
.formatted(Formatting.GOLD)
.append(" (")
.append(String.valueOf(this.tank.getCapacity().getRawValue() / 1000))
.append(")")
)
.formatted(Formatting.GRAY)
.append(
new LiteralText(String.valueOf(this.tank.getCapacity()))
.formatted(Formatting.GOLD)
.append(" (")
.append(String.valueOf(this.tank.getCapacity().getRawValue() / 1000))
.append(")")
)
);
}
@ -161,8 +160,8 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
@Override
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
return new ScreenHandlerBuilder("tank").player(player.inventory).inventory().hotbar()
.addInventory().blockEntity(this).fluidSlot(0, 100, 53).outputSlot(1, 140, 53)
.sync(tank).addInventory().create(this, syncID);
.addInventory().blockEntity(this).fluidSlot(0, 100, 53).outputSlot(1, 140, 53)
.sync(tank).addInventory().create(this, syncID);
}
@Nonnull

View file

@ -32,10 +32,8 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import reborncore.api.IListInfoProvider;
import reborncore.api.IToolDrop;
@ -247,7 +245,7 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
@Override
public boolean canInsert(int index, ItemStack stack, @Nullable Direction direction) {
return super.canInsert(index, stack, direction) && (this.isEmpty() && !isLocked() || isSameType(stack));
return super.canInsert(index, stack, direction) && (this.isEmpty() && !isLocked() || isSameType(stack));
}
public int getCurrentCapacity() {

View file

@ -85,7 +85,7 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity
@Override
public boolean canAcceptEnergy(Direction direction) {
if (TechRebornConfig.IC2TransformersStyle){
if (TechRebornConfig.IC2TransformersStyle) {
return getFacingEnum() == direction;
}
return getFacingEnum() != direction;
@ -93,7 +93,7 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity
@Override
public boolean canProvideEnergy(Direction direction) {
if (TechRebornConfig.IC2TransformersStyle){
if (TechRebornConfig.IC2TransformersStyle) {
return getFacingEnum() != direction;
}
return getFacing() == direction;
@ -122,7 +122,7 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity
// TileMachineBase
@Override
public Direction getFacingEnum() {
if(world == null){
if (world == null) {
return null;
}
Block block = world.getBlockState(pos).getBlock();

View file

@ -30,13 +30,12 @@ import techreborn.client.GuiType;
/**
* @author modmuss50
*
*/
public class DataDrivenMachineBlock extends GenericMachineBlock {
private final DataDrivenBEProvider provider;
public DataDrivenMachineBlock(String ident){
public DataDrivenMachineBlock(String ident) {
super(GuiType.DATA_DRIVEN, null);
provider = DataDrivenBEProvider.create(this, new Identifier(ident));
blockEntityClass = provider;

View file

@ -34,11 +34,10 @@ import java.util.function.Supplier;
/**
* @author drcrazy
*
*/
public class GenericMachineBlock extends BlockMachineBase {
private IMachineGuiHandler gui;
private final IMachineGuiHandler gui;
Supplier<BlockEntity> blockEntityClass;
public GenericMachineBlock(IMachineGuiHandler gui, Supplier<BlockEntity> blockEntityClass) {
@ -62,7 +61,6 @@ public class GenericMachineBlock extends BlockMachineBase {
}
@Override
public IMachineGuiHandler getGui() {
return gui;

View file

@ -52,12 +52,12 @@ public final class CableShapeUtil {
}
private VoxelShape getStateShape(BlockState state) {
final double size = cableBlock.type != null ? cableBlock.type.cableThickness : 6;
final double size = cableBlock.type != null ? cableBlock.type.cableThickness : 6;
final VoxelShape baseShape = Block.createCuboidShape(size, size, size, 16.0D - size, 16.0D - size, 16.0D - size);
final List<VoxelShape> connections = new ArrayList<>();
for(Direction dir : Direction.values()){
if(state.get(CableBlock.PROPERTY_MAP.get(dir))) {
for (Direction dir : Direction.values()) {
if (state.get(CableBlock.PROPERTY_MAP.get(dir))) {
double x = dir == Direction.WEST ? 0 : dir == Direction.EAST ? 16D : size;
double z = dir == Direction.NORTH ? 0 : dir == Direction.SOUTH ? 16D : size;
double y = dir == Direction.DOWN ? 0 : dir == Direction.UP ? 16D : size;

View file

@ -81,7 +81,7 @@ public class BlockFusionCoil extends Block {
@Environment(EnvType.CLIENT)
@Override
public void buildTooltip(ItemStack stack, @Nullable BlockView worldIn, List<Text> tooltip,
TooltipContext flagIn) {
TooltipContext flagIn) {
super.buildTooltip(stack, worldIn, tooltip, flagIn);
// TODO: Translate
tooltip.add(new LiteralText("Right click Fusion Control computer to auto place"));

View file

@ -52,23 +52,23 @@ public class BlockFusionControlComputer extends BlockMachineBase {
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
Hand hand, BlockHitResult hitResult) {
final FusionControlComputerBlockEntity blockEntityFusionControlComputer = (FusionControlComputerBlockEntity) worldIn.getBlockEntity(pos);
if(!playerIn.getStackInHand(hand).isEmpty() && (playerIn.getStackInHand(hand).getItem() == TRContent.Machine.FUSION_COIL.asItem())){
if (!playerIn.getStackInHand(hand).isEmpty() && (playerIn.getStackInHand(hand).getItem() == TRContent.Machine.FUSION_COIL.asItem())) {
List<BlockPos> coils = Torus.generate(blockEntityFusionControlComputer.getPos(), blockEntityFusionControlComputer.size);
boolean placed = false;
for(BlockPos coil : coils){
if(playerIn.getStackInHand(hand).isEmpty()){
for (BlockPos coil : coils) {
if (playerIn.getStackInHand(hand).isEmpty()) {
return ActionResult.SUCCESS;
}
if(worldIn.getBlockState(coil).canReplace(new ItemPlacementContext(new ItemUsageContext(playerIn, hand, hitResult)))
&& worldIn.getBlockState(pos).getBlock() != TRContent.Machine.FUSION_COIL.block) {
if (worldIn.getBlockState(coil).canReplace(new ItemPlacementContext(new ItemUsageContext(playerIn, hand, hitResult)))
&& worldIn.getBlockState(pos).getBlock() != TRContent.Machine.FUSION_COIL.block) {
worldIn.setBlockState(coil, TRContent.Machine.FUSION_COIL.block.getDefaultState());
if(!playerIn.isCreative()){
if (!playerIn.isCreative()) {
playerIn.getStackInHand(hand).decrement(1);
}
placed = true;
}
}
if(placed){
if (placed) {
return ActionResult.SUCCESS;
}

View file

@ -55,7 +55,7 @@ public class BlockSolarPanel extends BlockMachineBase {
@Override
public IMachineGuiHandler getGui() {
if(this.panelType == SolarPanels.CREATIVE){
if (this.panelType == SolarPanels.CREATIVE) {
return null;
}
return GuiType.SOLAR_PANEL;

View file

@ -39,17 +39,17 @@ import java.util.function.Supplier;
* for generators, like comparator output based on energy.
*/
public class GenericGeneratorBlock extends GenericMachineBlock {
public GenericGeneratorBlock(IMachineGuiHandler gui, Supplier<BlockEntity> blockEntityClass) {
super(gui, blockEntityClass);
}
public GenericGeneratorBlock(IMachineGuiHandler gui, Supplier<BlockEntity> blockEntityClass) {
super(gui, blockEntityClass);
}
@Override
public boolean hasComparatorOutput(BlockState state) {
return true;
}
@Override
public boolean hasComparatorOutput(BlockState state) {
return true;
}
@Override
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
return PowerAcceptorBlockEntity.calculateComparatorOutputFromEnergy(world.getBlockEntity(pos));
}
@Override
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
return PowerAcceptorBlockEntity.calculateComparatorOutputFromEnergy(world.getBlockEntity(pos));
}
}

View file

@ -56,8 +56,8 @@ public class BlockLamp extends BaseBlockEntityProvider {
public static BooleanProperty ACTIVE;
protected final VoxelShape[] shape;
private int cost;
private static int brightness = 15;
private final int cost;
private static final int brightness = 15;
public BlockLamp(int cost, double depth, double width) {
super(FabricBlockSettings.of(Material.REDSTONE_LAMP).strength(2f, 2f).lightLevel(brightness));
@ -68,7 +68,7 @@ public class BlockLamp extends BaseBlockEntityProvider {
}
private VoxelShape[] genCuboidShapes(double depth, double width) {
double culling = (16.0D - width) / 2 ;
double culling = (16.0D - width) / 2;
return new VoxelShape[]{
createCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling),
createCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling),
@ -76,7 +76,7 @@ public class BlockLamp extends BaseBlockEntityProvider {
createCuboidShape(culling, culling, 0.0D, 16.0 - culling, 16.0 - culling, depth),
createCuboidShape(16.0 - depth, culling, culling, 16.0D, 16.0 - culling, 16.0 - culling),
createCuboidShape(0.0D, culling, culling, depth, 16.0 - culling, 16.0 - culling)
};
};
}
@Override
@ -97,7 +97,7 @@ public class BlockLamp extends BaseBlockEntityProvider {
}
public static void setActive(Boolean active, World world, BlockPos pos) {
Direction facing = (Direction)world.getBlockState(pos).get(FACING);
Direction facing = world.getBlockState(pos).get(FACING);
BlockState state = world.getBlockState(pos).with(ACTIVE, active).with(FACING, facing);
world.setBlockState(pos, state, 3);
}

View file

@ -59,7 +59,7 @@ public class IronAlloyFurnaceBlock extends GenericMachineBlock {
worldIn.playSound(x, y, z, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
}
Direction facing = (Direction) stateIn.get(FACING);
Direction facing = stateIn.get(FACING);
Direction.Axis facing$Axis = facing.getAxis();
double double_5 = rand.nextDouble() * 0.6D - 0.3D;
double deltaX = facing$Axis == Direction.Axis.X ? (double) facing.getOffsetX() * 0.52D : double_5;

View file

@ -59,7 +59,7 @@ public class IronFurnaceBlock extends GenericMachineBlock {
worldIn.playSound(x, y, z, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
}
Direction facing = (Direction) stateIn.get(FACING);
Direction facing = stateIn.get(FACING);
Direction.Axis facing$Axis = facing.getAxis();
double double_5 = rand.nextDouble() * 0.6D - 0.3D;
double deltaX = facing$Axis == Direction.Axis.X ? (double) facing.getOffsetX() * 0.52D : double_5;

View file

@ -71,7 +71,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
@Override
public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer,
ItemStack stack) {
ItemStack stack) {
super.onPlaced(worldIn, pos, state, placer, stack);
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
if (blockEntity instanceof PlayerDectectorBlockEntity) {
@ -126,12 +126,12 @@ public class BlockPlayerDetector extends BlockMachineBase {
if (worldIn.isClient) {
ChatUtils.sendNoSpamMessages(MessageIDs.playerDetectorID,
new TranslatableText("techreborn.message.detects")
.formatted(Formatting.GRAY)
.append(" ")
.append(
new LiteralText(StringUtils.toFirstCapital(newType.asString()))
.formatted(color)
)
.formatted(Formatting.GRAY)
.append(" ")
.append(
new LiteralText(StringUtils.toFirstCapital(newType.asString()))
.formatted(color)
)
);
}
return ActionResult.SUCCESS;
@ -177,7 +177,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
private final String name;
private PlayerDetectorType(String name) {
PlayerDetectorType(String name) {
this.name = name;
}

View file

@ -55,7 +55,7 @@ import javax.annotation.Nullable;
import java.util.List;
public class BlockAlarm extends BaseBlockEntityProvider {
public static DirectionProperty FACING = Properties.FACING;
public static DirectionProperty FACING = Properties.FACING;
public static BooleanProperty ACTIVE;
protected final VoxelShape[] shape;
@ -67,7 +67,7 @@ public class BlockAlarm extends BaseBlockEntityProvider {
}
private VoxelShape[] GenCuboidShapes(double depth, double width) {
double culling = (16.0D - width) / 2 ;
double culling = (16.0D - width) / 2;
VoxelShape[] shapes = {
Block.createCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling),
Block.createCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling),
@ -84,7 +84,7 @@ public class BlockAlarm extends BaseBlockEntityProvider {
}
public static Direction getFacing(BlockState state) {
return (Direction) state.get(FACING);
return state.get(FACING);
}
public static void setFacing(Direction facing, World world, BlockPos pos) {

View file

@ -63,8 +63,7 @@ public class BlockComputerCube extends BlockMachineBase {
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
}
return ActionResult.SUCCESS;
}
else {
} else {
rotate(worldIn.getBlockState(pos), BlockRotation.CLOCKWISE_90);
return ActionResult.SUCCESS;
}

View file

@ -56,10 +56,10 @@ public class BlockNuke extends BaseBlock {
public void ignite(World worldIn, BlockPos pos, BlockState state, LivingEntity igniter) {
if (!worldIn.isClient) {
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (double) ((float) pos.getX() + 0.5F),
(double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), igniter);
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (float) pos.getX() + 0.5F,
pos.getY(), (float) pos.getZ() + 0.5F, igniter);
worldIn.spawnEntity(entitynukeprimed);
worldIn.playSound((PlayerEntity) null, entitynukeprimed.getX(), entitynukeprimed.getY(), entitynukeprimed.getZ(),
worldIn.playSound(null, entitynukeprimed.getX(), entitynukeprimed.getY(), entitynukeprimed.getZ(),
SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
}
@ -67,8 +67,8 @@ public class BlockNuke extends BaseBlock {
@Override
public void onDestroyedByExplosion(World worldIn, BlockPos pos, Explosion explosionIn) {
if (!worldIn.isClient) {
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (double) ((float) pos.getX() + 0.5F),
(double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), explosionIn.getCausingEntity());
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (float) pos.getX() + 0.5F,
pos.getY(), (float) pos.getZ() + 0.5F, explosionIn.getCausingEntity());
entitynukeprimed.setFuse(worldIn.random.nextInt(TechRebornConfig.nukeFuseTime / 4) + TechRebornConfig.nukeFuseTime / 8);
worldIn.spawnEntity(entitynukeprimed);
}

View file

@ -134,7 +134,9 @@ public class BlockRubberLog extends PillarBlock {
if (Energy.valid(stack)) {
Energy.of(stack).use(20);
} else {
stack.damage(1, playerIn, player -> { player.sendToolBreakStatus(hand); });
stack.damage(1, playerIn, player -> {
player.sendToolBreakStatus(hand);
});
}
if (!playerIn.inventory.insertStack(TRContent.Parts.SAP.getStack())) {
WorldUtils.dropItem(TRContent.Parts.SAP.getStack(), worldIn, pos.offset(hitResult.getSide()));

View file

@ -29,7 +29,6 @@ import techreborn.utils.InitUtils;
/**
* @author drcrazy
*
*/
public class RubberButtonBlock extends WoodButtonBlock {

View file

@ -29,7 +29,6 @@ import techreborn.utils.InitUtils;
/**
* @author drcrazy
*
*/
public class RubberDoorBlock extends DoorBlock {

View file

@ -29,7 +29,6 @@ import techreborn.utils.InitUtils;
/**
* @author drcrazy
*
*/
public class RubberPressurePlateBlock extends PressurePlateBlock {

View file

@ -29,7 +29,6 @@ import techreborn.utils.InitUtils;
/**
* @author drcrazy
*
*/
public class RubberTrapdoorBlock extends TrapdoorBlock {

View file

@ -28,10 +28,8 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.BucketItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ToolItem;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
@ -41,12 +39,10 @@ import net.minecraft.world.World;
import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.fluid.FluidValue;
import reborncore.common.fluid.RebornBucketItem;
import reborncore.common.fluid.container.FluidInstance;
import reborncore.common.fluid.container.ItemFluidInfo;
import reborncore.common.util.Tank;
import techreborn.blockentity.storage.fluid.TankUnitBaseBlockEntity;
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
import techreborn.client.GuiType;
import techreborn.init.TRContent;
@ -76,17 +72,17 @@ public class TankUnitBlock extends BlockMachineBase {
// Assuming ItemFluidInfo is 1 BUCKET, for now only allow exact amount or less
if (tankUnitEntity != null && itemInHand instanceof ItemFluidInfo) {
ItemFluidInfo itemFluid = (ItemFluidInfo)itemInHand;
ItemFluidInfo itemFluid = (ItemFluidInfo) itemInHand;
Fluid fluid = itemFluid.getFluid(stackInHand);
int amount = stackInHand.getCount();
FluidValue fluidValue = FluidValue.BUCKET.multiply(amount);
Tank tankInstance = tankUnitEntity.getTank();
if(tankInstance.canFit(fluid, fluidValue)){
if(tankInstance.getFluidInstance().isEmptyFluid()){
if (tankInstance.canFit(fluid, fluidValue)) {
if (tankInstance.getFluidInstance().isEmptyFluid()) {
tankInstance.setFluidInstance(new FluidInstance(fluid, fluidValue));
}else{
} else {
tankInstance.getFluidInstance().addAmount(fluidValue);
}

View file

@ -38,7 +38,6 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.api.items.InventoryBase;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.util.RebornInventory;
import reborncore.common.util.WorldUtils;
@ -90,7 +89,7 @@ public class StorageUnitBlock extends BlockMachineBase {
public void onBlockBreakStart(BlockState state, World world, BlockPos pos, PlayerEntity player) {
super.onBlockBreakStart(state, world, pos, player);
if(world.isClient) return;
if (world.isClient) return;
final StorageUnitBaseBlockEntity storageEntity = (StorageUnitBaseBlockEntity) world.getBlockEntity(pos);
ItemStack stackInHand = player.getStackInHand(Hand.MAIN_HAND);
@ -100,10 +99,10 @@ public class StorageUnitBlock extends BlockMachineBase {
ItemStack out = inventory.getStack(StorageUnitBaseBlockEntity.OUTPUT_SLOT);
// Drop stack if sneaking
if(player.isSneaking()){
if (player.isSneaking()) {
WorldUtils.dropItem(new ItemStack(out.getItem()), world, player.getBlockPos());
out.decrement(1);
}else {
} else {
WorldUtils.dropItem(out, world, player.getBlockPos());
out.setCount(0);
}
@ -114,7 +113,6 @@ public class StorageUnitBlock extends BlockMachineBase {
}
@Override
public IMachineGuiHandler getGui() {
return GuiType.STORAGE_UNIT;

View file

@ -72,7 +72,7 @@ public abstract class BlockTransformer extends BaseBlockEntityProvider {
// BaseTileBlock
@Override
public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer,
ItemStack stack) {
ItemStack stack) {
super.onPlaced(worldIn, pos, state, placer, stack);
Direction facing = placer.getHorizontalFacing().getOpposite();
if (placer.pitch < -50) {

View file

@ -24,7 +24,6 @@
package techreborn.client;
import io.netty.buffer.Unpooled;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
@ -172,7 +171,7 @@ public final class GuiType<T extends BlockEntity> implements IMachineGuiHandler
@Override
public void open(PlayerEntity player, BlockPos pos, World world) {
if(!world.isClient){
if (!world.isClient) {
//This is awful
player.openHandledScreen(new ExtendedScreenHandlerFactory() {
@Override

View file

@ -73,7 +73,7 @@ public class GuiAESU extends GuiBase<BuiltScreenHandler> {
super.drawForeground(matrixStack, mouseX, mouseY);
final Layer layer = Layer.FOREGROUND;
if(!hideGuiElements()){
if (!hideGuiElements()) {
RenderSystem.pushMatrix();
RenderSystem.scaled(0.6, 0.6, 1);
Text text = new LiteralText(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) blockEntity.getEnergy()))
@ -89,7 +89,7 @@ public class GuiAESU extends GuiBase<BuiltScreenHandler> {
builder.drawMultiEnergyBar(matrixStack, this, 81, 28, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
}
public void onClick(int amount){
public void onClick(int amount) {
NetworkManager.sendToServer(ServerboundPackets.createPacketAesu(amount, Screen.hasShiftDown(), Screen.hasControlDown(), blockEntity));
}
}

View file

@ -57,7 +57,7 @@ public class GuiBatbox extends GuiBase<BuiltScreenHandler> {
super.drawForeground(matrixStack, mouseX, mouseY);
final Layer layer = Layer.FOREGROUND;
if(!hideGuiElements()){
if (!hideGuiElements()) {
RenderSystem.pushMatrix();
RenderSystem.scaled(0.6, 0.6, 5);
Text text = new LiteralText(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) blockEntity.getEnergy()))

View file

@ -69,7 +69,7 @@ public class GuiChunkLoader extends GuiBase<BuiltScreenHandler> {
drawCentredText(matrixStack, text, 25, 4210752, layer);
}
public void onClick(int amount){
public void onClick(int amount) {
NetworkManager.sendToServer(ServerboundPackets.createPacketChunkloader(amount, blockEntity, ClientChunkManager.hasChunksForLoader(blockEntity.getPos())));
}
}

View file

@ -77,7 +77,7 @@ public class GuiDistillationTower extends GuiBase<BuiltScreenHandler> {
}
public void onClick(GuiButtonExtended button, Double x, Double y){
public void onClick(GuiButtonExtended button, Double x, Double y) {
blockEntity.renderMultiblock ^= !hideGuiElements();
}
}

View file

@ -49,11 +49,11 @@ public class GuiIronFurnace extends GuiBase<BuiltScreenHandler> {
IronFurnaceBlockEntity blockEntity;
public GuiIronFurnace(int syncID, PlayerEntity player, IronFurnaceBlockEntity furnace) {
super(player, furnace, furnace.createScreenHandler(syncID, player));
super(player, furnace, furnace.createScreenHandler(syncID, player));
this.blockEntity = furnace;
}
public void onClick(){
public void onClick() {
NetworkManager.sendToServer(ServerboundPackets.createPacketExperience(blockEntity));
}
@ -87,7 +87,7 @@ public class GuiIronFurnace extends GuiBase<BuiltScreenHandler> {
furnaceExp -= PlayerUtils.getLevelExperience(player.experienceLevel);
++levels;
}
message = message + "+" + String.valueOf(levels) + "L";
message = message + "+" + levels + "L";
}
}

View file

@ -57,15 +57,15 @@ public class GuiMFE extends GuiBase<BuiltScreenHandler> {
super.drawForeground(matrixStack, mouseX, mouseY);
final Layer layer = Layer.FOREGROUND;
if(!hideGuiElements()){
if (!hideGuiElements()) {
RenderSystem.pushMatrix();
RenderSystem.scaled(0.6, 0.6, 1);
drawCentredText(matrixStack, new LiteralText(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) mfe.getEnergy()))
.append("/")
.append(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) mfe.getMaxPower()))
.append(" ")
.append(PowerSystem.getDisplayPower().abbreviation)
drawCentredText(matrixStack, new LiteralText(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) mfe.getEnergy()))
.append("/")
.append(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) mfe.getMaxPower()))
.append(" ")
.append(PowerSystem.getDisplayPower().abbreviation)
, 35, 0, 58, layer);
RenderSystem.popMatrix();

View file

@ -59,9 +59,9 @@ public class GuiManual extends Screen {
@Override
public void init() {
int y = (height / 2) - guiHeight / 2;
y+= 40;
y += 40;
addButton(new GuiButtonExtended((width / 2 - 30), y + 10, 60, 20, new TranslatableText("techreborn.manual.wikibtn"), var1 -> client.openScreen(new ConfirmChatLinkScreen(t -> {
if(t){
if (t) {
Util.getOperatingSystem().open("http://wiki.techreborn.ovh");
this.client.openScreen(this);
} else {
@ -69,14 +69,14 @@ public class GuiManual extends Screen {
}
}, "http://wiki.techreborn.ovh", false))));
addButton(new GuiButtonExtended((width / 2 - 30), y + 60, 60, 20, new TranslatableText("techreborn.manual.discordbtn"), var1 -> client.openScreen(new ConfirmChatLinkScreen(t -> {
if(t){
if (t) {
Util.getOperatingSystem().open("https://discord.gg/teamreborn");
this.client.openScreen(this);
}else {
} else {
this.client.openScreen(this);
}
}, "https://discord.gg/teamreborn", false))));
if(TechRebornConfig.allowManualRefund){
if (TechRebornConfig.allowManualRefund) {
addButton(new GuiButtonExtended((width / 2 - 30), y + 110, 60, 20, new TranslatableText("techreborn.manual.refundbtn"), var1 -> {
NetworkManager.sendToServer(ServerboundPackets.createRefundPacket());
this.client.openScreen(null);

View file

@ -35,7 +35,6 @@ import techreborn.blockentity.generator.PlasmaGeneratorBlockEntity;
/**
* @author drcrazy
*
*/
@Environment(EnvType.CLIENT)
public class GuiPlasmaGenerator extends GuiBase<BuiltScreenHandler> {

View file

@ -38,7 +38,7 @@ public class GuiRollingMachine extends GuiBase<BuiltScreenHandler> {
RollingMachineBlockEntity rollingMachine;
public GuiRollingMachine(int syncID, final PlayerEntity player, final RollingMachineBlockEntity blockEntityRollingmachine) {
super(player, blockEntityRollingmachine, blockEntityRollingmachine.createScreenHandler(syncID, player));
super(player, blockEntityRollingmachine, blockEntityRollingmachine.createScreenHandler(syncID, player));
this.rollingMachine = blockEntityRollingmachine;
}
@ -62,7 +62,7 @@ public class GuiRollingMachine extends GuiBase<BuiltScreenHandler> {
drawOutputSlot(matrixStack, 124, gridYPos + 18, layer);
builder.drawJEIButton(matrixStack, this, 158, 5, layer);
builder.drawLockButton(matrixStack, this, 130, 4, mouseX, mouseY, layer,rollingMachine.locked);
builder.drawLockButton(matrixStack, this, 130, 4, mouseX, mouseY, layer, rollingMachine.locked);
}
@Override
@ -76,7 +76,7 @@ public class GuiRollingMachine extends GuiBase<BuiltScreenHandler> {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
if(isPointInRect(130, 4, 20, 12, mouseX, mouseY)){
if (isPointInRect(130, 4, 20, 12, mouseX, mouseY)) {
NetworkManager.sendToServer(ServerboundPackets.createPacketRollingMachineLock(rollingMachine, !rollingMachine.locked));
return true;
}

View file

@ -58,7 +58,9 @@ import java.util.function.Supplier;
public abstract class BaseDynamicFluidBakedModel implements BakedModel, FabricBakedModel {
public abstract ModelIdentifier getBaseModel();
public abstract ModelIdentifier getBackgroundModel();
public abstract ModelIdentifier getFluidModel();
@Override

Some files were not shown because too many files have changed in this diff Show more