Add JEI transfer support for ContainerBuilder + Convert Compressor, Extractor and Grinder
This commit is contained in:
parent
1df2c84e16
commit
94a0616d8e
28 changed files with 401 additions and 433 deletions
|
@ -1,47 +0,0 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.slots.BaseSlot;
|
||||
import reborncore.client.gui.slots.SlotOutput;
|
||||
import techreborn.api.gui.SlotUpgrade;
|
||||
import techreborn.tiles.teir1.TileCompressor;
|
||||
|
||||
public class ContainerCompressor extends ContainerCrafting {
|
||||
|
||||
public int connectionStatus;
|
||||
EntityPlayer player;
|
||||
TileCompressor tile;
|
||||
|
||||
public ContainerCompressor(TileCompressor tileGrinder, EntityPlayer player) {
|
||||
super(tileGrinder.crafter);
|
||||
tile = tileGrinder;
|
||||
this.player = player;
|
||||
|
||||
// input
|
||||
this.addSlotToContainer(new BaseSlot(tileGrinder.inventory, 0, 56, 34));
|
||||
this.addSlotToContainer(new SlotOutput(tileGrinder.inventory, 1, 116, 34));
|
||||
|
||||
// upgrades
|
||||
this.addSlotToContainer(new SlotUpgrade(tileGrinder.inventory, 2, 152, 8));
|
||||
this.addSlotToContainer(new SlotUpgrade(tileGrinder.inventory, 3, 152, 26));
|
||||
this.addSlotToContainer(new SlotUpgrade(tileGrinder.inventory, 4, 152, 44));
|
||||
this.addSlotToContainer(new SlotUpgrade(tileGrinder.inventory, 5, 152, 62));
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new BaseSlot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer p_75145_1_) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.slots.BaseSlot;
|
||||
import reborncore.client.gui.slots.SlotInput;
|
||||
import reborncore.client.gui.slots.SlotOutput;
|
||||
import techreborn.api.gui.SlotUpgrade;
|
||||
import techreborn.tiles.teir1.TileExtractor;
|
||||
|
||||
public class ContainerExtractor extends ContainerCrafting {
|
||||
|
||||
EntityPlayer player;
|
||||
TileExtractor tileExtractor;
|
||||
|
||||
public ContainerExtractor(EntityPlayer player, TileExtractor tileExtractor) {
|
||||
super(tileExtractor.crafter);
|
||||
this.player = player;
|
||||
this.tileExtractor = tileExtractor;
|
||||
// input
|
||||
this.addSlotToContainer(new SlotInput(tileExtractor.inventory, 0, 56, 34));
|
||||
this.addSlotToContainer(new SlotOutput(tileExtractor.inventory, 1, 116, 34));
|
||||
|
||||
// upgrades
|
||||
this.addSlotToContainer(new SlotUpgrade(tileExtractor.inventory, 2, 152, 8));
|
||||
this.addSlotToContainer(new SlotUpgrade(tileExtractor.inventory, 3, 152, 26));
|
||||
this.addSlotToContainer(new SlotUpgrade(tileExtractor.inventory, 4, 152, 44));
|
||||
this.addSlotToContainer(new SlotUpgrade(tileExtractor.inventory, 5, 152, 62));
|
||||
|
||||
addPlayerSlots();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer p_75145_1_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addPlayerSlots() {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new BaseSlot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.slots.BaseSlot;
|
||||
import reborncore.client.gui.slots.SlotInput;
|
||||
import reborncore.client.gui.slots.SlotOutput;
|
||||
import techreborn.api.gui.SlotUpgrade;
|
||||
import techreborn.tiles.teir1.TileGrinder;
|
||||
|
||||
public class ContainerGrinder extends ContainerCrafting {
|
||||
|
||||
public int connectionStatus;
|
||||
EntityPlayer player;
|
||||
TileGrinder tile;
|
||||
|
||||
public ContainerGrinder(EntityPlayer player, TileGrinder tile) {
|
||||
super(tile.crafter);
|
||||
this.player = player;
|
||||
this.tile = tile;
|
||||
addInventorySlots();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer p_75145_1_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addInventorySlots() {
|
||||
// input
|
||||
this.addSlotToContainer(new SlotInput(tile.inventory, 0, 56, 34));
|
||||
this.addSlotToContainer(new SlotOutput(tile.inventory, 1, 116, 34));
|
||||
|
||||
// upgrades
|
||||
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 2, 152, 8));
|
||||
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 3, 152, 26));
|
||||
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 4, 152, 44));
|
||||
this.addSlotToContainer(new SlotUpgrade(tile.inventory, 5, 152, 62));
|
||||
|
||||
addPlayerSlots();
|
||||
}
|
||||
|
||||
public void addPlayerSlots() {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new BaseSlot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -20,7 +20,9 @@ import java.util.function.IntConsumer;
|
|||
import java.util.function.IntSupplier;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
final class BuiltContainer extends Container {
|
||||
public class BuiltContainer extends Container {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final Predicate<EntityPlayer> canInteract;
|
||||
private final List<Range<Integer>> playerSlotRanges;
|
||||
|
@ -30,8 +32,11 @@ final class BuiltContainer extends Container {
|
|||
private final ArrayList<MutableTriple<IntSupplier, IntConsumer, Integer>> integerValues;
|
||||
private Integer[] integerParts;
|
||||
|
||||
public BuiltContainer(final Predicate<EntityPlayer> canInteract, final List<Range<Integer>> playerSlotRange,
|
||||
public BuiltContainer(final String name, final Predicate<EntityPlayer> canInteract,
|
||||
final List<Range<Integer>> playerSlotRange,
|
||||
final List<Range<Integer>> tileSlotRange) {
|
||||
this.name = name;
|
||||
|
||||
this.canInteract = canInteract;
|
||||
|
||||
this.playerSlotRanges = playerSlotRange;
|
||||
|
@ -242,4 +247,8 @@ final class BuiltContainer extends Container {
|
|||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
|
@ -15,6 +15,8 @@ import java.util.function.IntSupplier;
|
|||
import java.util.function.Predicate;
|
||||
|
||||
public class ContainerBuilder {
|
||||
|
||||
private final String name;
|
||||
private Predicate<EntityPlayer> canInteract = player -> true;
|
||||
|
||||
final List<Slot> slots;
|
||||
|
@ -23,7 +25,10 @@ public class ContainerBuilder {
|
|||
final List<Pair<IntSupplier, IntConsumer>> shortValues;
|
||||
final List<Pair<IntSupplier, IntConsumer>> integerValues;
|
||||
|
||||
public ContainerBuilder() {
|
||||
public ContainerBuilder(final String name) {
|
||||
|
||||
this.name = name;
|
||||
|
||||
this.slots = new ArrayList<>();
|
||||
this.playerInventoryRanges = new ArrayList<>();
|
||||
this.tileInventoryRanges = new ArrayList<>();
|
||||
|
@ -54,7 +59,7 @@ public class ContainerBuilder {
|
|||
}
|
||||
|
||||
public BuiltContainer create() {
|
||||
final BuiltContainer built = new BuiltContainer(this.canInteract, this.playerInventoryRanges,
|
||||
final BuiltContainer built = new BuiltContainer(this.name, this.canInteract, this.playerInventoryRanges,
|
||||
this.tileInventoryRanges);
|
||||
if (!this.shortValues.isEmpty())
|
||||
built.addShortSync(this.shortValues);
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraftforge.energy.CapabilityEnergy;
|
|||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import reborncore.api.power.IEnergyInterfaceItem;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.client.gui.slots.BaseSlot;
|
||||
import reborncore.client.gui.slots.SlotFake;
|
||||
import reborncore.client.gui.slots.SlotOutput;
|
||||
|
@ -110,6 +111,20 @@ public class ContainerTileInventoryBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
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);
|
||||
Core.logHelper
|
||||
.error(this.tile + " is not an instance of IRecipeCrafterProvider! Craft progress cannot be synced.");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContainerBuilder addInventory() {
|
||||
this.parent.tileInventoryRanges.add(Range.between(this.rangeStart, this.parent.slots.size() - 1));
|
||||
return this.parent;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue