mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
fix: more issues, ported item drill upgrade
This commit is contained in:
parent
cb45e86529
commit
12cd168a36
3 changed files with 20 additions and 19 deletions
|
@ -10,17 +10,22 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
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 de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
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.item.ItemStack;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.fml.network.NetworkHooks;
|
||||||
|
|
||||||
public class ItemCrafterOnAStick extends ItemBase {
|
public class ItemCrafterOnAStick extends ItemBase {
|
||||||
|
private static final ITextComponent CONTAINER_TITLE = new TranslationTextComponent("container.crafting");
|
||||||
|
|
||||||
public ItemCrafterOnAStick() {
|
public ItemCrafterOnAStick() {
|
||||||
super(ActuallyItems.defaultNonStacking());
|
super(ActuallyItems.defaultNonStacking());
|
||||||
|
@ -29,7 +34,7 @@ public class ItemCrafterOnAStick extends ItemBase {
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
||||||
if (!world.isClientSide) {
|
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));
|
return new ActionResult<>(ActionResultType.SUCCESS, player.getItemInHand(hand));
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class ItemDrillUpgrade extends ItemBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getSlotToPlaceFrom(ItemStack stack) {
|
public static int getSlotToPlaceFrom(ItemStack stack) {
|
||||||
CompoundNBT compound = stack.getTagCompound();
|
CompoundNBT compound = stack.getTag();
|
||||||
if (compound != null) {
|
if (compound != null) {
|
||||||
return compound.getInt("SlotToPlaceFrom") - 1;
|
return compound.getInt("SlotToPlaceFrom") - 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.potion.Potion;
|
import net.minecraft.potion.Potion;
|
||||||
import net.minecraft.potion.PotionEffect;
|
import net.minecraft.potion.PotionEffect;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
@ -54,19 +53,16 @@ public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDi
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getStoredBlaze(ItemStack stack) {
|
public static int getStoredBlaze(ItemStack stack) {
|
||||||
if (!StackUtil.isValid(stack) || !stack.hasTagCompound()) {
|
if (!StackUtil.isValid(stack) || !stack.hasTag()) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return stack.getTagCompound().getInteger("Blaze");
|
return stack.getOrCreateTag().getInt("Blaze");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setStoredBlaze(ItemStack stack, int amount) {
|
public static void setStoredBlaze(ItemStack stack, int amount) {
|
||||||
if (StackUtil.isValid(stack)) {
|
if (StackUtil.isValid(stack)) {
|
||||||
if (!stack.hasTagCompound()) {
|
stack.getOrCreateTag().putInt("Blaze", amount);
|
||||||
stack.setTagCompound(new CompoundNBT());
|
|
||||||
}
|
|
||||||
stack.getTagCompound().setInteger("Blaze", amount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue