mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
cleaned up radiation code, better geiger counter functionality
This commit is contained in:
parent
17ce5dbd43
commit
345440ea5d
@ -3,8 +3,9 @@ package com.hbm.blocks.fluid;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.util.ContaminationUtil;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
@ -103,7 +104,7 @@ public class ToxicBlock extends BlockFluidClassic {
|
||||
|
||||
//Library.applyRadiation(entity, 2 * 60 * 20, 50, 60 * 20, 35);
|
||||
|
||||
Library.applyRadData(entity, 1.0F);
|
||||
ContaminationUtil.applyRadData(entity, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import com.hbm.saveddata.RadiationSavedData;
|
||||
import com.hbm.tileentity.machine.TileEntityGeiger;
|
||||
import com.hbm.util.ContaminationUtil;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
@ -10,11 +10,9 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
public class GeigerCounter extends BlockContainer {
|
||||
|
||||
@ -123,15 +121,7 @@ public class GeigerCounter extends BlockContainer {
|
||||
} else if(!player.isSneaking())
|
||||
{
|
||||
world.playSoundAtEntity(player, "hbm:item.techBoop", 1.0F, 1.0F);
|
||||
|
||||
double eRad = ((int)(player.getEntityData().getFloat("hfr_radiation") * 10)) / 10D;
|
||||
|
||||
RadiationSavedData data = RadiationSavedData.getData(player.worldObj);
|
||||
Chunk chunk = world.getChunkFromBlockCoords((int)player.posX, (int)player.posZ);
|
||||
double rads = ((int)(data.getRadNumFromCoord(chunk.xPosition, chunk.zPosition) * 10)) / 10D;
|
||||
|
||||
player.addChatMessage(new ChatComponentText("Current chunk radiation: " + rads + " RAD/s"));
|
||||
player.addChatMessage(new ChatComponentText("Player contamination: " + eRad + " RAD"));
|
||||
ContaminationUtil.printGeigerData(player);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@ -2,42 +2,24 @@ package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.explosion.ExplosionNukeGeneric;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineGenerator;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class MachineGenerator extends BlockContainer {
|
||||
|
||||
private final Random field_149933_a = new Random();
|
||||
private Random rand;
|
||||
private static boolean keepInventory;
|
||||
public class MachineGenerator extends Block {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconSide;
|
||||
|
||||
public MachineGenerator(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
rand = new Random();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -56,96 +38,6 @@ public class MachineGenerator extends BlockContainer {
|
||||
@Override
|
||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
|
||||
{
|
||||
return Item.getItemFromBlock(ModBlocks.machine_reactor_small);
|
||||
}
|
||||
|
||||
@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())
|
||||
{
|
||||
TileEntityMachineGenerator entity = (TileEntityMachineGenerator) world.getTileEntity(x, y, z);
|
||||
if(entity != null)
|
||||
{
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_machine_generator, world, x, y, z);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
||||
return new TileEntityMachineGenerator();
|
||||
}
|
||||
|
||||
@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)
|
||||
{
|
||||
TileEntityMachineGenerator tileentityfurnace = (TileEntityMachineGenerator)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 onBlockDestroyedByExplosion(World p_149723_1_, int p_149723_2_, int p_149723_3_, int p_149723_4_, Explosion p_149723_5_)
|
||||
{
|
||||
if (!p_149723_1_.isRemote)
|
||||
{
|
||||
TileEntityMachineGenerator entity = (TileEntityMachineGenerator) p_149723_1_.getTileEntity(p_149723_2_, p_149723_3_, p_149723_4_);
|
||||
if(entity != null && entity.isLoaded)
|
||||
{
|
||||
p_149723_1_.createExplosion(null, p_149723_2_, p_149723_3_, p_149723_4_, 18.0F, true);
|
||||
ExplosionNukeGeneric.wasteNoSchrab(p_149723_1_, p_149723_2_, p_149723_3_, p_149723_4_, 35);
|
||||
p_149723_1_.setBlock(p_149723_2_, p_149723_3_, p_149723_4_, Blocks.flowing_lava);
|
||||
}
|
||||
}
|
||||
return ModItems.circuit_targeting_tier3;
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,8 +8,8 @@ import com.hbm.entity.mob.ai.EntityAINuclearCreeperSwell;
|
||||
import com.hbm.explosion.ExplosionParticle;
|
||||
import com.hbm.explosion.ExplosionParticleB;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.lib.ModDamageSource;
|
||||
import com.hbm.util.ContaminationUtil;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@ -38,17 +38,11 @@ import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityNuclearCreeper extends EntityMob {
|
||||
/**
|
||||
* Time when this creeper was last in an active state (Messed up code here, probably causes creeper animation to go
|
||||
* weird)
|
||||
*/
|
||||
|
||||
private int lastActiveTime;
|
||||
/** The amount of time since the creeper was close enough to the player to ignite */
|
||||
private int timeSinceIgnited;
|
||||
private int fuseTime = 75;
|
||||
/** Explosion radius for this creeper. */
|
||||
private int explosionRadius = 20;
|
||||
private static final String __OBFID = "CL_00001684";
|
||||
|
||||
public EntityNuclearCreeper(World p_i1733_1_)
|
||||
{
|
||||
@ -82,28 +76,19 @@ public class EntityNuclearCreeper extends EntityMob {
|
||||
|
||||
return super.attackEntityFrom(source, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the newer Entity AI code should be run
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean isAIEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of iterations PathFinder.getSafePoint will execute before giving up.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int getMaxSafePointTries()
|
||||
{
|
||||
return this.getAttackTarget() == null ? 3 : 3 + (int)(this.getHealth() - 1.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the mob is falling. Calculates and applies fall damage.
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected void fall(float p_70069_1_)
|
||||
{
|
||||
@ -124,10 +109,7 @@ public class EntityNuclearCreeper extends EntityMob {
|
||||
this.dataWatcher.addObject(17, Byte.valueOf((byte)0));
|
||||
this.dataWatcher.addObject(18, Byte.valueOf((byte)0));
|
||||
}
|
||||
|
||||
/**
|
||||
* (abstract) Protected helper method to write subclass entity data to NBT.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound p_70014_1_)
|
||||
{
|
||||
@ -142,10 +124,7 @@ public class EntityNuclearCreeper extends EntityMob {
|
||||
p_70014_1_.setByte("ExplosionRadius", (byte)this.explosionRadius);
|
||||
p_70014_1_.setBoolean("ignited", this.func_146078_ca());
|
||||
}
|
||||
|
||||
/**
|
||||
* (abstract) Protected helper method to read subclass entity data from NBT.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound p_70037_1_)
|
||||
{
|
||||
@ -167,10 +146,7 @@ public class EntityNuclearCreeper extends EntityMob {
|
||||
this.func_146079_cb();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to update the entity's position/logic.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
@ -214,7 +190,7 @@ public class EntityNuclearCreeper extends EntityMob {
|
||||
|
||||
for(Entity e : list)
|
||||
if(!(e instanceof EntityNuclearCreeper))
|
||||
Library.applyRadData(e, 0.25F);
|
||||
ContaminationUtil.applyRadData(e, 0.25F);
|
||||
|
||||
super.onUpdate();
|
||||
|
||||
@ -223,28 +199,19 @@ public class EntityNuclearCreeper extends EntityMob {
|
||||
this.heal(1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sound this mob makes when it is hurt.
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "mob.creeper.say";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sound this mob makes on death.
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected String getDeathSound()
|
||||
{
|
||||
return "mob.creeper.death";
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the mob's health reaches 0.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onDeath(DamageSource p_70645_1_)
|
||||
{
|
||||
@ -296,18 +263,12 @@ public class EntityNuclearCreeper extends EntityMob {
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the creeper is powered by a lightning bolt.
|
||||
*/
|
||||
|
||||
public boolean getPowered()
|
||||
{
|
||||
return this.dataWatcher.getWatchableObjectByte(17) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Params: (Float)Render tick. Returns the intensity of the creeper's flash when it is ignited.
|
||||
*/
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getCreeperFlashIntensity(float p_70831_1_)
|
||||
{
|
||||
@ -319,36 +280,24 @@ public class EntityNuclearCreeper extends EntityMob {
|
||||
{
|
||||
return Item.getItemFromBlock(Blocks.tnt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current state of creeper, -1 is idle, 1 is 'in fuse'
|
||||
*/
|
||||
|
||||
public int getCreeperState()
|
||||
{
|
||||
return this.dataWatcher.getWatchableObjectByte(16);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the state of creeper, -1 to idle and 1 to be 'in fuse'
|
||||
*/
|
||||
|
||||
public void setCreeperState(int p_70829_1_)
|
||||
{
|
||||
this.dataWatcher.updateObject(16, Byte.valueOf((byte)p_70829_1_));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a lightning bolt hits the entity.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onStruckByLightning(EntityLightningBolt p_70077_1_)
|
||||
{
|
||||
super.onStruckByLightning(p_70077_1_);
|
||||
this.dataWatcher.updateObject(17, Byte.valueOf((byte)1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected boolean interact(EntityPlayer p_70085_1_)
|
||||
{
|
||||
@ -378,7 +327,6 @@ public class EntityNuclearCreeper extends EntityMob {
|
||||
|
||||
if (this.getPowered())
|
||||
{
|
||||
//this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(this.explosionRadius * 2), flag);
|
||||
this.explosionRadius *= 3;
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ package com.hbm.explosion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.util.ContaminationUtil;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
@ -37,7 +37,7 @@ public class ExplosionHurtUtil {
|
||||
double interpolation = 1 - (dist / radius);
|
||||
float rad = (float) (outer + (inner - outer) * interpolation);
|
||||
|
||||
Library.applyRadData(entity, rad);
|
||||
ContaminationUtil.applyRadData(entity, rad);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package com.hbm.handler;
|
||||
|
||||
import com.hbm.items.tool.IItemAbility;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.util.ContaminationUtil;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.Entity;
|
||||
@ -28,7 +28,7 @@ public abstract class WeaponAbility {
|
||||
@Override
|
||||
public void onHit(World world, EntityPlayer player, Entity victim, IItemAbility tool) {
|
||||
|
||||
Library.applyRadData(victim, rad);
|
||||
ContaminationUtil.applyRadData(victim, rad);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -20,6 +20,11 @@ private TileEntityMachinePress nukeBoy;
|
||||
private int maxBurn;
|
||||
|
||||
public ContainerMachinePress(InventoryPlayer invPlayer, TileEntityMachinePress tedf) {
|
||||
|
||||
power = 0;
|
||||
progress = 0;
|
||||
burnTime = 0;
|
||||
maxBurn = 0;
|
||||
|
||||
nukeBoy = tedf;
|
||||
|
||||
|
||||
@ -4,8 +4,8 @@ import java.util.List;
|
||||
|
||||
import com.hbm.explosion.ExplosionLarge;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.util.ContaminationUtil;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@ -84,14 +84,14 @@ public class ItemEnergy extends Item {
|
||||
player.heal(4F);
|
||||
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 30 * 20, 1));
|
||||
player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 30 * 20, 1));
|
||||
Library.applyRadDirect(player, 5.0F);
|
||||
ContaminationUtil.applyRadDirect(player, 5.0F);
|
||||
}
|
||||
if(this == ModItems.bottle_cherry)
|
||||
{
|
||||
player.heal(6F);
|
||||
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 30 * 20, 0));
|
||||
player.addPotionEffect(new PotionEffect(Potion.jump.id, 30 * 20, 2));
|
||||
Library.applyRadDirect(player, 5.0F);
|
||||
ContaminationUtil.applyRadDirect(player, 5.0F);
|
||||
}
|
||||
if(this == ModItems.bottle_quantum)
|
||||
{
|
||||
@ -99,7 +99,7 @@ public class ItemEnergy extends Item {
|
||||
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 30 * 20, 1));
|
||||
player.addPotionEffect(new PotionEffect(Potion.resistance.id, 30 * 20, 2));
|
||||
player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 30 * 20, 1));
|
||||
Library.applyRadDirect(player, 15.0F);
|
||||
ContaminationUtil.applyRadDirect(player, 15.0F);
|
||||
}
|
||||
if(this == ModItems.bottle2_korl)
|
||||
{
|
||||
@ -136,7 +136,7 @@ public class ItemEnergy extends Item {
|
||||
player.addPotionEffect(new PotionEffect(Potion.resistance.id, 120 * 20, 2));
|
||||
player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 120 * 20, 2));
|
||||
player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 120 * 20, 1));
|
||||
Library.applyRadDirect(player, 5.0F);
|
||||
ContaminationUtil.applyRadDirect(player, 5.0F);
|
||||
}
|
||||
if(this == ModItems.bottle_rad)
|
||||
{
|
||||
@ -146,7 +146,7 @@ public class ItemEnergy extends Item {
|
||||
player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 120 * 20, 0));
|
||||
player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 120 * 20, 4));
|
||||
player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 120 * 20, 1));
|
||||
Library.applyRadDirect(player, 15.0F);
|
||||
ContaminationUtil.applyRadDirect(player, 15.0F);
|
||||
}
|
||||
if(this == ModItems.bottle2_sunset)
|
||||
{
|
||||
|
||||
@ -4,7 +4,7 @@ import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.bomb.BlockCrashedBomb;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.util.ContaminationUtil;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@ -49,7 +49,7 @@ public class ItemCell extends Item {
|
||||
}
|
||||
}
|
||||
|
||||
Library.applyRadDirect(player, 50F);
|
||||
ContaminationUtil.applyRadDirect(player, 50F);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ import java.util.List;
|
||||
|
||||
import com.hbm.handler.ArmorUtil;
|
||||
import com.hbm.inventory.BreederRecipes;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.util.ContaminationUtil;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@ -47,7 +47,7 @@ public class ItemRadioactive extends ItemCustomLore {
|
||||
if (entity instanceof EntityLivingBase) {
|
||||
|
||||
if(this.radiation > 0)
|
||||
Library.applyRadData(entity, this.radiation * mod / 20F);
|
||||
ContaminationUtil.applyRadData(entity, this.radiation * mod / 20F);
|
||||
|
||||
if(this.fire)
|
||||
entity.setFire(5);
|
||||
|
||||
@ -7,13 +7,13 @@ import java.util.Random;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.saveddata.RadiationSavedData;
|
||||
import com.hbm.util.ContaminationUtil;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
@ -105,15 +105,7 @@ public class ItemGeigerCounter extends Item {
|
||||
|
||||
if(!world.isRemote) {
|
||||
world.playSoundAtEntity(player, "hbm:item.techBoop", 1.0F, 1.0F);
|
||||
|
||||
double eRad = ((int)(player.getEntityData().getFloat("hfr_radiation") * 10)) / 10D;
|
||||
|
||||
RadiationSavedData data = RadiationSavedData.getData(player.worldObj);
|
||||
Chunk chunk = world.getChunkFromBlockCoords((int)player.posX, (int)player.posZ);
|
||||
double rads = ((int)(data.getRadNumFromCoord(chunk.xPosition, chunk.zPosition) * 10)) / 10D;
|
||||
|
||||
player.addChatMessage(new ChatComponentText("Current chunk radiation: " + rads + " RAD/s"));
|
||||
player.addChatMessage(new ChatComponentText("Player contamination: " + eRad + " RAD"));
|
||||
ContaminationUtil.printGeigerData(player);
|
||||
}
|
||||
|
||||
return stack;
|
||||
|
||||
@ -12,7 +12,6 @@ import com.hbm.calc.UnionOfTileEntitiesAndBooleansForFluids;
|
||||
import com.hbm.entity.mob.EntityHunterChopper;
|
||||
import com.hbm.entity.projectile.EntityChopperMine;
|
||||
import com.hbm.handler.FluidTypeHandler.FluidType;
|
||||
import com.hbm.handler.HazmatRegistry;
|
||||
import com.hbm.interfaces.IConductor;
|
||||
import com.hbm.interfaces.IConsumer;
|
||||
import com.hbm.interfaces.IFluidAcceptor;
|
||||
@ -22,7 +21,6 @@ import com.hbm.interfaces.ISource;
|
||||
import com.hbm.interfaces.Spaghetti;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.tool.ItemToolAbilityPower;
|
||||
import com.hbm.potion.HbmPotion;
|
||||
import com.hbm.tileentity.TileEntityProxyInventory;
|
||||
import com.hbm.tileentity.conductor.TileEntityCable;
|
||||
import com.hbm.tileentity.conductor.TileEntityCableSwitch;
|
||||
@ -84,39 +82,6 @@ public class Library {
|
||||
//currently unused
|
||||
public static List<String> superuser = new ArrayList<String>();
|
||||
|
||||
public static void applyRadData(Entity e, float f) {
|
||||
|
||||
if(!(e instanceof EntityLivingBase))
|
||||
return;
|
||||
|
||||
EntityLivingBase entity = (EntityLivingBase)e;
|
||||
|
||||
if(entity.isPotionActive(HbmPotion.mutation))
|
||||
return;
|
||||
|
||||
if(entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer)entity;
|
||||
|
||||
float koeff = 5.0F;
|
||||
f *= (float) Math.pow(koeff, -HazmatRegistry.instance.getResistance(player));
|
||||
}
|
||||
|
||||
float rad = e.getEntityData().getFloat("hfr_radiation");
|
||||
e.getEntityData().setFloat("hfr_radiation", Math.min(rad + f, 2500));
|
||||
}
|
||||
|
||||
public static void applyRadDirect(Entity e, float f) {
|
||||
|
||||
if(!(e instanceof EntityLivingBase))
|
||||
return;
|
||||
|
||||
if(((EntityLivingBase)e).isPotionActive(HbmPotion.mutation))
|
||||
return;
|
||||
|
||||
float rad = e.getEntityData().getFloat("hfr_radiation");
|
||||
e.getEntityData().setFloat("hfr_radiation", Math.min(rad + f, 2500));
|
||||
}
|
||||
|
||||
public static boolean checkForHeld(EntityPlayer player, Item item) {
|
||||
|
||||
if(player.getHeldItem() == null)
|
||||
|
||||
@ -52,6 +52,11 @@ public class CraftingManager {
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.circuit_targeting_tier4, 1), new Object[] { "CPC", 'C', ModItems.circuit_gold, 'P', "dustLapis" }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.circuit_targeting_tier5, 1), new Object[] { "CPC", 'C', ModItems.circuit_schrabidium, 'P', "dustDiamond" }));
|
||||
GameRegistry.addRecipe(new ItemStack(ModItems.circuit_targeting_tier6, 1), new Object[] { "P", "D", "C", 'C', ModItems.circuit_targeting_tier5, 'D', ModItems.battery_potatos, 'P', ModItems.powder_spark_mix });
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.circuit_aluminium, 2), new Object[] { ModItems.circuit_targeting_tier1 });
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.circuit_copper, 2), new Object[] { ModItems.circuit_targeting_tier2 });
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.circuit_red_copper, 2), new Object[] { ModItems.circuit_targeting_tier3 });
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.circuit_gold, 2), new Object[] { ModItems.circuit_targeting_tier4 });
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.circuit_schrabidium, 2), new Object[] { ModItems.circuit_targeting_tier5 });
|
||||
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Items.gunpowder, 3), new Object[] { "sulfur", "saltpeter", Items.coal }));
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Items.gunpowder, 3), new Object[] { "sulfur", "saltpeter", new ItemStack(Items.coal, 1, 1) }));
|
||||
@ -1097,8 +1102,8 @@ public class CraftingManager {
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getEmptyBattery(ModItems.battery_schrabidium), new Object[] { " A ", "PNP", "PSP", 'A', ModItems.wire_schrabidium, 'P', "plateSchrabidium", 'S', "dustSchrabidium", 'N', ModItems.powder_neptunium }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getEmptyBattery(ModItems.battery_schrabidium), new Object[] { " A ", "PSP", "PNP", 'A', ModItems.wire_schrabidium, 'P', "plateSchrabidium", 'S', "dustSchrabidium", 'N', ModItems.powder_neptunium }));
|
||||
GameRegistry.addRecipe(ItemBattery.getEmptyBattery(ModItems.battery_spark), new Object[] { " A ", "PSP", "PSP", 'A', ModItems.wire_magnetized_tungsten, 'P', ModItems.plate_dineutronium, 'S', ModItems.powder_spark_mix });
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getEmptyBattery(ModItems.battery_trixite), new Object[] { " A ", "PSP", "PTP", 'A', ModItems.wire_aluminium, 'P', "plateAluminum", 'S', ModItems.powder_spark_mix, 'T', ModItems.crystal_trixite }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getEmptyBattery(ModItems.battery_trixite), new Object[] { " A ", "PTP", "PSP", 'A', ModItems.wire_aluminium, 'P', "plateAluminum", 'S', ModItems.powder_spark_mix, 'T', ModItems.crystal_trixite }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getEmptyBattery(ModItems.battery_trixite), new Object[] { " A ", "PSP", "PTP", 'A', ModItems.wire_aluminium, 'P', "plateAluminum", 'S', ModItems.powder_power, 'T', ModItems.crystal_trixite }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getEmptyBattery(ModItems.battery_trixite), new Object[] { " A ", "PTP", "PSP", 'A', ModItems.wire_aluminium, 'P', "plateAluminum", 'S', ModItems.powder_power, 'T', ModItems.crystal_trixite }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getFullBattery(ModItems.energy_core), new Object[] { "PCW", "TRD", "PCW", 'P', ModItems.plate_advanced_alloy, 'C', ModItems.coil_advanced_alloy, 'W', ModItems.wire_advanced_alloy, 'R', ModItems.cell_tritium, 'D', ModItems.cell_deuterium, 'T', "ingotTungsten" }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getFullBattery(ModItems.energy_core), new Object[] { "PCW", "TDR", "PCW", 'P', ModItems.plate_advanced_alloy, 'C', ModItems.coil_advanced_alloy, 'W', ModItems.wire_advanced_alloy, 'R', ModItems.cell_tritium, 'D', ModItems.cell_deuterium, 'T', "ingotTungsten" }));
|
||||
|
||||
|
||||
@ -573,6 +573,7 @@ public class MainRegistry
|
||||
GameRegistry.registerTileEntity(TileEntityProxyCombo.class, "tileentity_proxy_combo");
|
||||
GameRegistry.registerTileEntity(TileEntityMicrowave.class, "tileentity_microwave");
|
||||
GameRegistry.registerTileEntity(TileEntityMachineMiniRTG.class, "tileentity_mini_rtg");
|
||||
GameRegistry.registerTileEntity(TileEntityITER.class, "tileentity_iter");
|
||||
|
||||
EntityRegistry.registerModEntity(EntityRocket.class, "entity_rocket", 0, this, 250, 1, true);
|
||||
EntityRegistry.registerModEntity(EntityNukeExplosion.class, "entity_nuke_explosion", 1, this, 250, 1, true);
|
||||
|
||||
@ -25,6 +25,7 @@ import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.RadSurveyPacket;
|
||||
import com.hbm.saveddata.AuxSavedData;
|
||||
import com.hbm.saveddata.RadiationSavedData;
|
||||
import com.hbm.util.ContaminationUtil;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
@ -241,13 +242,13 @@ public class ModEventHandler
|
||||
rad = MainRegistry.hellRad;
|
||||
|
||||
if(rad > 0) {
|
||||
Library.applyRadData(entity, rad / 2);
|
||||
ContaminationUtil.applyRadData(entity, rad / 2);
|
||||
}
|
||||
|
||||
if(entity.worldObj.isRaining() && MainRegistry.cont > 0 && AuxSavedData.getThunder(entity.worldObj) > 0 &&
|
||||
entity.worldObj.canBlockSeeTheSky(MathHelper.floor_double(entity.posX), MathHelper.floor_double(entity.posY), MathHelper.floor_double(entity.posZ))) {
|
||||
|
||||
Library.applyRadData(entity, MainRegistry.cont * 0.005F);
|
||||
ContaminationUtil.applyRadData(entity, MainRegistry.cont * 0.005F);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,9 +7,9 @@ import com.hbm.blocks.bomb.BlockTaint;
|
||||
import com.hbm.entity.mob.EntityTaintCrab;
|
||||
import com.hbm.entity.mob.EntityTaintedCreeper;
|
||||
import com.hbm.explosion.ExplosionLarge;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.lib.ModDamageSource;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.util.ContaminationUtil;
|
||||
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@ -108,7 +108,7 @@ public class HbmPotion extends Potion {
|
||||
}
|
||||
if(this == radiation) {
|
||||
|
||||
Library.applyRadData(entity, (float)(level + 1F) * 0.05F);
|
||||
ContaminationUtil.applyRadData(entity, (float)(level + 1F) * 0.05F);
|
||||
}
|
||||
if(this == radaway) {
|
||||
|
||||
|
||||
113
src/main/java/com/hbm/util/ContaminationUtil.java
Normal file
113
src/main/java/com/hbm/util/ContaminationUtil.java
Normal file
@ -0,0 +1,113 @@
|
||||
package com.hbm.util;
|
||||
|
||||
import com.hbm.handler.HazmatRegistry;
|
||||
import com.hbm.potion.HbmPotion;
|
||||
import com.hbm.saveddata.RadiationSavedData;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
public class ContaminationUtil {
|
||||
|
||||
/**
|
||||
* Calculates how much radiation can be applied to this entity by calculating resistance
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public static float calculateRadiationMod(EntityLivingBase entity) {
|
||||
|
||||
if(entity.isPotionActive(HbmPotion.mutation))
|
||||
return 0;
|
||||
|
||||
if(entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer)entity;
|
||||
|
||||
float koeff = 5.0F;
|
||||
return (float) Math.pow(koeff, -HazmatRegistry.instance.getResistance(player));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static void applyRadData(Entity e, float f) {
|
||||
|
||||
if(!(e instanceof EntityLivingBase))
|
||||
return;
|
||||
|
||||
EntityLivingBase entity = (EntityLivingBase)e;
|
||||
|
||||
f *= calculateRadiationMod(entity);
|
||||
|
||||
float rad = e.getEntityData().getFloat("hfr_radiation");
|
||||
e.getEntityData().setFloat("hfr_radiation", Math.min(rad + f, 2500));
|
||||
}
|
||||
|
||||
public static void applyRadDirect(Entity e, float f) {
|
||||
|
||||
if(!(e instanceof EntityLivingBase))
|
||||
return;
|
||||
|
||||
if(((EntityLivingBase)e).isPotionActive(HbmPotion.mutation))
|
||||
return;
|
||||
|
||||
float rad = e.getEntityData().getFloat("hfr_radiation");
|
||||
e.getEntityData().setFloat("hfr_radiation", Math.min(rad + f, 2500));
|
||||
}
|
||||
|
||||
public static void printGeigerData(EntityPlayer player) {
|
||||
|
||||
World world = player.worldObj;
|
||||
|
||||
double eRad = ((int)(player.getEntityData().getFloat("hfr_radiation") * 10)) / 10D;
|
||||
|
||||
RadiationSavedData data = RadiationSavedData.getData(player.worldObj);
|
||||
Chunk chunk = world.getChunkFromBlockCoords((int)player.posX, (int)player.posZ);
|
||||
double rads = ((int)(data.getRadNumFromCoord(chunk.xPosition, chunk.zPosition) * 10)) / 10D;
|
||||
|
||||
double res = 100.0D - ((int)(ContaminationUtil.calculateRadiationMod(player) * 10000)) / 100D;
|
||||
double resKoeff = ((int)(HazmatRegistry.instance.getResistance(player) * 100)) / 100D;
|
||||
|
||||
String chunkPrefix = "";
|
||||
String radPrefix = "";
|
||||
String resPrefix = "" + EnumChatFormatting.WHITE;
|
||||
|
||||
if(rads == 0)
|
||||
chunkPrefix += EnumChatFormatting.GREEN;
|
||||
else if(rads < 1)
|
||||
chunkPrefix += EnumChatFormatting.YELLOW;
|
||||
else if(rads < 10)
|
||||
chunkPrefix += EnumChatFormatting.GOLD;
|
||||
else if(rads < 100)
|
||||
chunkPrefix += EnumChatFormatting.RED;
|
||||
else if(rads < 1000)
|
||||
chunkPrefix += EnumChatFormatting.DARK_RED;
|
||||
else
|
||||
chunkPrefix += EnumChatFormatting.DARK_GRAY;
|
||||
|
||||
if(eRad < 200)
|
||||
radPrefix += EnumChatFormatting.GREEN;
|
||||
else if(eRad < 400)
|
||||
radPrefix += EnumChatFormatting.YELLOW;
|
||||
else if(eRad < 600)
|
||||
radPrefix += EnumChatFormatting.GOLD;
|
||||
else if(eRad < 800)
|
||||
radPrefix += EnumChatFormatting.RED;
|
||||
else if(eRad < 1000)
|
||||
radPrefix += EnumChatFormatting.DARK_RED;
|
||||
else
|
||||
radPrefix += EnumChatFormatting.DARK_GRAY;
|
||||
|
||||
if(resKoeff > 0)
|
||||
resPrefix += EnumChatFormatting.GREEN;
|
||||
|
||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "===== ☢ GEIGER COUNTER ☢ ====="));
|
||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Current chunk radiation: " + chunkPrefix + rads + " RAD/s"));
|
||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Player contamination: " + radPrefix + eRad + " RAD"));
|
||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Player resistance: " + resPrefix + res + "% (" + resKoeff + ")"));
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user