Skip to content

Commit a13b0b5

Browse files
committed
Overload Station Functionality #1
1 parent 8ddda63 commit a13b0b5

4 files changed

Lines changed: 16 additions & 36 deletions

File tree

src/main/java/com/redcrafter07/ultrautilities/container/OverloadStationContainer.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ public OverloadStationContainer(int containerId, World world, BlockPos blockPos,
3030

3131
if(tileEntity != null) {
3232
tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(handler -> {
33-
addSlot(new SlotItemHandler(handler, 0, 10, 13));
34-
addSlot(new SlotItemHandler(handler, 1, 54, 13));
35-
addSlot(new SlotItemHandler(handler, 2, 152, 55));
33+
addSlot(new SlotItemHandler(handler, 0, 9, 14));
34+
addSlot(new SlotItemHandler(handler, 1, 152, 67));
3635
});
3736
}
3837
}
@@ -79,7 +78,7 @@ private void layoutPlayerInventorySlots(int leftCol, int topRow) {
7978
private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT;
8079

8180
// THIS YOU HAVE TO DEFINE!
82-
private static final int TE_INVENTORY_SLOT_COUNT = 3; // must match TileEntityInventoryBasic.NUMBER_OF_SLOTS
81+
private static final int TE_INVENTORY_SLOT_COUNT = 2; // must match TileEntityInventoryBasic.NUMBER_OF_SLOTS
8382

8483
@Override
8584
public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) {

src/main/java/com/redcrafter07/ultrautilities/screen/OverloadStationScreen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import net.minecraft.util.text.ITextComponent;
1212

1313
public class OverloadStationScreen extends ContainerScreen<OverloadStationContainer> {
14-
private final ResourceLocation guiLocation = new ResourceLocation(UltraUtilities.MOD_ID, "textures/gui/crafting_station.png");
14+
private final ResourceLocation guiLocation = new ResourceLocation(UltraUtilities.MOD_ID, "textures/gui/overload_station.png");
1515

1616
public OverloadStationScreen(OverloadStationContainer container, PlayerInventory inv, ITextComponent textComponent) {
1717
super(container, inv, textComponent);

src/main/java/com/redcrafter07/ultrautilities/tileentity/OverloadStationTile.java

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.redcrafter07.ultrautilities.item.ModItems;
66
import net.minecraft.block.BlockState;
77
import net.minecraft.inventory.Inventory;
8+
import net.minecraft.item.Item;
89
import net.minecraft.item.ItemStack;
910
import net.minecraft.nbt.CompoundNBT;
1011
import net.minecraft.tileentity.ITickableTileEntity;
@@ -46,7 +47,7 @@ public CompoundNBT write(CompoundNBT nbt) {
4647
}
4748

4849
private ItemStackHandler createHandler() {
49-
return new ItemStackHandler(3) {
50+
return new ItemStackHandler(2) {
5051
@Override
5152
protected void onContentsChanged(int slot) {
5253
markDirty();
@@ -56,10 +57,8 @@ protected void onContentsChanged(int slot) {
5657
public boolean isItemValid(int slot, @Nonnull ItemStack stack) {
5758
switch (slot) {
5859
case 0:
59-
return stack.getItem() == ModItems.PROCESSOR_CORE.get();
60+
return stack.getItem() == ModItems.OVERLOAD_PROCESSOR.get();
6061
case 1:
61-
case 2:
62-
return stack.getItem() != ModItems.PROCESSOR_CORE.get();
6362
default: return true;
6463
}
6564
}
@@ -90,36 +89,18 @@ public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable D
9089
return super.getCapability(cap, side);
9190
}
9291

93-
public void craft() {
94-
Inventory inv = new Inventory(itemHandler.getSlots());
95-
for (int i = 0; i < itemHandler.getSlots(); i++) {
96-
inv.setInventorySlotContents(i, itemHandler.getStackInSlot(i));
97-
}
98-
99-
Optional<CraftingStationRecipe> recipe = world.getRecipeManager()
100-
.getRecipe(ModRecipeTypes.PROCESSOR_RECIPE, inv, world);
101-
102-
recipe.ifPresent(iRecipe -> {
103-
ItemStack output = iRecipe.getRecipeOutput();
104-
105-
// System.out.println(itemHandler.getStackInSlot(2).getCount());
106-
107-
if(itemHandler.getStackInSlot(2).getCount() < 1) {
108-
itemHandler.extractItem(0, 1, false);
109-
itemHandler.extractItem(1, 1, false);
110-
itemHandler.insertItem(2, output, false);
111-
}
112-
113-
114-
markDirty();
115-
});
116-
}
117-
11892
@Override
11993
public void tick() {
120-
if(world.isRemote) return;
94+
//if(world.isRemote) return;
12195

96+
System.out.println(itemHandler.getStackInSlot(0).getCount());
12297

123-
craft();
98+
if(itemHandler.getStackInSlot(0).getCount() != 0) {
99+
System.out.println(itemHandler.getStackInSlot(1).getItem().getName());
100+
101+
//if(item.getName().toString() != "processor_sword") return;
102+
103+
itemHandler.getStackInSlot(1).getItem().setDamage(itemHandler.getStackInSlot(1), itemHandler.getStackInSlot(1).getItem().getDamage(itemHandler.getStackInSlot(1)) - 1);
104+
}
124105
}
125106
}
3.42 KB
Loading

0 commit comments

Comments
 (0)