From 94795bbbf1d9097b41a97618fe9cacf7e79d56a6 Mon Sep 17 00:00:00 2001 From: HbmMods Date: Mon, 4 Feb 2019 18:04:12 +0100 Subject: [PATCH] electric press functionality, grenade pistol, gun "fun" stats --- assets/hbm/lang/de_DE.lang | 2 + assets/hbm/lang/en_US.lang | 2 + assets/hbm/textures/blocks/machine_epress.png | Bin 0 -> 221 bytes assets/hbm/textures/gui/gui_epress.png | Bin 0 -> 1577 bytes assets/hbm/textures/items/gun_hk69.png | Bin 0 -> 196 bytes com/hbm/blocks/machine/MachineEPress.java | 117 ++++++- .../entity/logic/EntityNukeExplosionMK4.java | 6 +- .../entity/projectile/EntityBulletBase.java | 7 +- com/hbm/explosion/ExplosionNukeRay.java | 1 + com/hbm/handler/BulletConfigFactory.java | 100 ++++++ com/hbm/handler/BulletConfigSyncingUtil.java | 12 + com/hbm/handler/BulletConfiguration.java | 1 + com/hbm/handler/GUIHandler.java | 18 ++ com/hbm/handler/GunConfigFactory.java | 41 +++ com/hbm/handler/GunConfiguration.java | 3 + com/hbm/handler/nei/PressRecipeHandler.java | 2 + .../container/ContainerMachineEPress.java | 111 +++++++ com/hbm/inventory/gui/GUIMachineEPress.java | 58 ++++ com/hbm/items/ModItems.java | 3 + com/hbm/items/weapon/GunLeverAction.java | 4 +- com/hbm/lib/HbmChestContents.java | 10 +- com/hbm/packet/TEPressPacket.java | 8 + com/hbm/render/misc/RenderScreenOverlay.java | 19 +- com/hbm/render/tileentity/RenderEPress.java | 58 +++- .../machine/TileEntityMachineEPress.java | 294 +++++++++++++++++- .../machine/TileEntityMachinePress.java | 16 +- 26 files changed, 859 insertions(+), 34 deletions(-) create mode 100644 assets/hbm/textures/blocks/machine_epress.png create mode 100644 assets/hbm/textures/gui/gui_epress.png create mode 100644 assets/hbm/textures/items/gun_hk69.png create mode 100644 com/hbm/inventory/container/ContainerMachineEPress.java create mode 100644 com/hbm/inventory/gui/GUIMachineEPress.java diff --git a/assets/hbm/lang/de_DE.lang b/assets/hbm/lang/de_DE.lang index ac278810d..0b43a10e9 100644 --- a/assets/hbm/lang/de_DE.lang +++ b/assets/hbm/lang/de_DE.lang @@ -410,6 +410,8 @@ tile.safe.name=Panzerschrank container.safe=Panzerschrank tile.machine_press.name=Befeuerte Presse container.press=Befeuerte Presse +tile.machine_epress.name=Hydraulische Presse +container.epress=Hydraulische Presse tile.machine_siren.name=Sirene container.siren=Sirene tile.machine_radgen.name=Strahlenbetriebener Generator diff --git a/assets/hbm/lang/en_US.lang b/assets/hbm/lang/en_US.lang index a5ecc252d..abe0f6fa2 100644 --- a/assets/hbm/lang/en_US.lang +++ b/assets/hbm/lang/en_US.lang @@ -410,6 +410,8 @@ tile.safe.name=Safe container.safe=Safe tile.machine_press.name=Burner Press container.press=Burner Press +tile.machine_epress.name=Electric Press +container.epress=Electric Press tile.machine_siren.name=Siren container.siren=Siren tile.machine_radgen.name=Radiation-Powered Engine diff --git a/assets/hbm/textures/blocks/machine_epress.png b/assets/hbm/textures/blocks/machine_epress.png new file mode 100644 index 0000000000000000000000000000000000000000..07ef28753e23c0104c1f8810379c1160dc54cfff GIT binary patch literal 221 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#VfMLK+v8huXdh6VuSZq)w^K9 z{dF~M1uiis$`3yL`nBiezfTs-6BaOXi|PF6_eo~f`N8Ai;c-CvEK95d&w(uFBBmzB zn1>CQxpQRp6qwn#ZD80FcjI$9n_cE1wjCQ%1WXu~i+`}3y^4Y1@=cA4H@`nx40IoZ Mr>mdKI;Vst0Q^u^ zrWmZImR7E^%o1fY^)@wa;`xISRJ+s=wQwpbxG&jlwX6NN=b!g;&-1>Y=ks}~sd&{DzmLZ z=9deXM-V>@()+y`U|4F%Y}LqT(_04)pa6%041~GX2p7qwN+5`#x*d?^7jWG8#;yBN z;@w|ajYRnt@Vi=Fs*3U`I4l%W72VkK9!=%vzql!$kIwREbDK!2N8NQQEW0+k%xr?g z^~*iSO!A^TO?|KqKA!A9 z`otSLe|a*Y7+5s5uNN(W1%)pNerFagZ+V;YxCr@pj^zTa%;l1R=4M*=$DRqW66qTV zc;OQVTf%+|*}TD8VzDoT!`cW`m(OHwM z5!7qAT!(36Z_kd)%0dumO-DRH@ZjVY;*yk@yQF`D*1wMN-$alR@Jt1OY=? zCms|*ve@rduY0~;whs?N7HzWi`vGFnS66$JchtpWX9;GT;&Bv4sF(V z!aFkxv2EOinJ0zDAXpL$XU0%OuJWE+BXEvxLDy`*@gvoscr&43f4*HpSn6Y2g=lVb z805vw?>|E9UsfidyP0PC_G(U+A)HCErQWPlf)3@)g^!=@0_5wpb_y4t-1W4Gl`;Q)? z6rmyc+w?=#*H}17(o#Zk`^y8@TthORoajy@5(qdPj^Jyilp41&v?=p!g+TN(3M^R# zWL^+BW%Yg|OX-}ijgPV=7Pnm*OHEb1em(SJz0qe3@03YrraJ1CoR+YP7q?LVN%1ju z>TVo6(Mflsq)6{|>53EXCh5GOtn+b(zq1q0cO@~anqm}$qwK}>f9v@e89bBsT+BaS zF3w@}Up!7-jmQh|ch+yMcOYgp@58+v;Cq)pX8FSw^N*YP)g=7ZZ*v%p|Cs&pO0lQ{ zk#xXXKODIr-p2yp=zArOVz*C^^F!{xS6W!1u!uby5Wz0GvU-f?4!zq((d`m52`Z1DUnw%!&BFik{}V?B{m52x-zUcI*lB4H Mh&)Jj*SkH+>beOy8b!i-Eyon!ur--+XqlsdTICo;4xIr;TmW8$K_qoe#|| r3!ZW@NJ~|OYui}8lal#RzM1)vv9)JLi`6@zGZ;Kw{an^LB{Ts53baF` literal 0 HcmV?d00001 diff --git a/com/hbm/blocks/machine/MachineEPress.java b/com/hbm/blocks/machine/MachineEPress.java index 4727a1e75..b51242a5b 100644 --- a/com/hbm/blocks/machine/MachineEPress.java +++ b/com/hbm/blocks/machine/MachineEPress.java @@ -1,14 +1,31 @@ package com.hbm.blocks.machine; -import com.hbm.tileentity.machine.TileEntityMachineEPress; -import com.hbm.tileentity.machine.TileEntityMachinePress; +import java.util.Random; +import com.hbm.blocks.ModBlocks; +import com.hbm.main.MainRegistry; +import com.hbm.tileentity.machine.TileEntityMachineEPress; +import com.hbm.tileentity.machine.TileEntityRtgFurnace; + +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class MachineEPress extends BlockContainer { + + private final Random field_149933_a = new Random(); + private static boolean keepInventory; public MachineEPress(Material p_i45386_1_) { super(p_i45386_1_); @@ -33,5 +50,101 @@ public class MachineEPress extends BlockContainer { public boolean renderAsNormalBlock() { return false; } + + @Override + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + if (!keepInventory) + { + ISidedInventory tileentityfurnace = (ISidedInventory)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); + if (tileentityfurnace != null) + { + for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) + { + ItemStack itemstack = tileentityfurnace.getStackInSlot(i1); + + if (itemstack != null) + { + float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F; + float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F; + float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F; + + while (itemstack.stackSize > 0) + { + int j1 = this.field_149933_a.nextInt(21) + 10; + + if (j1 > itemstack.stackSize) + { + j1 = itemstack.stackSize; + } + + itemstack.stackSize -= j1; + EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); + + if (itemstack.hasTagCompound()) + { + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + + float f3 = 0.05F; + entityitem.motionX = (float)this.field_149933_a.nextGaussian() * f3; + entityitem.motionY = (float)this.field_149933_a.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)this.field_149933_a.nextGaussian() * f3; + p_149749_1_.spawnEntityInWorld(entityitem); + } + } + } + + p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_); + } + } + + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) { + int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + + if(i == 0) + { + world.setBlockMetadataWithNotify(x, y, z, 2, 2); + } + if(i == 1) + { + world.setBlockMetadataWithNotify(x, y, z, 5, 2); + } + if(i == 2) + { + world.setBlockMetadataWithNotify(x, y, z, 3, 2); + } + if(i == 3) + { + world.setBlockMetadataWithNotify(x, y, z, 4, 2); + } + + if(itemStack.hasDisplayName()) + { + ((TileEntityMachineEPress)world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName()); + } + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + if(world.isRemote) + { + return true; + } else if(!player.isSneaking()) + { + TileEntityMachineEPress entity = (TileEntityMachineEPress) world.getTileEntity(x, y, z); + if(entity != null) + { + FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_machine_epress, world, x, y, z); + } + return true; + } else { + return false; + } + } } diff --git a/com/hbm/entity/logic/EntityNukeExplosionMK4.java b/com/hbm/entity/logic/EntityNukeExplosionMK4.java index b14f5f47e..134cad158 100644 --- a/com/hbm/entity/logic/EntityNukeExplosionMK4.java +++ b/com/hbm/entity/logic/EntityNukeExplosionMK4.java @@ -63,7 +63,9 @@ public class EntityNukeExplosionMK4 extends Entity { if(explosion == null) { explosion = new ExplosionNukeRay(worldObj, (int)this.posX, (int)this.posY, (int)this.posZ, this.strength, this.count, this.speed, this.length); - + + MainRegistry.logger.info("START: " + System.currentTimeMillis()); + /*if(!worldObj.isRemote) for(int x = (int) (posX - 1); x <= (int) (posX + 1); x++) for(int y = (int) (posY - 1); y <= (int) (posY + 1); y++) @@ -82,6 +84,8 @@ public class EntityNukeExplosionMK4 extends Entity { //MainRegistry.logger.info(explosion.getProgress() + " / " + count / length); explosion.processTip(1024); } else if(fallout) { + + MainRegistry.logger.info("STOP: " + System.currentTimeMillis()); EntityFalloutRain fallout = new EntityFalloutRain(this.worldObj, (int)(this.length * 0.9) * 2 * MainRegistry.falloutDura / 10); fallout.posX = this.posX; diff --git a/com/hbm/entity/projectile/EntityBulletBase.java b/com/hbm/entity/projectile/EntityBulletBase.java index d2ae56262..6e446ba2d 100644 --- a/com/hbm/entity/projectile/EntityBulletBase.java +++ b/com/hbm/entity/projectile/EntityBulletBase.java @@ -235,7 +235,7 @@ public class EntityBulletBase extends Entity implements IProjectile { boolean doesRic = config.doesRicochet || hRic; if(!config.isSpectral && !doesRic) - this.setDead(); + this.onBlockImpact(movement.blockX, movement.blockY, movement.blockZ); if(doesRic) { @@ -379,6 +379,11 @@ public class EntityBulletBase extends Entity implements IProjectile { if(config.shrapnel > 0 && !worldObj.isRemote) ExplosionLarge.spawnShrapnels(worldObj, posX, posY, posZ, config.shrapnel); + if(config.chlorine > 0 && !worldObj.isRemote) { + ExplosionChaos.spawnChlorine(worldObj, posX, posY, posZ, config.chlorine, 1.5, 0); + worldObj.playSoundEffect((double)(posX + 0.5F), (double)(posY + 0.5F), (double)(posZ + 0.5F), "random.fizz", 5.0F, 2.6F + (rand.nextFloat() - rand.nextFloat()) * 0.8F); + } + if(config.rainbow > 0 && !worldObj.isRemote) { this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "random.explode", 100.0f, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); diff --git a/com/hbm/explosion/ExplosionNukeRay.java b/com/hbm/explosion/ExplosionNukeRay.java index 5c93f0a64..0501fc211 100644 --- a/com/hbm/explosion/ExplosionNukeRay.java +++ b/com/hbm/explosion/ExplosionNukeRay.java @@ -315,6 +315,7 @@ public class ExplosionNukeRay { isAusf3Complete = true; }*/ + //currently used by mk4 public void collectTipMk4_5(int count) { int amountProcessed = 0; diff --git a/com/hbm/handler/BulletConfigFactory.java b/com/hbm/handler/BulletConfigFactory.java index 4aac83091..38d86b2c9 100644 --- a/com/hbm/handler/BulletConfigFactory.java +++ b/com/hbm/handler/BulletConfigFactory.java @@ -115,6 +115,31 @@ public class BulletConfigFactory { return bullet; } + protected static BulletConfiguration standardGrenadeConfig() { + + BulletConfiguration bullet = new BulletConfiguration(); + + bullet.velocity = 2.0F; + bullet.spread = 0.005F; + bullet.wear = 10; + bullet.bulletsMin = 1; + bullet.bulletsMax = 1; + bullet.gravity = 0.05D; + bullet.maxAge = 300; + bullet.doesRicochet = false; + bullet.ricochetAngle = 0; + bullet.HBRC = 0; + bullet.LBRC = 0; + bullet.bounceMod = 1.0; + bullet.doesPenetrate = false; + bullet.doesBreakGlass = false; + bullet.explosive = 2.5F; + bullet.style = BulletConfiguration.STYLE_GRENADE; + bullet.plink = BulletConfiguration.PLINK_GRENADE; + + return bullet; + } + /// ADJUSTED CONFIGS /// /// .357 /// @@ -390,5 +415,80 @@ public class BulletConfigFactory { return bullet; } + + protected static BulletConfiguration getGrenadeConfig() { + + BulletConfiguration bullet = standardGrenadeConfig(); + + bullet.ammo = ModItems.ammo_grenade; + bullet.velocity = 2.0F; + bullet.dmgMin = 10; + bullet.dmgMax = 15; + bullet.wear = 10; + bullet.trail = 0; + + return bullet; + } + + protected static BulletConfiguration getGrenadeHEConfig() { + + BulletConfiguration bullet = standardGrenadeConfig(); + + bullet.ammo = ModItems.ammo_grenade_he; + bullet.velocity = 2.0F; + bullet.dmgMin = 20; + bullet.dmgMax = 15; + bullet.wear = 10; + bullet.explosive = 5.0F; + bullet.trail = 1; + + return bullet; + } + + protected static BulletConfiguration getGrenadeIncendirayConfig() { + + BulletConfiguration bullet = standardGrenadeConfig(); + + bullet.ammo = ModItems.ammo_grenade_incendiary; + bullet.velocity = 2.0F; + bullet.dmgMin = 15; + bullet.dmgMax = 15; + bullet.wear = 10; + bullet.trail = 0; + bullet.incendiary = 2; + + return bullet; + } + + protected static BulletConfiguration getGrenadeChlorineConfig() { + + BulletConfiguration bullet = standardGrenadeConfig(); + + bullet.ammo = ModItems.ammo_grenade_toxic; + bullet.velocity = 2.0F; + bullet.dmgMin = 10; + bullet.dmgMax = 15; + bullet.wear = 10; + bullet.trail = 3; + bullet.explosive = 0; + bullet.chlorine = 50; + + return bullet; + } + + protected static BulletConfiguration getGrenadeSleekConfig() { + + BulletConfiguration bullet = standardGrenadeConfig(); + + bullet.ammo = ModItems.ammo_grenade_sleek; + bullet.velocity = 2.0F; + bullet.dmgMin = 10; + bullet.dmgMax = 15; + bullet.wear = 10; + bullet.trail = 4; + bullet.explosive = 7.5F; + + return bullet; + } } diff --git a/com/hbm/handler/BulletConfigSyncingUtil.java b/com/hbm/handler/BulletConfigSyncingUtil.java index b5afa578b..e7c3229b6 100644 --- a/com/hbm/handler/BulletConfigSyncingUtil.java +++ b/com/hbm/handler/BulletConfigSyncingUtil.java @@ -41,6 +41,12 @@ public class BulletConfigSyncingUtil { public static final int ROCKET_EMP = 0x24; public static final int ROCKET_GLARE = 0x25; public static final int ROCKET_SLEEK = 0x26; + + public static final int GRENADE_NORMAL = 0x30; + public static final int GRENADE_HE = 0x31; + public static final int GRENADE_INCENDIARY = 0x32; + public static final int GRENADE_CHEMICAL = 0x33; + public static final int GRENADE_SLEEK = 0x34; public static void loadConfigsForSync() { @@ -61,6 +67,12 @@ public class BulletConfigSyncingUtil { configSet.add(new ConfigKeyPair(BulletConfigFactory.getRocketEMPConfig(), ROCKET_EMP)); configSet.add(new ConfigKeyPair(BulletConfigFactory.getRocketGlareConfig(), ROCKET_GLARE)); configSet.add(new ConfigKeyPair(BulletConfigFactory.getRocketSleekConfig(), ROCKET_SLEEK)); + + configSet.add(new ConfigKeyPair(BulletConfigFactory.getGrenadeConfig(), GRENADE_NORMAL)); + configSet.add(new ConfigKeyPair(BulletConfigFactory.getGrenadeHEConfig(), GRENADE_HE)); + configSet.add(new ConfigKeyPair(BulletConfigFactory.getGrenadeIncendirayConfig(), GRENADE_INCENDIARY)); + configSet.add(new ConfigKeyPair(BulletConfigFactory.getGrenadeChlorineConfig(), GRENADE_CHEMICAL)); + configSet.add(new ConfigKeyPair(BulletConfigFactory.getGrenadeSleekConfig(), GRENADE_SLEEK)); } public static BulletConfiguration pullConfig(int key) { diff --git a/com/hbm/handler/BulletConfiguration.java b/com/hbm/handler/BulletConfiguration.java index 026dc23c0..f0c7a6f22 100644 --- a/com/hbm/handler/BulletConfiguration.java +++ b/com/hbm/handler/BulletConfiguration.java @@ -55,6 +55,7 @@ public class BulletConfiguration { public int rainbow; public int nuke; public int shrapnel; + public int chlorine; public boolean boxcar; public boolean boat; public boolean destroysBlocks; diff --git a/com/hbm/handler/GUIHandler.java b/com/hbm/handler/GUIHandler.java index 96840d36e..f458fbef3 100644 --- a/com/hbm/handler/GUIHandler.java +++ b/com/hbm/handler/GUIHandler.java @@ -722,6 +722,15 @@ public class GUIHandler implements IGuiHandler { } return null; } + + case ModBlocks.guiID_machine_epress: + { + if(entity instanceof TileEntityMachineEPress) + { + return new ContainerMachineEPress(player.inventory, (TileEntityMachineEPress) entity); + } + return null; + } } } else { //CLIENTONLY CONTAINERS @@ -1444,6 +1453,15 @@ public class GUIHandler implements IGuiHandler { } return null; } + + case ModBlocks.guiID_machine_epress: + { + if(entity instanceof TileEntityMachineEPress) + { + return new GUIMachineEPress(player.inventory, (TileEntityMachineEPress) entity); + } + return null; + } } } else { //CLIENTONLY GUIS diff --git a/com/hbm/handler/GunConfigFactory.java b/com/hbm/handler/GunConfigFactory.java index 5f191389d..8110ee619 100644 --- a/com/hbm/handler/GunConfigFactory.java +++ b/com/hbm/handler/GunConfigFactory.java @@ -26,6 +26,9 @@ public class GunConfigFactory { config.crosshair = Crosshair.L_CLASSIC; config.durability = 350; + config.name = "FFI Viper"; + config.manufacturer = "FlimFlam Industries"; + config.config = new ArrayList(); config.config.add(BulletConfigSyncingUtil.STEEL_REVOLVER); config.config.add(BulletConfigSyncingUtil.IRON_REVOLVER); @@ -52,6 +55,9 @@ public class GunConfigFactory { config.crosshair = Crosshair.L_CIRCLE; config.durability = 350; + config.name = "Winchester Model 1887"; + config.manufacturer = "Winchester Repeating Arms Company"; + config.config = new ArrayList(); config.config.add(BulletConfigSyncingUtil.G20_NORMAL); config.config.add(BulletConfigSyncingUtil.G20_SLUG); @@ -80,6 +86,9 @@ public class GunConfigFactory { config.allowsInfinity = true; config.crosshair = Crosshair.L_CIRCUMFLEX; + config.name = "Carl Gustav Recoilless Rifle M1"; + config.manufacturer = "Saab Bofors Dynamics"; + config.config = new ArrayList(); config.config.add(BulletConfigSyncingUtil.ROCKET_NORMAL); config.config.add(BulletConfigSyncingUtil.ROCKET_HE); @@ -92,5 +101,37 @@ public class GunConfigFactory { return config; } + + public static GunConfiguration getGrenadeConfig() { + + GunConfiguration config = new GunConfiguration(); + + config.rateOfFire = 30; + config.gunMode = GunConfiguration.MODE_NORMAL; + config.firingMode = GunConfiguration.FIRE_MANUAL; + config.hasReloadAnim = false; + config.hasFiringAnim = false; + config.hasSpinup = false; + config.hasSpindown = false; + config.reloadDuration = 40; + config.firingDuration = 0; + config.ammoCap = 1; + config.reloadType = GunConfiguration.RELOAD_SINGLE; + config.allowsInfinity = true; + config.crosshair = Crosshair.L_CIRCUMFLEX; + + config.name = "Granatpistole HK69"; + config.manufacturer = "Heckler & Koch"; + + config.config = new ArrayList(); + config.config.add(BulletConfigSyncingUtil.GRENADE_NORMAL); + config.config.add(BulletConfigSyncingUtil.GRENADE_HE); + config.config.add(BulletConfigSyncingUtil.GRENADE_INCENDIARY); + config.config.add(BulletConfigSyncingUtil.GRENADE_CHEMICAL); + config.config.add(BulletConfigSyncingUtil.GRENADE_SLEEK); + config.durability = 140; + + return config; + } } diff --git a/com/hbm/handler/GunConfiguration.java b/com/hbm/handler/GunConfiguration.java index 8970ebde8..a06324eb1 100644 --- a/com/hbm/handler/GunConfiguration.java +++ b/com/hbm/handler/GunConfiguration.java @@ -44,6 +44,9 @@ public class GunConfiguration { public int reloadType; //whether or not the infinity enchantment should work public boolean allowsInfinity; + + public String name; + public String manufacturer; //bullet configs for main and alt fire public List config; diff --git a/com/hbm/handler/nei/PressRecipeHandler.java b/com/hbm/handler/nei/PressRecipeHandler.java index 60aa82e70..0053e426a 100644 --- a/com/hbm/handler/nei/PressRecipeHandler.java +++ b/com/hbm/handler/nei/PressRecipeHandler.java @@ -9,6 +9,7 @@ import java.util.Map; import com.hbm.handler.nei.ShredderRecipeHandler.Fuel; import com.hbm.inventory.MachineRecipes; +import com.hbm.inventory.gui.GUIMachineEPress; import com.hbm.inventory.gui.GUIMachinePress; import com.hbm.inventory.gui.GUIMachineShredder; import com.hbm.items.ModItems; @@ -149,6 +150,7 @@ public class PressRecipeHandler extends TemplateRecipeHandler { transferRectsGui.add(new RecipeTransferRect(new Rectangle(74 + 6 + 18, 23, 24, 18), "pressing")); //guiRec.add(GuiRecipe.class); guiGui.add(GUIMachinePress.class); + guiGui.add(GUIMachineEPress.class); RecipeTransferRectHandler.registerRectsToGuis(getRecipeTransferRectGuis(), transferRects); //RecipeTransferRectHandler.registerRectsToGuis(guiRec, transferRectsRec); RecipeTransferRectHandler.registerRectsToGuis(guiGui, transferRectsGui); diff --git a/com/hbm/inventory/container/ContainerMachineEPress.java b/com/hbm/inventory/container/ContainerMachineEPress.java new file mode 100644 index 000000000..3b42c05c0 --- /dev/null +++ b/com/hbm/inventory/container/ContainerMachineEPress.java @@ -0,0 +1,111 @@ +package com.hbm.inventory.container; + +import com.hbm.inventory.SlotMachineOutput; +import com.hbm.tileentity.machine.TileEntityMachineEPress; +import com.hbm.tileentity.machine.TileEntityMachinePress; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class ContainerMachineEPress extends Container { + +private TileEntityMachineEPress nukeBoy; + + private int progress; + + public ContainerMachineEPress(InventoryPlayer invPlayer, TileEntityMachineEPress tedf) { + + nukeBoy = tedf; + + //Battery + this.addSlotToContainer(new Slot(tedf, 0, 44, 53)); + //Stamp + this.addSlotToContainer(new Slot(tedf, 1, 80, 17)); + //Input + this.addSlotToContainer(new Slot(tedf, 2, 80, 53)); + //Output + this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 3, 140, 35)); + + for(int i = 0; i < 3; i++) + { + for(int j = 0; j < 9; j++) + { + this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + + for(int i = 0; i < 9; i++) + { + this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142)); + } + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) + { + ItemStack var3 = null; + Slot var4 = (Slot) this.inventorySlots.get(par2); + + if (var4 != null && var4.getHasStack()) + { + ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + if (par2 <= 3) { + if (!this.mergeItemStack(var5, 4, this.inventorySlots.size(), true)) + { + return null; + } + } + else if (!this.mergeItemStack(var5, 2, 3, false)) + if (!this.mergeItemStack(var5, 0, 1, false)) + if (!this.mergeItemStack(var5, 1, 2, false)) + return null; + + if (var5.stackSize == 0) + { + var4.putStack((ItemStack) null); + } + else + { + var4.onSlotChanged(); + } + } + + return var3; + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return nukeBoy.isUseableByPlayer(player); + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + + for(int i = 0; i < this.crafters.size(); i++) + { + ICrafting par1 = (ICrafting)this.crafters.get(i); + + if(this.progress != this.nukeBoy.progress) + { + par1.sendProgressBarUpdate(this, 0, this.nukeBoy.progress); + } + } + + this.progress = this.nukeBoy.progress; + } + + @Override + public void updateProgressBar(int i, int j) { + if(i == 0) + { + nukeBoy.progress = j; + } + } +} diff --git a/com/hbm/inventory/gui/GUIMachineEPress.java b/com/hbm/inventory/gui/GUIMachineEPress.java new file mode 100644 index 000000000..9abe4c799 --- /dev/null +++ b/com/hbm/inventory/gui/GUIMachineEPress.java @@ -0,0 +1,58 @@ +package com.hbm.inventory.gui; + +import org.lwjgl.opengl.GL11; + +import com.hbm.handler.FluidTypeHandler.FluidType; +import com.hbm.inventory.container.ContainerMachineEPress; +import com.hbm.inventory.container.ContainerMachinePress; +import com.hbm.lib.RefStrings; +import com.hbm.tileentity.machine.TileEntityMachineEPress; +import com.hbm.tileentity.machine.TileEntityMachinePress; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +public class GUIMachineEPress extends GuiInfoContainer { + + private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_epress.png"); + private TileEntityMachineEPress press; + + public GUIMachineEPress(InventoryPlayer invPlayer, TileEntityMachineEPress tedf) { + super(new ContainerMachineEPress(invPlayer, tedf)); + press = tedf; + + this.xSize = 176; + this.ySize = 166; + } + + @Override + public void drawScreen(int mouseX, int mouseY, float f) { + super.drawScreen(mouseX, mouseY, f); + + this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 26, guiTop + 69 - 52, 16, 52, press.power, press.maxPower); + } + + @Override + protected void drawGuiContainerForegroundLayer( int i, int j) { + String name = this.press.hasCustomInventoryName() ? this.press.getInventoryName() : I18n.format(this.press.getInventoryName()); + + this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + + int i = (int)press.getPowerScaled(52); + drawTexturedModalRect(guiLeft + 26, guiTop + 69 - i, 176, 52 - i, 16, i); + + int k = press.getProgressScaled(16); + this.drawTexturedModalRect(guiLeft + 79, guiTop + 35, 192, 0, 18, k); + } +} diff --git a/com/hbm/items/ModItems.java b/com/hbm/items/ModItems.java index df8f4e9ac..ee9f1581b 100644 --- a/com/hbm/items/ModItems.java +++ b/com/hbm/items/ModItems.java @@ -852,6 +852,7 @@ public class ModItems { public static Item gun_rpg; public static Item gun_rpg_ammo; + public static Item gun_hk69; public static Item gun_stinger; public static Item gun_skystinger; public static Item gun_stinger_ammo; @@ -2298,6 +2299,7 @@ public class ModItems { gun_rpg = new ItemGunBase(GunConfigFactory.getGustavConfig()).setUnlocalizedName("gun_rpg").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_rpg"); gun_rpg_ammo = new Item().setUnlocalizedName("gun_rpg_ammo").setCreativeTab(null).setTextureName(RefStrings.MODID + ":gun_rpg_ammo_alt"); + gun_hk69 = new ItemGunBase(GunConfigFactory.getGrenadeConfig()).setUnlocalizedName("gun_hk69").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_hk69"); gun_stinger = new GunStinger().setUnlocalizedName("gun_stinger").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_stinger"); gun_skystinger = new GunStinger().setUnlocalizedName("gun_skystinger").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_skystinger"); gun_stinger_ammo = new Item().setUnlocalizedName("gun_stinger_ammo").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_stinger_ammo"); @@ -3914,6 +3916,7 @@ public class ModItems { GameRegistry.registerItem(gun_b92, gun_b92.getUnlocalizedName()); GameRegistry.registerItem(gun_b93, gun_b93.getUnlocalizedName()); GameRegistry.registerItem(gun_rpg, gun_rpg.getUnlocalizedName()); + GameRegistry.registerItem(gun_hk69, gun_hk69.getUnlocalizedName()); GameRegistry.registerItem(gun_stinger, gun_stinger.getUnlocalizedName()); GameRegistry.registerItem(gun_fatman, gun_fatman.getUnlocalizedName()); GameRegistry.registerItem(gun_proto, gun_proto.getUnlocalizedName()); diff --git a/com/hbm/items/weapon/GunLeverAction.java b/com/hbm/items/weapon/GunLeverAction.java index 3e338f285..ca19b83b7 100644 --- a/com/hbm/items/weapon/GunLeverAction.java +++ b/com/hbm/items/weapon/GunLeverAction.java @@ -58,7 +58,7 @@ public class GunLeverAction extends Item { boolean flag = p_77615_3_.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0; - if (flag || p_77615_3_.inventory.hasItem(ModItems.ammo_12gauge)) { + if (flag || p_77615_3_.inventory.hasItem(ModItems.ammo_20gauge)) { float f = j / 20.0F; f = (f * f + f * 2.0F) / 3.0F; @@ -109,7 +109,7 @@ public class GunLeverAction extends Item { p_77615_2_.playSoundAtEntity(p_77615_3_, "hbm:weapon.revolverShootAlt", 5.0F, 0.75F); if (flag) { } else { - p_77615_3_.inventory.consumeInventoryItem(ModItems.ammo_12gauge); + p_77615_3_.inventory.consumeInventoryItem(ModItems.ammo_20gauge); } if (!p_77615_2_.isRemote) { diff --git a/com/hbm/lib/HbmChestContents.java b/com/hbm/lib/HbmChestContents.java index 53517c0c9..1c04a510b 100644 --- a/com/hbm/lib/HbmChestContents.java +++ b/com/hbm/lib/HbmChestContents.java @@ -25,7 +25,7 @@ public class HbmChestContents { new WeightedRandomChestContent(ModItems.gun_revolver, 0, 1, 1, 3), new WeightedRandomChestContent(ModItems.gun_revolver_ammo, 0, 2, 6, 4), new WeightedRandomChestContent(ModItems.gun_lever_action, 0, 1, 1, 1), - new WeightedRandomChestContent(ModItems.gun_lever_action_ammo, 0, 2, 6, 3), + new WeightedRandomChestContent(ModItems.ammo_20gauge, 0, 2, 6, 3), new WeightedRandomChestContent(ModItems.battery_generic, 0, 1, 1, 4), new WeightedRandomChestContent(ModItems.battery_advanced, 0, 1, 1, 2), new WeightedRandomChestContent(ModItems.scrap, 0, 1, 3, 10), @@ -72,13 +72,13 @@ public class HbmChestContents { new WeightedRandomChestContent(ModItems.circuit_gold, 0, 1, 2, 3), new WeightedRandomChestContent(ModItems.circuit_targeting_tier4, 0, 1, 1, 2), new WeightedRandomChestContent(ModItems.gun_lever_action, 0, 1, 1, 5), - new WeightedRandomChestContent(ModItems.gun_lever_action_ammo, 0, 2, 6, 6), + new WeightedRandomChestContent(ModItems.ammo_20gauge, 0, 2, 6, 6), new WeightedRandomChestContent(ModItems.gun_revolver_gold, 0, 1, 1, 4), new WeightedRandomChestContent(ModItems.gun_revolver_gold_ammo, 0, 1, 6, 5), new WeightedRandomChestContent(ModItems.gun_revolver_lead, 0, 1, 1, 4), new WeightedRandomChestContent(ModItems.gun_revolver_lead_ammo, 0, 1, 6, 5), new WeightedRandomChestContent(ModItems.gun_rpg, 0, 1, 1, 4), - new WeightedRandomChestContent(ModItems.gun_rpg_ammo, 0, 1, 4, 5), + new WeightedRandomChestContent(ModItems.ammo_rocket, 0, 1, 4, 5), new WeightedRandomChestContent(ModItems.gun_fatman, 0, 1, 1, 1), new WeightedRandomChestContent(ModItems.gun_fatman_ammo, 0, 1, 2, 2), new WeightedRandomChestContent(ModItems.grenade_nuclear, 0, 1, 1, 2), @@ -159,7 +159,7 @@ public class HbmChestContents { new WeightedRandomChestContent(ModItems.gun_revolver, 0, 1, 1, 4), new WeightedRandomChestContent(ModItems.gun_revolver_ammo, 0, 1, 24, 4), new WeightedRandomChestContent(ModItems.gun_rpg, 0, 1, 1, 3), - new WeightedRandomChestContent(ModItems.gun_rpg_ammo, 0, 1, 6, 3), + new WeightedRandomChestContent(ModItems.ammo_rocket, 0, 1, 6, 3), new WeightedRandomChestContent(ModItems.rod_uranium_fuel, 0, 1, 1, 2), new WeightedRandomChestContent(ModItems.rod_dual_uranium_fuel, 0, 1, 1, 2), new WeightedRandomChestContent(ModItems.rod_quad_uranium_fuel, 0, 1, 1, 2), @@ -235,7 +235,7 @@ public class HbmChestContents { new WeightedRandomChestContent(ModItems.gun_calamity, 0, 1, 1, 1), new WeightedRandomChestContent(ModItems.bottle_quantum, 0, 1, 3, 1), new WeightedRandomChestContent(ModItems.ingot_advanced_alloy, 0, 4, 12, 1), - new WeightedRandomChestContent(ModItems.gun_calamity_ammo, 0, 24, 48, 1), + new WeightedRandomChestContent(ModItems.ammo_50bmg, 0, 24, 48, 1), new WeightedRandomChestContent(ModItems.circuit_red_copper, 0, 6, 12, 1), new WeightedRandomChestContent(ModItems.gas_mask_m65, 0, 1, 1, 1), new WeightedRandomChestContent(ModItems.grenade_if_he, 0, 1, 1, 1), diff --git a/com/hbm/packet/TEPressPacket.java b/com/hbm/packet/TEPressPacket.java index 08f4038f5..b8912f99d 100644 --- a/com/hbm/packet/TEPressPacket.java +++ b/com/hbm/packet/TEPressPacket.java @@ -1,6 +1,7 @@ package com.hbm.packet; import com.hbm.main.MainRegistry; +import com.hbm.tileentity.machine.TileEntityMachineEPress; import com.hbm.tileentity.machine.TileEntityMachinePress; import com.hbm.tileentity.machine.TileEntityMachineTurbofan; @@ -74,6 +75,13 @@ public class TEPressPacket implements IMessage { gen.meta = m.meta; gen.progress = m.progress; } + if (te != null && te instanceof TileEntityMachineEPress) { + + TileEntityMachineEPress gen = (TileEntityMachineEPress) te; + gen.item = m.item; + gen.meta = m.meta; + gen.progress = m.progress; + } return null; } } diff --git a/com/hbm/render/misc/RenderScreenOverlay.java b/com/hbm/render/misc/RenderScreenOverlay.java index 5d524d45f..45861e8cb 100644 --- a/com/hbm/render/misc/RenderScreenOverlay.java +++ b/com/hbm/render/misc/RenderScreenOverlay.java @@ -15,6 +15,7 @@ import net.minecraft.util.ResourceLocation; public class RenderScreenOverlay { private static final ResourceLocation misc = new ResourceLocation(RefStrings.MODID + ":textures/misc/overlay_misc.png"); + private static final ResourceLocation hud = new ResourceLocation("textures/gui/widgets.png"); private static long lastSurvey; private static float prevResult; @@ -77,6 +78,7 @@ public class RenderScreenOverlay { GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); GL11.glPopMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(hud); } private static int getScaled(double cur, double max, double scale) { @@ -88,13 +90,16 @@ public class RenderScreenOverlay { public static void renderCustomCrosshairs(ScaledResolution resolution, Gui gui, Crosshair cross) { int size = cross.size; - - Minecraft.getMinecraft().renderEngine.bindTexture(misc); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR, 1, 0); - gui.drawTexturedModalRect(resolution.getScaledWidth() / 2 - (size / 2), resolution.getScaledHeight() / 2 - (size / 2), cross.x, cross.y, size, size); - OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); - GL11.glDisable(GL11.GL_BLEND); + + GL11.glPushMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(misc); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR, 1, 0); + gui.drawTexturedModalRect(resolution.getScaledWidth() / 2 - (size / 2), resolution.getScaledHeight() / 2 - (size / 2), cross.x, cross.y, size, size); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(hud); } public enum Crosshair { diff --git a/com/hbm/render/tileentity/RenderEPress.java b/com/hbm/render/tileentity/RenderEPress.java index 7639d1173..1ccc7deab 100644 --- a/com/hbm/render/tileentity/RenderEPress.java +++ b/com/hbm/render/tileentity/RenderEPress.java @@ -3,7 +3,7 @@ package com.hbm.render.tileentity; import org.lwjgl.opengl.GL11; import com.hbm.main.ResourceManager; -import com.hbm.tileentity.machine.TileEntityMachinePress; +import com.hbm.tileentity.machine.TileEntityMachineEPress; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; @@ -28,6 +28,17 @@ public class RenderEPress extends TileEntitySpecialRenderer { GL11.glEnable(GL11.GL_LIGHTING); GL11.glRotatef(180, 0F, 1F, 0F); + switch(tileentity.getBlockMetadata()) { + case 2: + GL11.glRotatef(270, 0F, 1F, 0F); break; + case 4: + GL11.glRotatef(0, 0F, 1F, 0F); break; + case 3: + GL11.glRotatef(90, 0F, 1F, 0F); break; + case 5: + GL11.glRotatef(180, 0F, 1F, 0F); break; + } + this.bindTexture(ResourceManager.epress_body_tex); ResourceManager.epress_body.renderAll(); @@ -37,15 +48,26 @@ public class RenderEPress extends TileEntitySpecialRenderer { renderTileEntityAt2(tileentity, x, y, z, f); } - public void renderTileEntityAt2(TileEntity tileEntity, double x, double y, double z, float f) { + public void renderTileEntityAt2(TileEntity tileentity, double x, double y, double z, float f) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1 + 1 - 0.125, z + 0.5D); GL11.glEnable(GL11.GL_LIGHTING); GL11.glRotatef(180, 0F, 1F, 0F); + + switch(tileentity.getBlockMetadata()) { + case 2: + GL11.glRotatef(270, 0F, 1F, 0F); break; + case 4: + GL11.glRotatef(0, 0F, 1F, 0F); break; + case 3: + GL11.glRotatef(90, 0F, 1F, 0F); break; + case 5: + GL11.glRotatef(180, 0F, 1F, 0F); break; + } - //TileEntityMachinePress press = (TileEntityMachinePress)tileEntity; - //float f1 = press.progress * (1 - 0.125F) / press.maxProgress; - //GL11.glTranslated(0, -f1, 0); + TileEntityMachineEPress press = (TileEntityMachineEPress)tileentity; + float f1 = press.progress * (1 - 0.125F) / press.maxProgress; + GL11.glTranslated(0, -f1, 0); this.bindTexture(ResourceManager.epress_head_tex); @@ -53,26 +75,40 @@ public class RenderEPress extends TileEntitySpecialRenderer { GL11.glPopMatrix(); - //renderTileEntityAt3(tileEntity, x, y, z, f); + renderTileEntityAt3(tileentity, x, y, z, f); } - public void renderTileEntityAt3(TileEntity tileEntity, double x, double y, double z, float f) { + public void renderTileEntityAt3(TileEntity tileentity, double x, double y, double z, float f) { itemRenderer = new RenderDecoItem(this); itemRenderer.setRenderManager(renderManager); GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5D, y + 1, z - 0.5); + GL11.glTranslated(x + 0.5D, y + 1, z + 0.5); GL11.glEnable(GL11.GL_LIGHTING); GL11.glRotatef(180, 0F, 1F, 0F); - GL11.glRotatef(-90, 1F, 0F, 0F); - TileEntityMachinePress press = (TileEntityMachinePress)tileEntity; + switch(tileentity.getBlockMetadata()) { + case 2: + GL11.glRotatef(270, 0F, 1F, 0F); break; + case 4: + GL11.glRotatef(0, 0F, 1F, 0F); break; + case 3: + GL11.glRotatef(90, 0F, 1F, 0F); break; + case 5: + GL11.glRotatef(180, 0F, 1F, 0F); break; + } + + GL11.glRotatef(90, 0F, 1F, 0F); + GL11.glRotatef(-90, 1F, 0F, 0F); + GL11.glTranslatef(1.0F, 1.0F - 0.0625F * 165/100, 0.0F); + GL11.glTranslatef(-1, -1.15F, 0); + + TileEntityMachineEPress press = (TileEntityMachineEPress)tileentity; ItemStack stack = new ItemStack(Item.getItemById(press.item), 1, press.meta); if(!(stack.getItem() instanceof ItemBlock)) { EntityItem item = new EntityItem(null, 0.0D, 0.0D, 0.0D, stack); RenderItem.renderInFrame = true; - GL11.glTranslatef(0.0F, 1.0F - 0.0625F * 165/100, 0.0F); this.itemRenderer.doRender(item, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); RenderItem.renderInFrame = false; } diff --git a/com/hbm/tileentity/machine/TileEntityMachineEPress.java b/com/hbm/tileentity/machine/TileEntityMachineEPress.java index 491283acd..d8065e7ac 100644 --- a/com/hbm/tileentity/machine/TileEntityMachineEPress.java +++ b/com/hbm/tileentity/machine/TileEntityMachineEPress.java @@ -1,7 +1,299 @@ package com.hbm.tileentity.machine; +import com.hbm.interfaces.IConsumer; +import com.hbm.inventory.MachineRecipes; +import com.hbm.items.special.ItemBlades; +import com.hbm.lib.Library; +import com.hbm.packet.AuxElectricityPacket; +import com.hbm.packet.PacketDispatcher; +import com.hbm.packet.TEPressPacket; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.util.AxisAlignedBB; -public class TileEntityMachineEPress extends TileEntity { +public class TileEntityMachineEPress extends TileEntity implements ISidedInventory, IConsumer { + private ItemStack slots[]; + + public int progress = 0; + public long power = 0; + public final static int maxProgress = 200; + public final static long maxPower = 50000; + public int item; + public int meta; + boolean isRetracting = false; + + private String customName; + + public TileEntityMachineEPress() { + slots = new ItemStack[4]; + } + + @Override + public int getSizeInventory() { + return slots.length; + } + + @Override + public ItemStack getStackInSlot(int i) { + return slots[i]; + } + + @Override + public ItemStack getStackInSlotOnClosing(int i) { + if(slots[i] != null) + { + ItemStack itemStack = slots[i]; + slots[i] = null; + return itemStack; + } else { + return null; + } + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemStack) { + slots[i] = itemStack; + if(itemStack != null && itemStack.stackSize > getInventoryStackLimit()) + { + itemStack.stackSize = getInventoryStackLimit(); + } + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.epress"; + } + + @Override + public boolean hasCustomInventoryName() { + return this.customName != null && this.customName.length() > 0; + } + + public void setCustomName(String name) { + this.customName = name; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + if(worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) + { + return false; + }else{ + return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <=64; + } + } + + @Override + public void openInventory() {} + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(int i, ItemStack stack) { + + if(stack.getItem() instanceof ItemBlades && i == 1) + return true; + + if(TileEntityFurnace.getItemBurnTime(stack) > 0 && i == 0) + return true; + + return i == 2; + } + + @Override + public ItemStack decrStackSize(int i, int j) { + if(slots[i] != null) + { + if(slots[i].stackSize <= j) + { + ItemStack itemStack = slots[i]; + slots[i] = null; + return itemStack; + } + ItemStack itemStack1 = slots[i].splitStack(j); + if (slots[i].stackSize == 0) + { + slots[i] = null; + } + + return itemStack1; + } else { + return null; + } + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + NBTTagList list = nbt.getTagList("items", 10); + + progress = nbt.getInteger("progress"); + power = nbt.getInteger("power"); + isRetracting = nbt.getBoolean("ret"); + + slots = new ItemStack[getSizeInventory()]; + + for(int i = 0; i < list.tagCount(); i++) + { + NBTTagCompound nbt1 = list.getCompoundTagAt(i); + byte b0 = nbt1.getByte("slot"); + if(b0 >= 0 && b0 < slots.length) + { + slots[b0] = ItemStack.loadItemStackFromNBT(nbt1); + } + } + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + NBTTagList list = new NBTTagList(); + + nbt.setInteger("progress", progress); + nbt.setLong("power", power); + nbt.setBoolean("ret", isRetracting); + + for(int i = 0; i < slots.length; i++) + { + if(slots[i] != null) + { + NBTTagCompound nbt1 = new NBTTagCompound(); + nbt1.setByte("slot", (byte)i); + slots[i].writeToNBT(nbt1); + list.appendTag(nbt1); + } + } + nbt.setTag("items", list); + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) + { + return side == 0 ? new int[] { 3 } : new int[]{ 0, 1, 2 }; + } + + @Override + public boolean canInsertItem(int i, ItemStack itemStack, int j) { + return this.isItemValidForSlot(i, itemStack); + } + + @Override + public boolean canExtractItem(int i, ItemStack itemStack, int j) { + return i == 3; + } + + @Override + public void updateEntity() { + if(!worldObj.isRemote) + { + power = Library.chargeTEFromItems(slots, 0, power, maxPower); + + if(power >= 100) { + + int speed = 25; + + if(slots[1] != null && slots[2] != null) { + ItemStack stack = MachineRecipes.getPressResult(slots[2].copy(), slots[1].copy()); + if(stack != null && + (slots[3] == null || + (slots[3].getItem() == stack.getItem() && + slots[3].stackSize + stack.stackSize <= slots[3].getMaxStackSize()))) { + + power -= 100; + + if(progress >= maxProgress) { + + isRetracting = true; + + if(slots[3] == null) + slots[3] = stack.copy(); + else + slots[3].stackSize += stack.stackSize; + + slots[2].stackSize--; + if(slots[2].stackSize <= 0) + slots[2] = null; + + slots[1].setItemDamage(slots[1].getItemDamage() + 1); + if(slots[1].getItemDamage() >= slots[1].getMaxDamage()) + slots[1] = null; + + this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "hbm:block.pressOperate", 1.5F, 1.0F); + } + + if(!isRetracting) + progress += speed; + + } else { + isRetracting = true; + } + } else { + isRetracting = true; + } + + if(isRetracting) + progress -= speed; + } else { + isRetracting = true; + } + + if(progress <= 0) { + isRetracting = false; + progress = 0; + } + + PacketDispatcher.wrapper.sendToAll(new TEPressPacket(xCoord, yCoord, zCoord, slots[2], progress)); + PacketDispatcher.wrapper.sendToAll(new AuxElectricityPacket(xCoord, yCoord, zCoord, power)); + } + } + + public long getPowerScaled(int i) { + return (power * i) / maxPower; + } + + public int getProgressScaled(int i) { + return (progress * i) / maxProgress; + } + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return TileEntity.INFINITE_EXTENT_AABB; + } + + @Override + @SideOnly(Side.CLIENT) + public double getMaxRenderDistanceSquared() + { + return 65536.0D; + } + + @Override + public void setPower(long i) { + power = i; + + } + + @Override + public long getPower() { + return power; + } + + @Override + public long getMaxPower() { + return maxPower; + } } diff --git a/com/hbm/tileentity/machine/TileEntityMachinePress.java b/com/hbm/tileentity/machine/TileEntityMachinePress.java index 51752759c..89078c00b 100644 --- a/com/hbm/tileentity/machine/TileEntityMachinePress.java +++ b/com/hbm/tileentity/machine/TileEntityMachinePress.java @@ -6,6 +6,7 @@ import com.hbm.inventory.FluidTank; import com.hbm.inventory.MachineRecipes; import com.hbm.items.ModItems; import com.hbm.items.special.ItemBattery; +import com.hbm.items.special.ItemBlades; import com.hbm.main.MainRegistry; import com.hbm.packet.PacketDispatcher; import com.hbm.packet.TEPressPacket; @@ -118,7 +119,14 @@ public class TileEntityMachinePress extends TileEntity implements ISidedInventor @Override public boolean isItemValidForSlot(int i, ItemStack stack) { - return false; + + if(stack.getItem() instanceof ItemBlades && i == 1) + return true; + + if(TileEntityFurnace.getItemBurnTime(stack) > 0 && i == 0) + return true; + + return i == 2; } @Override @@ -192,9 +200,9 @@ public class TileEntityMachinePress extends TileEntity implements ISidedInventor } @Override - public int[] getAccessibleSlotsFromSide(int p_94128_1_) + public int[] getAccessibleSlotsFromSide(int side) { - return new int[] {0, 1, 2, 3}; + return side == 0 ? new int[] { 3 } : new int[]{ 0, 1, 2 }; } @Override @@ -204,7 +212,7 @@ public class TileEntityMachinePress extends TileEntity implements ISidedInventor @Override public boolean canExtractItem(int i, ItemStack itemStack, int j) { - return false; + return i == 3; } @Override