mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 02:55:17 +00:00
Update to 1.17
Update to Official classnames Patchwork Make the game compile and run Merge in the new HUD overlay API Merge in the new render properties API PEEL Use Gradle 7.2 snapshot to fix eclipse integration bug in 7.1, Would use 7.0 but FG needs 7.1 for some reason. New FML installer Update to 1.17.1 Co-authored-by: LexManos <[email protected]> Co-authored-by: SizableShrimp <[email protected]> Co-authored-by: cpw <[email protected]> Co-authored-by: Curle <[email protected]> Co-authored-by: Unnoen <[email protected]> Co-authored-by: covers1624 <[email protected]> Co-authored-by: DaemonUmbra <[email protected]> Co-authored-by: gigaherz <[email protected]> Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
1 parent
064ae6961b
commit
be5446b91c
1990 files changed
+35661
-37544
No files matched your search
@@ -19,17 +19,10 @@
|
||||
|
||||
package net.minecraftforge.items;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class CapabilityItemHandler
|
||||
{
|
||||
@CapabilityInject(IItemHandler.class)
|
||||
@@ -37,46 +30,7 @@ public class CapabilityItemHandler
|
||||
|
||||
public static void register()
|
||||
{
|
||||
CapabilityManager.INSTANCE.register(IItemHandler.class, new Capability.IStorage<IItemHandler>()
|
||||
{
|
||||
@Override
|
||||
public INBT writeNBT(Capability<IItemHandler> capability, IItemHandler instance, Direction side)
|
||||
{
|
||||
ListNBT nbtTagList = new ListNBT();
|
||||
int size = instance.getSlots();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
ItemStack stack = instance.getStackInSlot(i);
|
||||
if (!stack.isEmpty())
|
||||
{
|
||||
CompoundNBT itemTag = new CompoundNBT();
|
||||
itemTag.putInt("Slot", i);
|
||||
stack.save(itemTag);
|
||||
nbtTagList.add(itemTag);
|
||||
}
|
||||
}
|
||||
return nbtTagList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(Capability<IItemHandler> capability, IItemHandler instance, Direction side, INBT base)
|
||||
{
|
||||
if (!(instance instanceof IItemHandlerModifiable))
|
||||
throw new RuntimeException("IItemHandler instance does not implement IItemHandlerModifiable");
|
||||
IItemHandlerModifiable itemHandlerModifiable = (IItemHandlerModifiable) instance;
|
||||
ListNBT tagList = (ListNBT) base;
|
||||
for (int i = 0; i < tagList.size(); i++)
|
||||
{
|
||||
CompoundNBT itemTags = tagList.getCompound(i);
|
||||
int j = itemTags.getInt("Slot");
|
||||
|
||||
if (j >= 0 && j < instance.getSlots())
|
||||
{
|
||||
itemHandlerModifiable.setStackInSlot(j, ItemStack.of(itemTags));
|
||||
}
|
||||
}
|
||||
}
|
||||
}, ItemStackHandler::new);
|
||||
CapabilityManager.INSTANCE.register(IItemHandler.class);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user