Auto format code
This commit is contained in:
parent
fc4d8686b8
commit
b25742dde0
175 changed files with 527 additions and 737 deletions
|
@ -30,7 +30,6 @@ import net.minecraftforge.fml.relauncher.Side;
|
|||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.client.gui.slots.BaseSlot;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.tiles.lesu.TileLesu;
|
||||
|
||||
public class ContainerLESU extends RebornContainer {
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
|
||||
public interface IContainerProvider {
|
||||
|
|
|
@ -24,16 +24,14 @@
|
|||
|
||||
package techreborn.client.container.builder;
|
||||
|
||||
import org.apache.commons.lang3.Range;
|
||||
import org.apache.commons.lang3.tuple.MutableTriple;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.Range;
|
||||
import org.apache.commons.lang3.tuple.MutableTriple;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.client.container.IRightClickHandler;
|
||||
|
||||
|
@ -58,8 +56,8 @@ public class BuiltContainer extends Container {
|
|||
private Integer[] integerParts;
|
||||
|
||||
public BuiltContainer(final String name, final Predicate<EntityPlayer> canInteract,
|
||||
final List<Range<Integer>> playerSlotRange,
|
||||
final List<Range<Integer>> tileSlotRange) {
|
||||
final List<Range<Integer>> playerSlotRange,
|
||||
final List<Range<Integer>> tileSlotRange) {
|
||||
this.name = name;
|
||||
|
||||
this.canInteract = canInteract;
|
||||
|
@ -107,10 +105,10 @@ public class BuiltContainer extends Container {
|
|||
|
||||
@Override
|
||||
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
|
||||
if(dragType == 1 && slotId > 0 && slotId < 1000){
|
||||
if (dragType == 1 && slotId > 0 && slotId < 1000) {
|
||||
Slot slot = this.inventorySlots.get(slotId);
|
||||
if(slot instanceof IRightClickHandler){
|
||||
if(((IRightClickHandler) slot).handleRightClick(slot.getSlotIndex(), player, this)){
|
||||
if (slot instanceof IRightClickHandler) {
|
||||
if (((IRightClickHandler) slot).handleRightClick(slot.getSlotIndex(), player, this)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
@ -180,20 +178,16 @@ public class BuiltContainer extends Container {
|
|||
@Override
|
||||
public void updateProgressBar(final int id, final int value) {
|
||||
|
||||
if(id < this.shortValues.size())
|
||||
{
|
||||
if (id < this.shortValues.size()) {
|
||||
this.shortValues.get(id).getMiddle().accept((short) value);
|
||||
this.shortValues.get(id).setRight((short) value);
|
||||
}
|
||||
else if (id - this.shortValues.size() < this.integerValues.size() * 2)
|
||||
{
|
||||
} else if (id - this.shortValues.size() < this.integerValues.size() * 2) {
|
||||
|
||||
if ((id - this.shortValues.size()) % 2 == 0)
|
||||
this.integerParts[(id - this.shortValues.size()) / 2] = value;
|
||||
else
|
||||
{
|
||||
else {
|
||||
this.integerValues.get((id - this.shortValues.size()) / 2).getMiddle().accept(
|
||||
(this.integerParts[(id - this.shortValues.size()) / 2] & 0xFFFF) << 16 | value & 0xFFFF);
|
||||
(this.integerParts[(id - this.shortValues.size()) / 2] & 0xFFFF) << 16 | value & 0xFFFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +241,7 @@ public class BuiltContainer extends Container {
|
|||
final Slot slot = this.inventorySlots.get(slotIndex);
|
||||
final ItemStack stackInSlot = slot.getStack();
|
||||
if (stackInSlot != ItemStack.EMPTY && ItemUtils.isItemEqual(stackInSlot, stackToShift, true, true)
|
||||
&& slot.isItemValid(stackToShift)) {
|
||||
&& slot.isItemValid(stackToShift)) {
|
||||
final int resultingStackSize = stackInSlot.getCount() + stackToShift.getCount();
|
||||
final int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
|
||||
if (resultingStackSize <= max) {
|
||||
|
@ -299,4 +293,4 @@ public class BuiltContainer extends Container {
|
|||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,14 +24,13 @@
|
|||
|
||||
package techreborn.client.container.builder;
|
||||
|
||||
import org.apache.commons.lang3.Range;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import org.apache.commons.lang3.Range;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -91,8 +90,8 @@ public class ContainerBuilder {
|
|||
|
||||
public BuiltContainer create() {
|
||||
final BuiltContainer built = new BuiltContainer(this.name, this.canInteract,
|
||||
this.playerInventoryRanges,
|
||||
this.tileInventoryRanges);
|
||||
this.playerInventoryRanges,
|
||||
this.tileInventoryRanges);
|
||||
if (!this.shortValues.isEmpty())
|
||||
built.addShortSync(this.shortValues);
|
||||
if (!this.integerValues.isEmpty())
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
|
||||
package techreborn.client.container.builder;
|
||||
|
||||
import org.apache.commons.lang3.Range;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.SlotFurnaceFuel;
|
||||
|
@ -34,7 +31,8 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import org.apache.commons.lang3.Range;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import reborncore.api.power.IEnergyInterfaceItem;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IUpgrade;
|
||||
|
@ -43,7 +41,6 @@ import reborncore.client.gui.slots.BaseSlot;
|
|||
import reborncore.client.gui.slots.SlotFake;
|
||||
import reborncore.client.gui.slots.SlotOutput;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
|
||||
import techreborn.Core;
|
||||
import techreborn.client.container.builder.slot.FilteredSlot;
|
||||
import techreborn.client.container.builder.slot.UpgradeSlot;
|
||||
|
@ -63,7 +60,7 @@ public class ContainerTileInventoryBuilder {
|
|||
this.tile = tile;
|
||||
this.parent = parent;
|
||||
this.rangeStart = parent.slots.size();
|
||||
if(tile instanceof IUpgradeable){
|
||||
if (tile instanceof IUpgradeable) {
|
||||
upgradeSlots((IUpgradeable) tile);
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +81,7 @@ public class ContainerTileInventoryBuilder {
|
|||
}
|
||||
|
||||
public ContainerTileInventoryBuilder filterSlot(final int index, final int x, final int y,
|
||||
final Predicate<ItemStack> filter) {
|
||||
final Predicate<ItemStack> filter) {
|
||||
this.parent.slots.add(new FilteredSlot(this.tile, index, x, y).setFilter(filter));
|
||||
return this;
|
||||
}
|
||||
|
@ -92,20 +89,19 @@ public class ContainerTileInventoryBuilder {
|
|||
@SuppressWarnings("null")
|
||||
public ContainerTileInventoryBuilder energySlot(final int index, final int x, final int y) {
|
||||
this.parent.slots.add(new FilteredSlot(this.tile, index, x, y)
|
||||
.setFilter(stack -> stack.hasCapability(CapabilityEnergy.ENERGY, EnumFacing.UP)
|
||||
|| stack.getItem() instanceof IEnergyInterfaceItem));
|
||||
.setFilter(stack -> stack.hasCapability(CapabilityEnergy.ENERGY, EnumFacing.UP)
|
||||
|| stack.getItem() instanceof IEnergyInterfaceItem));
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("null")
|
||||
public ContainerTileInventoryBuilder fluidSlot(final int index, final int x, final int y) {
|
||||
this.parent.slots.add(new FilteredSlot(this.tile, index, x, y).setFilter(
|
||||
stack -> stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, EnumFacing.UP)));
|
||||
stack -> stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, EnumFacing.UP)));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContainerTileInventoryBuilder fuelSlot(final int index, final int x, final int y)
|
||||
{
|
||||
public ContainerTileInventoryBuilder fuelSlot(final int index, final int x, final int y) {
|
||||
this.parent.slots.add(new SlotFurnaceFuel(this.tile, index, x, y));
|
||||
return this;
|
||||
}
|
||||
|
@ -113,12 +109,12 @@ public class ContainerTileInventoryBuilder {
|
|||
@Deprecated
|
||||
public ContainerTileInventoryBuilder upgradeSlot(final int index, final int x, final int y) {
|
||||
this.parent.slots.add(new FilteredSlot(this.tile, index, x, y)
|
||||
.setFilter(stack -> stack.getItem() instanceof IUpgrade));
|
||||
.setFilter(stack -> stack.getItem() instanceof IUpgrade));
|
||||
return this;
|
||||
}
|
||||
|
||||
private ContainerTileInventoryBuilder upgradeSlots(IUpgradeable upgradeable){
|
||||
if(upgradeable.canBeUpgraded()){
|
||||
private ContainerTileInventoryBuilder upgradeSlots(IUpgradeable upgradeable) {
|
||||
if (upgradeable.canBeUpgraded()) {
|
||||
for (int i = 0; i < upgradeable.getUpgradeSlotCount(); i++) {
|
||||
this.parent.slots.add(new UpgradeSlot(upgradeable.getUpgradeInvetory(), i, -19, i * 18 + 12));
|
||||
}
|
||||
|
@ -127,12 +123,9 @@ public class ContainerTileInventoryBuilder {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param supplier
|
||||
* The supplier must supply a variable holding inside a Short, it
|
||||
* will be truncated by force.
|
||||
* @param setter
|
||||
* The setter to call when the variable has been updated.
|
||||
* @param supplier The supplier must supply a variable holding inside a Short, it
|
||||
* will be truncated by force.
|
||||
* @param setter The setter to call when the variable has been updated.
|
||||
*/
|
||||
public ContainerTileInventoryBuilder syncShortValue(final IntSupplier supplier, final IntConsumer setter) {
|
||||
this.parent.shortValues.add(Pair.of(supplier, setter));
|
||||
|
@ -140,12 +133,9 @@ public class ContainerTileInventoryBuilder {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param supplier
|
||||
* The supplier it can supply a variable holding in an Integer it
|
||||
* will be split inside multiples shorts.
|
||||
* @param setter
|
||||
* The setter to call when the variable has been updated.
|
||||
* @param supplier The supplier it can supply a variable holding in an Integer it
|
||||
* will be split inside multiples shorts.
|
||||
* @param setter The setter to call when the variable has been updated.
|
||||
*/
|
||||
public ContainerTileInventoryBuilder syncIntegerValue(final IntSupplier supplier, final IntConsumer setter) {
|
||||
this.parent.integerValues.add(Pair.of(supplier, setter));
|
||||
|
@ -155,7 +145,7 @@ public class ContainerTileInventoryBuilder {
|
|||
public ContainerTileInventoryBuilder syncEnergyValue() {
|
||||
if (this.tile instanceof TilePowerAcceptor)
|
||||
return this.syncIntegerValue(() -> (int) ((TilePowerAcceptor) this.tile).getEnergy(),
|
||||
((TilePowerAcceptor) this.tile)::setEnergy)
|
||||
((TilePowerAcceptor) this.tile)::setEnergy)
|
||||
.syncIntegerValue(() -> (int) ((TilePowerAcceptor) this.tile).extraPowerStoage,
|
||||
((TilePowerAcceptor) this.tile)::setExtraPowerStoage);
|
||||
Core.logHelper.error(this.tile + " is not an instance of TilePowerAcceptor! Energy cannot be synced.");
|
||||
|
@ -165,14 +155,14 @@ public class ContainerTileInventoryBuilder {
|
|||
public ContainerTileInventoryBuilder syncCrafterValue() {
|
||||
if (this.tile instanceof IRecipeCrafterProvider)
|
||||
return this
|
||||
.syncIntegerValue(() -> ((IRecipeCrafterProvider) this.tile).getRecipeCrafter().currentTickTime,
|
||||
(currentTickTime) -> ((IRecipeCrafterProvider) this.tile)
|
||||
.getRecipeCrafter().currentTickTime = currentTickTime)
|
||||
.syncIntegerValue(() -> ((IRecipeCrafterProvider) this.tile).getRecipeCrafter().currentNeededTicks,
|
||||
(currentNeededTicks) -> ((IRecipeCrafterProvider) this.tile)
|
||||
.getRecipeCrafter().currentNeededTicks = currentNeededTicks);
|
||||
.syncIntegerValue(() -> ((IRecipeCrafterProvider) this.tile).getRecipeCrafter().currentTickTime,
|
||||
(currentTickTime) -> ((IRecipeCrafterProvider) this.tile)
|
||||
.getRecipeCrafter().currentTickTime = currentTickTime)
|
||||
.syncIntegerValue(() -> ((IRecipeCrafterProvider) this.tile).getRecipeCrafter().currentNeededTicks,
|
||||
(currentNeededTicks) -> ((IRecipeCrafterProvider) this.tile)
|
||||
.getRecipeCrafter().currentNeededTicks = currentNeededTicks);
|
||||
Core.logHelper
|
||||
.error(this.tile + " is not an instance of IRecipeCrafterProvider! Craft progress cannot be synced.");
|
||||
.error(this.tile + " is not an instance of IRecipeCrafterProvider! Craft progress cannot be synced.");
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,14 +24,13 @@
|
|||
|
||||
package techreborn.client.container.builder.slot;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class SpriteSlot extends FilteredSlot {
|
||||
|
||||
private final String sprite;
|
||||
|
|
|
@ -31,7 +31,6 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import reborncore.api.tile.IUpgrade;
|
||||
import reborncore.api.tile.IUpgradeable;
|
||||
import reborncore.common.tile.TileBase;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.client.container.IRightClickHandler;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
|
@ -46,7 +45,6 @@ public class UpgradeSlot extends Slot implements IRightClickHandler {
|
|||
super(inventory, index, xPosition, yPosition);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack stack) {
|
||||
return stack.getItem() instanceof IUpgrade;
|
||||
|
@ -59,15 +57,15 @@ public class UpgradeSlot extends Slot implements IRightClickHandler {
|
|||
|
||||
@Override
|
||||
public boolean handleRightClick(int slotID, EntityPlayer player, BuiltContainer container) {
|
||||
if(inventory instanceof Inventory){
|
||||
if (inventory instanceof Inventory) {
|
||||
Inventory inv = (Inventory) inventory;
|
||||
TileEntity tileEntity = inv.getTileBase();
|
||||
if(tileEntity instanceof IUpgradeable){
|
||||
if (tileEntity instanceof IUpgradeable) {
|
||||
IUpgradeable upgradeable = (IUpgradeable) tileEntity;
|
||||
if(upgradeable.canBeUpgraded()){
|
||||
if (upgradeable.canBeUpgraded()) {
|
||||
ItemStack stack = upgradeable.getUpgradeInvetory().getStackInSlot(slotID);
|
||||
if(!stack.isEmpty() && stack.getItem() instanceof IUpgrade){
|
||||
if(player.world.isRemote){
|
||||
if (!stack.isEmpty() && stack.getItem() instanceof IUpgrade) {
|
||||
if (player.world.isRemote) {
|
||||
((IUpgrade) stack.getItem()).handleRightClick(tileEntity, stack, container, slotID);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue