diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrafterOnAStick.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrafterOnAStick.java index dc4d9f195..e64d6b04d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrafterOnAStick.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrafterOnAStick.java @@ -10,17 +10,22 @@ package de.ellpeck.actuallyadditions.mod.items; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.inventory.container.SimpleNamedContainerProvider; +import net.minecraft.inventory.container.WorkbenchContainer; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; +import net.minecraftforge.fml.network.NetworkHooks; public class ItemCrafterOnAStick extends ItemBase { + private static final ITextComponent CONTAINER_TITLE = new TranslationTextComponent("container.crafting"); public ItemCrafterOnAStick() { super(ActuallyItems.defaultNonStacking()); @@ -29,7 +34,7 @@ public class ItemCrafterOnAStick extends ItemBase { @Override public ActionResult use(World world, PlayerEntity player, Hand hand) { if (!world.isClientSide) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.CRAFTER.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ); + NetworkHooks.openGui((ServerPlayerEntity) player, new SimpleNamedContainerProvider((windowId, playerInventory, playerEntity) -> new WorkbenchContainer(windowId, playerInventory), CONTAINER_TITLE)); } return new ActionResult<>(ActionResultType.SUCCESS, player.getItemInHand(hand)); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java index 913aedb30..3a54306b0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java @@ -29,7 +29,7 @@ public class ItemDrillUpgrade extends ItemBase { } public static int getSlotToPlaceFrom(ItemStack stack) { - CompoundNBT compound = stack.getTagCompound(); + CompoundNBT compound = stack.getTag(); if (compound != null) { return compound.getInt("SlotToPlaceFrom") - 1; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPotionRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPotionRing.java index 9a66271bb..7e99bd2a8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPotionRing.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPotionRing.java @@ -26,7 +26,6 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.tileentity.TileEntity; @@ -54,19 +53,16 @@ public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDi } public static int getStoredBlaze(ItemStack stack) { - if (!StackUtil.isValid(stack) || !stack.hasTagCompound()) { + if (!StackUtil.isValid(stack) || !stack.hasTag()) { return 0; } else { - return stack.getTagCompound().getInteger("Blaze"); + return stack.getOrCreateTag().getInt("Blaze"); } } public static void setStoredBlaze(ItemStack stack, int amount) { if (StackUtil.isValid(stack)) { - if (!stack.hasTagCompound()) { - stack.setTagCompound(new CompoundNBT()); - } - stack.getTagCompound().setInteger("Blaze", amount); + stack.getOrCreateTag().putInt("Blaze", amount); } } @@ -90,8 +86,8 @@ public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDi @Override public String getDescriptionId(ItemStack stack) { return stack.getItemDamage() >= ALL_RINGS.length - ? StringUtil.BUGGED_ITEM_NAME - : this.getDescriptionId() + ALL_RINGS[stack.getItemDamage()].name; + ? StringUtil.BUGGED_ITEM_NAME + : this.getDescriptionId() + ALL_RINGS[stack.getItemDamage()].name; } @Override @@ -148,8 +144,8 @@ public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDi @Override public EnumRarity getRarity(ItemStack stack) { return stack.getItemDamage() >= ALL_RINGS.length - ? EnumRarity.COMMON - : ALL_RINGS[stack.getItemDamage()].rarity; + ? EnumRarity.COMMON + : ALL_RINGS[stack.getItemDamage()].rarity; } @Override @@ -177,16 +173,16 @@ public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDi @OnlyIn(Dist.CLIENT) public IItemColor getItemColor() { return (stack, tintIndex) -> stack.getItemDamage() >= ALL_RINGS.length - ? 0xFFFFFF - : ALL_RINGS[stack.getItemDamage()].color; + ? 0xFFFFFF + : ALL_RINGS[stack.getItemDamage()].color; } @Override public boolean update(ItemStack stack, TileEntity tile, int elapsedTicks) { boolean advanced = ((ItemPotionRing) stack.getItem()).isAdvanced; int range = advanced - ? 48 - : 16; + ? 48 + : 16; List entities = tile.getLevel().getEntitiesOfClass(EntityLivingBase.class, new AxisAlignedBB(tile.getBlockPos().getX() - range, tile.getBlockPos().getY() - range, tile.getBlockPos().getZ() - range, tile.getBlockPos().getX() + range, tile.getBlockPos().getY() + range, tile.getBlockPos().getZ() + range)); if (entities != null && !entities.isEmpty()) { if (advanced) {