Lots of work on tools

This commit is contained in:
Vincent Lee committed 2019-02-21 01:04:23 -06:00
1 parent 56e12c7dfd
commit 548898275e
40 files changed
+458 -595

No files matched your search

+102 -31
View File
@@ -25,11 +25,13 @@ import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.IItemTier;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.state.EnumProperty;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.RegistryNamespaced;
@@ -58,7 +60,9 @@ import vazkii.botania.api.subtile.signature.SubTileSignature;
import vazkii.botania.api.wiki.IWikiProvider;
import vazkii.botania.api.wiki.SimpleWikiProvider;
import vazkii.botania.api.wiki.WikiHooks;
import vazkii.botania.common.item.ModItems;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -77,9 +81,6 @@ public final class BotaniaAPI {
public static final Map<String, Brew> brewMap = new LinkedHashMap<>();
public static final List<String> disposableBlocks = new ArrayList<>();
public static final List<String> semiDisposableBlocks = new ArrayList<>();
public static final List<RecipePetals> petalRecipes = new ArrayList<>();
public static final List<RecipePureDaisy> pureDaisyRecipes = new ArrayList<>();
public static final List<RecipeManaInfusion> manaInfusionRecipes = new ArrayList<>();
@@ -102,18 +103,113 @@ public final class BotaniaAPI {
public static final Set<String> magnetBlacklist = new LinkedHashSet<>();
public static final Set<Class<? extends Entity>> gravityRodBlacklist = new LinkedHashSet<>();
// TODO 1.13 move these to eliminate dependence on botania proper in Ingredients
public static final ArmorMaterial manasteelArmorMaterial = EnumHelper.addArmorMaterial("MANASTEEL", "manasteel", 16,
new int[] { 2, 5, 6, 2 }, 18, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 0);
public static final ToolMaterial manasteelToolMaterial = EnumHelper.addToolMaterial("MANASTEEL", 3, 300, 6.2F, 2F, 20);
public static final IItemTier MANASTEEL_ITEM_TIER = new IItemTier() {
@Override
public int getMaxUses() {
return 300;
}
@Override
public float getEfficiency() {
return 6.2F;
}
@Override
public float getAttackDamage() {
return 2;
}
@Override
public int getHarvestLevel() {
return 3;
}
@Override
public int getEnchantability() {
return 20;
}
@Nonnull
@Override
public Ingredient getRepairMaterial() {
return Ingredient.fromItems(ModItems.manaSteel);
}
}
public static final ArmorMaterial elementiumArmorMaterial = EnumHelper.addArmorMaterial("B_ELEMENTIUM", "b_elementium", 18,
new int[] { 2, 5, 6, 2 }, 18, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 0);
public static final ToolMaterial elementiumToolMaterial = EnumHelper.addToolMaterial("B_ELEMENTIUM", 3, 720, 6.2F, 2F, 20);
public static final IItemTier ELEMENTIUM_ITEM_TIER = new IItemTier() {
@Override
public int getMaxUses() {
return 720;
}
@Override
public float getEfficiency() {
return 6.2F;
}
@Override
public float getAttackDamage() {
return 2;
}
@Override
public int getHarvestLevel() {
return 3;
}
@Override
public int getEnchantability() {
return 20;
}
@Nonnull
@Override
public Ingredient getRepairMaterial() {
return Ingredient.fromItems(ModItems.elementium);
}
}
public static final ArmorMaterial terrasteelArmorMaterial = EnumHelper.addArmorMaterial("TERRASTEEL", "terrasteel", 34,
new int[] { 3, 6, 8, 3 }, 26, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 3F);
public static final ToolMaterial terrasteelToolMaterial = EnumHelper.addToolMaterial("TERRASTEEL", 4, 2300, 9F, 3F, 26);
public static final IItemTier TERRASTEEL_ITEM_TIER = new IItemTier() {
@Override
public int getMaxUses() {
return 2300;
}
@Override
public float getEfficiency() {
return 9;
}
@Override
public float getAttackDamage() {
return 3;
}
@Override
public int getHarvestLevel() {
return 4;
}
@Override
public int getEnchantability() {
return 26;
}
@Nonnull
@Override
public Ingredient getRepairMaterial() {
return Ingredient.fromItems(ModItems.terrasteel);
}
}
public static final ArmorMaterial manaweaveArmorMaterial = EnumHelper.addArmorMaterial("MANAWEAVE", "manaweave", 5,
new int[] { 1, 2, 2, 1 }, 18, SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 0);
@@ -237,16 +333,6 @@ public final class BotaniaAPI {
registerPaintableBlock(Blocks.STAINED_HARDENED_CLAY, BlockColored.COLOR);
registerPaintableBlock(Blocks.WOOL, BlockColored.COLOR);
registerPaintableBlock(Blocks.CARPET, BlockCarpet.COLOR);
registerDisposableBlock("dirt"); // Vanilla
registerDisposableBlock("sand"); // Vanilla
registerDisposableBlock("gravel"); // Vanilla
registerDisposableBlock("cobblestone"); // Vanilla
registerDisposableBlock("netherrack"); // Vanilla
registerSemiDisposableBlock("stoneAndesite"); // Vanilla
registerSemiDisposableBlock("stoneBasalt"); // Vanilla
registerSemiDisposableBlock("stoneDiorite"); // Vanilla
registerSemiDisposableBlock("stoneGranite"); // Vanilla
}
/**
@@ -286,21 +372,6 @@ public final class BotaniaAPI {
return fallbackBrew;
}
/**
* Registers a Block as disposable using its Ore Dictionary Name.
*/
public static void registerDisposableBlock(String oreDictName) {
disposableBlocks.add(oreDictName);
}
/**
* Registers a Block as semi disposable using its Ore Dictionary Name.
* This means it will not be trashed when sneaking.
*/
public static void registerSemiDisposableBlock(String oreDictName) {
semiDisposableBlocks.add(oreDictName);
}
/**
* Registers a paintableBlock and returns it.
* You must also provide the PropertyEnum that this block uses to express its color
@@ -23,13 +23,13 @@ public class ItemAutocraftingHalo extends ItemCraftingHalo {
private static final ResourceLocation glowTexture = new ResourceLocation(LibResources.MISC_GLOW_CYAN);
public ItemAutocraftingHalo() {
super(LibItemNames.AUTOCRAFTING_HALO);
public ItemAutocraftingHalo(Properties props) {
super(props);
}
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) {
super.onUpdate(stack, world, entity, pos, equipped);
public void inventoryTick(ItemStack stack, World world, Entity entity, int pos, boolean equipped) {
super.inventoryTick(stack, world, entity, pos, equipped);
if(entity instanceof EntityPlayer && !equipped) {
EntityPlayer player = (EntityPlayer) entity;
@@ -15,7 +15,7 @@ import baubles.api.cap.BaublesCapabilities;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ActionResult;
@@ -27,6 +27,7 @@ import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;
@@ -40,11 +41,8 @@ import javax.annotation.Nullable;
public class ItemBaubleBox extends ItemMod {
private static final String TAG_ITEMS = "InvItems";
public ItemBaubleBox() {
super(LibItemNames.BAUBLE_BOX);
setMaxStackSize(1);
public ItemBaubleBox(Properties props) {
super(props);
}
@Nonnull
@@ -53,59 +51,39 @@ public class ItemBaubleBox extends ItemMod {
return new InvProvider();
}
private static class InvProvider implements ICapabilitySerializable<NBTBase> {
private static class InvProvider implements ICapabilitySerializable<INBTBase> {
private final IItemHandler inv = new ItemStackHandler(24) {
@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack toInsert, boolean simulate) {
if(!toInsert.isEmpty()) {
boolean isBauble = toInsert.hasCapability(BaublesCapabilities.CAPABILITY_ITEM_BAUBLE, null);
boolean isBauble = toInsert.getCapability(BaublesCapabilities.CAPABILITY_ITEM_BAUBLE).isPresent();
if(toInsert.getItem() instanceof IManaItem || isBauble)
return super.insertItem(slot, toInsert, simulate);
}
return toInsert;
}
};
private final LazyOptional<IItemHandler> opt = LazyOptional.of(() -> inv);
@Nonnull
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY;
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.orEmpty(capability, opt);
}
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(inv);
else return null;
}
@Override
public NBTBase serializeNBT() {
public INBTBase serializeNBT() {
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.writeNBT(inv, null);
}
@Override
public void deserializeNBT(NBTBase nbt) {
public void deserializeNBT(INBTBase nbt) {
CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.readNBT(inv, null, nbt);
}
}
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
if(stack.getTagCompound() != null && stack.getTagCompound().hasKey(TAG_ITEMS)) {
NBTTagList oldData = stack.getTagCompound().getTagList(TAG_ITEMS, Constants.NBT.TAG_COMPOUND);
IItemHandler newInv = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.readNBT(newInv, null, oldData);
stack.getTagCompound().removeTag(TAG_ITEMS);
if(stack.getTagCompound().getSize() == 0)
stack.setTagCompound(null);
}
}
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
@@ -12,11 +12,10 @@ package vazkii.botania.common.item;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.I18n;
@@ -27,7 +26,6 @@ import net.minecraft.init.Blocks;
import net.minecraft.inventory.ContainerWorkbench;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
@@ -37,11 +35,14 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.common.crafting.VanillaRecipeTypes;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -49,6 +50,7 @@ import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.items.ItemStackHandler;
import net.minecraftforge.items.wrapper.EmptyHandler;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.gui.crafting.ContainerCraftingHalo;
@@ -58,7 +60,6 @@ import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.core.helper.PlayerHelper;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.lib.LibGuiIDs;
import vazkii.botania.common.lib.LibItemNames;
import javax.annotation.Nonnull;
import java.util.Arrays;
@@ -76,16 +77,11 @@ public class ItemCraftingHalo extends ItemMod {
private static final String TAG_EQUIPPED = "equipped";
private static final String TAG_ROTATION_BASE = "rotationBase";
public ItemCraftingHalo() {
this(LibItemNames.CRAFTING_HALO);
public ItemCraftingHalo(Properties props) {
super(props);
MinecraftForge.EVENT_BUS.register(this);
}
public ItemCraftingHalo(String name) {
super(name);
setMaxStackSize(1);
}
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
@@ -114,7 +110,7 @@ public class ItemCraftingHalo extends ItemMod {
}
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) {
public void inventoryTick(ItemStack stack, World world, Entity entity, int pos, boolean equipped) {
if (!(entity instanceof EntityLivingBase))
return;
EntityLivingBase living = (EntityLivingBase) entity;
@@ -153,7 +149,7 @@ public class ItemCraftingHalo extends ItemMod {
for(int i = 0; i < 9; i++)
fakeInv.setInventorySlotContents(i, recipe[i]);
ItemStack result = CraftingManager.findMatchingResult(fakeInv, player.world);
ItemStack result = player.world.getRecipeManager().getResult(fakeInv, player.world, VanillaRecipeTypes.CRAFTING);
if(result.isEmpty()) {
assignRecipe(stack, recipe[9], slot);
return null;
@@ -178,7 +174,7 @@ public class ItemCraftingHalo extends ItemMod {
}
private static void doCraft(EntityPlayer player, ItemStack[] recipe, boolean particles) {
consumeRecipeIngredients(recipe, player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP), player);
consumeRecipeIngredients(recipe, player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP).orElse(EmptyHandler.INSTANCE), player);
ItemHandlerHelper.giveItemToPlayer(player, recipe[9]);
if(!particles)
@@ -230,7 +226,7 @@ public class ItemCraftingHalo extends ItemMod {
}
@Override
public boolean onEntitySwing(EntityLivingBase player, ItemStack stack) {
public boolean onEntitySwing(ItemStack stack, EntityLivingBase player) {
int segment = getSegmentLookedAt(stack, player);
if(segment == 0)
return false;
@@ -306,11 +302,11 @@ public class ItemCraftingHalo extends ItemMod {
@SubscribeEvent
public void onItemCrafted(ItemCraftedEvent event) {
if(!(event.player.openContainer instanceof ContainerCraftingHalo) || !(event.craftMatrix instanceof InventoryCrafting))
if(!(event.getPlayer().openContainer instanceof ContainerCraftingHalo) || !(event.getInventory() instanceof InventoryCrafting))
return;
for(int i = 0; i < event.player.inventory.getSizeInventory(); i++) {
ItemStack stack = event.player.inventory.getStackInSlot(i);
for(int i = 0; i < event.getPlayer().inventory.getSizeInventory(); i++) {
ItemStack stack = event.getPlayer().inventory.getStackInSlot(i);
if(!stack.isEmpty() && stack.getItem() instanceof ItemCraftingHalo)
saveRecipeToStack(event, stack);
}
@@ -320,21 +316,21 @@ public class ItemCraftingHalo extends ItemMod {
NBTTagCompound cmp = new NBTTagCompound();
NBTTagCompound cmp1 = new NBTTagCompound();
ItemStack result = CraftingManager.findMatchingResult((InventoryCrafting) event.craftMatrix, event.player.world);
ItemStack result = event.getPlayer().world.getRecipeManager().getResult(event.getInventory(), event.getPlayer().world, VanillaRecipeTypes.CRAFTING);
if(!result.isEmpty()) {
cmp1 = result.writeToNBT(cmp1);
cmp.setTag(TAG_ITEM_PREFIX + 9, cmp1);
cmp1 = result.write(cmp1);
cmp.put(TAG_ITEM_PREFIX + 9, cmp1);
for(int i = 0; i < 9; i++) {
cmp1 = new NBTTagCompound();
ItemStack stackSlot = event.craftMatrix.getStackInSlot(i);
ItemStack stackSlot = event.getInventory().getStackInSlot(i);
if(!stackSlot.isEmpty()) {
ItemStack writeStack = stackSlot.copy();
writeStack.setCount(1);
cmp1 = writeStack.writeToNBT(cmp1);
cmp1 = writeStack.write(cmp1);
}
cmp.setTag(TAG_ITEM_PREFIX + i, cmp1);
cmp.put(TAG_ITEM_PREFIX + i, cmp1);
}
}
@@ -373,11 +369,11 @@ public class ItemCraftingHalo extends ItemMod {
if(cmp == null)
return ItemStack.EMPTY;
NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_ITEM_PREFIX + pos);
NBTTagCompound cmp1 = cmp.getCompound(TAG_ITEM_PREFIX + pos);
if(cmp1 == null)
return ItemStack.EMPTY;
return new ItemStack(cmp1);
return ItemStack.read(cmp1);
}
public static boolean wasEquipped(ItemStack stack) {
@@ -399,7 +395,7 @@ public class ItemCraftingHalo extends ItemMod {
@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public void onRenderWorldLast(RenderWorldLastEvent event) {
EntityPlayer player = Minecraft.getMinecraft().player;
EntityPlayer player = Minecraft.getInstance().player;
ItemStack stack = PlayerHelper.getFirstHeldItemClass(player, ItemCraftingHalo.class);
if(!stack.isEmpty())
render(stack, player, event.getPartialTicks());
@@ -407,7 +403,7 @@ public class ItemCraftingHalo extends ItemMod {
@OnlyIn(Dist.CLIENT)
public void render(ItemStack stack, EntityPlayer player, float partialTicks) {
Minecraft mc = Minecraft.getMinecraft();
Minecraft mc = Minecraft.getInstance();
Tessellator tess = Tessellator.getInstance();
double renderPosX = mc.getRenderManager().renderPosX;
@@ -423,7 +419,7 @@ public class ItemCraftingHalo extends ItemMod {
double posY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks;
double posZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks;
GlStateManager.translate(posX - renderPosX, posY - renderPosY + player.getDefaultEyeHeight(), posZ - renderPosZ);
GlStateManager.translated(posX - renderPosX, posY - renderPosY + player.getDefaultEyeHeight(), posZ - renderPosZ);
float base = getRotationBase(stack);
@@ -445,29 +441,29 @@ public class ItemCraftingHalo extends ItemMod {
boolean inside = false;
float rotationAngle = (seg + 0.5F) * segAngles + shift;
GlStateManager.pushMatrix();
GlStateManager.rotate(rotationAngle, 0F, 1F, 0F);
GlStateManager.translate(s * m, -0.75F, 0F);
GlStateManager.rotatef(rotationAngle, 0F, 1F, 0F);
GlStateManager.translatef(s * m, -0.75F, 0F);
if(segmentLookedAt == seg)
inside = true;
ItemStack slotStack = getItemForSlot(stack, seg);
if(!slotStack.isEmpty()) {
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
mc.textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
RenderHelper.enableStandardItemLighting();
float scale = seg == 0 ? 0.9F : 0.8F;
GlStateManager.scale(scale, scale, scale);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(seg == 0 ? 0.5F : 0F, seg == 0 ? -0.1F : 0.6F, 0F);
GlStateManager.scalef(scale, scale, scale);
GlStateManager.rotatef(180F, 0F, 1F, 0F);
GlStateManager.translatef(seg == 0 ? 0.5F : 0F, seg == 0 ? -0.1F : 0.6F, 0F);
GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
Minecraft.getMinecraft().getRenderItem().renderItem(slotStack, ItemCameraTransforms.TransformType.GUI);
GlStateManager.rotatef(90.0F, 0.0F, 1.0F, 0.0F);
Minecraft.getInstance().getItemRenderer().renderItem(slotStack, ItemCameraTransforms.TransformType.GUI);
RenderHelper.disableStandardItemLighting();
}
GlStateManager.popMatrix();
GlStateManager.pushMatrix();
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.rotatef(180F, 1F, 0F, 0F);
float a = alpha;
if(inside) {
a += 0.3F;
@@ -478,12 +474,12 @@ public class ItemCraftingHalo extends ItemMod {
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if(seg % 2 == 0)
GlStateManager.color(0.6F, 0.6F, 0.6F, a);
else GlStateManager.color(1F, 1F, 1F, a);
GlStateManager.color4f(0.6F, 0.6F, 0.6F, a);
else GlStateManager.color4f(1F, 1F, 1F, a);
GlStateManager.disableCull();
ItemCraftingHalo item = (ItemCraftingHalo) stack.getItem();
mc.renderEngine.bindTexture(item.getGlowResource());
mc.textureManager.bindTexture(item.getGlowResource());
tess.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
for(int i = 0; i < segAngles; i++) {
float ang = i + seg * segAngles + shift;
@@ -535,7 +531,7 @@ public class ItemCraftingHalo extends ItemMod {
mc.fontRenderer.drawStringWithShadow(name, x, y, 0xFFFFFF);
} else {
ItemStack[] recipe = getCraftingItems(stack, slot);
String label = I18n.format("botaniamisc.unsetRecipe");
ITextComponent label = new TextComponentTranslation("botaniamisc.unsetRecipe");
boolean setRecipe = false;
if(recipe[9].isEmpty())
@@ -550,7 +546,7 @@ public class ItemCraftingHalo extends ItemMod {
}
@OnlyIn(Dist.CLIENT)
public static void renderRecipe(String label, ItemStack[] recipe, EntityPlayer player, boolean setRecipe) {
public static void renderRecipe(ITextComponent label, ItemStack[] recipe, EntityPlayer player, boolean setRecipe) {
Minecraft mc = Minecraft.getInstance();
if(!recipe[9].isEmpty()) {
@@ -12,7 +12,6 @@ package vazkii.botania.common.item;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -11,6 +11,7 @@
package vazkii.botania.common.item;
import net.minecraft.init.Items;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemRecord;
@@ -32,6 +33,7 @@ import vazkii.botania.common.item.equipment.armor.elementium.ItemElementiumBoots
import vazkii.botania.common.item.equipment.armor.elementium.ItemElementiumChest;
import vazkii.botania.common.item.equipment.armor.elementium.ItemElementiumHelm;
import vazkii.botania.common.item.equipment.armor.elementium.ItemElementiumLegs;
import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelArmor;
import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelBoots;
import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelChest;
import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelHelm;
@@ -207,20 +209,20 @@ public final class ModItems {
public static final Item manaMirror = new ItemManaMirror(unstackable().defaultMaxDamage(1000).setNoRepair()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_MIRROR);
public static final Item manasteelHelm = new ItemManasteelHelm(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANASTEEL_HELM);
public static final Item manasteelHelmRevealing = new ItemManasteelHelmRevealing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANASTEEL_HELM_R);
public static final Item manasteelChest = new ItemManasteelChest();
public static final Item manasteelLegs = new ItemManasteelLegs();
public static final Item manasteelBoots = new ItemManasteelBoots();
public static final Item manasteelPick = new ItemManasteelPick();
public static final Item manasteelShovel = new ItemManasteelShovel();
public static final Item manasteelAxe = new ItemManasteelAxe();
public static final Item manasteelSword = new ItemManasteelSword();
public static final Item manasteelShears = new ItemManasteelShears();
public static final Item manasteelChest = new ItemManasteelArmor(EntityEquipmentSlot.CHEST, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANASTEEL_CHEST);
public static final Item manasteelLegs = new ItemManasteelArmor(EntityEquipmentSlot.LEGS, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANASTEEL_LEGS);
public static final Item manasteelBoots = new ItemManasteelArmor(EntityEquipmentSlot.FEET, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANASTEEL_BOOTS);
public static final Item manasteelPick = new ItemManasteelPick(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANASTEEL_PICK);
public static final Item manasteelShovel = new ItemManasteelShovel(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANASTEEL_SHOVEL);
public static final Item manasteelAxe = new ItemManasteelAxe(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANASTEEL_AXE);
public static final Item manasteelSword = new ItemManasteelSword(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANASTEEL_SWORD);
public static final Item manasteelShears = new ItemManasteelShears(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANASTEEL_SHEARS);
public static final Item terrasteelHelm = new ItemTerrasteelHelm();
public static final Item terrasteelHelmRevealing = new ItemTerrasteelHelmRevealing();
public static final Item terrasteelChest = new ItemTerrasteelChest();
public static final Item terrasteelLegs = new ItemTerrasteelLegs();
public static final Item terrasteelBoots = new ItemTerrasteelBoots();
public static final Item terraSword = new ItemTerraSword();
public static final Item terraSword = new ItemTerraSword(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.TERRA_SWORD);
public static final Item tinyPlanet = new ItemTinyPlanet();
public static final Item manaRing = new ItemManaRing();
public static final Item auraRing = new ItemAuraRing();
@@ -236,7 +238,7 @@ public final class ModItems {
public static final Item terraPick = new ItemTerraPick();
public static final Item divaCharm = new ItemDivaCharm();
public static final Item flightTiara = new ItemFlightTiara();
public static final Item enderDagger = new ItemEnderDagger();
public static final Item enderDagger = new ItemEnderDagger(unstackable().defaultMaxDamage(69).setNoRepair()); // What you looking at?
public static final Item darkQuartz = new ItemMod(LibItemNames.QUARTZ_NAMES[0]);
public static final Item manaQuartz = new ItemMod(LibItemNames.QUARTZ_NAMES[1]);
public static final Item blazeQuartz = new ItemMod(LibItemNames.QUARTZ_NAMES[2]);
@@ -250,15 +252,15 @@ public final class ModItems {
public static final Item elementiumChest = new ItemElementiumChest();
public static final Item elementiumLegs = new ItemElementiumLegs();
public static final Item elementiumBoots = new ItemElementiumBoots();
public static final Item elementiumPick = new ItemElementiumPick();
public static final Item elementiumShovel = new ItemElementiumShovel();
public static final Item elementiumAxe = new ItemElementiumAxe();
public static final Item elementiumSword = new ItemElementiumSword();
public static final Item elementiumShears = new ItemElementiumShears();
public static final Item elementiumPick = new ItemElementiumPick(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ELEMENTIUM_PICK);
public static final Item elementiumShovel = new ItemElementiumShovel(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ELEMENTIUM_SHOVEL);
public static final Item elementiumAxe = new ItemElementiumAxe(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ELEMENTIUM_AXE);
public static final Item elementiumSword = new ItemElementiumSword(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ELEMENTIUM_SWORD);
public static final Item elementiumShears = new ItemElementiumShears(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ELEMENTIUM_SHEARS);
public static final Item openBucket = new ItemOpenBucket();
public static final Item spawnerMover = new ItemSpawnerMover();
public static final Item pixieRing = new ItemPixieRing();
public static final Item superTravelBelt = new ItemSuperTravelBelt();
public static final Item superTravelBelt = new ItemSuperTravelBelt(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.SUPER_TRAVEL_BELT);
public static final Item rainbowRod = new ItemRainbowRod();
public static final Item tornadoRod = new ItemTornadoRod();
public static final Item fireRod = new ItemFireRod();
@@ -291,7 +293,7 @@ public final class ModItems {
public static final Item holyCloak = new ItemHolyCloak();
public static final Item unholyCloak = new ItemUnholyCloak();
public static final Item balanceCloak = new ItemBalanceCloak();
public static final Item craftingHalo = new ItemCraftingHalo();
public static final Item craftingHalo = new ItemCraftingHalo(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.CRAFTING_HALO);
public static final Item blackLotus = new ItemBlackLotus(LibItemNames.BLACK_LOTUS);
public static final Item blackerLotus = new ItemBlackLotus(LibItemNames.BLACKER_LOTUS);
public static final Item monocle = new ItemMonocle();
@@ -359,15 +361,15 @@ public final class ModItems {
public static final Item manaweaveChest = new ItemManaweaveChest();
public static final Item manaweaveLegs = new ItemManaweaveLegs();
public static final Item manaweaveBoots = new ItemManaweaveBoots();
public static final Item autocraftingHalo = new ItemAutocraftingHalo();
public static final Item autocraftingHalo = new ItemAutocraftingHalo(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.AUTOCRAFTING_HALO);
public static final Item gaiaHead = new ItemGaiaHead();
public static final Item sextant = new ItemSextant(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.SEXTANT);
public static final Item speedUpBelt = new ItemSpeedUpBelt();
public static final Item baubleBox = new ItemBaubleBox();
public static final Item dodgeRing = new ItemDodgeRing();
public static final Item invisibilityCloak = new ItemInvisibilityCloak();
public static final Item cloudPendant = new ItemCloudPendant();
public static final Item superCloudPendant = new ItemSuperCloudPendant();
public static final Item speedUpBelt = new ItemSpeedUpBelt(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.SPEED_UP_BELT);
public static final Item baubleBox = new ItemBaubleBox(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.BAUBLE_BOX);
public static final Item dodgeRing = new ItemDodgeRing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.DODGE_RING);
public static final Item invisibilityCloak = new ItemInvisibilityCloak(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.INVISIBILITY_CLOAK);
public static final Item cloudPendant = new ItemCloudPendant(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.CLOUD_PENDANT);
public static final Item superCloudPendant = new ItemSuperCloudPendant(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.SUPER_CLOUD_PENDANT);
public static final Item thirdEye = new ItemThirdEye(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.THIRD_EYE);
public static final Item astrolabe = new ItemAstrolabe(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ASTROLABE);
public static final Item goddessCharm = new ItemGoddessCharm(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.GODDESS_CHARM);
@@ -1,22 +0,0 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Apr 13, 2014, 10:24:08 PM (GMT)]
*/
package vazkii.botania.common.item.equipment.armor.manasteel;
import net.minecraft.inventory.EntityEquipmentSlot;
import vazkii.botania.common.lib.LibItemNames;
public class ItemManasteelBoots extends ItemManasteelArmor {
public ItemManasteelBoots() {
super(EntityEquipmentSlot.FEET, LibItemNames.MANASTEEL_BOOTS);
}
}
@@ -1,22 +0,0 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Apr 13, 2014, 10:22:57 PM (GMT)]
*/
package vazkii.botania.common.item.equipment.armor.manasteel;
import net.minecraft.inventory.EntityEquipmentSlot;
import vazkii.botania.common.lib.LibItemNames;
public class ItemManasteelChest extends ItemManasteelArmor {
public ItemManasteelChest() {
super(EntityEquipmentSlot.CHEST, LibItemNames.MANASTEEL_CHEST);
}
}
@@ -1,22 +0,0 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Apr 13, 2014, 10:23:28 PM (GMT)]
*/
package vazkii.botania.common.item.equipment.armor.manasteel;
import net.minecraft.inventory.EntityEquipmentSlot;
import vazkii.botania.common.lib.LibItemNames;
public class ItemManasteelLegs extends ItemManasteelArmor {
public ItemManasteelLegs() {
super(EntityEquipmentSlot.LEGS, LibItemNames.MANASTEEL_LEGS);
}
}
@@ -33,8 +33,8 @@ import java.util.UUID;
public class ItemTerrasteelArmor extends ItemManasteelArmor {
public ItemTerrasteelArmor(EntityEquipmentSlot type, String name) {
super(type, name, BotaniaAPI.terrasteelArmorMaterial);
public ItemTerrasteelArmor(EntityEquipmentSlot type, Properties props) {
super(type, props, BotaniaAPI.terrasteelArmorMaterial);
}
@Override
@@ -49,8 +49,8 @@ public class ItemTerrasteelHelm extends ItemTerrasteelArmor implements IManaDisc
this(LibItemNames.TERRASTEEL_HELM);
}
public ItemTerrasteelHelm(String name) {
super(EntityEquipmentSlot.HEAD, name);
public ItemTerrasteelHelm(Properties props) {
super(EntityEquipmentSlot.HEAD, props);
MinecraftForge.EVENT_BUS.register(this);
}
@@ -15,8 +15,8 @@ import net.minecraft.item.ItemStack;
public abstract class CloudPendantShim extends ItemBauble {
public CloudPendantShim(String name) {
super(name);
public CloudPendantShim(Properties props) {
super(props);
}
@Override
@@ -37,12 +37,8 @@ public class ItemCloudPendant extends CloudPendantShim implements IBaubleRender
private static int timesJumped;
private static boolean jumpDown;
public ItemCloudPendant(String name) {
super(name);
}
public ItemCloudPendant() {
this(LibItemNames.CLOUD_PENDANT);
public ItemCloudPendant(Properties props) {
super(props);
}
@Override
@@ -53,7 +49,7 @@ public class ItemCloudPendant extends CloudPendantShim implements IBaubleRender
@Override
@OnlyIn(Dist.CLIENT)
public void clientWornTick(ItemStack stack, EntityLivingBase player) {
if(player instanceof EntityPlayerSP && player == Minecraft.getMinecraft().player) {
if(player instanceof EntityPlayerSP && player == Minecraft.getInstance().player) {
EntityPlayerSP playerSp = (EntityPlayerSP) player;
UUID uuid = playerSp.getUniqueID();
@@ -76,19 +72,19 @@ public class ItemCloudPendant extends CloudPendantShim implements IBaubleRender
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.BODY) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Helper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.translate(-0.2F, -0.3F, armor ? 0.2F : 0.15F);
GlStateManager.scale(0.5F, 0.5F, 0.5F);
GlStateManager.rotatef(180F, 1F, 0F, 0F);
GlStateManager.translatef(-0.2F, -0.3F, armor ? 0.2F : 0.15F);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.cirrusGem;
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F);
}
}
@@ -14,16 +14,14 @@ import baubles.api.BaubleType;
import baubles.api.BaublesApi;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -36,7 +34,7 @@ import vazkii.botania.common.lib.LibMisc;
import vazkii.botania.common.network.PacketDodge;
import vazkii.botania.common.network.PacketHandler;
@Mod.EventBusSubscriber(value = Side.CLIENT, modid = LibMisc.MOD_ID)
@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = LibMisc.MOD_ID)
public class ItemDodgeRing extends ItemBauble {
public static final String TAG_DODGE_COOLDOWN = "dodgeCooldown";
@@ -45,14 +43,14 @@ public class ItemDodgeRing extends ItemBauble {
private static boolean oldLeftDown, oldRightDown;
private static int leftDown, rightDown;
public ItemDodgeRing() {
super(LibItemNames.DODGE_RING);
public ItemDodgeRing(Properties props) {
super(props);
}
@SubscribeEvent
@OnlyIn(Dist.CLIENT)
public static void onKeyDown(KeyInputEvent event) {
Minecraft mc = Minecraft.getMinecraft();
Minecraft mc = Minecraft.getInstance();
IItemHandler baublesInv = BaublesApi.getBaublesHandler(mc.player);
ItemStack ringStack = baublesInv.getStackInSlot(1);
@@ -92,7 +90,7 @@ public class ItemDodgeRing extends ItemBauble {
}
private static void dodge(EntityPlayer player, boolean left) {
if(player.capabilities.isFlying || !player.onGround || player.moveForward > 0.2 || player.moveForward < -0.2)
if(player.abilities.isFlying || !player.onGround || player.moveForward > 0.2 || player.moveForward < -0.2)
return;
float yaw = player.rotationYaw;
@@ -22,8 +22,8 @@ import vazkii.botania.common.lib.LibItemNames;
public class ItemInvisibilityCloak extends ItemBauble implements IManaUsingItem {
public ItemInvisibilityCloak() {
super(LibItemNames.INVISIBILITY_CLOAK);
public ItemInvisibilityCloak(Properties props) {
super(props);
}
@Override
@@ -26,8 +26,8 @@ public class ItemSpeedUpBelt extends ItemTravelBelt {
private static final String TAG_OLD_Y = "oldY";
private static final String TAG_OLD_Z = "oldZ";
public ItemSpeedUpBelt() {
super(LibItemNames.SPEED_UP_BELT, 0F, 0.2F, 2F);
public ItemSpeedUpBelt(Properties props) {
super(props, 0F, 0.2F, 2F);
}
@Override
@@ -26,8 +26,8 @@ import vazkii.botania.common.lib.LibItemNames;
public class ItemSuperCloudPendant extends ItemCloudPendant {
public ItemSuperCloudPendant() {
super(LibItemNames.SUPER_CLOUD_PENDANT);
public ItemSuperCloudPendant(Properties props) {
super(props);
}
@Override
@@ -39,19 +39,19 @@ public class ItemSuperCloudPendant extends ItemCloudPendant {
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.BODY) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Helper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.translate(-0.2F, -0.45F, armor ? 0.2F : 0.15F);
GlStateManager.scale(0.5F, 0.5F, 0.5F);
GlStateManager.rotatef(180F, 1F, 0F, 0F);
GlStateManager.translatef(-0.2F, -0.45F, armor ? 0.2F : 0.15F);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.nimbusGem;
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F);
}
}
@@ -18,8 +18,8 @@ public class ItemSuperTravelBelt extends ItemTravelBelt {
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SUPER_TRAVEL_BELT);
public ItemSuperTravelBelt() {
super(LibItemNames.SUPER_TRAVEL_BELT, 0.085F, 0.3F, 4F);
public ItemSuperTravelBelt(Properties props) {
super(props, 0.085F, 0.3F, 4F);
}
@Override
@@ -14,15 +14,15 @@ import baubles.api.BaubleType;
import baubles.api.BaublesApi;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.model.ModelBiped;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -50,13 +50,13 @@ public class ItemTravelBelt extends ItemBauble implements IBaubleRender, IManaUs
public final float jump;
public final float fallBuffer;
public ItemTravelBelt() {
this(LibItemNames.TRAVEL_BELT, 0.035F, 0.2F, 2F);
public ItemTravelBelt(Properties props) {
this(props, 0.035F, 0.2F, 2F);
MinecraftForge.EVENT_BUS.register(this);
}
public ItemTravelBelt(String name, float speed, float jump, float fallBuffer) {
super(name);
public ItemTravelBelt(Properties props, float speed, float jump, float fallBuffer) {
super(props);
this.speed = speed;
this.jump = jump;
this.fallBuffer = fallBuffer;
@@ -79,9 +79,9 @@ public class ItemTravelBelt extends ItemBauble implements IBaubleRender, IManaUs
ItemTravelBelt beltItem = (ItemTravelBelt) belt.getItem();
if(player.world.isRemote) {
if((player.onGround || player.capabilities.isFlying) && player.moveForward > 0F && !player.isInsideOfMaterial(Material.WATER)) {
if((player.onGround || player.abilities.isFlying) && player.moveForward > 0F && !player.isInWaterOrBubbleColumn()) {
float speed = beltItem.getSpeed(belt);
player.moveRelative(0F, 0F, 1F, player.capabilities.isFlying ? speed : speed);
player.moveRelative(0F, 0F, 1F, player.abilities.isFlying ? speed : speed);
beltItem.onMovedTick(belt, player);
if(player.ticksExisted % COST_INTERVAL == 0)
@@ -132,7 +132,7 @@ public class ItemTravelBelt extends ItemBauble implements IBaubleRender, IManaUs
@SubscribeEvent
public void playerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) {
String username = event.player.getGameProfile().getName();
String username = event.getPlayer().getGameProfile().getName();
playersWithStepup.remove(username + ":false");
playersWithStepup.remove(username + ":true");
}
@@ -150,13 +150,13 @@ public class ItemTravelBelt extends ItemBauble implements IBaubleRender, IManaUs
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.BODY) {
Minecraft.getMinecraft().renderEngine.bindTexture(getRenderTexture());
Minecraft.getInstance().textureManager.bindTexture(getRenderTexture());
Helper.rotateIfSneaking(player);
GlStateManager.translate(0F, 0.2F, 0F);
GlStateManager.translatef(0F, 0.2F, 0F);
float s = 1.05F / 16F;
GlStateManager.scale(s, s, s);
GlStateManager.scalef(s, s, s);
if(model == null)
model = new ModelBiped();
@@ -29,10 +29,8 @@ import javax.annotation.Nonnull;
public class ItemEnderDagger extends ItemManasteelSword {
public ItemEnderDagger() {
super(BotaniaAPI.manasteelToolMaterial, LibItemNames.ENDER_DAGGER);
setMaxDamage(69); // What you looking at?
setNoRepair();
public ItemEnderDagger(Properties props) {
super(BotaniaAPI.MANASTEEL_ITEM_TIER, props);
}
@Override
@@ -48,7 +46,7 @@ public class ItemEnderDagger extends ItemManasteelSword {
}
@Override
public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) {}
public void inventoryTick(ItemStack stack, World world, Entity player, int par4, boolean par5) {}
@Override
public boolean usesMana(ItemStack stack) {
@@ -57,8 +55,8 @@ public class ItemEnderDagger extends ItemManasteelSword {
@Nonnull
@Override
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) {
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot) {
Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(equipmentSlot);
if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -1.25, 0));
@@ -12,32 +12,61 @@ package vazkii.botania.common.item.equipment.tool;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.IItemTier;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelPick;
import vazkii.botania.common.lib.LibItemNames;
import javax.annotation.Nonnull;
public class ItemGlassPick extends ItemManasteelPick {
private static final int MANA_PER_DAMAGE = 160;
private static final ToolMaterial MATERIAL = EnumHelper.addToolMaterial("MANASTEEL_GLASS", 0, 125, 4.8F, 0F, 10);
private static final IItemTier MATERIAL = new IItemTier() {
@Override
public int getMaxUses() {
return 125;
}
public ItemGlassPick() {
super(MATERIAL, LibItemNames.GLASS_PICK);
MinecraftForge.EVENT_BUS.register(this);
@Override
public float getEfficiency() {
return 4.8F;
}
@Override
public float getAttackDamage() {
return 0;
}
@Override
public int getHarvestLevel() {
return 0;
}
@Override
public int getEnchantability() {
return 10;
}
@Override
public Ingredient getRepairMaterial() {
return Ingredient.fromItems(Blocks.GLASS);
}
};
public ItemGlassPick(Properties props) {
super(MATERIAL, props);
MinecraftForge.EVENT_BUS.addListener(this::onBlockDrops);
attackSpeed = -1;
}
@SubscribeEvent
public void onBlockDrops(HarvestDropsEvent event) {
if(event.getHarvester() != null && event.getState() != null && event.getDrops() != null && event.getDrops().isEmpty() && !event.getHarvester().getHeldItemMainhand().isEmpty() && event.getHarvester().getHeldItemMainhand().getItem() == this && event.getState().getMaterial() == Material.GLASS && event.getState().getBlock().canSilkHarvest(event.getWorld(), event.getPos(), event.getState(), event.getHarvester()))
event.getDrops().add(new ItemStack(event.getState().getBlock(), 1, event.getState().getBlock().getMetaFromState(event.getState())));
private void onBlockDrops(HarvestDropsEvent event) {
if(event.getHarvester() != null && event.getState() != null && event.getDrops() != null && event.getDrops().isEmpty()
&& !event.getHarvester().getHeldItemMainhand().isEmpty()
&& event.getHarvester().getHeldItemMainhand().getItem() == this
&& event.getState().getMaterial() == Material.GLASS
&& event.getState().canSilkHarvest(event.getWorld().getWorld(), event.getPos(), event.getHarvester()))
event.getDrops().add(new ItemStack(event.getState().getBlock()));
}
@Override
@@ -45,11 +74,6 @@ public class ItemGlassPick extends ItemManasteelPick {
return MANA_PER_DAMAGE;
}
@Override
public boolean getIsRepairable(ItemStack pick, @Nonnull ItemStack material) {
return material.getItem() == Item.getItemFromBlock(Blocks.GLASS) ? true : super.getIsRepairable(pick, material);
}
@Override
public int getSortingPriority(ItemStack stack) {
return 0;
@@ -32,13 +32,13 @@ public class ItemStarSword extends ItemManasteelSword {
private static final int MANA_PER_DAMAGE = 120;
public ItemStarSword() {
super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.STAR_SWORD);
public ItemStarSword(Properties props) {
super(BotaniaAPI.TERRASTEEL_ITEM_TIER, props);
}
@Override
public void onUpdate(ItemStack par1ItemStack, World world, Entity par3Entity, int par4, boolean par5) {
super.onUpdate(par1ItemStack, world, par3Entity, par4, par5);
public void inventoryTick(ItemStack par1ItemStack, World world, Entity par3Entity, int par4, boolean par5) {
super.inventoryTick(par1ItemStack, world, par3Entity, par4, par5);
if(par3Entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) par3Entity;
PotionEffect haste = player.getActivePotionEffect(MobEffects.HASTE);
@@ -60,7 +60,7 @@ public class ItemStarSword extends ItemManasteelSword {
world.spawnEntity(star);
if (!world.isRaining()
&& Math.abs(world.getWorldTime() - 18000) < 1800
&& Math.abs(world.getDayTime() - 18000) < 1800
&& Math.random() < 0.125) {
EntityFallingStar bonusStar = new EntityFallingStar(player, world);
bonusStar.setPosition(posVec.x, posVec.y, posVec.z);
@@ -81,9 +81,4 @@ public class ItemStarSword extends ItemManasteelSword {
public int getManaPerDamage() {
return MANA_PER_DAMAGE;
}
@Override
public boolean getIsRepairable(ItemStack sword, @Nonnull ItemStack material) {
return material.getItem() == ModItems.terrasteel || super.getIsRepairable(sword, material);
}
}
@@ -38,8 +38,8 @@ public class ItemThunderSword extends ItemManasteelSword {
private static final String TAG_LIGHTNING_SEED = "lightningSeed";
public ItemThunderSword() {
super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.THUNDER_SWORD);
public ItemThunderSword(Properties props) {
super(BotaniaAPI.TERRASTEEL_ITEM_TIER, props);
}
@Override
@@ -82,8 +82,8 @@ public class ItemThunderSword extends ItemManasteelSword {
@Nonnull
@Override
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) {
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot) {
Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(equipmentSlot);
if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
multimap.removeAll(SharedMonsterAttributes.ATTACK_SPEED.getName());
@@ -19,6 +19,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Enchantments;
import net.minecraft.item.IItemTier;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
@@ -116,13 +117,13 @@ public final class ToolCommons {
return 0;
ItemTool tool = (ItemTool) item;
ToolMaterial material = tool.toolMaterial;
IItemTier material = tool.getTier();
int materialLevel = 0;
if(material == BotaniaAPI.manasteelToolMaterial)
if(material == BotaniaAPI.MANASTEEL_ITEM_TIER)
materialLevel = 10;
if(material == BotaniaAPI.elementiumToolMaterial)
if(material == BotaniaAPI.ELEMENTIUM_ITEM_TIER)
materialLevel = 11;
if(material == BotaniaAPI.terrasteelToolMaterial)
if(material == BotaniaAPI.TERRASTEEL_ITEM_TIER)
materialLevel = 20;
int modifier = 0;
@@ -10,7 +10,6 @@
*/
package vazkii.botania.common.item.equipment.tool.bow;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@@ -13,29 +13,25 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.entity.EntityDoppleganger;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelAxe;
import vazkii.botania.common.lib.LibItemNames;
import javax.annotation.Nonnull;
import java.util.Random;
public class ItemElementiumAxe extends ItemManasteelAxe {
public ItemElementiumAxe() {
super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_AXE);
MinecraftForge.EVENT_BUS.register(this);
public ItemElementiumAxe(Properties props) {
super(BotaniaAPI.ELEMENTIUM_ITEM_TIER, props);
MinecraftForge.EVENT_BUS.addListener(this::onEntityDrops);
}
// Thanks to SpitefulFox for the drop rates
// https://github.com/SpitefulFox/ForbiddenMagic/blob/master/src/com/spiteful/forbidden/FMEventHandler.java
@SubscribeEvent
public void onEntityDrops(LivingDropsEvent event) {
private void onEntityDrops(LivingDropsEvent event) {
if(event.isRecentlyHit() && event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityPlayer) {
ItemStack weapon = ((EntityPlayer) event.getSource().getTrueSource()).getHeldItemMainhand();
if(!weapon.isEmpty() && weapon.getItem() == this) {
@@ -43,14 +39,14 @@ public class ItemElementiumAxe extends ItemManasteelAxe {
int looting = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, weapon);
if(event.getEntityLiving() instanceof AbstractSkeleton && rand.nextInt(26) <= 3 + looting)
addDrop(event, new ItemStack(Items.SKULL, 1, event.getEntityLiving() instanceof EntityWitherSkeleton ? 1 : 0));
addDrop(event, new ItemStack(event.getEntity() instanceof EntityWitherSkeleton ? Items.WITHER_SKELETON_SKULL : Items.SKELETON_SKULL));
else if(event.getEntityLiving() instanceof EntityZombie && !(event.getEntityLiving() instanceof EntityPigZombie) && rand.nextInt(26) <= 2 + 2 * looting)
addDrop(event, new ItemStack(Items.SKULL, 1, 2));
addDrop(event, new ItemStack(Items.ZOMBIE_HEAD));
else if(event.getEntityLiving() instanceof EntityCreeper && rand.nextInt(26) <= 2 + 2 * looting)
addDrop(event, new ItemStack(Items.SKULL, 1, 4));
addDrop(event, new ItemStack(Items.CREEPER_HEAD));
else if(event.getEntityLiving() instanceof EntityPlayer && rand.nextInt(11) <= 1 + looting) {
ItemStack stack = new ItemStack(Items.SKULL, 1, 3);
ItemNBTHelper.setString(stack, "SkullOwner", event.getEntityLiving().getName());
ItemStack stack = new ItemStack(Items.PLAYER_HEAD);
ItemNBTHelper.setString(stack, "SkullOwner", ((EntityPlayer) event.getEntityLiving()).getGameProfile().getName());
addDrop(event, stack);
} else if(event.getEntityLiving() instanceof EntityDoppleganger && rand.nextInt(13) < 1 + looting)
addDrop(event, new ItemStack(ModItems.gaiaHead));
@@ -64,9 +60,4 @@ public class ItemElementiumAxe extends ItemManasteelAxe {
event.getDrops().add(entityitem);
}
@Override
public boolean getIsRepairable(ItemStack toRepair, @Nonnull ItemStack repairBy) {
return repairBy.getItem() == ModItems.elementium ? true : super.getIsRepairable(toRepair, repairBy);
}
}
@@ -1,28 +1,27 @@
package vazkii.botania.common.item.equipment.tool.elementium;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.oredict.OreDictionary;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelPick;
import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick;
import vazkii.botania.common.lib.LibItemNames;
import javax.annotation.Nonnull;
import vazkii.botania.common.lib.LibMisc;
public class ItemElementiumPick extends ItemManasteelPick {
public ItemElementiumPick() {
super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_PICK);
MinecraftForge.EVENT_BUS.register(this);
public ItemElementiumPick(Properties props) {
super(BotaniaAPI.ELEMENTIUM_ITEM_TIER, props);
MinecraftForge.EVENT_BUS.addListener(this::onHarvestDrops);
}
@SubscribeEvent
public void onHarvestDrops(HarvestDropsEvent event) {
private void onHarvestDrops(HarvestDropsEvent event) {
if(event.getHarvester() != null) {
ItemStack stack = event.getHarvester().getHeldItemMainhand();
if(!stack.isEmpty() && (stack.getItem() == this || stack.getItem() == ModItems.terraPick && ItemTerraPick.isTipped(stack))) {
@@ -32,33 +31,21 @@ public class ItemElementiumPick extends ItemManasteelPick {
}
}
private static final Tag<Item> DISPOSABLE = new ItemTags.Wrapper(new ResourceLocation(LibMisc.MOD_ID, "disposable"));
private static final Tag<Item> SEMI_DISPOSABLE = new ItemTags.Wrapper(new ResourceLocation(LibMisc.MOD_ID, "semi_disposable"));
public static boolean isDisposable(Block block) {
return isDisposable(new ItemStack(block));
return DISPOSABLE.contains(block.asItem());
}
private static boolean isDisposable(ItemStack stack) {
if(stack.isEmpty())
return false;
for(int id : OreDictionary.getOreIDs(stack)) {
String name = OreDictionary.getOreName(id);
if(BotaniaAPI.disposableBlocks.contains(name))
return true;
}
return false;
return DISPOSABLE.contains(stack.getItem());
}
private static boolean isSemiDisposable(ItemStack stack) {
for(int id : OreDictionary.getOreIDs(stack)) {
String name = OreDictionary.getOreName(id);
if(BotaniaAPI.semiDisposableBlocks.contains(name))
return true;
}
return false;
}
@Override
public boolean getIsRepairable(ItemStack toRepair, @Nonnull ItemStack repairBy) {
return repairBy.getItem() == ModItems.elementium ? true : super.getIsRepairable(toRepair, repairBy);
return SEMI_DISPOSABLE.contains(stack.getItem());
}
}
@@ -27,20 +27,20 @@ import java.util.List;
public class ItemElementiumShears extends ItemManasteelShears {
public ItemElementiumShears() {
super(LibItemNames.ELEMENTIUM_SHEARS);
public ItemElementiumShears(Properties props) {
super(props);
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "reddit"),
(stack, worldIn, entityIn) -> stack.getDisplayName().equalsIgnoreCase("dammit reddit") ? 1F: 0F);
(stack, worldIn, entityIn) -> stack.getDisplayName().getString().equalsIgnoreCase("dammit reddit") ? 1F: 0F);
}
@Nonnull
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
public EnumAction getUseAction(ItemStack par1ItemStack) {
return EnumAction.BOW;
}
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack) {
public int getUseDuration(ItemStack par1ItemStack) {
return 72000;
}
@@ -56,7 +56,7 @@ public class ItemElementiumShears extends ItemManasteelShears {
if(living.world.isRemote)
return;
if(count != getMaxItemUseDuration(stack) && count % 5 == 0) {
if(count != getUseDuration(stack) && count % 5 == 0) {
int range = 12;
List sheep = living.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(living.posX - range, living.posY - range, living.posZ - range, living.posX + range, living.posY + range, living.posZ + range), Predicates.instanceOf(IShearable.class));
if(sheep.size() > 0) {
@@ -79,7 +79,7 @@ public class ItemElementiumShears extends ItemManasteelShears {
@Override
public boolean getIsRepairable(ItemStack toRepair, @Nonnull ItemStack repairBy) {
return repairBy.getItem() == ModItems.elementium ? true : super.getIsRepairable(toRepair, repairBy);
return repairBy.getItem() == ModItems.elementium || super.getIsRepairable(toRepair, repairBy);
}
}
@@ -23,10 +23,8 @@ import java.util.List;
public class ItemElementiumShovel extends ItemManasteelShovel {
public static final List<Material> materialsShovel = Arrays.asList(Material.GRASS, Material.GROUND, Material.SAND, Material.SNOW, Material.CRAFTED_SNOW, Material.CLAY);
public ItemElementiumShovel() {
super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_SHOVEL);
public ItemElementiumShovel(Properties props) {
super(BotaniaAPI.ELEMENTIUM_ITEM_TIER, props);
}
@Override
@@ -49,9 +47,4 @@ public class ItemElementiumShovel extends ItemManasteelShovel {
return false;
}
@Override
public boolean getIsRepairable(ItemStack toRepair, @Nonnull ItemStack repairBy) {
return repairBy.getItem() == ModItems.elementium ? true : super.getIsRepairable(toRepair, repairBy);
}
}
@@ -11,8 +11,8 @@ import javax.annotation.Nonnull;
public class ItemElementiumSword extends ItemManasteelSword implements IPixieSpawner {
public ItemElementiumSword() {
super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_SWORD);
public ItemElementiumSword(Properties props) {
super(BotaniaAPI.ELEMENTIUM_ITEM_TIER, props);
}
@Override
@@ -20,9 +20,4 @@ public class ItemElementiumSword extends ItemManasteelSword implements IPixieSpa
return 0.05F;
}
@Override
public boolean getIsRepairable(ItemStack toRepair, @Nonnull ItemStack repairBy) {
return repairBy.getItem() == ModItems.elementium ? true : super.getIsRepairable(toRepair, repairBy);
}
}
@@ -11,13 +11,14 @@
package vazkii.botania.common.item.equipment.tool.manasteel;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.IItemTier;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
@@ -43,27 +44,18 @@ import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import java.util.regex.Pattern;
public class ItemManasteelAxe extends ItemAxe implements IManaUsingItem, ISortableTool, IModelRegister {
public class ItemManasteelAxe extends ItemAxe implements IManaUsingItem, ISortableTool {
private static final Pattern SAPLING_PATTERN = Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)sapling)|(?:(?:[a-z-_.:]|^)Sapling))(?:[A-Z-_.:]|$)");
private static final int MANA_PER_DAMAGE = 60;
public ItemManasteelAxe() {
this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_AXE);
public ItemManasteelAxe(Properties props) {
this(BotaniaAPI.MANASTEEL_ITEM_TIER, props);
}
public ItemManasteelAxe(ToolMaterial mat, String name) {
super(mat, 8F, -3.1F);
setCreativeTab(BotaniaCreativeTab.INSTANCE);
setRegistryName(new ResourceLocation(LibMisc.MOD_ID, name));
setTranslationKey(name);
}
@Nonnull
@Override
public String getUnlocalizedNameInefficiently(@Nonnull ItemStack par1ItemStack) {
return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD);
public ItemManasteelAxe(IItemTier mat, Properties props) {
super(mat, 8F, -3.1F, props);
}
@Override
@@ -86,17 +78,16 @@ public class ItemManasteelAxe extends ItemAxe implements IManaUsingItem, ISortab
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float sx, float sy, float sz) {
for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stackAt = player.inventory.getStackInSlot(i);
if(!stackAt.isEmpty() && SAPLING_PATTERN.matcher(stackAt.getItem().getTranslationKey()).find()) {
ItemStack saveHeldStack = player.getHeldItem(hand);
player.setHeldItem(hand, stackAt);
EnumActionResult did = stackAt.getItem().onItemUse(player, world, pos, hand, side, sx, sy, sz);
player.setHeldItem(hand, saveHeldStack);
ItemsRemainingRenderHandler.set(player, new ItemStack(Blocks.SAPLING), SAPLING_PATTERN);
return did;
public EnumActionResult onItemUse(ItemUseContext ctx) {
EntityPlayer player = ctx.getPlayer();
if(player != null) {
for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stackAt = player.inventory.getStackInSlot(i);
if(!stackAt.isEmpty() && SAPLING_PATTERN.matcher(stackAt.getItem().getTranslationKey()).find()) {
EnumActionResult did = stackAt.getItem().onItemUse(new ItemUseContext(player, stackAt, ctx.getPos(), ctx.getFace(), ctx.getHitX(), ctx.getHitY(), ctx.getHitZ()));
ItemsRemainingRenderHandler.set(player, new ItemStack(Blocks.OAK_SAPLING), SAPLING_PATTERN);
return did;
}
}
}
@@ -105,14 +96,9 @@ public class ItemManasteelAxe extends ItemAxe implements IManaUsingItem, ISortab
@Override
public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) {
if(!world.isRemote && player instanceof EntityPlayer && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, getManaPerDamage() * 2, true))
stack.setItemDamage(stack.getItemDamage() - 1);
}
@Override
public boolean getIsRepairable(ItemStack axe, @Nonnull ItemStack material) {
return material.getItem() == ModItems.manaSteel || super.getIsRepairable(axe, material);
public void inventoryTick(ItemStack stack, World world, Entity player, int par4, boolean par5) {
if(!world.isRemote && player instanceof EntityPlayer && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, getManaPerDamage() * 2, true))
stack.setDamage(stack.getDamage() - 1);
}
@Override
@@ -129,10 +115,4 @@ public class ItemManasteelAxe extends ItemAxe implements IManaUsingItem, ISortab
public int getSortingPriority(ItemStack stack) {
return ToolCommons.getToolPriority(stack);
}
@OnlyIn(Dist.CLIENT)
@Override
public void registerModels() {
ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory"));
}
}
@@ -11,59 +11,39 @@
package vazkii.botania.common.item.equipment.tool.manasteel;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.IItemTier;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.item.ISortableTool;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.client.core.handler.ItemsRemainingRenderHandler;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.client.render.IModelRegister;
import vazkii.botania.common.core.BotaniaCreativeTab;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.equipment.tool.ToolCommons;
import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import java.util.regex.Pattern;
public class ItemManasteelPick extends ItemPickaxe implements IManaUsingItem, ISortableTool, IModelRegister {
public class ItemManasteelPick extends ItemPickaxe implements IManaUsingItem, ISortableTool {
private static final Pattern TORCH_PATTERN = Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)torch)|(?:(?:[a-z-_.:]|^)Torch))(?:[A-Z-_.:]|$)");
private static final int MANA_PER_DAMAGE = 60;
public ItemManasteelPick() {
this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_PICK);
public ItemManasteelPick(Properties props) {
this(BotaniaAPI.MANASTEEL_ITEM_TIER, props);
}
public ItemManasteelPick(ToolMaterial mat, String name) {
super(mat);
setCreativeTab(BotaniaCreativeTab.INSTANCE);
setRegistryName(new ResourceLocation(LibMisc.MOD_ID, name));
setTranslationKey(name);
}
@Nonnull
@Override
public String getUnlocalizedNameInefficiently(@Nonnull ItemStack par1ItemStack) {
return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD);
public ItemManasteelPick(IItemTier mat, Properties props) {
super(mat, 1, -2.8F, props);
}
@Override
@@ -82,17 +62,17 @@ public class ItemManasteelPick extends ItemPickaxe implements IManaUsingItem, IS
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float sx, float sy, float sz) {
for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stackAt = player.inventory.getStackInSlot(i);
if(!stackAt.isEmpty() && TORCH_PATTERN.matcher(stackAt.getItem().getTranslationKey()).find()) {
ItemStack saveHeldStack = player.getHeldItem(hand);
player.setHeldItem(hand, stackAt);
EnumActionResult did = stackAt.getItem().onItemUse(player, world, pos, hand, side, sx, sy, sz);
player.setHeldItem(hand, saveHeldStack);
public EnumActionResult onItemUse(ItemUseContext ctx) {
EntityPlayer player = ctx.getPlayer();
ItemsRemainingRenderHandler.set(player, new ItemStack(Blocks.TORCH), TORCH_PATTERN);
return did;
if(player != null) {
for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stackAt = player.inventory.getStackInSlot(i);
if(!stackAt.isEmpty() && TORCH_PATTERN.matcher(stackAt.getItem().getTranslationKey()).find()) {
EnumActionResult did = stackAt.getItem().onItemUse(new ItemUseContext(player, stackAt, ctx.getPos(), ctx.getFace(), ctx.getHitX(), ctx.getHitY(), ctx.getHitZ()));
ItemsRemainingRenderHandler.set(player, new ItemStack(Blocks.TORCH), TORCH_PATTERN);
return did;
}
}
}
@@ -104,14 +84,9 @@ public class ItemManasteelPick extends ItemPickaxe implements IManaUsingItem, IS
}
@Override
public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) {
if(!world.isRemote && player instanceof EntityPlayer && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true))
stack.setItemDamage(stack.getItemDamage() - 1);
}
@Override
public boolean getIsRepairable(ItemStack pick, @Nonnull ItemStack material) {
return material.getItem() == ModItems.manaSteel ? true : super.getIsRepairable(pick, material);
public void inventoryTick(ItemStack stack, World world, Entity player, int par4, boolean par5) {
if(!world.isRemote && player instanceof EntityPlayer && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true))
stack.setDamage(stack.getDamage() - 1);
}
@Override
@@ -128,10 +103,4 @@ public class ItemManasteelPick extends ItemPickaxe implements IManaUsingItem, IS
public int getSortingPriority(ItemStack stack) {
return ToolCommons.getToolPriority(stack);
}
@OnlyIn(Dist.CLIENT)
@Override
public void registerModels() {
ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory"));
}
}
@@ -11,7 +11,6 @@
package vazkii.botania.common.item.equipment.tool.manasteel;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@@ -43,24 +42,12 @@ import javax.annotation.Nonnull;
import java.util.List;
import java.util.Random;
public class ItemManasteelShears extends ItemShears implements IManaUsingItem, IModelRegister {
public class ItemManasteelShears extends ItemShears implements IManaUsingItem {
public static final int MANA_PER_DAMAGE = 30;
public ItemManasteelShears() {
this(LibItemNames.MANASTEEL_SHEARS);
}
public ItemManasteelShears(String name) {
setCreativeTab(BotaniaCreativeTab.INSTANCE);
setRegistryName(new ResourceLocation(LibMisc.MOD_ID, name));
setTranslationKey(name);
}
@Nonnull
@Override
public String getUnlocalizedNameInefficiently(@Nonnull ItemStack par1ItemStack) {
return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD);
public ItemManasteelShears(Properties props) {
super(props);
}
@Override
@@ -110,7 +97,7 @@ public class ItemManasteelShears extends ItemShears implements IManaUsingItem, I
}
ToolCommons.damageItem(itemstack, 1, player, MANA_PER_DAMAGE);
player.addStat(StatList.getBlockStats(block), 1);
player.addStat(StatList.BLOCK_MINED.get(block), 1);
return true;
}
}
@@ -119,9 +106,9 @@ public class ItemManasteelShears extends ItemShears implements IManaUsingItem, I
}
@Override
public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) {
if(!world.isRemote && player instanceof EntityPlayer && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true))
stack.setItemDamage(stack.getItemDamage() - 1);
public void inventoryTick(ItemStack stack, World world, Entity player, int par4, boolean par5) {
if(!world.isRemote && player instanceof EntityPlayer && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true))
stack.setDamage(stack.getDamage() - 1);
}
@Override
@@ -133,10 +120,4 @@ public class ItemManasteelShears extends ItemShears implements IManaUsingItem, I
public boolean usesMana(ItemStack stack) {
return true;
}
@OnlyIn(Dist.CLIENT)
@Override
public void registerModels() {
ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory"));
}
}
@@ -12,13 +12,14 @@ package vazkii.botania.common.item.equipment.tool.manasteel;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.IItemTier;
import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
@@ -29,9 +30,9 @@ import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.UseHoeEvent;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.eventbus.api.Event;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.item.ISortableTool;
import vazkii.botania.api.mana.IManaUsingItem;
@@ -46,25 +47,16 @@ import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class ItemManasteelShovel extends ItemSpade implements IManaUsingItem, ISortableTool, IModelRegister {
public class ItemManasteelShovel extends ItemSpade implements IManaUsingItem, ISortableTool {
private static final int MANA_PER_DAMAGE = 60;
public ItemManasteelShovel() {
this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_SHOVEL);
public ItemManasteelShovel(Properties props) {
this(BotaniaAPI.MANASTEEL_ITEM_TIER, props);
}
public ItemManasteelShovel(ToolMaterial mat, String name) {
super(mat);
setCreativeTab(BotaniaCreativeTab.INSTANCE);
setRegistryName(new ResourceLocation(LibMisc.MOD_ID, name));
setTranslationKey(name);
}
@Nonnull
@Override
public String getUnlocalizedNameInefficiently(@Nonnull ItemStack par1ItemStack) {
return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD);
public ItemManasteelShovel(IItemTier mat, Properties props) {
super(mat, 1.5F, -3.5F, props);
}
@Override
@@ -83,24 +75,27 @@ public class ItemManasteelShovel extends ItemSpade implements IManaUsingItem, IS
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, @Nonnull World world, BlockPos pos, @Nonnull EnumHand hand, @Nonnull EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
public EnumActionResult onItemUse(ItemUseContext ctx) {
ItemStack stack = ctx.getItem();
EntityPlayer player = ctx.getPlayer();
World world = ctx.getWorld();
BlockPos pos = ctx.getPos();
if(!player.canPlayerEdit(pos, side, stack))
if(player == null || !player.canPlayerEdit(pos, ctx.getFace(), stack))
return EnumActionResult.PASS;
else {
UseHoeEvent event = new UseHoeEvent(player, stack, world, pos);
UseHoeEvent event = new UseHoeEvent(ctx);
if(MinecraftForge.EVENT_BUS.post(event))
return EnumActionResult.FAIL;
if(event.getResult() == Result.ALLOW) {
if(event.getResult() == Event.Result.ALLOW) {
ToolCommons.damageItem(stack, 1, player, MANA_PER_DAMAGE);
return EnumActionResult.SUCCESS;
}
Block block = world.getBlockState(pos).getBlock();
if(side != EnumFacing.DOWN && world.getBlockState(pos.up()).getBlock().isAir(world.getBlockState(pos.up()), world, pos.up()) && (block == Blocks.GRASS || block == Blocks.DIRT || block == Blocks.GRASS_PATH)) {
if(ctx.getFace() != EnumFacing.DOWN && world.getBlockState(pos.up()).getBlock().isAir(world.getBlockState(pos.up()), world, pos.up()) && (block == Blocks.GRASS || block == Blocks.DIRT || block == Blocks.GRASS_PATH)) {
Block block1 = Blocks.GRASS_PATH;
if(block == block1)
block1 = Blocks.FARMLAND;
@@ -121,14 +116,9 @@ public class ItemManasteelShovel extends ItemSpade implements IManaUsingItem, IS
}
@Override
public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) {
if(!world.isRemote && player instanceof EntityPlayer && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true))
stack.setItemDamage(stack.getItemDamage() - 1);
}
@Override
public boolean getIsRepairable(ItemStack shovel, @Nonnull ItemStack material) {
return material.getItem() == ModItems.manaSteel ? true : super.getIsRepairable(shovel, material);
public void inventoryTick(ItemStack stack, World world, Entity player, int par4, boolean par5) {
if(!world.isRemote && player instanceof EntityPlayer && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, MANA_PER_DAMAGE * 2, true))
stack.setDamage(stack.getDamage() - 1);
}
@Override
@@ -145,10 +135,4 @@ public class ItemManasteelShovel extends ItemSpade implements IManaUsingItem, IS
public int getSortingPriority(ItemStack stack) {
return ToolCommons.getToolPriority(stack);
}
@OnlyIn(Dist.CLIENT)
@Override
public void registerModels() {
ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory"));
}
}
@@ -11,10 +11,10 @@
package vazkii.botania.common.item.equipment.tool.manasteel;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.IItemTier;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.util.ResourceLocation;
@@ -36,27 +36,18 @@ import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class ItemManasteelSword extends ItemSword implements IManaUsingItem, IModelRegister {
public class ItemManasteelSword extends ItemSword implements IManaUsingItem {
public static final int MANA_PER_DAMAGE = 60;
public ItemManasteelSword() {
this(BotaniaAPI.manasteelToolMaterial, LibItemNames.MANASTEEL_SWORD);
public ItemManasteelSword(Properties props) {
this(BotaniaAPI.MANASTEEL_ITEM_TIER, props);
}
public ItemManasteelSword(ToolMaterial mat, String name) {
super(mat);
setCreativeTab(BotaniaCreativeTab.INSTANCE);
setRegistryName(new ResourceLocation(LibMisc.MOD_ID, name));
setTranslationKey(name);
public ItemManasteelSword(IItemTier mat, Properties props) {
super(mat, 3, -2.4F, props);
addPropertyOverride(new ResourceLocation("botania", "elucidator"),
(stack, worldIn, entityIn) -> "the elucidator".equals(stack.getDisplayName().toLowerCase().trim()) ? 1 : 0);
}
@Nonnull
@Override
public String getUnlocalizedNameInefficiently(@Nonnull ItemStack par1ItemStack) {
return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD);
(stack, worldIn, entityIn) -> "the elucidator".equals(stack.getDisplayName().getString().toLowerCase().trim()) ? 1 : 0);
}
@Override
@@ -75,7 +66,7 @@ public class ItemManasteelSword extends ItemSword implements IManaUsingItem, IMo
}
@Override
public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) {
public void inventoryTick(ItemStack stack, World world, Entity player, int par4, boolean par5) {
if(!world.isRemote && player instanceof EntityPlayer && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) player, getManaPerDamage() * 2, true))
stack.setDamage(stack.getDamage() - 1);
}
@@ -84,19 +75,8 @@ public class ItemManasteelSword extends ItemSword implements IManaUsingItem, IMo
return MANA_PER_DAMAGE;
}
@Override
public boolean getIsRepairable(ItemStack sword, @Nonnull ItemStack material) {
return material.getItem() == ModItems.manaSteel || super.getIsRepairable(sword, material);
}
@Override
public boolean usesMana(ItemStack stack) {
return true;
}
@OnlyIn(Dist.CLIENT)
@Override
public void registerModels() {
ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory"));
}
}
@@ -10,19 +10,19 @@
*/
package vazkii.botania.common.item.equipment.tool.terrasteel;
import gnu.trove.map.hash.TIntObjectHashMap;
import net.minecraft.block.Block;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Enchantments;
import net.minecraft.item.ItemStack;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
import vazkii.botania.api.BotaniaAPI;
@@ -36,9 +36,11 @@ import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Set;
@@ -73,10 +75,10 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker
* Represents a map of dimension IDs to a set of all block swappers
* active in that dimension.
*/
private static final TIntObjectHashMap<Set<BlockSwapper>> blockSwappers = new TIntObjectHashMap<>();
private static final Map<Integer, Set<BlockSwapper>> blockSwappers = new HashMap<>();
public ItemTerraAxe() {
super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.TERRA_AXE);
public ItemTerraAxe(Properties props) {
super(BotaniaAPI.TERRASTEEL_ITEM_TIER, props);
MinecraftForge.EVENT_BUS.register(this);
attackSpeed = -3f;
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "terraaxe_on"), (stack, world, entity) -> {
@@ -304,8 +306,8 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker
for(BlockPos adj : adjacent(cand.coordinates)) {
Block block = world.getBlockState(adj).getBlock();
boolean isWood = block.isWood(world, adj);
boolean isLeaf = block.isLeaves(world.getBlockState(adj), world, adj);
boolean isWood = BlockTags.LOGS.contains(block);
boolean isLeaf = BlockTags.LEAVES.contains(block);
// If it's not wood or a leaf, we aren't interested.
if(!isWood && !isLeaf)
@@ -13,13 +13,14 @@ package vazkii.botania.common.item.equipment.tool.terrasteel;
import net.minecraft.block.material.Material;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Enchantments;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
@@ -31,6 +32,8 @@ import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3i;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
@@ -74,15 +77,15 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ
10000 - 1, 1000000 - 1, 10000000 - 1, 100000000 - 1, 1000000000 - 1, MAX_MANA - 1
};
public ItemTerraPick() {
super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.TERRA_PICK);
public ItemTerraPick(Properties props) {
super(BotaniaAPI.TERRASTEEL_ITEM_TIER, props);
addPropertyOverride(new ResourceLocation("botania", "tipped"), (itemStack, world, entityLivingBase) -> isTipped(itemStack) ? 1 : 0);
addPropertyOverride(new ResourceLocation("botania", "enabled"), (itemStack, world, entityLivingBase) -> isEnabled(itemStack) ? 1 : 0);
}
@Override
public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> list) {
if(isInCreativeTab(tab)) {
public void fillItemGroup(@Nonnull ItemGroup tab, @Nonnull NonNullList<ItemStack> list) {
if(isInGroup(tab)) {
for(int mana : CREATIVE_MANA) {
ItemStack stack = new ItemStack(this);
setMana(stack, mana);
@@ -93,12 +96,12 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ
@OnlyIn(Dist.CLIENT)
@Override
public void addInformation(ItemStack par1ItemStack, World world, List<String> stacks, ITooltipFlag flags) {
String rank = I18n.format("botania.rank" + getLevel(par1ItemStack));
String rankFormat = I18n.format("botaniamisc.toolRank", rank);
stacks.add(rankFormat.replaceAll("&", "\u00a7"));
public void addInformation(ItemStack par1ItemStack, World world, List<ITextComponent> stacks, ITooltipFlag flags) {
ITextComponent rank = new TextComponentTranslation("botania.rank" + getLevel(par1ItemStack));
ITextComponent rankFormat = new TextComponentTranslation("botaniamisc.toolRank", rank);
stacks.add(rankFormat);
if(getMana(par1ItemStack) == Integer.MAX_VALUE)
stacks.add(TextFormatting.RED + I18n.format("botaniamisc.getALife"));
stacks.add(new TextComponentTranslation("botaniamisc.getALife").applyTextStyle(TextFormatting.RED));
}
@Nonnull
@@ -120,14 +123,14 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float sx, float sy, float sz) {
return player.isSneaking() ? super.onItemUse(player, world, pos, hand, side, sx, sy, sz)
public EnumActionResult onItemUse(ItemUseContext ctx) {
return ctx.getPlayer() == null || ctx.getPlayer().isSneaking() ? super.onItemUse(ctx)
: EnumActionResult.PASS;
}
@Override
public void onUpdate(ItemStack par1ItemStack, World world, Entity par3Entity, int par4, boolean par5) {
super.onUpdate(par1ItemStack, world, par3Entity, par4, par5);
public void inventoryTick(ItemStack par1ItemStack, World world, Entity par3Entity, int par4, boolean par5) {
super.inventoryTick(par1ItemStack, world, par3Entity, par4, par5);
if(isEnabled(par1ItemStack)) {
int level = getLevel(par1ItemStack);
@@ -274,11 +277,6 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ
return true;
}
@Override
public boolean getIsRepairable(ItemStack pick, @Nonnull ItemStack material) {
return material.getItem() == ModItems.terrasteel || super.getIsRepairable(pick, material);
}
@Override
public boolean disposeOfTrashBlocks(ItemStack stack) {
return isTipped(stack);
@@ -22,8 +22,8 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.AttackEntityEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.api.mana.BurstProperties;
@@ -47,21 +47,20 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect {
private static final int MANA_PER_DAMAGE = 100;
public ItemTerraSword() {
super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.TERRA_SWORD);
MinecraftForge.EVENT_BUS.register(this);
public ItemTerraSword(Properties props) {
super(BotaniaAPI.TERRASTEEL_ITEM_TIER, props);
MinecraftForge.EVENT_BUS.addListener(this::leftClick);
MinecraftForge.EVENT_BUS.addListener(this::attackEntity);
}
@SubscribeEvent
public void leftClick(PlayerInteractEvent.LeftClickEmpty evt) {
private void leftClick(PlayerInteractEvent.LeftClickEmpty evt) {
if (!evt.getItemStack().isEmpty()
&& evt.getItemStack().getItem() == this) {
PacketHandler.sendToServer(new PacketLeftClick());
}
}
@SubscribeEvent
public void attackEntity(AttackEntityEvent evt) {
private void attackEntity(AttackEntityEvent evt) {
if (!evt.getEntityPlayer().world.isRemote) {
trySpawnBurst(evt.getEntityPlayer());
}
@@ -97,7 +96,7 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect {
burst.setMotion(burst.motionX * motionModifier, burst.motionY * motionModifier, burst.motionZ * motionModifier);
ItemStack lens = stack.copy();
ItemNBTHelper.setString(lens, TAG_ATTACKER_USERNAME, player.getName());
ItemNBTHelper.setString(lens, TAG_ATTACKER_USERNAME, player.getGameProfile().getName());
burst.setSourceLens(lens);
return burst;
}
@@ -118,7 +117,7 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect {
String attacker = ItemNBTHelper.getString(burst.getSourceLens(), TAG_ATTACKER_USERNAME, "");
for(EntityLivingBase living : entities) {
if(living instanceof EntityPlayer && (living.getName().equals(attacker) || FMLCommonHandler.instance().getMinecraftServerInstance() != null && !FMLCommonHandler.instance().getMinecraftServerInstance().isPVPEnabled()))
if(living instanceof EntityPlayer && (living.getName().getString().equals(attacker) || ServerLifecycleHooks.getCurrentServer() != null && !ServerLifecycleHooks.getCurrentServer().isPVPEnabled()))
continue;
if(living.hurtTime == 0) {
@@ -126,11 +125,11 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect {
int mana = burst.getMana();
if(mana >= cost) {
burst.setMana(mana - cost);
float damage = 4F + BotaniaAPI.terrasteelToolMaterial.getAttackDamage();
float damage = 4F + BotaniaAPI.TERRASTEEL_ITEM_TIER.getAttackDamage();
if(!burst.isFake() && !entity.world.isRemote) {
EntityPlayer player = living.world.getPlayerEntityByName(attacker);
living.attackEntityFrom(player == null ? DamageSource.MAGIC : DamageSource.causePlayerDamage(player), damage);
entity.setDead();
entity.remove();
break;
}
}
@@ -142,9 +141,4 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect {
public boolean doParticles(IManaBurst burst, ItemStack stack) {
return true;
}
@Override
public boolean getIsRepairable(ItemStack sword, @Nonnull ItemStack material) {
return material.getItem() == ModItems.terrasteel || super.getIsRepairable(sword, material);
}
}