mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 16:58:34 +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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,8 +86,8 @@ public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDi
|
||||||
@Override
|
@Override
|
||||||
public String getDescriptionId(ItemStack stack) {
|
public String getDescriptionId(ItemStack stack) {
|
||||||
return stack.getItemDamage() >= ALL_RINGS.length
|
return stack.getItemDamage() >= ALL_RINGS.length
|
||||||
? StringUtil.BUGGED_ITEM_NAME
|
? StringUtil.BUGGED_ITEM_NAME
|
||||||
: this.getDescriptionId() + ALL_RINGS[stack.getItemDamage()].name;
|
: this.getDescriptionId() + ALL_RINGS[stack.getItemDamage()].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -148,8 +144,8 @@ public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDi
|
||||||
@Override
|
@Override
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
public EnumRarity getRarity(ItemStack stack) {
|
||||||
return stack.getItemDamage() >= ALL_RINGS.length
|
return stack.getItemDamage() >= ALL_RINGS.length
|
||||||
? EnumRarity.COMMON
|
? EnumRarity.COMMON
|
||||||
: ALL_RINGS[stack.getItemDamage()].rarity;
|
: ALL_RINGS[stack.getItemDamage()].rarity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -177,16 +173,16 @@ public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDi
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public IItemColor getItemColor() {
|
public IItemColor getItemColor() {
|
||||||
return (stack, tintIndex) -> stack.getItemDamage() >= ALL_RINGS.length
|
return (stack, tintIndex) -> stack.getItemDamage() >= ALL_RINGS.length
|
||||||
? 0xFFFFFF
|
? 0xFFFFFF
|
||||||
: ALL_RINGS[stack.getItemDamage()].color;
|
: ALL_RINGS[stack.getItemDamage()].color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(ItemStack stack, TileEntity tile, int elapsedTicks) {
|
public boolean update(ItemStack stack, TileEntity tile, int elapsedTicks) {
|
||||||
boolean advanced = ((ItemPotionRing) stack.getItem()).isAdvanced;
|
boolean advanced = ((ItemPotionRing) stack.getItem()).isAdvanced;
|
||||||
int range = advanced
|
int range = advanced
|
||||||
? 48
|
? 48
|
||||||
: 16;
|
: 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));
|
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 (entities != null && !entities.isEmpty()) {
|
||||||
if (advanced) {
|
if (advanced) {
|
||||||
|
|
Loading…
Reference in a new issue