diff options
author | miozune <miozune@gmail.com> | 2023-05-17 00:01:01 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-16 17:01:01 +0200 |
commit | 04514282c08ebefdb3e68a46db34092f72be2316 (patch) | |
tree | 0c9bc99f480f7e7f45a99a55a5b6619ebb5b014b /src/main/java/gtPlusPlus/xmod/gregtech/api/items | |
parent | cd58ff7cd4dc4b5ffe917a24a4b4c6da577f462d (diff) | |
download | GT5-Unofficial-04514282c08ebefdb3e68a46db34092f72be2316.tar.gz GT5-Unofficial-04514282c08ebefdb3e68a46db34092f72be2316.tar.bz2 GT5-Unofficial-04514282c08ebefdb3e68a46db34092f72be2316.zip |
Remove a lot of unused classes (#629)
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/items')
4 files changed, 0 insertions, 1058 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/tools/GT_MetaGenTool.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/tools/GT_MetaGenTool.java deleted file mode 100644 index 91ad6d9d9c..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/tools/GT_MetaGenTool.java +++ /dev/null @@ -1,617 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.items.tools; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map.Entry; - -import net.minecraft.block.Block; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.item.EntityMinecart; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.Potion; -import net.minecraft.stats.AchievementList; -import net.minecraft.stats.StatList; -import net.minecraft.util.MathHelper; -import net.minecraft.world.World; -import net.minecraftforge.event.world.BlockEvent; - -import gregtech.api.GregTech_API; -import gregtech.api.enchants.Enchantment_Radioactivity; -import gregtech.api.enums.Materials; -import gregtech.api.enums.TC_Aspects.TC_AspectStack; -import gregtech.api.interfaces.IToolStats; -import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ToolStats; - -/** - * This is an example on how you can create a Tool ItemStack, in this case a Bismuth Wrench: - * GT_MetaGenerated_Tool.sInstances.get("gt.metatool.01").getToolWithStats(16, 1, Materials.Bismuth, Materials.Bismuth, - * null); - */ -public abstract class GT_MetaGenTool extends GT_MetaGenerated_Tool { - - /** - * All instances of this Item Class are listed here. This gets used to register the Renderer to all Items of this - * Type, if useStandardMetaItemRenderer() returns true. - * <p/> - * You can also use the unlocalized Name gotten from getUnlocalizedName() as Key if you want to get a specific Item. - */ - public static final HashMap<String, GT_MetaGenTool> sInstances = new HashMap<>(); - - /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ - - public final HashMap<Short, IToolStats> mToolStats = new HashMap<>(); - - /** - * Creates the Item using these Parameters. - * - * @param aUnlocalized The Unlocalized Name of this Item. - */ - public GT_MetaGenTool(final String aUnlocalized) { - super(aUnlocalized); - GT_ModHandler.registerBoxableItemToToolBox(this); - this.setCreativeTab(GregTech_API.TAB_GREGTECH); - this.setMaxStackSize(1); - sInstances.put(this.getUnlocalizedName(), this); - } - - /* ---------- FOR ADDING CUSTOM ITEMS INTO THE REMAINING 766 RANGE ---------- */ - - public static final Materials getPrimaryMaterialEx(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("GT.ToolStats"); - if (aNBT != null) { - return Materials.getRealMaterial(aNBT.getString("PrimaryMaterial")); - } - } - return Materials._NULL; - } - - public static final Materials getSecondaryMaterialEx(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("GT.ToolStats"); - if (aNBT != null) { - return Materials.getRealMaterial(aNBT.getString("SecondaryMaterial")); - } - } - return Materials._NULL; - } - - /** - * This adds a Custom Item to the ending Range. - * - * @param aID The Id of the assigned Tool Class [0 - 32765] (only even Numbers allowed! Uneven - * ID's are empty electric Items) - * @param aEnglish The Default Localized Name of the created Item - * @param aToolTip The Default ToolTip of the created Item, you can also insert null for having no - * ToolTip - * @param aToolStats The Food Value of this Item. Can be null as well. - * @param aOreDictNamesAndAspects The OreDict Names you want to give the Item. Also used to assign Thaumcraft - * Aspects. - * @return An ItemStack containing the newly created Item, but without specific Stats. - */ - public final ItemStack addToolEx(final int aID, final String aEnglish, String aToolTip, final IToolStats aToolStats, - final Object... aOreDictNamesAndAspects) { - if (aToolTip == null) { - aToolTip = ""; - } - if ((aID >= 0) && (aID < 32766) && ((aID % 2) == 0)) { - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + "." + aID + ".name", aEnglish); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + "." + aID + ".tooltip", aToolTip); - GT_LanguageManager.addStringLocalization( - this.getUnlocalizedName() + "." + (aID + 1) + ".name", - aEnglish + " (Empty)"); - GT_LanguageManager.addStringLocalization( - this.getUnlocalizedName() + "." + (aID + 1) + ".tooltip", - "You need to recharge it"); - this.mToolStats.put((short) aID, aToolStats); - this.mToolStats.put((short) (aID + 1), aToolStats); - aToolStats.onStatsAddedToTool(this, aID); - final ItemStack rStack = new ItemStack(this, 1, aID); - final List<TC_AspectStack> tAspects = new ArrayList<>(); - for (final Object tOreDictNameOrAspect : aOreDictNamesAndAspects) { - if (tOreDictNameOrAspect instanceof TC_AspectStack) { - ((TC_AspectStack) tOreDictNameOrAspect).addToAspectList(tAspects); - } else { - GT_OreDictUnificator.registerOre(tOreDictNameOrAspect, rStack); - } - } - if (GregTech_API.sThaumcraftCompat != null) { - GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); - } - return rStack; - } - return null; - } - - /** - * This Function gets an ItemStack Version of this Tool - * - * @param aToolID the ID of the Tool Class - * @param aAmount Amount of Items (well normally you only need 1) - * @param aPrimaryMaterial Primary Material of this Tool - * @param aSecondaryMaterial Secondary (Rod/Handle) Material of this Tool - * @param aElectricArray The Electric Stats of this Tool (or null if not electric) - */ - public final ItemStack getToolWithStatsEx(final int aToolID, final int aAmount, final Materials aPrimaryMaterial, - final Materials aSecondaryMaterial, final long[] aElectricArray) { - final ItemStack rStack = new ItemStack(this, aAmount, aToolID); - final IToolStats tToolStats = this.getToolStats(rStack); - if (tToolStats != null) { - final NBTTagCompound tMainNBT = new NBTTagCompound(), tToolNBT = new NBTTagCompound(); - if (aPrimaryMaterial != null) { - tToolNBT.setString("PrimaryMaterial", aPrimaryMaterial.toString()); - tToolNBT.setLong( - "MaxDamage", - 100L * (long) (aPrimaryMaterial.mDurability * tToolStats.getMaxDurabilityMultiplier())); - } - if (aSecondaryMaterial != null) { - tToolNBT.setString("SecondaryMaterial", aSecondaryMaterial.toString()); - } - - if (aElectricArray != null) { - tToolNBT.setBoolean("Electric", true); - tToolNBT.setLong("MaxCharge", aElectricArray[0]); - tToolNBT.setLong("Voltage", aElectricArray[1]); - tToolNBT.setLong("Tier", aElectricArray[2]); - tToolNBT.setLong("SpecialData", aElectricArray[3]); - } - - tMainNBT.setTag("GT.ToolStats", tToolNBT); - rStack.setTagCompound(tMainNBT); - } - this.isItemStackUsable(rStack); - return rStack; - } - - /** - * Called by the Block Harvesting Event within the GT_Proxy - */ - @Override - public void onHarvestBlockEvent(final ArrayList<ItemStack> aDrops, final ItemStack aStack, - final EntityPlayer aPlayer, final Block aBlock, final int aX, final int aY, final int aZ, - final byte aMetaData, final int aFortune, final boolean aSilkTouch, - final BlockEvent.HarvestDropsEvent aEvent) { - final IToolStats tStats = this.getToolStats(aStack); - if (this.isItemStackUsable(aStack) && (this.getDigSpeed(aStack, aBlock, aMetaData) > 0.0F)) { - this.doDamage( - aStack, - tStats.convertBlockDrops( - aDrops, - aStack, - aPlayer, - aBlock, - aX, - aY, - aZ, - aMetaData, - aFortune, - aSilkTouch, - aEvent) * tStats.getToolDamagePerDropConversion()); - } - } - - @Override - public boolean onLeftClickEntity(final ItemStack aStack, final EntityPlayer aPlayer, final Entity aEntity) { - final IToolStats tStats = this.getToolStats(aStack); - if ((tStats == null) || !this.isItemStackUsable(aStack)) { - return true; - } - GT_Utility.doSoundAtClient(tStats.getEntityHitSound(), 1, 1.0F); - if (super.onLeftClickEntity(aStack, aPlayer, aEntity)) { - return true; - } - if (aEntity.canAttackWithItem() && !aEntity.hitByEntity(aPlayer)) { - final float tMagicDamage = tStats - .getMagicDamageAgainstEntity( - aEntity instanceof EntityLivingBase - ? EnchantmentHelper - .getEnchantmentModifierLiving(aPlayer, (EntityLivingBase) aEntity) - : 0.0F, - aEntity, - aStack, - aPlayer); - float tDamage = tStats.getNormalDamageAgainstEntity( - (float) aPlayer.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue() - + this.getToolCombatDamage(aStack), - aEntity, - aStack, - aPlayer); - if ((tDamage + tMagicDamage) > 0.0F) { - final boolean tCriticalHit = (aPlayer.fallDistance > 0.0F) && !aPlayer.onGround - && !aPlayer.isOnLadder() - && !aPlayer.isInWater() - && !aPlayer.isPotionActive(Potion.blindness) - && (aPlayer.ridingEntity == null) - && (aEntity instanceof EntityLivingBase); - if (tCriticalHit && (tDamage > 0.0F)) { - tDamage *= 1.5F; - } - tDamage += tMagicDamage; - if (aEntity.attackEntityFrom(tStats.getDamageSource(aPlayer, aEntity), tDamage)) { - if (aEntity instanceof EntityLivingBase) { - aEntity.setFire(EnchantmentHelper.getFireAspectModifier(aPlayer) * 4); - } - final int tKnockcack = (aPlayer.isSprinting() ? 1 : 0) + (aEntity instanceof EntityLivingBase - ? EnchantmentHelper.getKnockbackModifier(aPlayer, (EntityLivingBase) aEntity) - : 0); - if (tKnockcack > 0) { - aEntity.addVelocity( - -MathHelper.sin((aPlayer.rotationYaw * (float) Math.PI) / 180.0F) * tKnockcack * 0.5F, - 0.1D, - MathHelper.cos((aPlayer.rotationYaw * (float) Math.PI) / 180.0F) * tKnockcack * 0.5F); - aPlayer.motionX *= 0.6D; - aPlayer.motionZ *= 0.6D; - aPlayer.setSprinting(false); - } - if (tCriticalHit) { - aPlayer.onCriticalHit(aEntity); - } - if (tMagicDamage > 0.0F) { - aPlayer.onEnchantmentCritical(aEntity); - } - if (tDamage >= 18.0F) { - aPlayer.triggerAchievement(AchievementList.overkill); - } - aPlayer.setLastAttacker(aEntity); - if (aEntity instanceof EntityLivingBase) { - EnchantmentHelper.func_151384_a((EntityLivingBase) aEntity, aPlayer); - } - EnchantmentHelper.func_151385_b(aPlayer, aEntity); - if (aEntity instanceof EntityLivingBase) { - aPlayer.addStat(StatList.damageDealtStat, Math.round(tDamage * 10.0F)); - } - aEntity.hurtResistantTime = Math - .max(1, tStats.getHurtResistanceTime(aEntity.hurtResistantTime, aEntity)); - aPlayer.addExhaustion(0.3F); - this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); - } - } - } - if (aStack.stackSize <= 0) { - aPlayer.destroyCurrentEquippedItem(); - } - return true; - } - - @Override - public ItemStack onItemRightClick(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { - final IToolStats tStats = this.getToolStats(aStack); - if ((tStats != null) && tStats.canBlock()) { - aPlayer.setItemInUse(aStack, 72000); - } - return super.onItemRightClick(aStack, aWorld, aPlayer); - } - - @Override - public Long[] getFluidContainerStats(final ItemStack aStack) { - return null; - } - - @Override - public Long[] getElectricStats(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("GT.ToolStats"); - if ((aNBT != null) && aNBT.getBoolean("Electric")) { - return new Long[] { aNBT.getLong("MaxCharge"), aNBT.getLong("Voltage"), aNBT.getLong("Tier"), - aNBT.getLong("SpecialData") }; - } - } - return null; - } - - @Override - public float getToolCombatDamage(final ItemStack aStack) { - final IToolStats tStats = this.getToolStats(aStack); - if (tStats == null) { - return 0; - } - return tStats.getBaseDamage() + getPrimaryMaterial(aStack).mToolQuality; - } - - @Override - public float getDigSpeed(final ItemStack aStack, final Block aBlock, final int aMetaData) { - if (!this.isItemStackUsable(aStack)) { - return 0.0F; - } - final IToolStats tStats = this.getToolStats(aStack); - if ((tStats == null) || (Math.max(0, this.getHarvestLevel(aStack, "")) < aBlock.getHarvestLevel(aMetaData))) { - return 0.0F; - } - return tStats.isMinableBlock(aBlock, (byte) aMetaData) - ? Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed) - : 0.0F; - } - - @Override - public boolean onBlockDestroyed(final ItemStack aStack, final World aWorld, final Block aBlock, final int aX, - final int aY, final int aZ, final EntityLivingBase aPlayer) { - if (!this.isItemStackUsable(aStack)) { - return false; - } - final IToolStats tStats = this.getToolStats(aStack); - if (tStats == null) { - return false; - } - GT_Utility.doSoundAtClient(tStats.getMiningSound(), 1, 1.0F); - this.doDamage( - aStack, - (int) Math.max(1, aBlock.getBlockHardness(aWorld, aX, aY, aZ) * tStats.getToolDamagePerBlockBreak())); - return this.getDigSpeed(aStack, aBlock, aWorld.getBlockMetadata(aX, aY, aZ)) > 0.0F; - } - - private ItemStack getContainerItem(ItemStack aStack, final boolean playSound) { - if (!this.isItemStackUsable(aStack)) { - return null; - } - aStack = GT_Utility.copyAmount(1, aStack); - final IToolStats tStats = this.getToolStats(aStack); - if (tStats == null) { - return null; - } - this.doDamage(aStack, tStats.getToolDamagePerContainerCraft()); - aStack = aStack.stackSize > 0 ? aStack : null; - if (playSound) { - // String sound = (aStack == null) ? tStats.getBreakingSound() : tStats.getCraftingSound(); - // GT_Utility.doSoundAtClient(sound, 1, 1.0F); - } - return aStack; - } - - @Override - public Interface_ToolStats getToolStats(final ItemStack aStack) { - this.isItemStackUsable(aStack); - return this.getToolStatsInternal(aStack); - } - - private Interface_ToolStats getToolStatsInternal(final ItemStack aStack) { - return (Interface_ToolStats) (aStack == null ? null : this.mToolStats.get((short) aStack.getItemDamage())); - } - - @Override - public float getSaplingModifier(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer, - final int aX, final int aY, final int aZ) { - final IToolStats tStats = this.getToolStats(aStack); - return (tStats != null) && tStats.isGrafter() ? Math.min(100.0F, (1 + this.getHarvestLevel(aStack, "")) * 20.0F) - : 0.0F; - } - - @Override - public boolean canWhack(final EntityPlayer aPlayer, final ItemStack aStack, final int aX, final int aY, - final int aZ) { - if (!this.isItemStackUsable(aStack)) { - return false; - } - final IToolStats tStats = this.getToolStats(aStack); - return (tStats != null) && tStats.isCrowbar(); - } - - @Override - public void onWhack(final EntityPlayer aPlayer, final ItemStack aStack, final int aX, final int aY, final int aZ) { - final IToolStats tStats = this.getToolStats(aStack); - if (tStats != null) { - this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); - } - } - - @Override - public boolean canWrench(final EntityPlayer player, final int x, final int y, final int z) { - System.out.println("canWrench"); - if (player == null) { - return false; - } - if (player.getCurrentEquippedItem() == null) { - return false; - } - if (!this.isItemStackUsable(player.getCurrentEquippedItem())) { - return false; - } - final Interface_ToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); - return (tStats != null) && tStats.isWrench(); - } - - @Override - public void wrenchUsed(final EntityPlayer player, final int x, final int y, final int z) { - if (player == null) { - return; - } - if (player.getCurrentEquippedItem() == null) { - return; - } - final IToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); - if (tStats != null) { - this.doDamage(player.getCurrentEquippedItem(), tStats.getToolDamagePerEntityAttack()); - } - } - - @Override - public boolean canUse(final ItemStack stack, final EntityPlayer player, final int x, final int y, final int z) { - return this.canWrench(player, x, y, z); - } - - @Override - public void used(final ItemStack stack, final EntityPlayer player, final int x, final int y, final int z) { - this.wrenchUsed(player, x, y, z); - } - - @Override - public boolean shouldHideFacades(final ItemStack stack, final EntityPlayer player) { - if (player == null) { - return false; - } - if (player.getCurrentEquippedItem() == null) { - return false; - } - if (!this.isItemStackUsable(player.getCurrentEquippedItem())) { - return false; - } - final Interface_ToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); - return tStats.isWrench(); - } - - @Override - public boolean canLink(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { - if (!this.isItemStackUsable(aStack)) { - return false; - } - final IToolStats tStats = this.getToolStats(aStack); - return (tStats != null) && tStats.isCrowbar(); - } - - @Override - public void onLink(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { - final IToolStats tStats = this.getToolStats(aStack); - if (tStats != null) { - this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); - } - } - - @Override - public boolean canBoost(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { - if (!this.isItemStackUsable(aStack)) { - return false; - } - final IToolStats tStats = this.getToolStats(aStack); - return (tStats != null) && tStats.isCrowbar(); - } - - @Override - public void onBoost(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { - final IToolStats tStats = this.getToolStats(aStack); - if (tStats != null) { - this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); - } - } - - @Override - public void onCreated(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { - final IToolStats tStats = this.getToolStats(aStack); - if ((tStats != null) && (aPlayer != null)) { - tStats.onToolCrafted(aStack, aPlayer); - } - super.onCreated(aStack, aWorld, aPlayer); - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean isItemStackUsable(final ItemStack aStack) { - final IToolStats tStats = this.getToolStatsInternal(aStack); - if (((aStack.getItemDamage() % 2) == 1) || (tStats == null)) { - final NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT.removeTag("ench"); - } - return false; - } - final Materials aMaterial = getPrimaryMaterial(aStack); - final HashMap<Integer, Integer> tMap = new HashMap<>(), tResult = new HashMap<>(); - if (aMaterial.mEnchantmentTools != null) { - tMap.put(aMaterial.mEnchantmentTools.effectId, (int) aMaterial.mEnchantmentToolsLevel); - if (aMaterial.mEnchantmentTools == Enchantment.fortune) { - tMap.put(Enchantment.looting.effectId, (int) aMaterial.mEnchantmentToolsLevel); - } - if (aMaterial.mEnchantmentTools == Enchantment.knockback) { - tMap.put(Enchantment.power.effectId, (int) aMaterial.mEnchantmentToolsLevel); - } - if (aMaterial.mEnchantmentTools == Enchantment.fireAspect) { - tMap.put(Enchantment.flame.effectId, (int) aMaterial.mEnchantmentToolsLevel); - } - } - final Enchantment[] tEnchants = tStats.getEnchantments(aStack); - final int[] tLevels = tStats.getEnchantmentLevels(aStack); - for (int i = 0; i < tEnchants.length; i++) { - if (tLevels[i] > 0) { - final Integer tLevel = tMap.get(tEnchants[i].effectId); - tMap.put( - tEnchants[i].effectId, - tLevel == null ? tLevels[i] : tLevel == tLevels[i] ? tLevel + 1 : Math.max(tLevel, tLevels[i])); - } - } - for (final Entry<Integer, Integer> tEntry : tMap.entrySet()) { - if ((tEntry.getKey() == 33) || ((tEntry.getKey() == 20) && (tEntry.getValue() > 2)) - || (tEntry.getKey() == Enchantment_Radioactivity.INSTANCE.effectId)) { - tResult.put(tEntry.getKey(), tEntry.getValue()); - } else { - switch (Enchantment.enchantmentsList[tEntry.getKey()].type) { - case weapon: - if (tStats.isWeapon()) { - tResult.put(tEntry.getKey(), tEntry.getValue()); - } - break; - case all: - tResult.put(tEntry.getKey(), tEntry.getValue()); - break; - case armor: - case armor_feet: - case armor_head: - case armor_legs: - case armor_torso: - break; - case bow: - if (tStats.isRangedWeapon()) { - tResult.put(tEntry.getKey(), tEntry.getValue()); - } - break; - case breakable: - break; - case fishing_rod: - break; - case digger: - if (tStats.isMiningTool()) { - tResult.put(tEntry.getKey(), tEntry.getValue()); - } - break; - } - } - } - EnchantmentHelper.setEnchantments(tResult, aStack); - return true; - } - - @Override - public short getChargedMetaData(final ItemStack aStack) { - return (short) (aStack.getItemDamage() - (aStack.getItemDamage() % 2)); - } - - @Override - public short getEmptyMetaData(final ItemStack aStack) { - final NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT.removeTag("ench"); - } - return (short) ((aStack.getItemDamage() + 1) - (aStack.getItemDamage() % 2)); - } - - @Override - public int getItemEnchantability() { - return 0; - } - - @Override - public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { - return false; - } - - @Override - public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Base.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Base.java deleted file mode 100644 index 463b6d9f7f..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Base.java +++ /dev/null @@ -1,96 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.items.types; - -import java.util.List; - -import net.minecraft.block.BlockDispenser; -import net.minecraft.dispenser.BehaviorDefaultDispenseItem; -import net.minecraft.dispenser.IBlockSource; -import net.minecraft.dispenser.IPosition; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityArrow; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.world.World; - -import gregtech.api.enums.SubTag; -import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ItemBehaviour; -import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaItem_Base; - -public class ToolType_Base implements Interface_ItemBehaviour<Gregtech_MetaItem_Base> { - - @Override - public boolean onLeftClickEntity(final Gregtech_MetaItem_Base aItem, final ItemStack aStack, - final EntityPlayer aPlayer, final Entity aEntity) { - return false; - } - - @Override - public boolean onItemUse(final Gregtech_MetaItem_Base aItem, final ItemStack aStack, final EntityPlayer aPlayer, - final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, - final float hitY, final float hitZ) { - return false; - } - - @Override - public boolean onItemUseFirst(final Gregtech_MetaItem_Base aItem, final ItemStack aStack, - final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, - final float hitX, final float hitY, final float hitZ) { - return false; - } - - @Override - public ItemStack onItemRightClick(final Gregtech_MetaItem_Base aItem, final ItemStack aStack, final World aWorld, - final EntityPlayer aPlayer) { - return aStack; - } - - @Override - public List<String> getAdditionalToolTips(final Gregtech_MetaItem_Base aItem, final List<String> aList, - final ItemStack aStack) { - return aList; - } - - @Override - public void onUpdate(final Gregtech_MetaItem_Base aItem, final ItemStack aStack, final World aWorld, - final Entity aPlayer, final int aTimer, final boolean aIsInHand) {} - - @Override - public boolean isItemStackUsable(final Gregtech_MetaItem_Base aItem, final ItemStack aStack) { - return true; - } - - @Override - public boolean canDispense(final Gregtech_MetaItem_Base aItem, final IBlockSource aSource, final ItemStack aStack) { - return false; - } - - @Override - public ItemStack onDispense(final Gregtech_MetaItem_Base aItem, final IBlockSource aSource, - final ItemStack aStack) { - final EnumFacing enumfacing = BlockDispenser.func_149937_b(aSource.getBlockMetadata()); - final IPosition iposition = BlockDispenser.func_149939_a(aSource); - final ItemStack itemstack1 = aStack.splitStack(1); - BehaviorDefaultDispenseItem.doDispense(aSource.getWorld(), itemstack1, 6, enumfacing, iposition); - return aStack; - } - - @Override - public boolean hasProjectile(final Gregtech_MetaItem_Base aItem, final SubTag aProjectileType, - final ItemStack aStack) { - return false; - } - - @Override - public EntityArrow getProjectile(final Gregtech_MetaItem_Base aItem, final SubTag aProjectileType, - final ItemStack aStack, final World aWorld, final double aX, final double aY, final double aZ) { - return null; - } - - @Override - public EntityArrow getProjectile(final Gregtech_MetaItem_Base aItem, final SubTag aProjectileType, - final ItemStack aStack, final World aWorld, final EntityLivingBase aEntity, final float aSpeed) { - return null; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_HardHammer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_HardHammer.java deleted file mode 100644 index c387c513a4..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_HardHammer.java +++ /dev/null @@ -1,157 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.items.types; - -import java.util.List; -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.IFluidBlock; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.api.items.GT_MetaBase_Item; -import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.api.objects.ItemData; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; -import gregtech.common.blocks.GT_Block_Ores; -import gregtech.common.blocks.GT_TileEntity_Ores; - -public class ToolType_HardHammer extends ToolType_Base { - - private final int mVanillaCosts; - private final int mEUCosts; - private final String mTooltip = GT_LanguageManager - .addStringLocalization("gt.behaviour.prospecting", "Usable for Prospecting"); - - public ToolType_HardHammer(final int aVanillaCosts, final int aEUCosts) { - this.mVanillaCosts = aVanillaCosts; - this.mEUCosts = aEUCosts; - } - - public boolean onItemUseFirst(final GT_MetaBase_Item aItem, final ItemStack aStack, final EntityPlayer aPlayer, - final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, - final float hitY, final float hitZ) { - if (aWorld.isRemote) { - return false; - } - final Block aBlock = aWorld.getBlock(aX, aY, aZ); - if (aBlock == null) { - return false; - } - final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); - - ItemData tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(aBlock, 1, aMeta)); - if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore"))) { - GT_Utility.sendChatToPlayer( - aPlayer, - "This is " + tAssotiation.mMaterial.mMaterial.mDefaultLocalName + " Ore."); - GT_Utility.sendSoundToPlayers( - aWorld, - GregTech_API.sSoundList.get(Integer.valueOf(1)), - 1.0F, - -1.0F, - aX, - aY, - aZ); - return true; - } - if ((aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) - || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, GregTech_API.sBlockGranites)) - || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.netherrack)) - || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.end_stone))) { - if (GT_ModHandler.damageOrDechargeItem(aStack, this.mVanillaCosts, this.mEUCosts, aPlayer)) { - GT_Utility.sendSoundToPlayers( - aWorld, - GregTech_API.sSoundList.get(Integer.valueOf(1)), - 1.0F, - -1.0F, - aX, - aY, - aZ); - int tX = aX; - int tY = aY; - int tZ = aZ; - int tMetaID = 0; - final int tQuality = (aItem instanceof GT_MetaGenerated_Tool) - ? ((GT_MetaGenerated_Tool) aItem).getHarvestLevel(aStack, "") - : 0; - - int i = 0; - for (final int j = 6 + tQuality; i < j; i++) { - tX -= ForgeDirection.getOrientation(aSide).offsetX; - tY -= ForgeDirection.getOrientation(aSide).offsetY; - tZ -= ForgeDirection.getOrientation(aSide).offsetZ; - - final Block tBlock = aWorld.getBlock(tX, tY, tZ); - if ((tBlock == Blocks.lava) || (tBlock == Blocks.flowing_lava)) { - GT_Utility.sendChatToPlayer(aPlayer, "There is Lava behind this Rock."); - break; - } - if ((tBlock == Blocks.water) || (tBlock == Blocks.flowing_water) - || ((tBlock instanceof IFluidBlock))) { - GT_Utility.sendChatToPlayer(aPlayer, "There is a Liquid behind this Rock."); - break; - } - if ((tBlock == Blocks.monster_egg) || (!GT_Utility.hasBlockHitBox(aWorld, tX, tY, tZ))) { - GT_Utility.sendChatToPlayer(aPlayer, "There is an Air Pocket behind this Rock."); - break; - } - if (tBlock != aBlock) { - if (i >= 4) { - break; - } - GT_Utility.sendChatToPlayer(aPlayer, "Material is changing behind this Rock."); - break; - } - } - final Random tRandom = new Random(aX ^ aY ^ aZ ^ aSide); - i = 0; - for (final int j = 9 + (2 * tQuality); i < j; i++) { - tX = (aX - 4 - tQuality) + tRandom.nextInt(j); - tY = (aY - 4 - tQuality) + tRandom.nextInt(j); - tZ = (aZ - 4 - tQuality) + tRandom.nextInt(j); - final Block tBlock = aWorld.getBlock(tX, tY, tZ); - if ((tBlock instanceof GT_Block_Ores)) { - final TileEntity tTileEntity = aWorld.getTileEntity(tX, tY, tZ); - if ((tTileEntity instanceof GT_TileEntity_Ores)) { - final Materials tMaterial = GregTech_API.sGeneratedMaterials[(((GT_TileEntity_Ores) tTileEntity).mMetaData - % 1000)]; - if ((tMaterial != null) && (tMaterial != Materials._NULL)) { - GT_Utility.sendChatToPlayer( - aPlayer, - "Found traces of " + tMaterial.mDefaultLocalName + " Ore."); - return true; - } - } - } else { - tMetaID = aWorld.getBlockMetadata(tX, tY, tZ); - tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(tBlock, 1, tMetaID)); - if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore"))) { - GT_Utility.sendChatToPlayer( - aPlayer, - "Found traces of " + tAssotiation.mMaterial.mMaterial.mDefaultLocalName + " Ore."); - return true; - } - } - } - GT_Utility.sendChatToPlayer(aPlayer, "No Ores found."); - } - return true; - } - return false; - } - - public List<String> getAdditionalToolTips(final GT_MetaBase_Item aItem, final List<String> aList, - final ItemStack aStack) { - aList.add(this.mTooltip); - return aList; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Wrench.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Wrench.java deleted file mode 100644 index e117c1b28e..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Wrench.java +++ /dev/null @@ -1,188 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.items.types; - -import java.util.Arrays; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.GregTech_API; -import gregtech.api.items.GT_MetaBase_Item; -import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; -import ic2.api.tile.IWrenchable; - -public class ToolType_Wrench extends ToolType_Base { - - private final int mCosts; - private final String mTooltip = GT_LanguageManager - .addStringLocalization("gt.behaviour.wrench", "Rotates Blocks on Rightclick"); - - public ToolType_Wrench(final int aCosts) { - this.mCosts = aCosts; - } - - public boolean onItemUseFirst(final GT_MetaBase_Item aItem, final ItemStack aStack, final EntityPlayer aPlayer, - final World aWorld, final int aX, final int aY, final int aZ, final int ordinalSide, final float hitX, - final float hitY, final float hitZ) { - if (aWorld.isRemote) { - return false; - } - final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); - final Block aBlock = aWorld.getBlock(aX, aY, aZ); - if (aBlock == null) { - return false; - } - final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); - final ForgeDirection targetSide = GT_Utility.determineWrenchingSide(side, hitX, hitY, hitZ); - final byte ordinalTargetSide = (byte) targetSide.ordinal(); - final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - try { - if ((aTileEntity != null) && ((aTileEntity instanceof IWrenchable wrenchable))) { - if (wrenchable.wrenchCanSetFacing(aPlayer, ordinalTargetSide)) { - if ((aPlayer.capabilities.isCreativeMode) - || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - wrenchable.setFacing(ordinalTargetSide); - GT_Utility - .sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if (((IWrenchable) aTileEntity).wrenchCanRemove(aPlayer)) { - final int tDamage = ((IWrenchable) aTileEntity).getWrenchDropRate() < 1.0F ? 10 : 3; - if ((aPlayer.capabilities.isCreativeMode) - || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, tDamage * this.mCosts))) { - ItemStack tOutput = ((IWrenchable) aTileEntity).getWrenchDrop(aPlayer); - for (final ItemStack tStack : aBlock.getDrops(aWorld, aX, aY, aZ, aMeta, 0)) { - if (tOutput == null) { - aWorld.spawnEntityInWorld( - new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, tStack)); - } else { - aWorld.spawnEntityInWorld( - new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, tOutput)); - tOutput = null; - } - } - aWorld.setBlockToAir(aX, aY, aZ); - GT_Utility - .sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - return true; - } - } catch (final Throwable e) {} - if ((aBlock == Blocks.log) || (aBlock == Blocks.log2) || (aBlock == Blocks.hay_block)) { - if ((aPlayer.capabilities.isCreativeMode) - || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, (aMeta + 4) % 12, 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if ((aBlock == Blocks.powered_repeater) || (aBlock == Blocks.unpowered_repeater)) { - if ((aPlayer.capabilities.isCreativeMode) - || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if ((aBlock == Blocks.powered_comparator) || (aBlock == Blocks.unpowered_comparator)) { - if ((aPlayer.capabilities.isCreativeMode) - || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if ((aBlock == Blocks.crafting_table) || (aBlock == Blocks.bookshelf)) { - if ((aPlayer.capabilities.isCreativeMode) - || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - aWorld.spawnEntityInWorld( - new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, aMeta))); - aWorld.setBlockToAir(aX, aY, aZ); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if (aMeta == ordinalTargetSide) { - if ((aBlock == Blocks.pumpkin) || (aBlock == Blocks.lit_pumpkin) - || (aBlock == Blocks.piston) - || (aBlock == Blocks.sticky_piston) - || (aBlock == Blocks.dispenser) - || (aBlock == Blocks.dropper) - || (aBlock == Blocks.furnace) - || (aBlock == Blocks.lit_furnace) - || (aBlock == Blocks.chest) - || (aBlock == Blocks.trapped_chest) - || (aBlock == Blocks.ender_chest) - || (aBlock == Blocks.hopper)) { - if ((aPlayer.capabilities.isCreativeMode) - || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - aWorld.spawnEntityInWorld( - new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, 0))); - aWorld.setBlockToAir(aX, aY, aZ); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - } else { - if ((aBlock == Blocks.piston) || (aBlock == Blocks.sticky_piston) - || (aBlock == Blocks.dispenser) - || (aBlock == Blocks.dropper)) { - if ((aMeta < 6) && ((aPlayer.capabilities.isCreativeMode) - || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ordinalTargetSide, 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if ((aBlock == Blocks.pumpkin) || (aBlock == Blocks.lit_pumpkin) - || (aBlock == Blocks.furnace) - || (aBlock == Blocks.lit_furnace) - || (aBlock == Blocks.chest) - || (aBlock == Blocks.ender_chest) - || (aBlock == Blocks.trapped_chest)) { - if ((targetSide.offsetY == 0) && ((aPlayer.capabilities.isCreativeMode) - || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ordinalTargetSide, 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if (aBlock == Blocks.hopper) { - if ((targetSide != ForgeDirection.UP) && ((aPlayer.capabilities.isCreativeMode) - || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ordinalTargetSide, 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - } - if ((Arrays.asList(aBlock.getValidRotations(aWorld, aX, aY, aZ)).contains(targetSide)) - && ((aPlayer.capabilities.isCreativeMode) || (!GT_ModHandler.isElectricItem(aStack)) - || (GT_ModHandler.canUseElectricItem(aStack, this.mCosts))) - && (aBlock.rotateBlock(aWorld, aX, aY, aZ, targetSide))) { - if (!aPlayer.capabilities.isCreativeMode) { - ((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts); - } - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ); - } - return false; - } - - public List<String> getAdditionalToolTips(final GT_MetaBase_Item aItem, final List<String> aList, - final ItemStack aStack) { - aList.add(this.mTooltip); - return aList; - } -} |