55import com .redcrafter07 .ultrautilities .item .ModItems ;
66import net .minecraft .block .BlockState ;
77import net .minecraft .inventory .Inventory ;
8+ import net .minecraft .item .Item ;
89import net .minecraft .item .ItemStack ;
910import net .minecraft .nbt .CompoundNBT ;
1011import 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}
0 commit comments