diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index 38a2e1aa2..c80848efa 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -87,6 +87,7 @@ import mekanism.common.IElectricChest; import mekanism.common.IInvConfiguration; import mekanism.common.Mekanism; import mekanism.common.block.BlockMachine.MachineType; +import mekanism.common.entity.EntityBabySkeleton; import mekanism.common.entity.EntityBalloon; import mekanism.common.entity.EntityObsidianTNT; import mekanism.common.entity.EntityRobit; @@ -133,6 +134,7 @@ import mekanism.common.tile.TileEntitySeismicVibrator; import mekanism.common.tile.TileEntityTeleporter; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.entity.RenderSkeleton; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -313,6 +315,7 @@ public class ClientProxy extends CommonProxy RenderingRegistry.registerEntityRenderingHandler(EntityObsidianTNT.class, new RenderObsidianTNTPrimed()); RenderingRegistry.registerEntityRenderingHandler(EntityRobit.class, new RenderRobit()); RenderingRegistry.registerEntityRenderingHandler(EntityBalloon.class, new RenderBalloon()); + RenderingRegistry.registerEntityRenderingHandler(EntityBabySkeleton.class, new RenderSkeleton()); //Register item handler ItemRenderingHandler handler = new ItemRenderingHandler(); @@ -334,6 +337,7 @@ public class ClientProxy extends CommonProxy MinecraftForgeClient.registerItemRenderer(Mekanism.FreeRunners, handler); MinecraftForgeClient.registerItemRenderer(Mekanism.AtomicDisassembler, handler); MinecraftForgeClient.registerItemRenderer(Mekanism.GlowPanel, handler); + MinecraftForgeClient.registerItemRenderer(Mekanism.Flamethrower, handler); //Register block handlers RenderingRegistry.registerBlockHandler(new MachineRenderingHandler()); diff --git a/src/main/java/mekanism/client/model/ModelFlamethrower.java b/src/main/java/mekanism/client/model/ModelFlamethrower.java new file mode 100644 index 000000000..e882a69c8 --- /dev/null +++ b/src/main/java/mekanism/client/model/ModelFlamethrower.java @@ -0,0 +1,215 @@ +package mekanism.client.model; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ModelFlamethrower extends ModelBase +{ + ModelRenderer RingButtom; + ModelRenderer RingTop; + ModelRenderer Ring; + ModelRenderer Axle; + ModelRenderer AxleBLeft; + ModelRenderer AxleBRight; + ModelRenderer AxleTRight; + ModelRenderer AxleTLeft; + ModelRenderer Grasp; + ModelRenderer GraspRod; + ModelRenderer SupportCentre; + ModelRenderer SupportFront; + ModelRenderer SupportRear; + ModelRenderer LargeBarrel; + ModelRenderer LargeBarrelDecor; + ModelRenderer LargeBarrelDecor2; + ModelRenderer Barrel; + ModelRenderer BarrelRing; + ModelRenderer BarrelRing2; + ModelRenderer Flame; + ModelRenderer FlameStrut; + ModelRenderer HydrogenDecor; + ModelRenderer Hydrogen; + + public ModelFlamethrower() + { + textureWidth = 64; + textureHeight = 64; + + RingButtom = new ModelRenderer(this, 19, 14); + RingButtom.addBox(0F, 0F, 0F, 3, 1, 3); + RingButtom.setRotationPoint(-2F, 19.5F, 1.5F); + RingButtom.setTextureSize(64, 64); + RingButtom.mirror = true; + setRotation(RingButtom, 0F, 0F, 0F); + RingTop = new ModelRenderer(this, 19, 14); + RingTop.addBox(0F, 0F, 0F, 3, 1, 3); + RingTop.setRotationPoint(-2F, 13.5F, 1.466667F); + RingTop.setTextureSize(64, 64); + RingTop.mirror = true; + setRotation(RingTop, 0F, 0F, 0F); + Ring = new ModelRenderer(this, 0, 14); + Ring.addBox(0F, 0F, 0F, 5, 6, 4); + Ring.setRotationPoint(-3F, 14F, 1F); + Ring.setTextureSize(64, 64); + Ring.mirror = true; + setRotation(Ring, 0F, 0F, 0F); + Axle = new ModelRenderer(this, 32, 12); + Axle.addBox(0F, 0F, 0F, 4, 4, 7); + Axle.setRotationPoint(-2.5F, 15F, -6.5F); + Axle.setTextureSize(64, 64); + Axle.mirror = true; + setRotation(Axle, 0F, 0F, 0F); + AxleBLeft = new ModelRenderer(this, 0, 25); + AxleBLeft.addBox(-0.5F, -0.5F, 0F, 1, 1, 8); + AxleBLeft.setRotationPoint(-2F, 19F, -7F); + AxleBLeft.setTextureSize(64, 64); + AxleBLeft.mirror = true; + setRotation(AxleBLeft, 0F, 0F, 0.2094395F); + AxleBRight = new ModelRenderer(this, 0, 25); + AxleBRight.addBox(-0.5F, -0.5F, 0F, 1, 1, 8); + AxleBRight.setRotationPoint(1F, 19F, -7F); + AxleBRight.setTextureSize(64, 64); + AxleBRight.mirror = true; + setRotation(AxleBRight, 0.0174533F, 0F, -0.2094395F); + AxleTRight = new ModelRenderer(this, 0, 25); + AxleTRight.addBox(-0.5F, -0.5F, 0F, 1, 1, 8); + AxleTRight.setRotationPoint(1F, 15F, -7F); + AxleTRight.setTextureSize(64, 64); + AxleTRight.mirror = true; + setRotation(AxleTRight, 0F, 0F, 0.2094395F); + AxleTLeft = new ModelRenderer(this, 0, 25); + AxleTLeft.addBox(-0.5F, -0.5F, 0F, 1, 1, 8); + AxleTLeft.setRotationPoint(-2F, 15F, -7F); + AxleTLeft.setTextureSize(64, 64); + AxleTLeft.mirror = true; + setRotation(AxleTLeft, 0F, 0F, -0.2094395F); + Grasp = new ModelRenderer(this, 24, 19); + Grasp.addBox(0F, 0F, 0F, 2, 1, 1); + Grasp.setRotationPoint(-1.5F, 13F, -1.1F); + Grasp.setTextureSize(64, 64); + Grasp.mirror = true; + setRotation(Grasp, 0.7807508F, 0F, 0F); + Grasp.mirror = false; + GraspRod = new ModelRenderer(this, 19, 19); + GraspRod.addBox(0F, 0F, 0F, 1, 3, 1); + GraspRod.setRotationPoint(-1F, 13F, -1F); + GraspRod.setTextureSize(64, 64); + GraspRod.mirror = true; + setRotation(GraspRod, 0.2230717F, 0F, 0F); + SupportCentre = new ModelRenderer(this, 0, 40); + SupportCentre.addBox(0F, 0F, 0F, 2, 1, 6); + SupportCentre.setRotationPoint(-1.5F, 12.4F, 6.6F); + SupportCentre.setTextureSize(64, 64); + SupportCentre.mirror = true; + setRotation(SupportCentre, -0.1115358F, 0F, 0F); + SupportFront = new ModelRenderer(this, 19, 24); + SupportFront.addBox(0F, 0F, 0F, 1, 1, 4); + SupportFront.setRotationPoint(-1F, 13.1F, 12.5F); + SupportFront.setTextureSize(64, 64); + SupportFront.mirror = true; + setRotation(SupportFront, -1.226894F, 0F, 0F); + SupportRear = new ModelRenderer(this, 0, 35); + SupportRear.addBox(0F, 0F, 0F, 3, 1, 3); + SupportRear.setRotationPoint(-2F, 14F, 4F); + SupportRear.setTextureSize(64, 64); + SupportRear.mirror = true; + setRotation(SupportRear, 0.5424979F, 0F, 0F); + LargeBarrel = new ModelRenderer(this, 19, 48); + LargeBarrel.addBox(0F, 0F, 0F, 2, 3, 7); + LargeBarrel.setRotationPoint(-1.5F, 16F, 4F); + LargeBarrel.setTextureSize(64, 64); + LargeBarrel.mirror = true; + setRotation(LargeBarrel, 0F, 0F, 0F); + LargeBarrelDecor = new ModelRenderer(this, 0, 48); + LargeBarrelDecor.addBox(0F, 0F, 0F, 3, 3, 6); + LargeBarrelDecor.setRotationPoint(-2F, 15F, 4F); + LargeBarrelDecor.setTextureSize(64, 64); + LargeBarrelDecor.mirror = true; + setRotation(LargeBarrelDecor, -0.1115358F, 0F, 0F); + LargeBarrelDecor2 = new ModelRenderer(this, 17, 41); + LargeBarrelDecor2.addBox(0F, 0F, 0F, 4, 2, 4); + LargeBarrelDecor2.setRotationPoint(-2.5F, 16F, 4F); + LargeBarrelDecor2.setTextureSize(64, 64); + LargeBarrelDecor2.mirror = true; + setRotation(LargeBarrelDecor2, 0F, 0F, 0F); + Barrel = new ModelRenderer(this, 19, 30); + Barrel.addBox(0F, 0F, 0F, 2, 2, 8); + Barrel.setRotationPoint(-1.5F, 16.5F, 11F); + Barrel.setTextureSize(64, 64); + Barrel.mirror = true; + setRotation(Barrel, 0F, 0F, 0F); + BarrelRing = new ModelRenderer(this, 30, 25); + BarrelRing.addBox(0F, 0F, 0F, 3, 3, 1); + BarrelRing.setRotationPoint(-2F, 16F, 13F); + BarrelRing.setTextureSize(64, 64); + BarrelRing.mirror = true; + setRotation(BarrelRing, 0F, 0F, 0F); + BarrelRing2 = new ModelRenderer(this, 30, 25); + BarrelRing2.addBox(0F, 0F, 0F, 3, 3, 1); + BarrelRing2.setRotationPoint(-2F, 16F, 17F); + BarrelRing2.setTextureSize(64, 64); + BarrelRing2.mirror = true; + setRotation(BarrelRing2, 0F, 0F, 0F); + Flame = new ModelRenderer(this, 38, 0); + Flame.addBox(0F, 0F, 0F, 1, 1, 2); + Flame.setRotationPoint(-1F, 19.5F, 19F); + Flame.setTextureSize(64, 64); + Flame.mirror = true; + setRotation(Flame, 0.7063936F, 0F, 0F); + FlameStrut = new ModelRenderer(this, 27, 0); + FlameStrut.addBox(0F, 0F, 0F, 2, 1, 3); + FlameStrut.setRotationPoint(-1.466667F, 18.5F, 17F); + FlameStrut.setTextureSize(64, 64); + FlameStrut.mirror = true; + setRotation(FlameStrut, -0.2602503F, 0F, 0F); + HydrogenDecor = new ModelRenderer(this, 27, 5); + HydrogenDecor.addBox(0F, 0F, 0F, 3, 1, 5); + HydrogenDecor.setRotationPoint(1.5F, 15.66667F, -4.933333F); + HydrogenDecor.setTextureSize(64, 64); + HydrogenDecor.mirror = true; + setRotation(HydrogenDecor, 0F, 0F, 0.4438713F); + Hydrogen = new ModelRenderer(this, 0, 0); + Hydrogen.addBox(0F, 0F, 0F, 3, 3, 10); + Hydrogen.setRotationPoint(1.5F, 16F, -5.5F); + Hydrogen.setTextureSize(64, 64); + Hydrogen.mirror = true; + setRotation(Hydrogen, 0F, 0F, 0.4438713F); + } + + public void render(float size) + { + RingButtom.render(size); + RingTop.render(size); + Ring.render(size); + Axle.render(size); + AxleBLeft.render(size); + AxleBRight.render(size); + AxleTRight.render(size); + AxleTLeft.render(size); + Grasp.render(size); + GraspRod.render(size); + SupportCentre.render(size); + SupportFront.render(size); + SupportRear.render(size); + LargeBarrel.render(size); + LargeBarrelDecor.render(size); + LargeBarrelDecor2.render(size); + Barrel.render(size); + BarrelRing.render(size); + BarrelRing2.render(size); + Flame.render(size); + FlameStrut.render(size); + HydrogenDecor.render(size); + Hydrogen.render(size); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } +} diff --git a/src/main/java/mekanism/client/render/item/ItemRenderingHandler.java b/src/main/java/mekanism/client/render/item/ItemRenderingHandler.java index 0eb054eaa..acc5564bc 100644 --- a/src/main/java/mekanism/client/render/item/ItemRenderingHandler.java +++ b/src/main/java/mekanism/client/render/item/ItemRenderingHandler.java @@ -8,6 +8,7 @@ import mekanism.client.model.ModelArmoredJetpack; import mekanism.client.model.ModelAtomicDisassembler; import mekanism.client.model.ModelEnergyCube; import mekanism.client.model.ModelEnergyCube.ModelEnergyCore; +import mekanism.client.model.ModelFlamethrower; import mekanism.client.model.ModelFreeRunners; import mekanism.client.model.ModelGasMask; import mekanism.client.model.ModelGasTank; @@ -31,6 +32,7 @@ import mekanism.common.item.ItemAtomicDisassembler; import mekanism.common.item.ItemBalloon; import mekanism.common.item.ItemBlockBasic; import mekanism.common.item.ItemBlockMachine; +import mekanism.common.item.ItemFlamethrower; import mekanism.common.item.ItemFreeRunners; import mekanism.common.item.ItemGasMask; import mekanism.common.item.ItemRobit; @@ -83,6 +85,7 @@ public class ItemRenderingHandler implements IItemRenderer public ModelFreeRunners freeRunners = new ModelFreeRunners(); public ModelAtomicDisassembler atomicDisassembler = new ModelAtomicDisassembler(); public ModelPortableTank portableTank = new ModelPortableTank(); + public ModelFlamethrower flamethrower = new ModelFlamethrower(); private final RenderBalloon balloonRenderer = new RenderBalloon(); private final RenderBin binRenderer = (RenderBin)TileEntityRendererDispatcher.instance.mapSpecialRenderers.get(TileEntityBin.class); @@ -435,6 +438,15 @@ public class ItemRenderingHandler implements IItemRenderer GL11.glEnable(GL11.GL_CULL_FACE); GL11.glPopAttrib(); } + else if(item.getItem() instanceof ItemFlamethrower) + { + GL11.glPushMatrix(); + GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Flamethrower.png")); + + flamethrower.render(0.0625F); + GL11.glPopMatrix(); + } else if(MachineType.get(item) == MachineType.PORTABLE_TANK) { GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F); diff --git a/src/main/java/mekanism/common/CommonProxy.java b/src/main/java/mekanism/common/CommonProxy.java index d8232099f..d740ce3ac 100644 --- a/src/main/java/mekanism/common/CommonProxy.java +++ b/src/main/java/mekanism/common/CommonProxy.java @@ -189,6 +189,7 @@ public class CommonProxy Mekanism.voiceServerEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoiceServerEnabled", true).getBoolean(true); Mekanism.cardboardSpawners = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "AllowSpawnerBoxPickup", true).getBoolean(true); Mekanism.enableWorldRegeneration = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnableWorldRegeneration", false).getBoolean(false); + Mekanism.spawnBabySkeletons = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "SpawnBabySkeletons", true).getBoolean(true); Mekanism.obsidianTNTDelay = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTDelay", 100).getInt(); Mekanism.obsidianTNTBlastRadius = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTBlastRadius", 12).getInt(); Mekanism.UPDATE_DELAY = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ClientUpdateDelay", 10).getInt(); diff --git a/src/main/java/mekanism/common/Mekanism.java b/src/main/java/mekanism/common/Mekanism.java index 1b0bd7584..e49e182ce 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -49,6 +49,7 @@ import mekanism.common.block.BlockOre; import mekanism.common.block.BlockPlastic; import mekanism.common.block.BlockPlasticFence; import mekanism.common.block.BlockSalt; +import mekanism.common.entity.EntityBabySkeleton; import mekanism.common.entity.EntityBalloon; import mekanism.common.entity.EntityObsidianTNT; import mekanism.common.entity.EntityRobit; @@ -73,6 +74,7 @@ import mekanism.common.item.ItemDust; import mekanism.common.item.ItemElectricBow; import mekanism.common.item.ItemEnergized; import mekanism.common.item.ItemFilterCard; +import mekanism.common.item.ItemFlamethrower; import mekanism.common.item.ItemFreeRunners; import mekanism.common.item.ItemGasMask; import mekanism.common.item.ItemHDPE; @@ -111,6 +113,7 @@ import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.common.voice.VoiceServerManager; import mekanism.common.world.GenHandler; import net.minecraft.block.Block; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -120,6 +123,8 @@ import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.WorldChunkManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.event.world.ChunkDataEvent; @@ -258,6 +263,7 @@ public class Mekanism public static ItemJetpack Jetpack; public static ItemScubaTank ScubaTank; public static ItemGasMask GasMask; + public static ItemFlamethrower Flamethrower; public static Item Dictionary; public static Item Balloon; public static Item ElectrolyticCore; @@ -309,6 +315,7 @@ public class Mekanism public static boolean cardboardSpawners = true; public static boolean machineEffects = true; public static boolean enableWorldRegeneration = true; + public static boolean spawnBabySkeletons = true; public static int obsidianTNTBlastRadius = 12; public static int osmiumPerChunk = 12; public static int copperPerChunk = 16; @@ -967,6 +974,7 @@ public class Mekanism Jetpack = (ItemJetpack)new ItemJetpack().setUnlocalizedName("Jetpack"); ArmoredJetpack = (ItemJetpack)new ItemJetpack().setUnlocalizedName("ArmoredJetpack"); FreeRunners = new ItemFreeRunners().setUnlocalizedName("FreeRunners"); + Flamethrower = (ItemFlamethrower)new ItemFlamethrower().setUnlocalizedName("Flamethrower"); BrineBucket = new ItemMekanism().setMaxStackSize(1).setContainerItem(Items.bucket).setUnlocalizedName("BrineBucket"); Sawdust = new ItemMekanism().setUnlocalizedName("Sawdust"); Salt = new ItemMekanism().setUnlocalizedName("Salt"); @@ -1033,6 +1041,7 @@ public class Mekanism GameRegistry.registerItem(Polyethene, "Polyethene"); GameRegistry.registerItem(BioFuel, "BioFuel"); GameRegistry.registerItem(GlowPanel, "GlowPanel"); + GameRegistry.registerItem(Flamethrower, "Flamethrower"); } /** @@ -1237,11 +1246,13 @@ public class Mekanism EntityRegistry.registerGlobalEntityID(EntityObsidianTNT.class, "ObsidianTNT", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerGlobalEntityID(EntityRobit.class, "Robit", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerGlobalEntityID(EntityBalloon.class, "Balloon", EntityRegistry.findGlobalUniqueEntityId()); + EntityRegistry.registerGlobalEntityID(EntityBabySkeleton.class, "BabySkeleton", EntityRegistry.findGlobalUniqueEntityId()); //Registrations EntityRegistry.registerModEntity(EntityObsidianTNT.class, "ObsidianTNT", 0, this, 40, 5, true); EntityRegistry.registerModEntity(EntityRobit.class, "Robit", 1, this, 40, 2, true); EntityRegistry.registerModEntity(EntityBalloon.class, "Balloon", 2, this, 40, 1, true); + EntityRegistry.registerModEntity(EntityBabySkeleton.class, "BabySkeleton", 3, this, 64, 5, true); //Tile entities GameRegistry.registerTileEntity(TileEntityBoundingBlock.class, "BoundingBlock"); @@ -1379,6 +1390,18 @@ public class Mekanism //Load configuration proxy.loadConfiguration(); + + //Add baby skeleton spawner + if(spawnBabySkeletons) + { + for(BiomeGenBase biome : WorldChunkManager.allowedBiomes) + { + if(biome.getSpawnableList(EnumCreatureType.monster) != null && biome.getSpawnableList(EnumCreatureType.monster).size() > 0) + { + EntityRegistry.addSpawn(EntityBabySkeleton.class, 6, 1, 3, EnumCreatureType.monster, new BiomeGenBase[] {biome}); + } + } + } //Load this module addItems(); diff --git a/src/main/java/mekanism/common/entity/EntityBabySkeleton.java b/src/main/java/mekanism/common/entity/EntityBabySkeleton.java new file mode 100644 index 000000000..afee33af3 --- /dev/null +++ b/src/main/java/mekanism/common/entity/EntityBabySkeleton.java @@ -0,0 +1,85 @@ +package mekanism.common.entity; + +import java.util.UUID; + +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public class EntityBabySkeleton extends EntitySkeleton +{ + private static final UUID babySpeedBoostUUID = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); + private static final AttributeModifier babySpeedBoostModifier = new AttributeModifier(babySpeedBoostUUID, "Baby speed boost", 0.5D, 1); + + public EntityBabySkeleton(World world) + { + super(world); + + setChild(true); + System.out.println("Spawned"); + } + + @Override + protected void entityInit() + { + super.entityInit(); + + getDataWatcher().addObject(12, new Byte((byte)0)); + } + + @Override + public void onUpdate() + { + super.onUpdate(); + + System.out.println(posX + " " + posY + " " + posZ); + } + + public void setChild(boolean child) + { + getDataWatcher().updateObject(12, Byte.valueOf((byte)(child ? 1 : 0))); + + if(worldObj != null && !worldObj.isRemote) + { + IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed); + iattributeinstance.removeModifier(babySpeedBoostModifier); + + if(child) + { + iattributeinstance.applyModifier(babySpeedBoostModifier); + } + } + + updateChildSize(child); + } + + @Override + public boolean isChild() + { + return getDataWatcher().getWatchableObjectByte(12) == 1; + } + + @Override + protected int getExperiencePoints(EntityPlayer p_70693_1_) + { + if(isChild()) + { + experienceValue = (int)((float)experienceValue * 2.5F); + } + + return super.getExperiencePoints(p_70693_1_); + } + + public void updateChildSize(boolean child) + { + updateSize(child ? 0.5F : 1.0F); + } + + protected final void updateSize(float size) + { + super.setSize(size, size); + } +} diff --git a/src/main/java/mekanism/common/item/ItemFlamethrower.java b/src/main/java/mekanism/common/item/ItemFlamethrower.java new file mode 100644 index 000000000..c21259f35 --- /dev/null +++ b/src/main/java/mekanism/common/item/ItemFlamethrower.java @@ -0,0 +1,172 @@ +package mekanism.common.item; + +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import mekanism.api.gas.Gas; +import mekanism.api.gas.GasRegistry; +import mekanism.api.gas.GasStack; +import mekanism.api.gas.IGasItem; +import mekanism.common.item.ItemJetpack.JetpackMode; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ItemFlamethrower extends ItemMekanism implements IGasItem +{ + public int MAX_GAS = 24000; + public int TRANSFER_RATE = 16; + + public ItemFlamethrower() + { + setMaxStackSize(1); + setMaxDamage(100); + setNoRepair(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) {} + + public void useGas(ItemStack stack) + { + setGas(stack, new GasStack(getGas(stack).getGas(), getGas(stack).amount-1)); + } + + @Override + public int getMaxGas(ItemStack itemstack) + { + return MAX_GAS; + } + + @Override + public int getRate(ItemStack itemstack) + { + return TRANSFER_RATE; + } + + @Override + public int addGas(ItemStack itemstack, GasStack stack) + { + if(getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) + { + return 0; + } + + if(stack.getGas() != GasRegistry.getGas("hydrogen")) + { + return 0; + } + + int toUse = Math.min(getMaxGas(itemstack)-getStored(itemstack), Math.min(getRate(itemstack), stack.amount)); + setGas(itemstack, new GasStack(stack.getGas(), getStored(itemstack)+toUse)); + + return toUse; + } + + @Override + public GasStack removeGas(ItemStack itemstack, int amount) + { + if(getGas(itemstack) == null) + { + return null; + } + + Gas type = getGas(itemstack).getGas(); + + int gasToUse = Math.min(getStored(itemstack), Math.min(getRate(itemstack), amount)); + setGas(itemstack, new GasStack(type, getStored(itemstack)-gasToUse)); + + return new GasStack(type, gasToUse); + } + + public int getStored(ItemStack itemstack) + { + return getGas(itemstack) != null ? getGas(itemstack).amount : 0; + } + + @Override + public boolean canReceiveGas(ItemStack itemstack, Gas type) + { + return type == GasRegistry.getGas("hydrogen"); + } + + @Override + public boolean canProvideGas(ItemStack itemstack, Gas type) + { + return false; + } + + @Override + public GasStack getGas(ItemStack itemstack) + { + if(itemstack.stackTagCompound == null) + { + return null; + } + + GasStack stored = GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored")); + + if(stored == null) + { + itemstack.setItemDamage(100); + } + else { + itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)stored.amount/getMaxGas(itemstack))*100)-100)))); + } + + return stored; + } + + @Override + public boolean isMetadataSpecific(ItemStack itemStack) + { + return false; + } + + @Override + public void setGas(ItemStack itemstack, GasStack stack) + { + if(itemstack.stackTagCompound == null) + { + itemstack.setTagCompound(new NBTTagCompound()); + } + + if(stack == null || stack.amount == 0) + { + itemstack.setItemDamage(100); + itemstack.stackTagCompound.removeTag("stored"); + } + else { + int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); + GasStack gasStack = new GasStack(stack.getGas(), amount); + + itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)amount/getMaxGas(itemstack))*100)-100)))); + itemstack.stackTagCompound.setTag("stored", gasStack.write(new NBTTagCompound())); + } + } + + public ItemStack getEmptyItem() + { + ItemStack empty = new ItemStack(this); + setGas(empty, null); + empty.setItemDamage(100); + return empty; + } + + @Override + public void getSubItems(Item item, CreativeTabs tabs, List list) + { + ItemStack empty = new ItemStack(this); + setGas(empty, null); + empty.setItemDamage(100); + list.add(empty); + + ItemStack filled = new ItemStack(this); + setGas(filled, new GasStack(GasRegistry.getGas("hydrogen"), ((IGasItem)filled.getItem()).getMaxGas(filled))); + list.add(filled); + } +} diff --git a/src/main/resources/assets/mekanism/lang/en_US.lang b/src/main/resources/assets/mekanism/lang/en_US.lang index 8758a0994..855986a14 100644 --- a/src/main/resources/assets/mekanism/lang/en_US.lang +++ b/src/main/resources/assets/mekanism/lang/en_US.lang @@ -40,6 +40,7 @@ item.HDPERod.name=HDPE Rod item.HDPESheet.name=HDPE Sheet item.PlaStick.name=PlaStick item.Substrate.name=Substrate +item.Flamethrower.name=Flamethrower //Control Circuits item.BasicControlCircuit.name=Basic Control Circuit diff --git a/src/main/resources/assets/mekanism/render/Flamethrower.png b/src/main/resources/assets/mekanism/render/Flamethrower.png new file mode 100644 index 000000000..63b4cdbea Binary files /dev/null and b/src/main/resources/assets/mekanism/render/Flamethrower.png differ