fix: more issues, ported item drill upgrade

This commit is contained in:
Michael Hillcox 2021-08-23 11:19:49 +01:00
parent cb45e86529
commit 12cd168a36
3 changed files with 20 additions and 19 deletions

View file

@ -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<ItemStack> 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));
}

View file

@ -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;
}

View file

@ -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);
}
}