mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
entity specific contamination, rad improvements
This commit is contained in:
parent
6e6685fa98
commit
f55293ceb1
@ -205,7 +205,7 @@ public class TestEventTester extends Block {
|
|||||||
|
|
||||||
Chunk chunk = worldObj.getChunkFromBlockCoords(x1, z1);
|
Chunk chunk = worldObj.getChunkFromBlockCoords(x1, z1);
|
||||||
|
|
||||||
data.setRadForCoord(chunk.xPosition, chunk.zPosition, 1000000);
|
data.setRadForCoord(chunk.xPosition, chunk.zPosition, 100);
|
||||||
|
|
||||||
System.out.println(data.getRadNumFromCoord(chunk.xPosition, chunk.zPosition));
|
System.out.println(data.getRadNumFromCoord(chunk.xPosition, chunk.zPosition));
|
||||||
}
|
}
|
||||||
@ -230,7 +230,7 @@ public class TestEventTester extends Block {
|
|||||||
|
|
||||||
if(worldObj.getBlock(x1, y1 - 1, z1) == ModBlocks.block_steel) {
|
if(worldObj.getBlock(x1, y1 - 1, z1) == ModBlocks.block_steel) {
|
||||||
|
|
||||||
System.out.println(data.count);
|
System.out.println(data.contamination.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(worldObj.getBlock(x1, y1 - 1, z1) == ModBlocks.block_uranium) {
|
if(worldObj.getBlock(x1, y1 - 1, z1) == ModBlocks.block_uranium) {
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import com.hbm.items.gear.JetpackRegular;
|
|||||||
import com.hbm.items.gear.JetpackVectorized;
|
import com.hbm.items.gear.JetpackVectorized;
|
||||||
import com.hbm.lib.ModDamageSource;
|
import com.hbm.lib.ModDamageSource;
|
||||||
import com.hbm.potion.HbmPotion;
|
import com.hbm.potion.HbmPotion;
|
||||||
|
import com.hbm.saveddata.RadEntitySavedData;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
@ -215,6 +216,9 @@ public class ItemSyringe extends Item {
|
|||||||
if (!world.isRemote)
|
if (!world.isRemote)
|
||||||
{
|
{
|
||||||
player.removePotionEffect(HbmPotion.radiation.id);
|
player.removePotionEffect(HbmPotion.radiation.id);
|
||||||
|
|
||||||
|
RadEntitySavedData entityData = RadEntitySavedData.getData(world);
|
||||||
|
entityData.setRadForEntity(player, 0);
|
||||||
|
|
||||||
stack.stackSize--;
|
stack.stackSize--;
|
||||||
world.playSoundAtEntity(player, "hbm:item.radaway", 1.0F, 1.0F);
|
world.playSoundAtEntity(player, "hbm:item.radaway", 1.0F, 1.0F);
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import com.hbm.lib.RefStrings;
|
|||||||
import com.hbm.packet.PacketDispatcher;
|
import com.hbm.packet.PacketDispatcher;
|
||||||
import com.hbm.packet.RadSurveyPacket;
|
import com.hbm.packet.RadSurveyPacket;
|
||||||
import com.hbm.potion.HbmPotion;
|
import com.hbm.potion.HbmPotion;
|
||||||
|
import com.hbm.saveddata.RadEntitySavedData;
|
||||||
import com.hbm.saveddata.RadiationSavedData;
|
import com.hbm.saveddata.RadiationSavedData;
|
||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
@ -101,25 +102,18 @@ public class ModEventHandler
|
|||||||
|
|
||||||
if(event.world != null && !event.world.isRemote) {
|
if(event.world != null && !event.world.isRemote) {
|
||||||
if(!event.world.playerEntities.isEmpty()) {
|
if(!event.world.playerEntities.isEmpty()) {
|
||||||
|
|
||||||
|
RadiationSavedData data = RadiationSavedData.getData(event.world);
|
||||||
|
RadEntitySavedData eData = RadEntitySavedData.getData(event.world);
|
||||||
|
|
||||||
for(Object o : event.world.playerEntities) {
|
for(Object o : event.world.playerEntities) {
|
||||||
|
|
||||||
EntityPlayer player = (EntityPlayer)o;
|
EntityPlayer player = (EntityPlayer)o;
|
||||||
|
PacketDispatcher.wrapper.sendTo(new RadSurveyPacket(eData.getRadFromEntity(player)), (EntityPlayerMP) player);
|
||||||
RadiationSavedData data = RadiationSavedData.getData(player.worldObj);
|
}
|
||||||
Chunk chunk = player.worldObj.getChunkFromBlockCoords((int)player.posX, (int)player.posZ);
|
|
||||||
|
if(event.world.getTotalWorldTime() % 20 == 0) {
|
||||||
float[] rads = new float[9];
|
data.updateSystem();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,6 +158,8 @@ public class ModEventHandler
|
|||||||
|
|
||||||
for(Object e : oList) {
|
for(Object e : oList) {
|
||||||
if(e instanceof EntityLivingBase) {
|
if(e instanceof EntityLivingBase) {
|
||||||
|
|
||||||
|
//effect for radiation
|
||||||
EntityLivingBase entity = (EntityLivingBase) e;
|
EntityLivingBase entity = (EntityLivingBase) e;
|
||||||
PotionEffect effect = entity.getActivePotionEffect(HbmPotion.radiation);
|
PotionEffect effect = entity.getActivePotionEffect(HbmPotion.radiation);
|
||||||
|
|
||||||
@ -235,7 +231,9 @@ public class ModEventHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//radiation end
|
||||||
|
|
||||||
|
//effect for tainted heart
|
||||||
if(entity.isPotionActive(HbmPotion.mutation) && !entity.isDead && entity.getHealth() > 0) {
|
if(entity.isPotionActive(HbmPotion.mutation) && !entity.isDead && entity.getHealth() > 0) {
|
||||||
|
|
||||||
if(event.world.rand.nextInt(300) == 0)
|
if(event.world.rand.nextInt(300) == 0)
|
||||||
@ -269,6 +267,22 @@ public class ModEventHandler
|
|||||||
if(entity.isPotionActive(Potion.moveSlowdown))
|
if(entity.isPotionActive(Potion.moveSlowdown))
|
||||||
entity.removePotionEffect(Potion.moveSlowdown.id);
|
entity.removePotionEffect(Potion.moveSlowdown.id);
|
||||||
}
|
}
|
||||||
|
//effect end
|
||||||
|
|
||||||
|
//apply radiation
|
||||||
|
|
||||||
|
if(event.world.getTotalWorldTime() % 20 == 0) {
|
||||||
|
|
||||||
|
RadiationSavedData chunkData = RadiationSavedData.getData(event.world);
|
||||||
|
RadEntitySavedData entityData = RadEntitySavedData.getData(event.world);
|
||||||
|
|
||||||
|
Chunk chunk = entity.worldObj.getChunkFromBlockCoords((int)entity.posX, (int)entity.posZ);
|
||||||
|
float rad = chunkData.getRadNumFromCoord(chunk.xPosition, chunk.zPosition);
|
||||||
|
|
||||||
|
if(rad > 0) {
|
||||||
|
entityData.setRadForEntity(entity, entityData.getRadFromEntity(entity) + rad * 0.5F);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import com.hbm.items.ModItems;
|
|||||||
import com.hbm.items.tool.ItemGeigerCounter;
|
import com.hbm.items.tool.ItemGeigerCounter;
|
||||||
import com.hbm.lib.Library;
|
import com.hbm.lib.Library;
|
||||||
import com.hbm.render.misc.RenderScreenOverlay;
|
import com.hbm.render.misc.RenderScreenOverlay;
|
||||||
|
import com.hbm.saveddata.RadEntitySavedData;
|
||||||
import com.hbm.saveddata.RadiationSavedData;
|
import com.hbm.saveddata.RadiationSavedData;
|
||||||
import com.hbm.sound.MovingSoundChopper;
|
import com.hbm.sound.MovingSoundChopper;
|
||||||
import com.hbm.sound.MovingSoundChopperMine;
|
import com.hbm.sound.MovingSoundChopperMine;
|
||||||
@ -48,9 +49,8 @@ public class ModEventHandlerClient {
|
|||||||
|
|
||||||
////TEST
|
////TEST
|
||||||
|
|
||||||
RadiationSavedData data = RadiationSavedData.getData(player.worldObj);
|
RadEntitySavedData data = RadEntitySavedData.getData(player.worldObj);
|
||||||
Chunk chunk = player.worldObj.getChunkFromBlockCoords((int)player.posX, (int)player.posZ);
|
rads = data.getRadFromEntity(player);
|
||||||
rads = data.getRadNumFromCoord(chunk.xPosition, chunk.zPosition);
|
|
||||||
|
|
||||||
////TEST
|
////TEST
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.hbm.packet;
|
|||||||
|
|
||||||
import com.hbm.interfaces.IConsumer;
|
import com.hbm.interfaces.IConsumer;
|
||||||
import com.hbm.interfaces.ISource;
|
import com.hbm.interfaces.ISource;
|
||||||
|
import com.hbm.saveddata.RadEntitySavedData;
|
||||||
import com.hbm.saveddata.RadiationSavedData;
|
import com.hbm.saveddata.RadiationSavedData;
|
||||||
import com.hbm.tileentity.machine.TileEntityMachinePress;
|
import com.hbm.tileentity.machine.TileEntityMachinePress;
|
||||||
|
|
||||||
@ -20,14 +21,14 @@ import net.minecraft.world.chunk.Chunk;
|
|||||||
|
|
||||||
public class RadSurveyPacket implements IMessage {
|
public class RadSurveyPacket implements IMessage {
|
||||||
|
|
||||||
float[] rad;
|
float rad;
|
||||||
|
|
||||||
public RadSurveyPacket()
|
public RadSurveyPacket()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RadSurveyPacket(float[] rad)
|
public RadSurveyPacket(float rad)
|
||||||
{
|
{
|
||||||
this.rad = rad;
|
this.rad = rad;
|
||||||
}
|
}
|
||||||
@ -35,17 +36,13 @@ public class RadSurveyPacket implements IMessage {
|
|||||||
@Override
|
@Override
|
||||||
public void fromBytes(ByteBuf buf) {
|
public void fromBytes(ByteBuf buf) {
|
||||||
|
|
||||||
rad = new float[9];
|
rad = buf.readFloat();
|
||||||
|
|
||||||
for(int i = 0; i < 9; i++)
|
|
||||||
rad[i] = buf.readFloat();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toBytes(ByteBuf buf) {
|
public void toBytes(ByteBuf buf) {
|
||||||
|
|
||||||
for(int i = 0; i < 9; i++)
|
buf.writeFloat(rad);
|
||||||
buf.writeFloat(rad[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Handler implements IMessageHandler<RadSurveyPacket, IMessage> {
|
public static class Handler implements IMessageHandler<RadSurveyPacket, IMessage> {
|
||||||
@ -56,23 +53,9 @@ public class RadSurveyPacket implements IMessage {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||||
RadiationSavedData data = RadiationSavedData.getData(player.worldObj);
|
RadEntitySavedData data = RadEntitySavedData.getData(player.worldObj);
|
||||||
data.jettisonData();
|
|
||||||
|
data.setRadForEntity(player, m.rad);
|
||||||
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) { }
|
} catch (Exception x) { }
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -14,7 +14,11 @@ public class RenderScreenOverlay {
|
|||||||
|
|
||||||
private static final ResourceLocation misc = new ResourceLocation(RefStrings.MODID + ":textures/misc/overlay_misc.png");
|
private static final ResourceLocation misc = new ResourceLocation(RefStrings.MODID + ":textures/misc/overlay_misc.png");
|
||||||
|
|
||||||
public static void renderRadCounter(ScaledResolution resolution, float radiation, Gui gui) {
|
private static long lastSurvey;
|
||||||
|
private static float prevResult;
|
||||||
|
private static float lastResult;
|
||||||
|
|
||||||
|
public static void renderRadCounter(ScaledResolution resolution, float in, Gui gui) {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
@ -23,14 +27,24 @@ public class RenderScreenOverlay {
|
|||||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||||
|
|
||||||
|
float radiation = 0;
|
||||||
|
|
||||||
|
radiation = lastResult - prevResult;
|
||||||
|
|
||||||
|
if(System.currentTimeMillis() >= lastSurvey + 1000) {
|
||||||
|
lastSurvey = System.currentTimeMillis();
|
||||||
|
prevResult = lastResult;
|
||||||
|
lastResult = in;
|
||||||
|
}
|
||||||
|
|
||||||
int length = 74;
|
int length = 74;
|
||||||
int maxRad = 1000;
|
int maxRad = 1000;
|
||||||
|
|
||||||
int bar = getScaled(radiation, maxRad, 74);
|
int bar = getScaled(in, maxRad, 74);
|
||||||
|
|
||||||
if(radiation >= 1 && radiation <= 999)
|
//if(radiation >= 1 && radiation <= 999)
|
||||||
bar -= (2 + Minecraft.getMinecraft().theWorld.rand.nextInt(5));
|
// bar -= (1 + Minecraft.getMinecraft().theWorld.rand.nextInt(3));
|
||||||
|
|
||||||
int posX = 16;
|
int posX = 16;
|
||||||
int posY = resolution.getScaledHeight() - 18 - 2;
|
int posY = resolution.getScaledHeight() - 18 - 2;
|
||||||
|
|||||||
106
com/hbm/saveddata/RadEntitySavedData.java
Normal file
106
com/hbm/saveddata/RadEntitySavedData.java
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
package com.hbm.saveddata;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.WorldSavedData;
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
|
||||||
|
public class RadEntitySavedData extends WorldSavedData {
|
||||||
|
|
||||||
|
public HashMap<Integer, Float> contaminated = new HashMap();
|
||||||
|
|
||||||
|
private World worldObj;
|
||||||
|
|
||||||
|
public RadEntitySavedData(String p_i2141_1_) {
|
||||||
|
super(p_i2141_1_);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RadEntitySavedData(World p_i1678_1_)
|
||||||
|
{
|
||||||
|
super("radentity");
|
||||||
|
this.worldObj = p_i1678_1_;
|
||||||
|
this.markDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getRadFromEntity(Entity e) {
|
||||||
|
|
||||||
|
Iterator it = contaminated.entrySet().iterator();
|
||||||
|
|
||||||
|
while(it.hasNext()) {
|
||||||
|
|
||||||
|
Map.Entry pair = (Map.Entry)it.next();
|
||||||
|
|
||||||
|
if(((Integer)pair.getKey()).intValue() == e.getEntityId()) {
|
||||||
|
return (Float)pair.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRadForEntity(Entity e, float rad) {
|
||||||
|
|
||||||
|
Iterator it = contaminated.entrySet().iterator();
|
||||||
|
|
||||||
|
while(it.hasNext()) {
|
||||||
|
|
||||||
|
Map.Entry pair = (Map.Entry)it.next();
|
||||||
|
|
||||||
|
if(((Integer)pair.getKey()).intValue() == e.getEntityId()) {
|
||||||
|
pair.setValue(rad);
|
||||||
|
|
||||||
|
this.markDirty();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contaminated.put(e.getEntityId(), rad);
|
||||||
|
|
||||||
|
this.markDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound nbt) {
|
||||||
|
int count = nbt.getInteger("contCount");
|
||||||
|
|
||||||
|
for(int i = 0; i < count; i++) {
|
||||||
|
|
||||||
|
contaminated.put(nbt.getInteger("entID_" + i), nbt.getFloat("cont_" + i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
|
nbt.setInteger("contCount", contaminated.entrySet().size());
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (Map.Entry<Integer, Float> entry : contaminated.entrySet()) {
|
||||||
|
|
||||||
|
nbt.setInteger("entID_" + i, entry.getKey());
|
||||||
|
nbt.setFloat("cont_" + i, entry.getValue());
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RadEntitySavedData getData(World worldObj) {
|
||||||
|
|
||||||
|
RadEntitySavedData data = (RadEntitySavedData)worldObj.perWorldStorage.loadData(RadEntitySavedData.class, "radentity");
|
||||||
|
if(data == null) {
|
||||||
|
worldObj.perWorldStorage.setData("radentity", new RadEntitySavedData(worldObj));
|
||||||
|
|
||||||
|
data = (RadEntitySavedData)worldObj.perWorldStorage.loadData(RadEntitySavedData.class, "radentity");
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -6,11 +6,10 @@ import java.util.List;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldSavedData;
|
import net.minecraft.world.WorldSavedData;
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
|
||||||
public class RadiationSavedData extends WorldSavedData {
|
public class RadiationSavedData extends WorldSavedData {
|
||||||
|
|
||||||
public int count;
|
|
||||||
|
|
||||||
public List<RadiationSaveStructure> contamination = new ArrayList();
|
public List<RadiationSaveStructure> contamination = new ArrayList();
|
||||||
|
|
||||||
private World worldObj;
|
private World worldObj;
|
||||||
@ -34,19 +33,19 @@ public class RadiationSavedData extends WorldSavedData {
|
|||||||
public void createEntry(int x, int y, float rad) {
|
public void createEntry(int x, int y, float rad) {
|
||||||
|
|
||||||
contamination.add(new RadiationSaveStructure(x, y, rad));
|
contamination.add(new RadiationSaveStructure(x, y, rad));
|
||||||
count = contamination.size();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteEntry(RadiationSaveStructure struct) {
|
public void deleteEntry(RadiationSaveStructure struct) {
|
||||||
|
|
||||||
contamination.remove(struct);
|
contamination.remove(struct);
|
||||||
count = contamination.size();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void jettisonData() {
|
public void jettisonData() {
|
||||||
|
|
||||||
contamination.clear();
|
contamination.clear();
|
||||||
count = contamination.size();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRadForCoord(int x, int y, float radiation) {
|
public void setRadForCoord(int x, int y, float radiation) {
|
||||||
@ -63,10 +62,10 @@ public class RadiationSavedData extends WorldSavedData {
|
|||||||
|
|
||||||
entry = new RadiationSaveStructure(x, y, radiation);
|
entry = new RadiationSaveStructure(x, y, radiation);
|
||||||
contamination.add(entry);
|
contamination.add(entry);
|
||||||
count = contamination.size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.radiation = radiation;
|
entry.radiation = radiation;
|
||||||
|
this.markDirty();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,6 +96,13 @@ public class RadiationSavedData extends WorldSavedData {
|
|||||||
for(RadiationSaveStructure struct : tempList) {
|
for(RadiationSaveStructure struct : tempList) {
|
||||||
|
|
||||||
if(struct.radiation != 0) {
|
if(struct.radiation != 0) {
|
||||||
|
|
||||||
|
struct.radiation *= 0.999F;
|
||||||
|
struct.radiation -= 0.5F;
|
||||||
|
|
||||||
|
if(struct.radiation <= 0) {
|
||||||
|
struct.radiation = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(struct.radiation > 1) {
|
if(struct.radiation > 1) {
|
||||||
|
|
||||||
@ -111,7 +117,7 @@ public class RadiationSavedData extends WorldSavedData {
|
|||||||
rads[6] = getRadNumFromCoord(struct.chunkX + 1, struct.chunkY - 1);
|
rads[6] = getRadNumFromCoord(struct.chunkX + 1, struct.chunkY - 1);
|
||||||
rads[7] = getRadNumFromCoord(struct.chunkX + 1, struct.chunkY);
|
rads[7] = getRadNumFromCoord(struct.chunkX + 1, struct.chunkY);
|
||||||
rads[8] = getRadNumFromCoord(struct.chunkX, struct.chunkY);
|
rads[8] = getRadNumFromCoord(struct.chunkX, struct.chunkY);
|
||||||
|
|
||||||
float main = 0.6F;
|
float main = 0.6F;
|
||||||
float side = 0.075F;
|
float side = 0.075F;
|
||||||
float corner = 0.025F;
|
float corner = 0.025F;
|
||||||
@ -133,19 +139,18 @@ public class RadiationSavedData extends WorldSavedData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
count = contamination.size();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbt) {
|
public void readFromNBT(NBTTagCompound nbt) {
|
||||||
count = nbt.getInteger("radCount");
|
int count = nbt.getInteger("radCount");
|
||||||
|
|
||||||
for(int i = 0; i < count; i++) {
|
for(int i = 0; i < count; i++) {
|
||||||
RadiationSaveStructure struct = new RadiationSaveStructure();
|
RadiationSaveStructure struct = new RadiationSaveStructure();
|
||||||
struct.readFromNBT(nbt, i);
|
struct.readFromNBT(nbt, i);
|
||||||
|
|
||||||
createEntry(struct.chunkX, struct.chunkY, struct.radiation);
|
contamination.add(struct);
|
||||||
//contamination.add(struct);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,5 +174,19 @@ public class RadiationSavedData extends WorldSavedData {
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void incrementRad(World worldObj, int x, int z, float rad, float maxRad) {
|
||||||
|
|
||||||
|
RadiationSavedData data = getData(worldObj);
|
||||||
|
|
||||||
|
Chunk chunk = worldObj.getChunkFromBlockCoords(x, z);
|
||||||
|
|
||||||
|
float r = data.getRadNumFromCoord(chunk.xPosition, chunk.zPosition);
|
||||||
|
|
||||||
|
if(r < maxRad) {
|
||||||
|
|
||||||
|
data.setRadForCoord(chunk.xPosition, chunk.zPosition, r + rad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user