From 75d417bfadc00fe14cfa3322a89dfc4b929919d4 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 9 Apr 2019 14:28:22 +1000 Subject: + Added some new OSRS materials. % Logging tweaks to HazmatUtils.java. --- src/Java/gtPlusPlus/core/item/ModItems.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/Java/gtPlusPlus/core/item/ModItems.java') diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index e8f0e31458..aa450ccd4b 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -522,7 +522,13 @@ public final class ModItems { MaterialGenerator.generate(ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN); MaterialGenerator.generate(ELEMENT.STANDALONE.HYPOGEN); MaterialGenerator.generate(ELEMENT.STANDALONE.CHRONOMATIC_GLASS); - + + //Custom Materials that are from Runescape + MaterialGenerator.generate(ELEMENT.STANDALONE.BLACK_METAL); + MaterialGenerator.generate(ELEMENT.STANDALONE.WHITE_METAL); + MaterialGenerator.generate(ELEMENT.STANDALONE.GRANITE); + MaterialGenerator.generate(ELEMENT.STANDALONE.RUNITE); + MaterialGenerator.generate(ELEMENT.STANDALONE.DRAGON_METAL); //Carbides - Tungsten Carbide exists in .09 so don't generate it. - Should still come before alloys though if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ -- cgit From 4e1fe73afd9d8c8097a1b89f6f47b07c0ebbb729 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 9 Apr 2019 17:11:48 +1000 Subject: + Added Babbit Alloy and Black Titanium Alloys. % Adjusted colouring of new OSRS materials. --- src/Java/gtPlusPlus/core/item/ModItems.java | 17 +++++- src/Java/gtPlusPlus/core/material/ALLOY.java | 85 +++++++++++++++++++++----- src/Java/gtPlusPlus/core/material/ELEMENT.java | 12 ++-- 3 files changed, 90 insertions(+), 24 deletions(-) (limited to 'src/Java/gtPlusPlus/core/item/ModItems.java') diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index aa450ccd4b..e3c01b7ea5 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -526,9 +526,9 @@ public final class ModItems { //Custom Materials that are from Runescape MaterialGenerator.generate(ELEMENT.STANDALONE.BLACK_METAL); MaterialGenerator.generate(ELEMENT.STANDALONE.WHITE_METAL); - MaterialGenerator.generate(ELEMENT.STANDALONE.GRANITE); - MaterialGenerator.generate(ELEMENT.STANDALONE.RUNITE); - MaterialGenerator.generate(ELEMENT.STANDALONE.DRAGON_METAL); + MaterialGenerator.generate(ELEMENT.STANDALONE.GRANITE, false, false); + MaterialGenerator.generate(ELEMENT.STANDALONE.RUNITE, false); + MaterialGenerator.generate(ELEMENT.STANDALONE.DRAGON_METAL, false); //Carbides - Tungsten Carbide exists in .09 so don't generate it. - Should still come before alloys though if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ @@ -640,6 +640,17 @@ public final class ModItems { MaterialGenerator.generate(ALLOY.TITANSTEEL); MaterialGenerator.generate(ALLOY.ARCANITE); MaterialGenerator.generate(ALLOY.OCTIRON); + + MaterialGenerator.generate(ALLOY.BABBIT_ALLOY, false); + MaterialGenerator.generate(ALLOY.BLACK_TITANIUM, false); + + + + + + + + //Must be the final Alloy to Generate MaterialGenerator.generate(ALLOY.QUANTUM); diff --git a/src/Java/gtPlusPlus/core/material/ALLOY.java b/src/Java/gtPlusPlus/core/material/ALLOY.java index 4edd36c51f..f18cd4ec73 100644 --- a/src/Java/gtPlusPlus/core/material/ALLOY.java +++ b/src/Java/gtPlusPlus/core/material/ALLOY.java @@ -190,7 +190,7 @@ public final class ALLOY { new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 20), new MaterialStack(NICHROME, 10) }); - + public static final Material NITINOL_60 = new Material( "Nitinol 60", //Material Name MaterialState.SOLID, //State @@ -474,7 +474,7 @@ public final class ALLOY { new MaterialStack(ELEMENT.getInstance().CARBON, 50), new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 50) }); - + public static final Material TUNGSTEN_TITANIUM_CARBIDE = new Material( "Tungsten Titanium Carbide", //Material Name MaterialState.SOLID, //State @@ -549,7 +549,7 @@ public final class ALLOY { new MaterialStack(ELEMENT.getInstance().NIOBIUM, 50), new MaterialStack(ELEMENT.getInstance().CARBON, 50) }); - + public static final Material ARCANITE = new Material( "Arcanite", //Material Name MaterialState.SOLID, //State @@ -680,7 +680,7 @@ public final class ALLOY { new MaterialStack(TRINIUM_NAQUADAH, 9), new MaterialStack(ELEMENT.getInstance().CARBON, 1) }); - + public static final Material TRINIUM_REINFORCED_STEEL = new Material( "Arceus Alloy 2B", //Material Name MaterialState.SOLID, //State @@ -697,8 +697,8 @@ public final class ALLOY { new MaterialStack(ALLOY.TUNGSTENSTEEL, 20), new MaterialStack(ALLOY.OSMIRIDIUM, 10) }); - - + + /* * Witchery Material @@ -719,12 +719,12 @@ public final class ALLOY { new MaterialStack(ELEMENT.getInstance().THAUMIUM, 30), new MaterialStack(ELEMENT.getInstance().IRON, 35) }); - - + + /* * Top Tier Alloys */ - + //0lafe Compound public static final Material LAFIUM = new Material( "Lafium Compound", //Material Name @@ -768,12 +768,12 @@ public final class ALLOY { new MaterialStack(ELEMENT.getInstance().TITANIUM, 12), new MaterialStack(ALLOY.OSMIRIDIUM, 6) }); - + //Piky Alloy public static final Material PIKYONIUM = new Material( "Pikyonium 64B", //Material Name MaterialState.SOLID, //State - new short[]{52, 103, 186, 0}, //Material Colour + new short[]{52, 103, 186, 0}, //Material Colour 7850, //Melting Point in C 11765, //Boiling Point in C -1, @@ -790,7 +790,7 @@ public final class ALLOY { new MaterialStack(ELEMENT.getInstance().YTTRIUM, 2), new MaterialStack(ALLOY.TUNGSTENSTEEL, 8) }); - + //Piky Alloy public static final Material ABYSSAL = new Material( "Abyssal Alloy", //Material Name @@ -812,7 +812,7 @@ public final class ALLOY { new MaterialStack(ELEMENT.getInstance().RADON, 2), new MaterialStack(ELEMENT.getInstance().GERMANIUM, 2), }); - + //Titansteel public static final Material TITANSTEEL = new Material( "Titansteel", //Material Name @@ -830,8 +830,8 @@ public final class ALLOY { new MaterialStack(ELEMENT.getInstance().TERRA, 1), new MaterialStack(ELEMENT.getInstance().PERDITIO, 1), }); - - + + public static final Material OCTIRON = new Material( "Octiron", //Material Name MaterialState.SOLID, //State @@ -849,7 +849,62 @@ public final class ALLOY { new MaterialStack(STEEL_BLACK, 10), new MaterialStack(ELEMENT.getInstance().THAUMIUM, 25) }); + + + + public static final Material BLACK_TITANIUM = new Material( + "Black Titanium", //Material Name + MaterialState.SOLID, //State + null, //Material Colour + Materials.Titanium.mMeltingPoint*4, //Melting Point in C + Materials.Titanium.mMeltingPoint*16, + -1, + -1, + true, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().TITANIUM, 55), + new MaterialStack(ELEMENT.getInstance().PRASEODYMIUM, 12), + new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 8), + new MaterialStack(ELEMENT.getInstance().COBALT, 6), + new MaterialStack(ELEMENT.getInstance().MANGANESE, 4), + new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 4), + new MaterialStack(ELEMENT.getInstance().PALLADIUM, 4), + new MaterialStack(ELEMENT.getInstance().NIOBIUM, 2), + new MaterialStack(ELEMENT.getInstance().ARGON, 5) + }); + public static final Material BABBIT_ALLOY = new Material( + "Babbit Alloy", //Material Name + MaterialState.SOLID, //State + null, //Material Colour + 268, //Melting Point in C + 589, + -1, + -1, + true, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().TIN, 10), + new MaterialStack(ELEMENT.getInstance().LEAD, 72), + new MaterialStack(ELEMENT.getInstance().ANTIMONY, 16), + new MaterialStack(ELEMENT.getInstance().ARSENIC, 2) + }); + + + + + + + + + + + + + + + //Quantum public static final Material QUANTUM = new Material( "Quantum", //Material Name diff --git a/src/Java/gtPlusPlus/core/material/ELEMENT.java b/src/Java/gtPlusPlus/core/material/ELEMENT.java index 9a4947027d..9727ccbed5 100644 --- a/src/Java/gtPlusPlus/core/material/ELEMENT.java +++ b/src/Java/gtPlusPlus/core/material/ELEMENT.java @@ -212,15 +212,15 @@ public final class ELEMENT { public static final Material ASTRAL_TITANIUM = new Material("Astral Titanium", MaterialState.SOLID, TextureSets.REFINED.get(), new short[] {220, 160, 240, 2}, INSTANCE.TITANIUM.getMeltingPointC()+7500, INSTANCE.TITANIUM.getBoilingPointC()+7500, 145, 133, true, "✧◇✧", 0);//Not a GT Inherited Material public static final Material CHRONOMATIC_GLASS = new Material("Chromatic Glass", MaterialState.SOLID, new short[]{255, 255, 255, 3}, 9200, 17550, 40, 51, false, "⌘☯𓍰 𓍱 𓍲 𓍳 𓍴 𓍵 𓍶 𓍷 𓍸 ☯⌘ ", 0);//Not a GT Inherited Material public static final Material ADVANCED_NITINOL = new Material("Advanced Nitinol", MaterialState.SOLID, TextureSets.ENRICHED.get(), ALLOY.NITINOL_60.getRGB(), 8400, 14377, 40, 51, true, "⚷⚙⚷ Ni4Ti6", 0);//Not a GT Inherited Material - public static final Material HYPOGEN = new Material("Hypogen", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{220, 120, 75}, 12255, 19377, 240, 251, true, "Hy⚶", 0);//Not a GT Inherited Material + public static final Material HYPOGEN = new Material("Hypogen", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{220, 120, 75, 2}, 12255, 19377, 240, 251, true, "Hy⚶", 0);//Not a GT Inherited Material //Runescape materials - public static final Material BLACK_METAL = new Material("Black", MaterialState.SOLID, TextureSet.SET_FINE, new short[] {5, 5, 5}, 2350, 4650, 24, 17, false, "҈", 0);//Not a GT Inherited Material - public static final Material WHITE_METAL = new Material("White", MaterialState.SOLID, TextureSet.SET_FINE, new short[] {250, 250, 250}, 4560, 7580, 35, 41, false, "҉", 0);//Not a GT Inherited Material - public static final Material GRANITE = new Material("Ancient Granite", MaterialState.SOLID, TextureSet.SET_SAND, new short[] {127, 127, 127}, 500, 2000, 16, 12, false, "«»", 0);//Not a GT Inherited Material - public static final Material RUNITE = new Material("Runite", MaterialState.SOLID, TextureSet.SET_METALLIC, new short[] {20, 40, 220}, 6750, 11550, 73, 87, true, "§", 0);//Not a GT Inherited Material - public static final Material DRAGON_METAL = new Material("Dragon", MaterialState.SOLID, TextureSet.SET_SHINY, new short[] {220, 40, 20}, 12560, 19850, 96, 105, true, "۞", 0);//Not a GT Inherited Material + public static final Material BLACK_METAL = new Material("Black", MaterialState.SOLID, TextureSet.SET_METALLIC, new short[] {5, 5, 5}, 2350, 4650, 24, 17, false, "҈", 0, new MaterialStack[]{new MaterialStack(getInstance().LEAD, 15), new MaterialStack(getInstance().TUNGSTEN, 25), new MaterialStack(getInstance().CARBON, 60)});//Not a GT Inherited Material + public static final Material WHITE_METAL = new Material("White", MaterialState.SOLID, TextureSet.SET_METALLIC, new short[] {255, 255, 255}, 4560, 7580, 35, 41, false, "҉", 0, new MaterialStack[]{new MaterialStack(getInstance().COPPER, 5), new MaterialStack(getInstance().ANTIMONY, 10), new MaterialStack(getInstance().PLATINUM, 10), new MaterialStack(getInstance().TIN, 75)});//Not a GT Inherited Material + public static final Material GRANITE = new Material("Ancient Granite", MaterialState.SOLID, TextureSet.SET_SAND, new short[] {107, 107, 107}, 500, 2000, 16, 12, false, "«»", 0);//Not a GT Inherited Material + public static final Material RUNITE = new Material("Runite", MaterialState.SOLID, TextureSet.SET_FINE, new short[] {60, 200, 190}, 6750, 11550, 73, 87, true, "§", 0);//Not a GT Inherited Material + public static final Material DRAGON_METAL = new Material("Dragon", MaterialState.SOLID, TextureSet.SET_SHINY, new short[] {220, 40, 20, 2}, 10160, 17850, 96, 105, true, "۞", 0);//Not a GT Inherited Material } -- cgit From 3b7cff8412af5afbf99bfd40fee1193a6cd8c400 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 11 Apr 2019 02:59:02 +1000 Subject: + Added some new Monster Killer Baubles. Kill nearby mobs for power, power cost scales with HP total, left and other EntityLiving stats. + Added new constructors for AutoMaps. + Added a Wrapper (AABB) for AxisAlignedBB. $ Fixed Hot Titanium Ingot recipe. --- src/Java/gtPlusPlus/api/objects/data/AutoMap.java | 40 +++++++++++ .../gtPlusPlus/api/objects/minecraft/AABB.java | 65 ++++++++++++++++++ .../core/common/compat/COMPAT_Baubles.java | 12 ++++ src/Java/gtPlusPlus/core/item/ModItems.java | 12 +++- .../core/item/bauble/MonsterKillerBaseBauble.java | 78 +++++++++++++++++----- .../core/util/minecraft/EntityUtils.java | 48 ++++++++++--- 6 files changed, 227 insertions(+), 28 deletions(-) create mode 100644 src/Java/gtPlusPlus/api/objects/minecraft/AABB.java (limited to 'src/Java/gtPlusPlus/core/item/ModItems.java') diff --git a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java index fe2caa466d..3583a04a74 100644 --- a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java +++ b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java @@ -31,6 +31,46 @@ public class AutoMap implements Iterable, Cloneable, Serializable, Collect mInternalNameMap = new LinkedHashMap(); } + /** + * Generates an AutoMap from the List. + * @param aList - Data to be inserted into the AutoMap. + */ + public AutoMap(List aList) { + mInternalMap = new LinkedHashMap(); + mInternalNameMap = new LinkedHashMap(); + if (aList != null && aList.size() > 0) { + for (V obj : aList) { + add(obj); + } + } + } + /** + * Generates an AutoMap from a Set. + * @param aList - Data to be inserted into the AutoMap. + */ + public AutoMap(Set aList) { + mInternalMap = new LinkedHashMap(); + mInternalNameMap = new LinkedHashMap(); + if (aList != null && aList.size() > 0) { + for (V obj : aList) { + add(obj); + } + } + } + /** + * Generates an AutoMap from a Collection. + * @param aList - Data to be inserted into the AutoMap. + */ + public AutoMap(Collection aList) { + mInternalMap = new LinkedHashMap(); + mInternalNameMap = new LinkedHashMap(); + if (aList != null && aList.size() > 0) { + for (V obj : aList) { + add(obj); + } + } + } + @Override public Iterator iterator() { return values().iterator(); diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/AABB.java b/src/Java/gtPlusPlus/api/objects/minecraft/AABB.java new file mode 100644 index 0000000000..722ac00b64 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/AABB.java @@ -0,0 +1,65 @@ +package gtPlusPlus.api.objects.minecraft; + +import gtPlusPlus.core.util.minecraft.EntityUtils; +import net.minecraft.entity.Entity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +/** + * Generates an AABB around an entity. + * @author Alkalus + * + */ +public class AABB { + + private final AxisAlignedBB mAabb; + private final World mWorld; + + /** + * Creates a AxisAlignedBB based around an Entity. + * @param aEntity - The Entity to work with. + * @param x - Maximum X from origin. + * @param y - Maximum Y from origin. + * @param z - Maximum Z from origin. + */ + public AABB(Entity aEntity, int x, int y, int z) { + if (aEntity == null) { + mAabb = null; + mWorld = null; + } + else { + mWorld = aEntity.worldObj; + BlockPos aEntityLocation = EntityUtils.findBlockPosUnderEntity(aEntity); + int xMin, xMax, yMin, yMax, zMin, zMax; + xMin = aEntityLocation.xPos; + yMin = aEntityLocation.yPos; + zMin = aEntityLocation.zPos; + xMax = aEntityLocation.xPos + x; + yMax = aEntityLocation.yPos + y; + zMax = aEntityLocation.zPos + z; + mAabb = AxisAlignedBB.getBoundingBox(xMin, yMin, zMin, xMax, yMax, zMax); + } + + } + + /** + * Used to get the AxisAlignedBB from this class. + * @return + */ + public AxisAlignedBB get() { + return mAabb; + } + + /** + * Used to determine if this object is valid or not. + * @return + */ + public boolean valid() { + return mAabb != null && mWorld != null; + } + + public World world() { + return mWorld; + } + +} diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java index f57c09b62d..d779e60975 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java @@ -3,10 +3,16 @@ package gtPlusPlus.core.common.compat; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.item.bauble.BatteryPackBaseBauble; +import gtPlusPlus.core.item.bauble.MonsterKillerBaseBauble; import gtPlusPlus.core.item.general.ItemCloakingDevice; import gtPlusPlus.core.item.general.ItemHealingDevice; import gtPlusPlus.core.item.general.ItemSlowBuildingRing; import gtPlusPlus.core.lib.LoadedMods; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.entity.monster.EntityEnderman; +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.entity.monster.EntitySpider; +import net.minecraft.entity.monster.EntityZombie; public class COMPAT_Baubles { @@ -34,6 +40,12 @@ public class COMPAT_Baubles { catch (Throwable t) { t.printStackTrace(); } + + ModItems.itemAmuletMonsterKiller_Zombie = new MonsterKillerBaseBauble(new Class[] {EntityZombie.class}, "Zombie", 6); + ModItems.itemAmuletMonsterKiller_Skeleton = new MonsterKillerBaseBauble(new Class[] {EntitySkeleton.class}, "Skeleton", 6); + ModItems.itemAmuletMonsterKiller_Spider = new MonsterKillerBaseBauble(new Class[] {EntitySpider.class}, "Spider", 6); + ModItems.itemAmuletMonsterKiller_Creeper = new MonsterKillerBaseBauble(new Class[] {EntityCreeper.class}, "Creeper", 6); + ModItems.itemAmuletMonsterKiller_Enderman = new MonsterKillerBaseBauble(new Class[] {EntityEnderman.class}, "Enderman", 6); if (LoadedMods.PlayerAPI){ ModItems.itemSlowBuildingRing = new ItemSlowBuildingRing(); diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index e3c01b7ea5..68aacd6943 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -32,6 +32,7 @@ import gtPlusPlus.core.item.base.plates.BaseItemPlateDouble; import gtPlusPlus.core.item.bauble.BatteryPackBaseBauble; import gtPlusPlus.core.item.bauble.HealthBoostBauble; import gtPlusPlus.core.item.bauble.ModularBauble; +import gtPlusPlus.core.item.bauble.MonsterKillerBaseBauble; import gtPlusPlus.core.item.chemistry.AgriculturalChem; import gtPlusPlus.core.item.chemistry.CoalTar; import gtPlusPlus.core.item.chemistry.GenericChem; @@ -345,6 +346,15 @@ public final class ModItems { public static CoreItem itemDetCable; public static ItemThrowableBomb itemBomb; + public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Zombie; + public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Skeleton; + public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Spider; + public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Creeper; + public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Enderman; + + public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Nether; + public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Infernal; + static { Logger.INFO("Items!"); //Default item used when recipes fail, handy for debugging. Let's make sure they exist when this class is called upon. @@ -829,7 +839,7 @@ public final class ModItems { else { itemHotTitaniumIngot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotHotTitanium", 1); } - GT_Values.RA.addBlastRecipe(ELEMENT.getInstance().TITANIUM.getIngot(1), null, itemHotTitaniumIngot, null, 10 * 20, 512, Materials.Titanium.mBlastFurnaceTemp); + GT_Values.RA.addBlastRecipe(ELEMENT.getInstance().TITANIUM.getIngot(1), CI.getNumberedCircuit(16), itemHotTitaniumIngot, null, 10 * 20, 500, Materials.Titanium.mBlastFurnaceTemp); //Special Sillyness if (true) { diff --git a/src/Java/gtPlusPlus/core/item/bauble/MonsterKillerBaseBauble.java b/src/Java/gtPlusPlus/core/item/bauble/MonsterKillerBaseBauble.java index 024f6aa907..2cffb8737f 100644 --- a/src/Java/gtPlusPlus/core/item/bauble/MonsterKillerBaseBauble.java +++ b/src/Java/gtPlusPlus/core/item/bauble/MonsterKillerBaseBauble.java @@ -3,14 +3,18 @@ package gtPlusPlus.core.item.bauble; import java.util.List; import baubles.api.BaubleType; -import cpw.mods.fml.common.Optional; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.GT_Values; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.AABB; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; import ic2.api.item.ElectricItem; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -20,14 +24,13 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.World; public class MonsterKillerBaseBauble extends ElectricBaseBauble { - - private final int mTier; + private final Class[] mTargets; - public MonsterKillerBaseBauble(Class[] aMonsterBaseClassArray, String aMonsterTypeName, int aPowerTier) { - super(BaubleType.AMULET, aPowerTier, GT_Values.V[aPowerTier] * 20 * 300, "GTPP.MonsterKiller."+aMonsterTypeName+".name"); - mTier = aPowerTier; - mTargets = aMonsterBaseClassArray; + public MonsterKillerBaseBauble(Class[] aMonsterBaseClassArray, String aMonsterTypeName, int aPowerTier) { + super(BaubleType.AMULET, aPowerTier, GT_Values.V[aPowerTier] * 20 * 300, + "GTPP.MonsterKiller." + aMonsterTypeName + ".name"); + mTargets = aMonsterBaseClassArray; } @SideOnly(Side.CLIENT) @@ -56,7 +59,7 @@ public class MonsterKillerBaseBauble extends ElectricBaseBauble { @Override public boolean canProvideEnergy(final ItemStack itemStack) { - double aItemCharge = ElectricItem.manager.getCharge(itemStack); + double aItemCharge = ElectricItem.manager.getCharge(itemStack); return aItemCharge > 0; } @@ -78,17 +81,18 @@ public class MonsterKillerBaseBauble extends ElectricBaseBauble { String aString2 = StatCollector.translateToLocal("GTPP.monsterkiller.tooltip.2"); String aString3 = StatCollector.translateToLocal("GTPP.monsterkiller.tooltip.3"); String aString4 = StatCollector.translateToLocal("GTPP.monsterkiller.tooltip.4"); - String aEU = StatCollector.translateToLocal("GTPP.info.eu"); - String aEUT = aEU+"/t"; + String aEU = StatCollector.translateToLocal("GTPP.info.eu"); + String aEUT = aEU + "/t"; list.add(EnumChatFormatting.GREEN + aString1 + EnumChatFormatting.GRAY); - list.add(EnumChatFormatting.GREEN + aString2+" " + (int) getTransferLimit(stack) + aEUT + aString3 + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN + aString2 + " " + (int) getTransferLimit(stack) + aEUT + aString3 + + EnumChatFormatting.GRAY); list.add(""); - list.add(""+EnumChatFormatting.GREEN + aString4 + " " + EnumChatFormatting.GRAY); + list.add("" + EnumChatFormatting.GREEN + aString4 + " " + EnumChatFormatting.GRAY); for (Class cz : mTargets) { - list.add("- "+EnumChatFormatting.DARK_GREEN + cz.getSimpleName() + EnumChatFormatting.GRAY); + list.add("- " + EnumChatFormatting.DARK_GREEN + cz.getSimpleName() + EnumChatFormatting.GRAY); } - + super.addInformation(stack, aPlayer, list, bool); } @@ -113,17 +117,57 @@ public class MonsterKillerBaseBauble extends ElectricBaseBauble { } @Override // TODO - public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase aPlayer) { + public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase aPlayerEntity) { + if (aPlayerEntity == null) { + return; + } + EntityPlayer aPlayer = (EntityPlayer) aPlayerEntity; if (!aPlayer.worldObj.isRemote) { if (this.getCharge(aBaubleStack) >= getTransferLimit(aBaubleStack)) { - + AABB aPlayerBox = new AABB(aPlayerEntity, 5, 5, 5); + if (this.mTargets != null && this.mTargets.length > 0) { + for (Class clazz : mTargets) { + AutoMap aEnts = EntityUtils.getEntitiesWithinBoundingBox(clazz, aPlayerBox); + if (aEnts.isEmpty()) { + continue; + } else { + EntityLiving aClosest = null; + double aEntityDistance = Short.MIN_VALUE; + for (Object ent : aEnts) { + if (!EntityLiving.class.isInstance(ent)) { + continue; + } else { + double aCurEntDis = EntityUtils.getDistance(aPlayerEntity, (Entity) ent); + if (aEntityDistance == Short.MIN_VALUE || aCurEntDis < aEntityDistance) { + aEntityDistance = aCurEntDis; + aClosest = (EntityLiving) ent; + } + } + } + if (aClosest != null) { + float aEntHealth = aClosest.getHealth(); + float aEntMaxHealth = aClosest.getMaxHealth(); + double aEntHealthPerc = MathUtils.findPercentage(aEntHealth, aEntMaxHealth); + long aEuUsage = (long) (aEntHealthPerc * 50 * aEntMaxHealth); + if (this.discharge(aBaubleStack, aEuUsage, mTier, true, false, false) > 0) { + aClosest.setDead(); + break; + } + } else { + continue; + } + } + } + } + } else { + return; } } } @Override public String getTextureNameForBauble() { - return CORE.MODID+":"+""; + return CORE.MODID + ":" + "baubles/itemAmulet"; } } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java index 844bb0bcaf..8c5a9f6581 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java @@ -3,26 +3,28 @@ package gtPlusPlus.core.util.minecraft; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.HashMap; +import java.util.List; import java.util.Map; import cpw.mods.fml.common.registry.EntityRegistry; -import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.AABB; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import ic2.core.IC2Potion; +import ic2.core.item.armor.ItemArmorHazmat; import net.minecraft.block.Block; -import net.minecraft.entity.*; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; -import gregtech.api.util.GT_Utility; - -import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.core.util.reflect.ReflectionUtils; -import ic2.core.IC2Potion; -import ic2.core.item.armor.ItemArmorHazmat; - public class EntityUtils { public static void setEntityOnFire(final Entity entity, final int length){ @@ -158,5 +160,31 @@ public class EntityUtils { } return false; } + + public static double getDistance(Entity p1, Entity p2) { + return Math.sqrt( Math.pow(p1.posX - p2.posX, 2) + Math.pow(p1.posY - p2.posY, 2) + Math.pow(p1.posZ - p2.posZ, 2)); + } + + public static AutoMap getEntitiesWithinBoundingBoxExcluding(Entity aExclusion, AABB aBoundingBox){ + + if (aExclusion == null) { + return new AutoMap(); + } + else { + List aEntities = aBoundingBox.world().getEntitiesWithinAABBExcludingEntity(aExclusion, aBoundingBox.get()); + return new AutoMap(aEntities); + } + } + + public static AutoMap getEntitiesWithinBoundingBox(Class aEntityType, AABB aBoundingBox){ + + if (aEntityType == null) { + return new AutoMap(); + } + else { + List aEntities = aBoundingBox.world().getEntitiesWithinAABB(aEntityType, aBoundingBox.get()); + return new AutoMap(aEntities); + } + } } -- cgit