mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +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;
|
||||
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<EntityLivingBase> 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) {
|
||||
|
|
Loading…
Reference in a new issue