From 6e6685fa9870e844825e5369780646e2e1f2d039 Mon Sep 17 00:00:00 2001 From: HbmMods Date: Sat, 17 Nov 2018 18:13:08 +0100 Subject: [PATCH] falling custom nuke, new rad system, fixed analzyer --- assets/hbm/lang/de_DE.lang | 1 + assets/hbm/lang/en_US.lang | 1 + .../blocks/machine_boiler_nuclear.png | Bin 0 -> 345 bytes .../blocks/machine_boiler_nuclear_front.png | Bin 0 -> 369 bytes .../machine_boiler_nuclear_front_lit.png | Bin 0 -> 419 bytes assets/hbm/textures/items/custom_fall.png | Bin 0 -> 403 bytes assets/hbm/textures/misc/overlay_misc.png | Bin 0 -> 2628 bytes com/hbm/blocks/bomb/NukeCustom.java | 402 +++++++++--------- com/hbm/blocks/test/TestEventTester.java | 52 +++ .../entity/missile/EntityMissileNuclear.java | 1 - .../entity/projectile/EntityFallingNuke.java | 103 +++++ com/hbm/items/ModItems.java | 4 +- com/hbm/items/special/ItemCustomLore.java | 6 + com/hbm/items/tool/ItemAnalyzer.java | 5 +- com/hbm/items/tool/ItemGeigerCounter.java | 2 +- com/hbm/main/ClientProxy.java | 1 + com/hbm/main/MainRegistry.java | 2 + com/hbm/main/ModEventHandler.java | 30 ++ com/hbm/main/ModEventHandlerClient.java | 43 ++ com/hbm/packet/AuxGaugePacket.java | 6 + com/hbm/packet/PacketDispatcher.java | 2 + com/hbm/packet/RadSurveyPacket.java | 81 ++++ com/hbm/render/entity/RenderFallingNuke.java | 64 +++ com/hbm/render/misc/RenderScreenOverlay.java | 71 ++++ com/hbm/saveddata/RadiationSaveStructure.java | 35 ++ com/hbm/saveddata/RadiationSavedData.java | 173 ++++++++ .../tileentity/bomb/TileEntityNukeCustom.java | 10 +- 27 files changed, 900 insertions(+), 195 deletions(-) create mode 100644 assets/hbm/textures/blocks/machine_boiler_nuclear.png create mode 100644 assets/hbm/textures/blocks/machine_boiler_nuclear_front.png create mode 100644 assets/hbm/textures/blocks/machine_boiler_nuclear_front_lit.png create mode 100644 assets/hbm/textures/items/custom_fall.png create mode 100644 assets/hbm/textures/misc/overlay_misc.png create mode 100644 com/hbm/entity/projectile/EntityFallingNuke.java create mode 100644 com/hbm/packet/RadSurveyPacket.java create mode 100644 com/hbm/render/entity/RenderFallingNuke.java create mode 100644 com/hbm/render/misc/RenderScreenOverlay.java create mode 100644 com/hbm/saveddata/RadiationSaveStructure.java create mode 100644 com/hbm/saveddata/RadiationSavedData.java diff --git a/assets/hbm/lang/de_DE.lang b/assets/hbm/lang/de_DE.lang index 3f5c58202..4349c72d6 100644 --- a/assets/hbm/lang/de_DE.lang +++ b/assets/hbm/lang/de_DE.lang @@ -220,6 +220,7 @@ item.custom_hydro.name=AB - Wasserstoffelement item.custom_amat.name=AB - Antimaterie-Element item.custom_dirty.name=AB - Schmutziges Element item.custom_schrab.name=AB - Schrabidiumelement +item.custom_fall.name=AB - Abwurf-Upgrade container.nukeGadget=The Gadget container.nukeBoy=Little Boy diff --git a/assets/hbm/lang/en_US.lang b/assets/hbm/lang/en_US.lang index 5a2a3f7c6..2d2c20735 100644 --- a/assets/hbm/lang/en_US.lang +++ b/assets/hbm/lang/en_US.lang @@ -220,6 +220,7 @@ item.custom_hydro.name=Custom Nuke Hydrogen Rod item.custom_amat.name=Custom Nuke Antimatter Rod item.custom_dirty.name=Custom Nuke Dirty Rod item.custom_schrab.name=Custom Nuke Schrabidium Rod +item.custom_fall.name=Custom Nuke Drop Upgrade container.nukeGadget=The Gadget container.nukeBoy=Little Boy diff --git a/assets/hbm/textures/blocks/machine_boiler_nuclear.png b/assets/hbm/textures/blocks/machine_boiler_nuclear.png new file mode 100644 index 0000000000000000000000000000000000000000..6acf56292ef772cc6532415e09eb88c1e1410dde GIT binary patch literal 345 zcmV-f0jB@1umnxA?E2Y~n?c4dqN(o&=5%3i!bB0ZBq$mc= zco+k{UN0pg)LNmcFc1;$V7WwuV1bB$nOl<0+u!3nPn1&r2vimGJl|F&qPA9R1rcH2 zcc>~D0GPQ;GE%R`KFbl2Uj;H=Slu}3HQELTz<3_o*Ii=L*bIzTqY;ug~io}n7X8?f5mi=d- zdBDu=*rAlt+6VwK#zvNNzHFl}7%UJGJfGjq%<)!Q5&ve02*KodcwcPIh{wEOlD2K@ rs(NEB$F8z}WMO3YcS1xu!mIcP``YbL@FP9!00000NkvXXu0mjfVS1M^ literal 0 HcmV?d00001 diff --git a/assets/hbm/textures/blocks/machine_boiler_nuclear_front.png b/assets/hbm/textures/blocks/machine_boiler_nuclear_front.png new file mode 100644 index 0000000000000000000000000000000000000000..ca198b3a0ceb2a9001ee7d20c4eae6af915202e5 GIT binary patch literal 369 zcmV-%0gnEOP)%-ZI8#C literal 0 HcmV?d00001 diff --git a/assets/hbm/textures/blocks/machine_boiler_nuclear_front_lit.png b/assets/hbm/textures/blocks/machine_boiler_nuclear_front_lit.png new file mode 100644 index 0000000000000000000000000000000000000000..751b376dafdf890159fba590ad64b5415099041a GIT binary patch literal 419 zcmV;U0bKrxP)bVc& zt%`aml{M&Y4?626=s?(?%*;Rk%+AVUu?Ql9_nr^}Y9hit(^wH9Q(&#d7!!l^zn-Zb zk4H|Y)0H5EK)>I=TUA7&&wG!Eu-$G6Az%QEF|8maP1We9G1l6%0uhM>tJVH)->D4- zMZ}p()QUfEUjRIRzC`@^KI8Y}o5>K?uQNh;XcMGz0VYHEyPN>)3$BWWb!R3<3B30) zxhfj=`#n|BP!$b8JX7=DW75HCQk`EFDX#NCod=wAt)Uu~bL$E<**OQms60fUww-ma ztj+_Y@_=)$m5^d%Ol(``^Lgm?dX#0!a=C3O(8^t#PDku^JDR3B-vXQ$V?2I}!|b-C zyOO>c5g}7KsikvKpAvWD;vQ@^n^x8CVAEAjA6eFAPj|vv+akP${{e;4(3F@R6HWjC N002ovPDHLkV1io?wP)NklSejHE{g~en(=h+!O8hfV7XkD-1e{IXA$A<=JH^o6R9%G xi5%zg^u2h6DwlncsvO)u=)6|u4;Zgtq002ovPDHLkV1fwztG@sM literal 0 HcmV?d00001 diff --git a/assets/hbm/textures/misc/overlay_misc.png b/assets/hbm/textures/misc/overlay_misc.png new file mode 100644 index 0000000000000000000000000000000000000000..63a6ccfe9eee7488178f334d22ea8160d09b060a GIT binary patch literal 2628 zcma)8X*kqtAO6pR#u7u;A(Ab!78;7-)j6n0vPPUk$<{Ck%`hXUlW?q&og`DXQH{ev zW_lCJHr6q+haqERU&oy3{cx`LKXumcoYO2;pY_(%*)%n0u8gYxqgHP+!5ad0D$e=SXo?;Dp($Wmn6@W1-|>unZg(& zQbvzYrcEbX$n=lM1SKbVz{O5Ipq?5y=N%t9?e3uTFexM}3G%|A6(4uP&RPk!I4BQm zRE}#E6B~(x8cV~9m9fvSgw_)o?{XQ8Tt*>jQuMd%T*fy4ViA**vmN8Nk*Vle2z`j# z?{{47UOA}6AhB3%C}(feL8Km<6=WsP`StBcC#glM_@e{h61u;&?9LXbFd5ho0lFD? z_W1XFBO|wG*QckaJD7p=8pBZ2+BE3Z%)-LLE>y3nz?BR@b8i(vPvxd0G!%t)_x)wg zQJvW?J`D1#=NGa83>z9a)s}S5UK_<3r(P=$D|s+JKK^y|!p!qjvqXgP-PWN>m#_UV zF2Uie^ZDqXT3Jy5`7setU1qa;pj%m5E;E_-W{-Q#x#x?p?7tc?bGGuwkGGkwG)ti0 zZ92zC3Npxm<~g|$({I~e%~ATwDFOSUW;;`}d8U!<*72su{Dupz*5H>5z4&hQ41Q<& zQD8H|H3fS0n!y5hC&^S~0`^25bbX_Vg01>F(gu)ZvDt0dm3Pu`#uZM7uQ-~**)l;3 z31$MejrW$_Su9p-Pmi6I)%m@J=OUBv)Arz(O2~JSc}GevsSxsVmh7d2{}=UICCM;G zvG8?$z260MVB9z{AqQt3B;-t8aQOwHd;g<5AfpEZ_%DMApiID#zB z5T2cyQqu8gNW*qZAVg<+cEaONMmJj{NkKSS?ALZos-nDn>)~|uBXx5H?Yi{#+3`n+ zvgFvi5@LISCucOgD@GZ`>hyY_2qQEv*WyFljmv&-XC7~vT6+?^cG(_4oO620p*|~ zsfB2!ohMd)%0I3sl08`04vJmc)wSb`S{oZ2ozeT>&R^#xecLCx3pvBX4nv;qnNz4q>Kmp zfJRN7Cm~_uE`Td}*xH%et6D8Vs z4KJkIluYsO13owMzjiHtK>f)R4sZ7&M04!;%r*<3wBXlVF?-(!n2N|;!R9(-(W}0J zy~6>Yddftt6kz+Q+JLSPNpHe>6vbcn6EUY@<@A7; zb80I;Y1iG->Wn-7R!fifvHpYbi`rTfI`*Hdn^sWBtWJW|TRAcQpzHqYNme4rUG@jk z)+>1|xZe+P#*}$lR{e~{Fdbv&`K^+sAN(bb7(9ncm4*Cc#v_E9J712T57r`LWNE)T zL;g!(!0%Wf??J);FZ$P<;FNnd215RjTaG3;s+~Z&Nx({Cerm@@8p6UiTLk={FCvtN zaN;tzJdZft0g=Cy4xu~ng!1B{KM^AyCyo(ls>x{ocC-(?kg}_TN?-b%hla@{vrh3&%;$4Dd@5&bS^;Zd zT;F!LAR7wRd}zZncN!p>(3pX-9Q++rAE?PhVDa-&uq~kQoR1dc?-~DQUhzyhN8V!M zq&Uia5MJO9`J-|NNlt*$L@z4Bb@pP@rG8TZ0<-I-l&VQBm)#&y0Ed`ruSSvoK--ieOb$q{ihfau z2-03tpxoUAn5!x&>@@;XH zakl`@of>YK(|C_k>)hEw_35*H-{_^&-x~Rg*k_&1!pZUa6iiaKqi?;ku2pb?1@%y? zQMs0FETY=klb?UHw%1Y2$xp|HQRTX)2p4CkydT-?g!H`h4nsp))nl8u;LRwxp7!R^~SOt2i}8QX!5ssv>=$ ztp*bQa&VqQens`CgB0Gfl*SBJPI{E%N97E-kqjT@GaYjn{Dt5!EkI<#xPulX~)WOFzjfQGcoKv}x)KUs>SB2PD! z*1#?rYd%wD3D6We{8pUk#@q$0ahP!_UKL;l00!l-&6<8y`4f?lCaz||MO_cWEKY>OUa*jR(_q)DObonRwp zJ3!4&!ooV(6v<4WF;Fr;qRK#w&t$Nyi#qxSyG3X4X@n&k(!dKv&GXSi+XCh9l&jcN zgW?473Rbn(9Fkk12)QqRMCb`DV>a?zl$6)4;}#Q 0) { - EntityGrenadeZOMG zomg = new EntityGrenadeZOMG(world); - zomg.posX = x + 0.5; - zomg.posY = y + 0.5; - zomg.posZ = z + 0.5; - ExplosionChaos.zomgMeSinPi(world, x, y, z, 1000, null, zomg); - } else if(schrab > 0) { - nuke += (tnt/2); - hydro += (nuke/2); - amat += (hydro/2); - schrab += (amat/2); + if(!fall) { - if(schrab > 300) - schrab = 300; + explodeCustom(world, x + 0.5, y + 0.5, z + 0.5, tnt, nuke, hydro, amat, dirty, schrab, euph); + world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F); - EntityNukeExplosionPlus entity = new EntityNukeExplosionPlus(world); - entity.posX = x + 0.5; - entity.posY = y + 0.5; - entity.posZ = z + 0.5; - entity.destructionRange = (int)schrab; - entity.speed = MainRegistry.blastSpeed; - entity.coefficient = 1.0F; - entity.waste = false; - - world.spawnEntityInWorld(entity); - - EntityCloudFleija cloud = new EntityCloudFleija(world, (int)schrab); - cloud.posX = x + 0.5; - cloud.posY = y + 0.5; - cloud.posZ = z + 0.5; - world.spawnEntityInWorld(cloud); + } else { + EntityFallingNuke bomb = new EntityFallingNuke(world, tnt, nuke, hydro, amat, dirty, schrab, euph); + bomb.getDataWatcher().updateObject(20, (byte)meta); + bomb.setPositionAndRotation(x + 0.5, y, z + 0.5, 0, 0); - } else if (amat > 0) { - nuke += (tnt/2); - hydro += (nuke/2); - amat += (hydro/2); - - if(amat > 350) - amat = 350; - - EntityNukeExplosionPlus entity = new EntityNukeExplosionPlus(world); - entity.posX = x + 0.5; - entity.posY = y + 0.5; - entity.posZ = z + 0.5; - entity.destructionRange = (int)amat; - entity.speed = 25; - entity.coefficient = 10.0F; - entity.wasteRange = (int) (amat * 1.4) + (int) dirty; - - world.spawnEntityInWorld(entity); - - if(amat < 75) { - ExplosionParticleB.spawnMush(world, x, y - ((int)amat / 10), z); - } else if(amat < 200) { - if(MainRegistry.enableNukeClouds) { - EntityNukeCloudSmall entity2 = new EntityNukeCloudSmall(world, 1000, amat * 0.005F); - entity2.posX = x; - entity2.posY = y - (amat/10); - entity2.posZ = z; - world.spawnEntityInWorld(entity2); - } else { - EntityNukeCloudSmall entity2 = new EntityNukeCloudNoShroom(world, 1000); - entity2.posX = x; - entity2.posY = y - (amat/10); - entity2.posZ = z; - world.spawnEntityInWorld(entity2); - } - } else { - if(MainRegistry.enableNukeClouds) { - EntityNukeCloudBig entity2 = new EntityNukeCloudBig(world, 1000); - entity2.posX = x; - entity2.posY = y - (amat/10); - entity2.posZ = z; - world.spawnEntityInWorld(entity2); - } else { - EntityNukeCloudSmall entity2 = new EntityNukeCloudNoShroom(world, 1000); - entity2.posX = x; - entity2.posY = y - (amat/10); - entity2.posZ = z; - world.spawnEntityInWorld(entity2); - } - } - - } else if(hydro > 0) { - nuke += (tnt/2); - hydro += (nuke/2); - - if(hydro > 350) - hydro = 350; - - EntityNukeExplosionPlus entity = new EntityNukeExplosionPlus(world); - entity.posX = x + 0.5; - entity.posY = y + 0.5; - entity.posZ = z + 0.5; - entity.destructionRange = (int)hydro; - entity.speed = 25; - entity.coefficient = 10.0F; - entity.wasteRange = (int) (hydro * 1.4) + (int) dirty; - - world.spawnEntityInWorld(entity); - - if(hydro < 75) { - ExplosionParticle.spawnMush(world, x, y - ((int)hydro / 10), z); - } else if(hydro < 200) { - if(MainRegistry.enableNukeClouds) { - EntityNukeCloudSmall entity2 = new EntityNukeCloudSmall(world, 1000, hydro * 0.005F); - entity2.posX = x; - entity2.posY = y - (hydro/10); - entity2.posZ = z; - world.spawnEntityInWorld(entity2); - } else { - EntityNukeCloudSmall entity2 = new EntityNukeCloudNoShroom(world, 1000); - entity2.posX = x; - entity2.posY = y - (hydro/10); - entity2.posZ = z; - world.spawnEntityInWorld(entity2); - } - } else { - if(MainRegistry.enableNukeClouds) { - EntityNukeCloudBig entity2 = new EntityNukeCloudBig(world, 1000); - entity2.posX = x; - entity2.posY = y - (hydro/10); - entity2.posZ = z; - world.spawnEntityInWorld(entity2); - } else { - EntityNukeCloudSmall entity2 = new EntityNukeCloudNoShroom(world, 1000); - entity2.posX = x; - entity2.posY = y - (hydro/10); - entity2.posZ = z; - world.spawnEntityInWorld(entity2); - } - } - - } else if(nuke > 0) { - nuke += (tnt/2); - - if(nuke > 350) - nuke = 350; - - EntityNukeExplosionPlus entity = new EntityNukeExplosionPlus(world); - entity.posX = x + 0.5; - entity.posY = y + 0.5; - entity.posZ = z + 0.5; - entity.destructionRange = (int)nuke; - entity.speed = 25; - entity.coefficient = 10.0F; - entity.wasteRange = (int) (nuke * 1.4) + (int) dirty; - - world.spawnEntityInWorld(entity); - - if(nuke < 75) { - ExplosionParticle.spawnMush(world, x, y - ((int)nuke / 10), z); - } else if(nuke < 200) { - if(MainRegistry.enableNukeClouds) { - EntityNukeCloudSmall entity2 = new EntityNukeCloudSmall(world, 1000, nuke * 0.005F); - entity2.posX = x; - entity2.posY = y - (nuke/10); - entity2.posZ = z; - world.spawnEntityInWorld(entity2); - } else { - EntityNukeCloudSmall entity2 = new EntityNukeCloudNoShroom(world, 1000); - entity2.posX = x; - entity2.posY = y - (nuke/10); - entity2.posZ = z; - world.spawnEntityInWorld(entity2); - } - } else { - if(MainRegistry.enableNukeClouds) { - EntityNukeCloudBig entity2 = new EntityNukeCloudBig(world, 1000); - entity2.posX = x; - entity2.posY = y - (nuke/10); - entity2.posZ = z; - world.spawnEntityInWorld(entity2); - } else { - EntityNukeCloudSmall entity2 = new EntityNukeCloudNoShroom(world, 1000); - entity2.posX = x; - entity2.posY = y - (nuke/10); - entity2.posZ = z; - world.spawnEntityInWorld(entity2); - } - } - - } else if(tnt > 0) { - - if(tnt > 100) - tnt = 100; - //world.newExplosion((Entity)null, x + 0.5F, y + 0.5F, z + 0.5F, tnt, field_149933_a.nextInt(5) == 0 ? true : false, true); - ExplosionLarge.explode(world, x, y, z, tnt, true, true, true); + world.spawnEntityInWorld(bomb); } } return false; } + + public static void explodeCustom(World world, double posX, double posY, double posZ, float tnt, float nuke, float hydro, float amat, float dirty, float schrab, float euph) { + + if(euph > 0) { + EntityGrenadeZOMG zomg = new EntityGrenadeZOMG(world); + zomg.posX = posX; + zomg.posY = posY; + zomg.posZ = posZ; + ExplosionChaos.zomgMeSinPi(world, posX, posY, posZ, 1000, null, zomg); + } else if(schrab > 0) { + nuke += (tnt/2); + hydro += (nuke/2); + amat += (hydro/2); + schrab += (amat/2); + + if(schrab > 300) + schrab = 300; + + EntityNukeExplosionPlus entity = new EntityNukeExplosionPlus(world); + entity.posX = posX; + entity.posY = posY; + entity.posZ = posZ; + entity.destructionRange = (int)schrab; + entity.speed = MainRegistry.blastSpeed; + entity.coefficient = 1.0F; + entity.waste = false; + + world.spawnEntityInWorld(entity); + + EntityCloudFleija cloud = new EntityCloudFleija(world, (int)schrab); + cloud.posX = posX; + cloud.posY = posY; + cloud.posZ = posZ; + world.spawnEntityInWorld(cloud); + + } else if (amat > 0) { + nuke += (tnt/2); + hydro += (nuke/2); + amat += (hydro/2); + + if(amat > 350) + amat = 350; + + EntityNukeExplosionPlus entity = new EntityNukeExplosionPlus(world); + entity.posX = posX; + entity.posY = posY; + entity.posZ = posZ; + entity.destructionRange = (int)amat; + entity.speed = 25; + entity.coefficient = 10.0F; + entity.wasteRange = (int) (amat * 1.4) + (int) dirty; + + world.spawnEntityInWorld(entity); + + if(amat < 75) { + ExplosionParticleB.spawnMush(world, posX, posY, posZ); + } else if(amat < 200) { + if(MainRegistry.enableNukeClouds) { + EntityNukeCloudSmall entity2 = new EntityNukeCloudSmall(world, 1000, amat * 0.005F); + entity2.posX = posX; + entity2.posY = posY; + entity2.posZ = posZ; + world.spawnEntityInWorld(entity2); + } else { + EntityNukeCloudSmall entity2 = new EntityNukeCloudNoShroom(world, 1000); + entity2.posX = posX; + entity2.posY = posY; + entity2.posZ = posZ; + world.spawnEntityInWorld(entity2); + } + } else { + if(MainRegistry.enableNukeClouds) { + EntityNukeCloudBig entity2 = new EntityNukeCloudBig(world, 1000); + entity2.posX = posX; + entity2.posY = posY; + entity2.posZ = posZ; + world.spawnEntityInWorld(entity2); + } else { + EntityNukeCloudSmall entity2 = new EntityNukeCloudNoShroom(world, 1000); + entity2.posX = posX; + entity2.posY = posY; + entity2.posZ = posZ; + world.spawnEntityInWorld(entity2); + } + } + + } else if(hydro > 0) { + nuke += (tnt/2); + hydro += (nuke/2); + + if(hydro > 350) + hydro = 350; + + EntityNukeExplosionPlus entity = new EntityNukeExplosionPlus(world); + entity.posX = posX; + entity.posY = posY; + entity.posZ = posZ; + entity.destructionRange = (int)hydro; + entity.speed = 25; + entity.coefficient = 10.0F; + entity.wasteRange = (int) (hydro * 1.4) + (int) dirty; + + world.spawnEntityInWorld(entity); + + if(hydro < 75) { + ExplosionParticle.spawnMush(world, posX, posY, posZ); + } else if(hydro < 200) { + if(MainRegistry.enableNukeClouds) { + EntityNukeCloudSmall entity2 = new EntityNukeCloudSmall(world, 1000, hydro * 0.005F); + entity2.posX = posX; + entity2.posY = posY; + entity2.posZ = posZ; + world.spawnEntityInWorld(entity2); + } else { + EntityNukeCloudSmall entity2 = new EntityNukeCloudNoShroom(world, 1000); + entity2.posX = posX; + entity2.posY = posY; + entity2.posZ = posZ; + world.spawnEntityInWorld(entity2); + } + } else { + if(MainRegistry.enableNukeClouds) { + EntityNukeCloudBig entity2 = new EntityNukeCloudBig(world, 1000); + entity2.posX = posX; + entity2.posY = posY; + entity2.posZ = posZ; + world.spawnEntityInWorld(entity2); + } else { + EntityNukeCloudSmall entity2 = new EntityNukeCloudNoShroom(world, 1000); + entity2.posX = posX; + entity2.posY = posY; + entity2.posZ = posZ; + world.spawnEntityInWorld(entity2); + } + } + + } else if(nuke > 0) { + nuke += (tnt/2); + + if(nuke > 350) + nuke = 350; + + EntityNukeExplosionPlus entity = new EntityNukeExplosionPlus(world); + entity.posX = posX; + entity.posY = posY; + entity.posZ = posZ; + entity.destructionRange = (int)nuke; + entity.speed = 25; + entity.coefficient = 10.0F; + entity.wasteRange = (int) (nuke * 1.4) + (int) dirty; + + world.spawnEntityInWorld(entity); + + if(nuke < 75) { + ExplosionParticle.spawnMush(world, posX, posY, posZ); + } else if(nuke < 200) { + if(MainRegistry.enableNukeClouds) { + EntityNukeCloudSmall entity2 = new EntityNukeCloudSmall(world, 1000, nuke * 0.005F); + entity2.posX = posX; + entity2.posY = posY; + entity2.posZ = posZ; + world.spawnEntityInWorld(entity2); + } else { + EntityNukeCloudSmall entity2 = new EntityNukeCloudNoShroom(world, 1000); + entity2.posX = posX; + entity2.posY = posY; + entity2.posZ = posZ; + world.spawnEntityInWorld(entity2); + } + } else { + if(MainRegistry.enableNukeClouds) { + EntityNukeCloudBig entity2 = new EntityNukeCloudBig(world, 1000); + entity2.posX = posX; + entity2.posY = posY; + entity2.posZ = posZ; + world.spawnEntityInWorld(entity2); + } else { + EntityNukeCloudSmall entity2 = new EntityNukeCloudNoShroom(world, 1000); + entity2.posX = posX; + entity2.posY = posY; + entity2.posZ = posZ; + world.spawnEntityInWorld(entity2); + } + } + + } else if(tnt > 0) { + + if(tnt > 100) + tnt = 100; + ExplosionLarge.explode(world, posX, posY, posZ, tnt, true, true, true); + } + } @Override public int getRenderType() { @@ -376,10 +396,12 @@ public class NukeCustom extends BlockContainer implements IBomb { { if (entity.isReady()) { float[] f = entity.returnAllValues(); + boolean fall = entity.falls; + int meta = world.getBlockMetadata(x, y, z); this.onBlockDestroyedByPlayer(world, x, y, z, 1); entity.clearSlots(); world.setBlockToAir(x, y, z); - igniteTestBomb(world, x, y, z, f); + igniteTestBomb(world, x, y, z, f, fall, meta); } } } diff --git a/com/hbm/blocks/test/TestEventTester.java b/com/hbm/blocks/test/TestEventTester.java index 130c336af..2a7ee65d3 100644 --- a/com/hbm/blocks/test/TestEventTester.java +++ b/com/hbm/blocks/test/TestEventTester.java @@ -20,6 +20,8 @@ import com.hbm.lib.HbmChestContents; import com.hbm.main.MainRegistry; import com.hbm.main.ModEventHandler; import com.hbm.potion.HbmPotion; +import com.hbm.saveddata.RadiationSaveStructure; +import com.hbm.saveddata.RadiationSavedData; import com.hbm.saveddata.SatelliteSaveStructure; import com.hbm.saveddata.SatelliteSavedData; import com.hbm.tileentity.machine.TileEntityCrateSteel; @@ -190,7 +192,57 @@ public class TestEventTester extends Block { if(!worldObj.isRemote) worldObj.spawnEntityInWorld(rainbow);*/ + RadiationSavedData data = RadiationSavedData.getData(worldObj); + //ALU SETS RAD TO 1000 + //BER PRINTS RAD LEVEL + //COP INITIATES CYCLE + //RED FLUSHES ALL RAD + //STE PRINTS RAD CHUNKS + //URA PRINTS TOTAL RAD + + if(worldObj.getBlock(x1, y1 - 1, z1) == ModBlocks.block_aluminium) { + + Chunk chunk = worldObj.getChunkFromBlockCoords(x1, z1); + + data.setRadForCoord(chunk.xPosition, chunk.zPosition, 1000000); + + System.out.println(data.getRadNumFromCoord(chunk.xPosition, chunk.zPosition)); + } + + if(worldObj.getBlock(x1, y1 - 1, z1) == ModBlocks.block_beryllium) { + + Chunk chunk = worldObj.getChunkFromBlockCoords(x1, z1); + + System.out.println(data.getRadNumFromCoord(chunk.xPosition, chunk.zPosition)); + } + + if(worldObj.getBlock(x1, y1 - 1, z1) == ModBlocks.block_copper) { + data.updateSystem(); + } + + if(worldObj.getBlock(x1, y1 - 1, z1) == ModBlocks.block_red_copper) { + + Chunk chunk = worldObj.getChunkFromBlockCoords(x1, z1); + + data.jettisonData(); + } + + if(worldObj.getBlock(x1, y1 - 1, z1) == ModBlocks.block_steel) { + + System.out.println(data.count); + } + + if(worldObj.getBlock(x1, y1 - 1, z1) == ModBlocks.block_uranium) { + + float r = 0; + + for(RadiationSaveStructure st : data.contamination) { + r += st.radiation; + } + + System.out.println(r); + } } } diff --git a/com/hbm/entity/missile/EntityMissileNuclear.java b/com/hbm/entity/missile/EntityMissileNuclear.java index f5beda3eb..9766a8da6 100644 --- a/com/hbm/entity/missile/EntityMissileNuclear.java +++ b/com/hbm/entity/missile/EntityMissileNuclear.java @@ -41,7 +41,6 @@ public class EntityMissileNuclear extends EntityMissileBaseAdvanced { entity2.posX = this.posX; entity2.posY = this.posY/* - 9*/; entity2.posZ = this.posZ; - entity2.getDataWatcher().updateObject(18, 2F); this.worldObj.spawnEntityInWorld(entity2); } diff --git a/com/hbm/entity/projectile/EntityFallingNuke.java b/com/hbm/entity/projectile/EntityFallingNuke.java new file mode 100644 index 000000000..13579b466 --- /dev/null +++ b/com/hbm/entity/projectile/EntityFallingNuke.java @@ -0,0 +1,103 @@ +package com.hbm.entity.projectile; + +import com.hbm.blocks.bomb.NukeCustom; +import com.hbm.entity.logic.EntityNukeExplosionMK4; +import com.hbm.entity.missile.EntityBombletSelena; +import com.hbm.entity.particle.EntitySSmokeFX; +import com.hbm.explosion.ExplosionChaos; +import com.hbm.explosion.ExplosionLarge; +import com.hbm.explosion.ExplosionParticle; +import com.hbm.explosion.ExplosionParticleB; +import com.hbm.main.MainRegistry; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +public class EntityFallingNuke extends EntityThrowable { + + float tnt; + float nuke; + float hydro; + float amat; + float dirty; + float schrab; + float euph; + + public EntityFallingNuke(World p_i1582_1_) { + super(p_i1582_1_); + this.ignoreFrustumCheck = true; + } + + public EntityFallingNuke(World p_i1582_1_, float tnt, float nuke, float hydro, float amat, float dirty, float schrab, float euph) { + super(p_i1582_1_); + this.ignoreFrustumCheck = true; + + this.tnt = tnt; + this.nuke = nuke; + this.hydro = hydro; + this.amat = amat; + this.dirty = dirty; + this.schrab = schrab; + this.euph = euph; + this.prevRotationYaw = this.rotationYaw = 90; + this.prevRotationPitch = this.rotationPitch = 90; + } + + protected void entityInit() { + this.dataWatcher.addObject(20, Byte.valueOf((byte)0)); + } + + @Override + public void onUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + + this.motionX *= 0.99; + this.motionZ *= 0.99; + this.motionY -= 0.05D; + + if(motionY < -1) + motionY = -1; + + this.rotation(); + + if(this.worldObj.getBlock((int)this.posX, (int)this.posY, (int)this.posZ) != Blocks.air) + { + if(!this.worldObj.isRemote) + { + NukeCustom.explodeCustom(worldObj, posX, posY, posZ, tnt, nuke, hydro, amat, dirty, schrab, euph); + this.setDead(); + } + } + } + + public void rotation() { + + this.prevRotationPitch = rotationPitch; + + if(rotationPitch > -75) + this.rotationPitch -= 2; + } + + @Override + protected void onImpact(MovingObjectPosition p_70184_1_) { + } + + @Override + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(double distance) + { + return distance < 25000; + } +} diff --git a/com/hbm/items/ModItems.java b/com/hbm/items/ModItems.java index ae48cdc94..7bca29bef 100644 --- a/com/hbm/items/ModItems.java +++ b/com/hbm/items/ModItems.java @@ -920,7 +920,7 @@ public class ModItems { public static Item custom_amat; public static Item custom_dirty; public static Item custom_schrab; - + public static Item custom_fall; public static Item battery_generic; public static Item battery_advanced; @@ -2210,6 +2210,7 @@ public class ModItems { custom_amat = new ItemCustomLore().setUnlocalizedName("custom_amat").setMaxStackSize(1).setCreativeTab(MainRegistry.nukeTab).setTextureName(RefStrings.MODID + ":custom_amat"); custom_dirty = new ItemCustomLore().setUnlocalizedName("custom_dirty").setMaxStackSize(1).setCreativeTab(MainRegistry.nukeTab).setTextureName(RefStrings.MODID + ":custom_dirty"); custom_schrab = new ItemCustomLore().setUnlocalizedName("custom_schrab").setMaxStackSize(1).setCreativeTab(MainRegistry.nukeTab).setTextureName(RefStrings.MODID + ":custom_schrab"); + custom_fall = new ItemCustomLore().setUnlocalizedName("custom_fall").setMaxStackSize(1).setCreativeTab(MainRegistry.nukeTab).setTextureName(RefStrings.MODID + ":custom_fall"); battery_generic = new ItemBattery(50, 1, 1).setUnlocalizedName("battery_generic").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_generic"); battery_advanced = new ItemBattery(200, 5, 5).setUnlocalizedName("battery_advanced").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_advanced"); @@ -3876,6 +3877,7 @@ public class ModItems { GameRegistry.registerItem(custom_amat, custom_amat.getUnlocalizedName()); GameRegistry.registerItem(custom_dirty, custom_dirty.getUnlocalizedName()); GameRegistry.registerItem(custom_schrab, custom_schrab.getUnlocalizedName()); + GameRegistry.registerItem(custom_fall, custom_fall.getUnlocalizedName()); //Power Armor GameRegistry.registerItem(t45_helmet, t45_helmet.getUnlocalizedName()); diff --git a/com/hbm/items/special/ItemCustomLore.java b/com/hbm/items/special/ItemCustomLore.java index 4bcb2ff1b..c92fd8a09 100644 --- a/com/hbm/items/special/ItemCustomLore.java +++ b/com/hbm/items/special/ItemCustomLore.java @@ -639,6 +639,12 @@ public class ItemCustomLore extends ItemRadioactive { list.add("Removes fallout"); } + if(this == ModItems.custom_fall) + { + list.add("That's what you've aaaaaaall been waiting for!"); + list.add("Makes bomb drop upon activation"); + } + if(this == ModItems.pin) { list.add("Can be used with a screwdriver to pick locks."); diff --git a/com/hbm/items/tool/ItemAnalyzer.java b/com/hbm/items/tool/ItemAnalyzer.java index 458ae6893..baf9e74f3 100644 --- a/com/hbm/items/tool/ItemAnalyzer.java +++ b/com/hbm/items/tool/ItemAnalyzer.java @@ -30,7 +30,7 @@ public class ItemAnalyzer extends Item { Block block = world.getBlock(x, y, z); TileEntity te = world.getTileEntity(x, y, z); - if(!world.isRemote) { + if(world.isRemote) { player.addChatMessage(new ChatComponentText( "Block: " + I18n.format(block.getUnlocalizedName() + ".name") + " (" + block.getUnlocalizedName() + ")" )); @@ -38,6 +38,9 @@ public class ItemAnalyzer extends Item { player.addChatMessage(new ChatComponentText( "Meta: " + world.getBlockMetadata(x, y, z) )); + } + + if(!world.isRemote) { if(te == null) { player.addChatMessage(new ChatComponentText( diff --git a/com/hbm/items/tool/ItemGeigerCounter.java b/com/hbm/items/tool/ItemGeigerCounter.java index 2cd2cd5c7..9fff259cf 100644 --- a/com/hbm/items/tool/ItemGeigerCounter.java +++ b/com/hbm/items/tool/ItemGeigerCounter.java @@ -62,7 +62,7 @@ public class ItemGeigerCounter extends Item { stack.stackTagCompound.setInteger(name, i); } - static int getInt(ItemStack stack, String name) { + public static int getInt(ItemStack stack, String name) { if(stack.hasTagCompound()) return stack.stackTagCompound.getInteger(name); diff --git a/com/hbm/main/ClientProxy.java b/com/hbm/main/ClientProxy.java index f49ed12b7..512ce56e5 100644 --- a/com/hbm/main/ClientProxy.java +++ b/com/hbm/main/ClientProxy.java @@ -328,6 +328,7 @@ public class ClientProxy extends ServerProxy RenderingRegistry.registerEntityRenderingHandler(EntityBooster.class, new RenderBoosterMissile()); RenderingRegistry.registerEntityRenderingHandler(EntityBomber.class, new RenderBomber()); RenderingRegistry.registerEntityRenderingHandler(EntityBurningFOEQ.class, new RenderFOEQ()); + RenderingRegistry.registerEntityRenderingHandler(EntityFallingNuke.class, new RenderFallingNuke()); RenderingRegistry.registerEntityRenderingHandler(EntityMissileTaint.class, new RenderMissileTaint()); RenderingRegistry.registerEntityRenderingHandler(EntityMissileMicro.class, new RenderMissileTaint()); diff --git a/com/hbm/main/MainRegistry.java b/com/hbm/main/MainRegistry.java index 93ff70491..3b993833e 100644 --- a/com/hbm/main/MainRegistry.java +++ b/com/hbm/main/MainRegistry.java @@ -170,6 +170,7 @@ import com.hbm.entity.projectile.EntityChopperMine; import com.hbm.entity.projectile.EntityCombineBall; import com.hbm.entity.projectile.EntityDischarge; import com.hbm.entity.projectile.EntityExplosiveBeam; +import com.hbm.entity.projectile.EntityFallingNuke; import com.hbm.entity.projectile.EntityFire; import com.hbm.entity.projectile.EntityLN2; import com.hbm.entity.projectile.EntityLaser; @@ -859,6 +860,7 @@ public class MainRegistry EntityRegistry.registerModEntity(EntityGrenadeIFSpark.class, "entity_grenade_ironshod", 127, this, 250, 1, true); EntityRegistry.registerModEntity(EntityGrenadeIFHopwire.class, "entity_grenade_ironshod", 128, this, 250, 1, true); EntityRegistry.registerModEntity(EntityGrenadeIFNull.class, "entity_grenade_ironshod", 129, this, 250, 1, true); + EntityRegistry.registerModEntity(EntityFallingNuke.class, "entity_falling_bomb", 130, this, 1000, 1, true); EntityRegistry.registerGlobalEntityID(EntityNuclearCreeper.class, "entity_mob_nuclear_creeper", EntityRegistry.findGlobalUniqueEntityId(), 0x204131, 0x75CE00); EntityRegistry.registerGlobalEntityID(EntityTaintedCreeper.class, "entity_mob_tainted_creeper", EntityRegistry.findGlobalUniqueEntityId(), 0x813b9b, 0xd71fdd); diff --git a/com/hbm/main/ModEventHandler.java b/com/hbm/main/ModEventHandler.java index 515b9e81c..fa6529a4f 100644 --- a/com/hbm/main/ModEventHandler.java +++ b/com/hbm/main/ModEventHandler.java @@ -10,7 +10,10 @@ import com.hbm.entity.projectile.EntityMeteor; import com.hbm.items.ModItems; import com.hbm.lib.ModDamageSource; import com.hbm.lib.RefStrings; +import com.hbm.packet.PacketDispatcher; +import com.hbm.packet.RadSurveyPacket; import com.hbm.potion.HbmPotion; +import com.hbm.saveddata.RadiationSavedData; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; @@ -25,12 +28,14 @@ import net.minecraft.entity.passive.EntityCow; import net.minecraft.entity.passive.EntityMooshroom; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; import net.minecraftforge.event.entity.EntityEvent.EnteringChunk; import net.minecraftforge.event.entity.living.LivingSpawnEvent; @@ -94,6 +99,31 @@ public class ModEventHandler //try { ///// + if(event.world != null && !event.world.isRemote) { + if(!event.world.playerEntities.isEmpty()) { + + for(Object o : event.world.playerEntities) { + EntityPlayer player = (EntityPlayer)o; + + RadiationSavedData data = RadiationSavedData.getData(player.worldObj); + Chunk chunk = player.worldObj.getChunkFromBlockCoords((int)player.posX, (int)player.posZ); + + float[] rads = new float[9]; + rads[0] = data.getRadNumFromCoord(chunk.xPosition + 1, chunk.zPosition + 1); + rads[1] = data.getRadNumFromCoord(chunk.xPosition, chunk.zPosition + 1); + rads[2] = data.getRadNumFromCoord(chunk.xPosition - 1, chunk.zPosition + 1); + rads[3] = data.getRadNumFromCoord(chunk.xPosition - 1, chunk.zPosition); + rads[4] = data.getRadNumFromCoord(chunk.xPosition - 1, chunk.zPosition - 1); + rads[5] = data.getRadNumFromCoord(chunk.xPosition, chunk.zPosition - 1); + rads[6] = data.getRadNumFromCoord(chunk.xPosition + 1, chunk.zPosition - 1); + rads[7] = data.getRadNumFromCoord(chunk.xPosition + 1, chunk.zPosition); + rads[8] = data.getRadNumFromCoord(chunk.xPosition, chunk.zPosition); + + PacketDispatcher.wrapper.sendTo(new RadSurveyPacket(rads), (EntityPlayerMP) player); + } + } + } + if(event.world != null && !event.world.isRemote && event.world.provider.isSurfaceWorld() && MainRegistry.enableMeteorStrikes) { if(event.world.rand.nextInt(meteorShower > 0 ? MainRegistry.meteorShowerChance : MainRegistry.meteorStrikeChance) == 0) { if(!event.world.playerEntities.isEmpty()) { diff --git a/com/hbm/main/ModEventHandlerClient.java b/com/hbm/main/ModEventHandlerClient.java index 61e5667ea..210d047ca 100644 --- a/com/hbm/main/ModEventHandlerClient.java +++ b/com/hbm/main/ModEventHandlerClient.java @@ -2,7 +2,11 @@ package com.hbm.main; import com.hbm.entity.mob.EntityHunterChopper; import com.hbm.entity.projectile.EntityChopperMine; +import com.hbm.items.ModItems; +import com.hbm.items.tool.ItemGeigerCounter; import com.hbm.lib.Library; +import com.hbm.render.misc.RenderScreenOverlay; +import com.hbm.saveddata.RadiationSavedData; import com.hbm.sound.MovingSoundChopper; import com.hbm.sound.MovingSoundChopperMine; import com.hbm.sound.MovingSoundCrashing; @@ -14,10 +18,49 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.ResourceLocation; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.client.event.sound.PlaySoundEvent17; public class ModEventHandlerClient { + + @SubscribeEvent + public void onOverlayRender(RenderGameOverlayEvent event) { + + if(event.type == ElementType.HOTBAR) { + + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + + if(player.inventory.hasItem(ModItems.geiger_counter)) { + + float rads = 0; + + for(int i = 0; i < player.inventory.getSizeInventory(); i++) { + + if(player.inventory.getStackInSlot(i) != null && player.inventory.getStackInSlot(i).getItem() == ModItems.geiger_counter) { + rads = ItemGeigerCounter.getInt(player.inventory.getStackInSlot(i), "ticker"); + break; + } + } + + ////TEST + + RadiationSavedData data = RadiationSavedData.getData(player.worldObj); + Chunk chunk = player.worldObj.getChunkFromBlockCoords((int)player.posX, (int)player.posZ); + rads = data.getRadNumFromCoord(chunk.xPosition, chunk.zPosition); + + ////TEST + + //if(player.worldObj.rand.nextInt(100) == 0) + // System.out.println(rads); + + RenderScreenOverlay.renderRadCounter(event.resolution, rads, Minecraft.getMinecraft().ingameGUI); + } + } + } @SubscribeEvent public void onPlaySound(PlaySoundEvent17 e) { diff --git a/com/hbm/packet/AuxGaugePacket.java b/com/hbm/packet/AuxGaugePacket.java index b0e219d89..3228b7550 100644 --- a/com/hbm/packet/AuxGaugePacket.java +++ b/com/hbm/packet/AuxGaugePacket.java @@ -2,6 +2,7 @@ package com.hbm.packet; import com.hbm.interfaces.IConsumer; import com.hbm.interfaces.ISource; +import com.hbm.tileentity.bomb.TileEntityNukeCustom; import com.hbm.tileentity.bomb.TileEntityTurretCIWS; import com.hbm.tileentity.bomb.TileEntityTurretCheapo; import com.hbm.tileentity.deco.TileEntityBomber; @@ -197,6 +198,11 @@ public class AuxGaugePacket implements IMessage { if(m.id == 0) boiler.heat = m.value; } + if (te instanceof TileEntityNukeCustom) { + TileEntityNukeCustom nuke = (TileEntityNukeCustom)te; + + nuke.falls = m.value == 1; + } } catch (Exception x) {} return null; diff --git a/com/hbm/packet/PacketDispatcher.java b/com/hbm/packet/PacketDispatcher.java index ba23ecb9d..55a2a8f90 100644 --- a/com/hbm/packet/PacketDispatcher.java +++ b/com/hbm/packet/PacketDispatcher.java @@ -71,6 +71,8 @@ public class PacketDispatcher { wrapper.registerMessage(SatPanelPacket.Handler.class, SatPanelPacket.class, i++, Side.CLIENT); //Packet to send block break particles wrapper.registerMessage(ParticleBurstPacket.Handler.class, ParticleBurstPacket.class, i++, Side.CLIENT); + //Packet to send chunk radiation info to individual players + wrapper.registerMessage(RadSurveyPacket.Handler.class, RadSurveyPacket.class, i++, Side.CLIENT); } } diff --git a/com/hbm/packet/RadSurveyPacket.java b/com/hbm/packet/RadSurveyPacket.java new file mode 100644 index 000000000..d526a5753 --- /dev/null +++ b/com/hbm/packet/RadSurveyPacket.java @@ -0,0 +1,81 @@ +package com.hbm.packet; + +import com.hbm.interfaces.IConsumer; +import com.hbm.interfaces.ISource; +import com.hbm.saveddata.RadiationSavedData; +import com.hbm.tileentity.machine.TileEntityMachinePress; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.chunk.Chunk; + +public class RadSurveyPacket implements IMessage { + + float[] rad; + + public RadSurveyPacket() + { + + } + + public RadSurveyPacket(float[] rad) + { + this.rad = rad; + } + + @Override + public void fromBytes(ByteBuf buf) { + + rad = new float[9]; + + for(int i = 0; i < 9; i++) + rad[i] = buf.readFloat(); + } + + @Override + public void toBytes(ByteBuf buf) { + + for(int i = 0; i < 9; i++) + buf.writeFloat(rad[i]); + } + + public static class Handler implements IMessageHandler { + + @Override + @SideOnly(Side.CLIENT) + public IMessage onMessage(RadSurveyPacket m, MessageContext ctx) { + try { + + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + RadiationSavedData data = RadiationSavedData.getData(player.worldObj); + data.jettisonData(); + + Chunk[] chunks = new Chunk[9]; + + chunks[0] = player.worldObj.getChunkFromBlockCoords((int)player.posX + 16, (int)player.posZ + 16); + chunks[1] = player.worldObj.getChunkFromBlockCoords((int)player.posX, (int)player.posZ + 16); + chunks[2] = player.worldObj.getChunkFromBlockCoords((int)player.posX - 16, (int)player.posZ + 16); + chunks[3] = player.worldObj.getChunkFromBlockCoords((int)player.posX - 16, (int)player.posZ); + chunks[4] = player.worldObj.getChunkFromBlockCoords((int)player.posX - 16, (int)player.posZ - 16); + chunks[5] = player.worldObj.getChunkFromBlockCoords((int)player.posX, (int)player.posZ - 16); + chunks[6] = player.worldObj.getChunkFromBlockCoords((int)player.posX + 16, (int)player.posZ - 16); + chunks[7] = player.worldObj.getChunkFromBlockCoords((int)player.posX + 16, (int)player.posZ); + chunks[8] = player.worldObj.getChunkFromBlockCoords((int)player.posX, (int)player.posZ); + + for(int i = 0; i < 9; i++) + data.createEntry(chunks[i].xPosition, chunks[i].zPosition, m.rad[i]); + + } catch (Exception x) { } + return null; + } + } +} diff --git a/com/hbm/render/entity/RenderFallingNuke.java b/com/hbm/render/entity/RenderFallingNuke.java new file mode 100644 index 000000000..428a93819 --- /dev/null +++ b/com/hbm/render/entity/RenderFallingNuke.java @@ -0,0 +1,64 @@ +package com.hbm.render.entity; + +import org.lwjgl.opengl.GL11; + +import com.hbm.lib.RefStrings; + +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.AdvancedModelLoader; +import net.minecraftforge.client.model.IModelCustom; + +public class RenderFallingNuke extends Render { + + private static final ResourceLocation objTesterModelRL = new ResourceLocation(/*"/assets/" + */RefStrings.MODID, "models/LilBoy1.obj"); + private IModelCustom boyModel; + private ResourceLocation boyTexture; + + public RenderFallingNuke() { + boyModel = AdvancedModelLoader.loadModel(objTesterModelRL); + boyTexture = new ResourceLocation(RefStrings.MODID, "textures/models/CustomNuke.png"); + } + + @Override + public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { + + GL11.glPushMatrix(); + GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_, (float)p_76986_6_); + + switch(p_76986_1_.getDataWatcher().getWatchableObjectByte(20)) + { + case 2: + GL11.glRotatef(90, 0F, 1F, 0F); + GL11.glTranslated(-2.0D, 0.0D, 0.0D); break; + case 4: + GL11.glRotatef(180, 0F, 1F, 0F); + GL11.glTranslated(-2.0D, 0.0D, 0.0D); break; + case 3: + GL11.glRotatef(270, 0F, 1F, 0F); + GL11.glTranslated(-2.0D, 0.0D, 0.0D); break; + case 5: + GL11.glRotatef(0, 0F, 1F, 0F); + GL11.glTranslated(-2.0D, 0.0D, 0.0D); break; + } + + float f = p_76986_1_.prevRotationPitch + (p_76986_1_.rotationPitch - p_76986_1_.prevRotationPitch) * p_76986_9_; + + if(f < -80) + f = 0; + + //GL11.glRotatef(p_76986_1_.prevRotationYaw + (p_76986_1_.rotationYaw - p_76986_1_.prevRotationYaw) * p_76986_9_ - 90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(f, 0.0F, 0.0F, 1.0F); + + bindTexture(boyTexture); + boyModel.renderAll(); + + GL11.glPopMatrix(); + } + + @Override + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return new ResourceLocation(RefStrings.MODID +":textures/models/TheGadget3_.png"); + } +} diff --git a/com/hbm/render/misc/RenderScreenOverlay.java b/com/hbm/render/misc/RenderScreenOverlay.java new file mode 100644 index 000000000..6a7bae550 --- /dev/null +++ b/com/hbm/render/misc/RenderScreenOverlay.java @@ -0,0 +1,71 @@ +package com.hbm.render.misc; + +import org.lwjgl.opengl.GL11; + +import com.hbm.lib.RefStrings; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.util.ResourceLocation; + +public class RenderScreenOverlay { + + private static final ResourceLocation misc = new ResourceLocation(RefStrings.MODID + ":textures/misc/overlay_misc.png"); + + public static void renderRadCounter(ScaledResolution resolution, float radiation, Gui gui) { + GL11.glPushMatrix(); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_ALPHA_TEST); + + int length = 74; + int maxRad = 1000; + + int bar = getScaled(radiation, maxRad, 74); + + if(radiation >= 1 && radiation <= 999) + bar -= (2 + Minecraft.getMinecraft().theWorld.rand.nextInt(5)); + + int posX = 16; + int posY = resolution.getScaledHeight() - 18 - 2; + + Minecraft.getMinecraft().renderEngine.bindTexture(misc); + gui.drawTexturedModalRect(posX, posY, 0, 0, 94, 18); + gui.drawTexturedModalRect(posX + 1, posY + 1, 1, 19, bar, 16); + + if(radiation >= maxRad * 0.75) { + gui.drawTexturedModalRect(posX + length + 2, posY - 18, 36, 36, 18, 18); + + } else if(radiation >= maxRad * 0.5) { + gui.drawTexturedModalRect(posX + length + 2, posY - 18, 18, 36, 18, 18); + + } else if(radiation >= maxRad * 0.25) { + gui.drawTexturedModalRect(posX + length + 2, posY - 18, 0, 36, 18, 18); + + } + + if(radiation > 1000) { + Minecraft.getMinecraft().fontRenderer.drawString(">1000 RAD/s", posX, posY - 8, 0xFF0000); + } else if(radiation >= 1) { + Minecraft.getMinecraft().fontRenderer.drawString(((int)Math.round(radiation)) + " RAD/s", posX, posY - 8, 0xFF0000); + } else if(radiation > 0) { + Minecraft.getMinecraft().fontRenderer.drawString("<1 RAD/s", posX, posY - 8, 0xFF0000); + } + + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(true); + GL11.glPopMatrix(); + } + + private static int getScaled(double cur, double max, double scale) { + + return (int) Math.min(cur / max * scale, scale); + } + +} diff --git a/com/hbm/saveddata/RadiationSaveStructure.java b/com/hbm/saveddata/RadiationSaveStructure.java new file mode 100644 index 000000000..c0a440fb4 --- /dev/null +++ b/com/hbm/saveddata/RadiationSaveStructure.java @@ -0,0 +1,35 @@ +package com.hbm.saveddata; + +import java.util.Arrays; + +import com.hbm.handler.FluidTypeHandler.FluidType; + +import net.minecraft.nbt.NBTTagCompound; + +public class RadiationSaveStructure { + + public int chunkX; + public int chunkY; + public float radiation; + + public RadiationSaveStructure() { } + + public RadiationSaveStructure(int x, int y, float rad) { + chunkX = x; + chunkY = y; + radiation = rad; + } + + public void readFromNBT(NBTTagCompound nbt, int index) { + chunkX = nbt.getInteger("rad_" + index + "_x"); + chunkY = nbt.getInteger("rad_" + index + "_y"); + radiation = nbt.getFloat("rad_" + index + "_level"); + } + + public void writeToNBT(NBTTagCompound nbt, int index) { + nbt.setInteger("rad_" + index + "_x", chunkX); + nbt.setInteger("rad_" + index + "_y", chunkY); + nbt.setFloat("rad_" + index + "_level", radiation); + } + +} diff --git a/com/hbm/saveddata/RadiationSavedData.java b/com/hbm/saveddata/RadiationSavedData.java new file mode 100644 index 000000000..b7e201661 --- /dev/null +++ b/com/hbm/saveddata/RadiationSavedData.java @@ -0,0 +1,173 @@ +package com.hbm.saveddata; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraft.world.WorldSavedData; + +public class RadiationSavedData extends WorldSavedData { + + public int count; + + public List contamination = new ArrayList(); + + private World worldObj; + + public RadiationSavedData(String p_i2141_1_) { + super(p_i2141_1_); + } + + public RadiationSavedData(World p_i1678_1_) + { + super("radiation"); + this.worldObj = p_i1678_1_; + this.markDirty(); + } + + public boolean doesEntryExist(int x, int y) { + + return getRadFromCoord(x, y) != null; + } + + public void createEntry(int x, int y, float rad) { + + contamination.add(new RadiationSaveStructure(x, y, rad)); + count = contamination.size(); + } + + public void deleteEntry(RadiationSaveStructure struct) { + + contamination.remove(struct); + count = contamination.size(); + } + + public void jettisonData() { + + contamination.clear(); + count = contamination.size(); + } + + public void setRadForCoord(int x, int y, float radiation) { + + RadiationSaveStructure entry = null; + + for(RadiationSaveStructure rad : contamination) + if(rad.chunkX == x && rad.chunkY == y) { + entry = rad; + break; + } + + if(entry == null) { + + entry = new RadiationSaveStructure(x, y, radiation); + contamination.add(entry); + count = contamination.size(); + } + + entry.radiation = radiation; + + } + + public RadiationSaveStructure getRadFromCoord(int x, int y) { + + for(RadiationSaveStructure rad : contamination) + if(rad.chunkX == x && rad.chunkY == y) + return rad; + + return null; + } + + public float getRadNumFromCoord(int x, int y) { + + for(RadiationSaveStructure rad : contamination) + if(rad.chunkX == x && rad.chunkY == y) + return rad.radiation; + + return 0F; + } + + public void updateSystem() { + + List tempList = new ArrayList(contamination); + + contamination.clear(); + + for(RadiationSaveStructure struct : tempList) { + + if(struct.radiation != 0) { + + if(struct.radiation > 1) { + + float[] rads = new float[9]; + + rads[0] = getRadNumFromCoord(struct.chunkX + 1, struct.chunkY + 1); + rads[1] = getRadNumFromCoord(struct.chunkX, struct.chunkY + 1); + rads[2] = getRadNumFromCoord(struct.chunkX - 1, struct.chunkY + 1); + rads[3] = getRadNumFromCoord(struct.chunkX - 1, struct.chunkY); + rads[4] = getRadNumFromCoord(struct.chunkX - 1, struct.chunkY - 1); + rads[5] = getRadNumFromCoord(struct.chunkX, struct.chunkY - 1); + rads[6] = getRadNumFromCoord(struct.chunkX + 1, struct.chunkY - 1); + rads[7] = getRadNumFromCoord(struct.chunkX + 1, struct.chunkY); + rads[8] = getRadNumFromCoord(struct.chunkX, struct.chunkY); + + float main = 0.6F; + float side = 0.075F; + float corner = 0.025F; + + setRadForCoord(struct.chunkX + 1, struct.chunkY + 1, rads[0] + struct.radiation * corner); + setRadForCoord(struct.chunkX, struct.chunkY + 1, rads[1] + struct.radiation * side); + setRadForCoord(struct.chunkX - 1, struct.chunkY + 1, rads[2] + struct.radiation * corner); + setRadForCoord(struct.chunkX - 1, struct.chunkY, rads[3] + struct.radiation * side); + setRadForCoord(struct.chunkX - 1, struct.chunkY - 1, rads[4] + struct.radiation * corner); + setRadForCoord(struct.chunkX, struct.chunkY - 1, rads[5] + struct.radiation * side); + setRadForCoord(struct.chunkX + 1, struct.chunkY - 1, rads[6] + struct.radiation * corner); + setRadForCoord(struct.chunkX + 1, struct.chunkY, rads[7] + struct.radiation * side); + setRadForCoord(struct.chunkX, struct.chunkY, rads[8] + struct.radiation * main); + + } else { + + this.setRadForCoord(struct.chunkX, struct.chunkY, getRadNumFromCoord(struct.chunkX, struct.chunkY) + struct.radiation); + } + } + } + + count = contamination.size(); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + count = nbt.getInteger("radCount"); + + for(int i = 0; i < count; i++) { + RadiationSaveStructure struct = new RadiationSaveStructure(); + struct.readFromNBT(nbt, i); + + createEntry(struct.chunkX, struct.chunkY, struct.radiation); + //contamination.add(struct); + } + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + nbt.setInteger("radCount", contamination.size()); + + for(int i = 0; i < contamination.size(); i++) { + contamination.get(i).writeToNBT(nbt, i); + } + } + + public static RadiationSavedData getData(World worldObj) { + + RadiationSavedData data = (RadiationSavedData)worldObj.perWorldStorage.loadData(RadiationSavedData.class, "radiation"); + if(data == null) { + worldObj.perWorldStorage.setData("radiation", new RadiationSavedData(worldObj)); + + data = (RadiationSavedData)worldObj.perWorldStorage.loadData(RadiationSavedData.class, "radiation"); + } + + return data; + } + +} diff --git a/com/hbm/tileentity/bomb/TileEntityNukeCustom.java b/com/hbm/tileentity/bomb/TileEntityNukeCustom.java index 50bcec6c6..a7c03d2c8 100644 --- a/com/hbm/tileentity/bomb/TileEntityNukeCustom.java +++ b/com/hbm/tileentity/bomb/TileEntityNukeCustom.java @@ -2,6 +2,8 @@ package com.hbm.tileentity.bomb; import com.hbm.blocks.ModBlocks; import com.hbm.items.ModItems; +import com.hbm.packet.AuxGaugePacket; +import com.hbm.packet.PacketDispatcher; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -27,6 +29,7 @@ public class TileEntityNukeCustom extends TileEntity implements ISidedInventory public float dirtyStrength; public float schrabStrength; public float euphStrength; + public boolean falls; public TileEntityNukeCustom() { slots = new ItemStack[27]; @@ -37,6 +40,7 @@ public class TileEntityNukeCustom extends TileEntity implements ISidedInventory dirtyStrength = 0; schrabStrength = 0; euphStrength = 0; + falls = false; } @Override @@ -354,6 +358,10 @@ public class TileEntityNukeCustom extends TileEntity implements ISidedInventory if(item == ModItems.ingot_euphemium) { this.euphStrength += 1F; } + + if(item == ModItems.custom_fall) { + this.falls = true; + } } } @@ -473,7 +481,7 @@ public class TileEntityNukeCustom extends TileEntity implements ISidedInventory } public float[] returnAllValues() { - return new float[] { this.tntStrength, this.nukeStrength, this.hydroStrength, this.amatStrength, this.dirtyStrength, this.schrabStrength, this.euphStrength}; + return new float[] { this.tntStrength, this.nukeStrength, this.hydroStrength, this.amatStrength, this.dirtyStrength, this.schrabStrength, this.euphStrength }; } public void clearSlots() {