An absolute ton of cleanup.

This commit is contained in:
BallOfEnergy 2025-01-04 01:04:57 -06:00
parent c25f4c8d60
commit ec6cd544d2
32 changed files with 789 additions and 1150 deletions

View File

@ -80,7 +80,7 @@ public class CommandPacketInfo extends CommandBase {
if (totalCnt != 0) if (totalCnt != 0)
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "% Remaining to process: " + BobMathUtil.roundDecimal(((double) PacketThreading.threadPool.getQueue().size() / totalCnt) * 100, 2) + "%")); sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "% Remaining to process: " + BobMathUtil.roundDecimal(((double) PacketThreading.threadPool.getQueue().size() / totalCnt) * 100, 2) + "%"));
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Time spent waiting on thread(s) last tick: " + BobMathUtil.roundDecimal(TimeUnit.NANOSECONDS.convert(PacketThreading.nanoTimeWaited, TimeUnit.MILLISECONDS), 4) + "ms")); sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Time spent waiting on thread(s) last tick: " + BobMathUtil.roundDecimal(TimeUnit.MILLISECONDS.convert(PacketThreading.nanoTimeWaited, TimeUnit.NANOSECONDS), 4) + "ms"));
return; return;
} }
} }

View File

@ -30,7 +30,7 @@ public class EntityMissileAntiBallistic extends EntityThrowableInterp implements
public Entity tracking; public Entity tracking;
public double velocity; public double velocity;
protected int activationTimer; protected int activationTimer;
public static double baseSpeed = 1.5D; public static double baseSpeed = 1.5D;
public EntityMissileAntiBallistic(World world) { public EntityMissileAntiBallistic(World world) {
@ -60,21 +60,21 @@ public class EntityMissileAntiBallistic extends EntityThrowableInterp implements
super.onUpdate(); super.onUpdate();
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
if(velocity < 6) velocity += 0.1; if(velocity < 6) velocity += 0.1;
if(activationTimer < 40) { if(activationTimer < 40) {
activationTimer++; activationTimer++;
motionY = baseSpeed; motionY = baseSpeed;
} else { } else {
Entity prevTracking = this.tracking; Entity prevTracking = this.tracking;
if(this.tracking == null || this.tracking.isDead) this.targetMissile(); if(this.tracking == null || this.tracking.isDead) this.targetMissile();
if(prevTracking == null && this.tracking != null) { if(prevTracking == null && this.tracking != null) {
ExplosionLarge.spawnShock(worldObj, posX, posY, posZ, 24, 3F); ExplosionLarge.spawnShock(worldObj, posX, posY, posZ, 24, 3F);
} }
if(this.tracking != null) { if(this.tracking != null) {
this.aimAtTarget(); this.aimAtTarget();
} else { } else {
@ -83,15 +83,20 @@ public class EntityMissileAntiBallistic extends EntityThrowableInterp implements
} }
loadNeighboringChunks((int) Math.floor(posX / 16), (int) Math.floor(posZ / 16)); loadNeighboringChunks((int) Math.floor(posX / 16), (int) Math.floor(posZ / 16));
if(this.posY > 2000 && (this.tracking == null || this.tracking.isDead)) this.setDead(); if(this.posY > 2000 && (this.tracking == null || this.tracking.isDead)) this.setDead();
} else { } else {
Vec3 vec = Vec3.createVectorHelper(motionX, motionY, motionZ).normalize(); Vec3 vec = Vec3.createVectorHelper(motionX, motionY, motionZ).normalize();
MainRegistry.proxy.particleControl(posX - vec.xCoord, posY - vec.yCoord, posZ - vec.zCoord, 2); NBTTagCompound data = new NBTTagCompound();
data.setString("type", "ABMContrail");
data.setDouble("posX", posX - vec.xCoord);
data.setDouble("posY", posY - vec.yCoord);
data.setDouble("posZ", posZ - vec.zCoord);
MainRegistry.proxy.effectNT(data);
} }
float f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); float f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
for(this.rotationPitch = (float) (Math.atan2(this.motionY, f2) * 180.0D / Math.PI) - 90; this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F); for(this.rotationPitch = (float) (Math.atan2(this.motionY, f2) * 180.0D / Math.PI) - 90; this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F);
@ -102,33 +107,33 @@ public class EntityMissileAntiBallistic extends EntityThrowableInterp implements
/** Detects and caches nearby EntityMissileBaseNT */ /** Detects and caches nearby EntityMissileBaseNT */
protected void targetMissile() { protected void targetMissile() {
Entity closest = null; Entity closest = null;
double dist = 1_000; double dist = 1_000;
for(Entity e : TileEntityMachineRadarNT.matchingEntities) { for(Entity e : TileEntityMachineRadarNT.matchingEntities) {
if(e.dimension != this.dimension) continue; if(e.dimension != this.dimension) continue;
if(!(e instanceof EntityMissileBaseNT)) continue; //can only lock onto missiles if(!(e instanceof EntityMissileBaseNT)) continue; //can only lock onto missiles
if(e instanceof EntityMissileStealth) continue; //cannot lack onto missiles with stealth coating if(e instanceof EntityMissileStealth) continue; //cannot lack onto missiles with stealth coating
Vec3 vec = Vec3.createVectorHelper(e.posX - posX, e.posY - posY, e.posZ - posZ); Vec3 vec = Vec3.createVectorHelper(e.posX - posX, e.posY - posY, e.posZ - posZ);
if(vec.lengthVector() < dist) { if(vec.lengthVector() < dist) {
closest = e; closest = e;
} }
} }
this.tracking = closest; this.tracking = closest;
} }
/** Predictive targeting system */ /** Predictive targeting system */
protected void aimAtTarget() { protected void aimAtTarget() {
Vec3 delta = Vec3.createVectorHelper(tracking.posX - posX, tracking.posY - posY, tracking.posZ - posZ); Vec3 delta = Vec3.createVectorHelper(tracking.posX - posX, tracking.posY - posY, tracking.posZ - posZ);
double intercept = delta.lengthVector() / (this.baseSpeed * this.velocity); double intercept = delta.lengthVector() / (this.baseSpeed * this.velocity);
Vec3 predicted = Vec3.createVectorHelper(tracking.posX + (tracking.posX - tracking.lastTickPosX) * intercept, tracking.posY + (tracking.posY - tracking.lastTickPosY) * intercept, tracking.posZ + (tracking.posZ - tracking.lastTickPosZ) * intercept); Vec3 predicted = Vec3.createVectorHelper(tracking.posX + (tracking.posX - tracking.lastTickPosX) * intercept, tracking.posY + (tracking.posY - tracking.lastTickPosY) * intercept, tracking.posZ + (tracking.posZ - tracking.lastTickPosZ) * intercept);
Vec3 motion = Vec3.createVectorHelper(predicted.xCoord - posX, predicted.yCoord - posY, predicted.zCoord - posZ).normalize(); Vec3 motion = Vec3.createVectorHelper(predicted.xCoord - posX, predicted.yCoord - posY, predicted.zCoord - posZ).normalize();
if(delta.lengthVector() < 10 && activationTimer >= 40) { if(delta.lengthVector() < 10 && activationTimer >= 40) {
this.setDead(); this.setDead();
ExplosionLarge.explode(worldObj, posX, posY, posZ, 15F, true, false, false); ExplosionLarge.explode(worldObj, posX, posY, posZ, 15F, true, false, false);
@ -168,13 +173,13 @@ public class EntityMissileAntiBallistic extends EntityThrowableInterp implements
super.readEntityFromNBT(nbt); super.readEntityFromNBT(nbt);
this.velocity = nbt.getDouble("veloc"); this.velocity = nbt.getDouble("veloc");
} }
@Override @Override
public void writeEntityToNBT(NBTTagCompound nbt) { public void writeEntityToNBT(NBTTagCompound nbt) {
super.writeEntityToNBT(nbt); super.writeEntityToNBT(nbt);
nbt.setDouble("veloc", this.velocity); nbt.setDouble("veloc", this.velocity);
} }
@Override @Override
public void init(Ticket ticket) { public void init(Ticket ticket) {
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
@ -197,7 +202,7 @@ public class EntityMissileAntiBallistic extends EntityThrowableInterp implements
public void loadNeighboringChunks(int newChunkX, int newChunkZ) { public void loadNeighboringChunks(int newChunkX, int newChunkZ) {
if(!worldObj.isRemote && loaderTicket != null) { if(!worldObj.isRemote && loaderTicket != null) {
clearChunkLoader(); clearChunkLoader();
loadedChunks.clear(); loadedChunks.clear();
@ -208,13 +213,13 @@ public class EntityMissileAntiBallistic extends EntityThrowableInterp implements
} }
} }
} }
@Override @Override
public void setDead() { public void setDead() {
super.setDead(); super.setDead();
this.clearChunkLoader(); this.clearChunkLoader();
} }
public void clearChunkLoader() { public void clearChunkLoader() {
if(!worldObj.isRemote && loaderTicket != null) { if(!worldObj.isRemote && loaderTicket != null) {
for(ChunkCoordIntPair chunk : loadedChunks) { for(ChunkCoordIntPair chunk : loadedChunks) {

View File

@ -78,7 +78,7 @@ public class EntityMissileCustom extends EntityMissileBaseNT implements IChunkLo
ExplosionLarge.spawnShrapnelShower(worldObj, posX, posY, posZ, motionX, motionY, motionZ, 15, 0.075); ExplosionLarge.spawnShrapnelShower(worldObj, posX, posY, posZ, motionX, motionY, motionZ, 15, 0.075);
} }
} }
@Override @Override
public void onUpdate() { public void onUpdate() {
@ -87,11 +87,11 @@ public class EntityMissileCustom extends EntityMissileBaseNT implements IChunkLo
if(type != null && type.updateCustom != null) { if(type != null && type.updateCustom != null) {
type.updateCustom.accept(this); type.updateCustom.accept(this);
} }
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
if(this.hasPropulsion()) this.fuel -= this.consumption; if(this.hasPropulsion()) this.fuel -= this.consumption;
} }
super.onUpdate(); super.onUpdate();
} }
@ -131,7 +131,7 @@ public class EntityMissileCustom extends EntityMissileBaseNT implements IChunkLo
nbt.setInteger("fins", this.dataWatcher.getWatchableObjectInt(11)); nbt.setInteger("fins", this.dataWatcher.getWatchableObjectInt(11));
nbt.setInteger("thruster", this.dataWatcher.getWatchableObjectInt(12)); nbt.setInteger("thruster", this.dataWatcher.getWatchableObjectInt(12));
} }
@Override @Override
protected void spawnContrail() { protected void spawnContrail() {
@ -148,7 +148,16 @@ public class EntityMissileCustom extends EntityMissileBaseNT implements IChunkLo
case XENON: break; case XENON: break;
} }
if(!smoke.isEmpty()) for(int i = 0; i < velocity; i++) MainRegistry.proxy.spawnParticle(posX - v.xCoord * i, posY - v.yCoord * i, posZ - v.zCoord * i, smoke, null); if(!smoke.isEmpty()) {
for (int i = 0; i < velocity; i++) {
NBTTagCompound data = new NBTTagCompound();
data.setDouble("posX", posX - v.xCoord * i);
data.setDouble("posY", posY - v.yCoord * i);
data.setDouble("posZ", posZ - v.zCoord * i);
data.setString("type", smoke);
MainRegistry.proxy.effectNT(data);
}
}
} }
@Override @Override
@ -158,7 +167,7 @@ public class EntityMissileCustom extends EntityMissileBaseNT implements IChunkLo
WarheadType type = (WarheadType) part.attributes[0]; WarheadType type = (WarheadType) part.attributes[0];
float strength = (Float) part.attributes[1]; float strength = (Float) part.attributes[1];
if(type.impactCustom != null) { if(type.impactCustom != null) {
type.impactCustom.accept(this); type.impactCustom.accept(this);
return; return;
@ -244,7 +253,7 @@ public class EntityMissileCustom extends EntityMissileBaseNT implements IChunkLo
if(top == PartSize.SIZE_15 && bottom == PartSize.SIZE_15) return "radar.target.custom15"; if(top == PartSize.SIZE_15 && bottom == PartSize.SIZE_15) return "radar.target.custom15";
if(top == PartSize.SIZE_15 && bottom == PartSize.SIZE_20) return "radar.target.custom1520"; if(top == PartSize.SIZE_15 && bottom == PartSize.SIZE_20) return "radar.target.custom1520";
if(top == PartSize.SIZE_20 && bottom == PartSize.SIZE_20) return "radar.target.custom20"; if(top == PartSize.SIZE_20 && bottom == PartSize.SIZE_20) return "radar.target.custom20";
return "radar.target.custom"; return "radar.target.custom";
} }
@ -260,7 +269,7 @@ public class EntityMissileCustom extends EntityMissileBaseNT implements IChunkLo
if(top == PartSize.SIZE_15 && bottom == PartSize.SIZE_15) return IRadarDetectableNT.TIER15; if(top == PartSize.SIZE_15 && bottom == PartSize.SIZE_15) return IRadarDetectableNT.TIER15;
if(top == PartSize.SIZE_15 && bottom == PartSize.SIZE_20) return IRadarDetectableNT.TIER15_20; if(top == PartSize.SIZE_15 && bottom == PartSize.SIZE_20) return IRadarDetectableNT.TIER15_20;
if(top == PartSize.SIZE_20 && bottom == PartSize.SIZE_20) return IRadarDetectableNT.TIER20; if(top == PartSize.SIZE_20 && bottom == PartSize.SIZE_20) return IRadarDetectableNT.TIER20;
return IRadarDetectableNT.TIER1; return IRadarDetectableNT.TIER1;
} }

View File

@ -28,14 +28,14 @@ import net.minecraftforge.common.ForgeChunkManager.Type;
public class EntityArtilleryRocket extends EntityThrowableInterp implements IChunkLoader, IRadarDetectable { public class EntityArtilleryRocket extends EntityThrowableInterp implements IChunkLoader, IRadarDetectable {
private Ticket loaderTicket; private Ticket loaderTicket;
//TODO: find satisfying solution for when an entity is unloaded and reloaded, possibly a custom entity lookup using persistent UUIDs //TODO: find satisfying solution for when an entity is unloaded and reloaded, possibly a custom entity lookup using persistent UUIDs
public Entity targetEntity = null; public Entity targetEntity = null;
public Vec3 lastTargetPos; public Vec3 lastTargetPos;
public IRocketTargetingBehavior targeting; public IRocketTargetingBehavior targeting;
public IRocketSteeringBehavior steering; public IRocketSteeringBehavior steering;
public EntityArtilleryRocket(World world) { public EntityArtilleryRocket(World world) {
super(world); super(world);
this.ignoreFrustumCheck = true; this.ignoreFrustumCheck = true;
@ -49,18 +49,18 @@ public class EntityArtilleryRocket extends EntityThrowableInterp implements IChu
init(ForgeChunkManager.requestTicket(MainRegistry.instance, worldObj, Type.ENTITY)); init(ForgeChunkManager.requestTicket(MainRegistry.instance, worldObj, Type.ENTITY));
this.dataWatcher.addObject(10, new Integer(0)); this.dataWatcher.addObject(10, new Integer(0));
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public boolean isInRangeToRenderDist(double distance) { public boolean isInRangeToRenderDist(double distance) {
return true; return true;
} }
public EntityArtilleryRocket setType(int type) { public EntityArtilleryRocket setType(int type) {
this.dataWatcher.updateObject(10, type); this.dataWatcher.updateObject(10, type);
return this; return this;
} }
public HIMARSRocket getType() { public HIMARSRocket getType() {
try { try {
return ItemAmmoHIMARS.itemTypes[this.dataWatcher.getWatchableObjectInt(10)]; return ItemAmmoHIMARS.itemTypes[this.dataWatcher.getWatchableObjectInt(10)];
@ -68,35 +68,35 @@ public class EntityArtilleryRocket extends EntityThrowableInterp implements IChu
return ItemAmmoHIMARS.itemTypes[0]; return ItemAmmoHIMARS.itemTypes[0];
} }
} }
public EntityArtilleryRocket setTarget(Entity target) { public EntityArtilleryRocket setTarget(Entity target) {
this.targetEntity = target; this.targetEntity = target;
setTarget(target.posX, target.posY - target.yOffset + target.height / 2D, target.posZ); setTarget(target.posX, target.posY - target.yOffset + target.height / 2D, target.posZ);
return this; return this;
} }
public EntityArtilleryRocket setTarget(double x, double y, double z) { public EntityArtilleryRocket setTarget(double x, double y, double z) {
this.lastTargetPos = Vec3.createVectorHelper(x, y, z); this.lastTargetPos = Vec3.createVectorHelper(x, y, z);
return this; return this;
} }
public Vec3 getLastTarget() { public Vec3 getLastTarget() {
return this.lastTargetPos; return this.lastTargetPos;
} }
@Override @Override
public void onUpdate() { public void onUpdate() {
if(worldObj.isRemote) { if(worldObj.isRemote) {
this.lastTickPosX = this.posX; this.lastTickPosX = this.posX;
this.lastTickPosY = this.posY; this.lastTickPosY = this.posY;
this.lastTickPosZ = this.posZ; this.lastTickPosZ = this.posZ;
} }
super.onUpdate(); super.onUpdate();
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
/*if(this.targetEntity == null) { /*if(this.targetEntity == null) {
Vec3 delta = Vec3.createVectorHelper(this.lastTargetPos.xCoord - this.posX, this.lastTargetPos.yCoord - this.posY, this.lastTargetPos.zCoord - this.posZ); Vec3 delta = Vec3.createVectorHelper(this.lastTargetPos.xCoord - this.posX, this.lastTargetPos.yCoord - this.posY, this.lastTargetPos.zCoord - this.posZ);
if(delta.lengthVector() <= 15D) { if(delta.lengthVector() <= 15D) {
@ -104,26 +104,35 @@ public class EntityArtilleryRocket extends EntityThrowableInterp implements IChu
this.steering = null; this.steering = null;
} }
}*/ }*/
if(this.targeting != null && this.targetEntity != null) this.targeting.recalculateTargetPosition(this, this.targetEntity); if(this.targeting != null && this.targetEntity != null) this.targeting.recalculateTargetPosition(this, this.targetEntity);
if(this.steering != null) this.steering.adjustCourse(this, 25D, 15D); if(this.steering != null) this.steering.adjustCourse(this, 25D, 15D);
loadNeighboringChunks((int)Math.floor(posX / 16D), (int)Math.floor(posZ / 16D)); loadNeighboringChunks((int)Math.floor(posX / 16D), (int)Math.floor(posZ / 16D));
this.getType().onUpdate(this); this.getType().onUpdate(this);
} else { } else {
Vec3 v = Vec3.createVectorHelper(lastTickPosX - posX, lastTickPosY - posY, lastTickPosZ - posZ); Vec3 v = Vec3.createVectorHelper(lastTickPosX - posX, lastTickPosY - posY, lastTickPosZ - posZ);
double velocity = v.lengthVector(); double velocity = v.lengthVector();
v = v.normalize(); v = v.normalize();
int offset = 6; int offset = 6;
if(velocity > 1) for(int i = offset; i < velocity + offset; i++) MainRegistry.proxy.spawnParticle(posX + v.xCoord * i, posY + v.yCoord * i, posZ + v.zCoord * i, "exKerosene", null); if(velocity > 1) {
for (int i = offset; i < velocity + offset; i++) {
NBTTagCompound data = new NBTTagCompound();
data.setDouble("posX", posX + v.xCoord * i);
data.setDouble("posY", posY + v.yCoord * i);
data.setDouble("posZ", posZ + v.zCoord * i);
data.setString("type", "exKerosene");
MainRegistry.proxy.effectNT(data);
}
}
} }
} }
@Override @Override
protected void onImpact(MovingObjectPosition mop) { protected void onImpact(MovingObjectPosition mop) {
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
this.getType().onImpact(this, mop); this.getType().onImpact(this, mop);
} }
@ -145,7 +154,7 @@ public class EntityArtilleryRocket extends EntityThrowableInterp implements IChu
public void loadNeighboringChunks(int newChunkX, int newChunkZ) { public void loadNeighboringChunks(int newChunkX, int newChunkZ) {
if(!worldObj.isRemote && loaderTicket != null) { if(!worldObj.isRemote && loaderTicket != null) {
clearChunkLoader(); clearChunkLoader();
loadedChunks.clear(); loadedChunks.clear();
@ -157,12 +166,12 @@ public class EntityArtilleryRocket extends EntityThrowableInterp implements IChu
} }
} }
} }
public void killAndClear() { public void killAndClear() {
this.setDead(); this.setDead();
this.clearChunkLoader(); this.clearChunkLoader();
} }
public void clearChunkLoader() { public void clearChunkLoader() {
if(!worldObj.isRemote && loaderTicket != null) { if(!worldObj.isRemote && loaderTicket != null) {
for(ChunkCoordIntPair chunk : loadedChunks) { for(ChunkCoordIntPair chunk : loadedChunks) {
@ -174,15 +183,15 @@ public class EntityArtilleryRocket extends EntityThrowableInterp implements IChu
@Override @Override
public void writeEntityToNBT(NBTTagCompound nbt) { public void writeEntityToNBT(NBTTagCompound nbt) {
super.writeEntityToNBT(nbt); super.writeEntityToNBT(nbt);
if(this.lastTargetPos == null) { if(this.lastTargetPos == null) {
this.lastTargetPos = Vec3.createVectorHelper(posX, posY, posZ); this.lastTargetPos = Vec3.createVectorHelper(posX, posY, posZ);
} }
nbt.setDouble("targetX", this.lastTargetPos.xCoord); nbt.setDouble("targetX", this.lastTargetPos.xCoord);
nbt.setDouble("targetY", this.lastTargetPos.yCoord); nbt.setDouble("targetY", this.lastTargetPos.yCoord);
nbt.setDouble("targetZ", this.lastTargetPos.zCoord); nbt.setDouble("targetZ", this.lastTargetPos.zCoord);
nbt.setInteger("type", this.dataWatcher.getWatchableObjectInt(10)); nbt.setInteger("type", this.dataWatcher.getWatchableObjectInt(10));
} }
@ -191,7 +200,7 @@ public class EntityArtilleryRocket extends EntityThrowableInterp implements IChu
super.readEntityFromNBT(nbt); super.readEntityFromNBT(nbt);
this.lastTargetPos = Vec3.createVectorHelper(nbt.getDouble("targetX"), nbt.getDouble("targetY"), nbt.getDouble("targetZ")); this.lastTargetPos = Vec3.createVectorHelper(nbt.getDouble("targetX"), nbt.getDouble("targetY"), nbt.getDouble("targetZ"));
this.dataWatcher.updateObject(10, nbt.getInteger("type")); this.dataWatcher.updateObject(10, nbt.getInteger("type"));
} }
@ -209,7 +218,7 @@ public class EntityArtilleryRocket extends EntityThrowableInterp implements IChu
public RadarTargetType getTargetType() { public RadarTargetType getTargetType() {
return RadarTargetType.ARTILLERY; return RadarTargetType.ARTILLERY;
} }
@Override @Override
public int approachNum() { public int approachNum() {
return 0; // return 0; //

View File

@ -24,7 +24,7 @@ public class EntityWaterSplash extends EntityThrowable {
public EntityWaterSplash(World p_i1775_1_, double p_i1775_2_, double p_i1775_4_, double p_i1775_6_) { public EntityWaterSplash(World p_i1775_1_, double p_i1775_2_, double p_i1775_4_, double p_i1775_6_) {
super(p_i1775_1_, p_i1775_2_, p_i1775_4_, p_i1775_6_); super(p_i1775_1_, p_i1775_2_, p_i1775_4_, p_i1775_6_);
} }
@Override @Override
public void onUpdate() { public void onUpdate() {
super.onUpdate(); super.onUpdate();
@ -35,8 +35,12 @@ public class EntityWaterSplash extends EntityThrowable {
this.setDead(); this.setDead();
} }
} else { } else {
NBTTagCompound data = new NBTTagCompound();
MainRegistry.proxy.particleControl(posX, posY, posZ, 0); data.setString("type", "waterSplash");
data.setDouble("posX", posX);
data.setDouble("posY", posY);
data.setDouble("posZ", posZ);
MainRegistry.proxy.effectNT(data);
} }
} }

View File

@ -16,6 +16,7 @@ import com.hbm.handler.HbmKeybinds.EnumKeybind;
import com.hbm.handler.pollution.PollutionHandler; import com.hbm.handler.pollution.PollutionHandler;
import com.hbm.handler.pollution.PollutionHandler.PollutionType; import com.hbm.handler.pollution.PollutionHandler.PollutionType;
import com.hbm.handler.radiation.ChunkRadiationManager; import com.hbm.handler.radiation.ChunkRadiationManager;
import com.hbm.handler.threading.PacketThreading;
import com.hbm.interfaces.IArmorModDash; import com.hbm.interfaces.IArmorModDash;
import com.hbm.items.armor.ArmorFSB; import com.hbm.items.armor.ArmorFSB;
import com.hbm.items.weapon.sedna.factory.ConfettiUtil; import com.hbm.items.weapon.sedna.factory.ConfettiUtil;
@ -81,7 +82,6 @@ public class EntityEffectHandler {
if(entity instanceof EntityPlayerMP) { if(entity instanceof EntityPlayerMP) {
HbmLivingProps props = HbmLivingProps.getData(entity); HbmLivingProps props = HbmLivingProps.getData(entity);
HbmPlayerProps pprps = HbmPlayerProps.getData((EntityPlayerMP) entity); HbmPlayerProps pprps = HbmPlayerProps.getData((EntityPlayerMP) entity);
ByteBuf buf = PooledByteBufAllocator.DEFAULT.buffer();
if(pprps.shield < pprps.getEffectiveMaxShield() && entity.ticksExisted > pprps.lastDamage + 60) { if(pprps.shield < pprps.getEffectiveMaxShield() && entity.ticksExisted > pprps.lastDamage + 60) {
int tsd = entity.ticksExisted - (pprps.lastDamage + 60); int tsd = entity.ticksExisted - (pprps.lastDamage + 60);
@ -91,10 +91,7 @@ public class EntityEffectHandler {
if(pprps.shield > pprps.getEffectiveMaxShield()) if(pprps.shield > pprps.getEffectiveMaxShield())
pprps.shield = pprps.getEffectiveMaxShield(); pprps.shield = pprps.getEffectiveMaxShield();
props.serialize(buf); PacketThreading.createSendToThreadedPacket(new ExtPropPacket(props, pprps), (EntityPlayerMP) entity);
pprps.serialize(buf);
PacketDispatcher.wrapper.sendTo(new ExtPropPacket(buf), (EntityPlayerMP) entity);
buf.release();
} }
if(!entity.worldObj.isRemote) { if(!entity.worldObj.isRemote) {

View File

@ -5,12 +5,14 @@ import java.util.Map.Entry;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.config.RadiationConfig; import com.hbm.config.RadiationConfig;
import com.hbm.main.MainRegistry;
import com.hbm.packet.PacketDispatcher; import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toclient.AuxParticlePacket;
import com.hbm.packet.toclient.AuxParticlePacketNT;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -25,31 +27,31 @@ import net.minecraftforge.event.world.WorldEvent;
* @author hbm * @author hbm
*/ */
public class ChunkRadiationHandlerSimple extends ChunkRadiationHandler { public class ChunkRadiationHandlerSimple extends ChunkRadiationHandler {
private HashMap<World, SimpleRadiationPerWorld> perWorld = new HashMap(); private HashMap<World, SimpleRadiationPerWorld> perWorld = new HashMap();
private static final float maxRad = 100_000F; private static final float maxRad = 100_000F;
@Override @Override
public float getRadiation(World world, int x, int y, int z) { public float getRadiation(World world, int x, int y, int z) {
SimpleRadiationPerWorld radWorld = perWorld.get(world); SimpleRadiationPerWorld radWorld = perWorld.get(world);
if(radWorld != null) { if(radWorld != null) {
ChunkCoordIntPair coords = new ChunkCoordIntPair(x >> 4, z >> 4); ChunkCoordIntPair coords = new ChunkCoordIntPair(x >> 4, z >> 4);
Float rad = radWorld.radiation.get(coords); Float rad = radWorld.radiation.get(coords);
return rad == null ? 0F : MathHelper.clamp_float(rad, 0, maxRad); return rad == null ? 0F : MathHelper.clamp_float(rad, 0, maxRad);
} }
return 0; return 0;
} }
@Override @Override
public void setRadiation(World world, int x, int y, int z, float rad) { public void setRadiation(World world, int x, int y, int z, float rad) {
SimpleRadiationPerWorld radWorld = perWorld.get(world); SimpleRadiationPerWorld radWorld = perWorld.get(world);
if(radWorld != null) { if(radWorld != null) {
if(world.blockExists(x, 0, z)) { if(world.blockExists(x, 0, z)) {
ChunkCoordIntPair coords = new ChunkCoordIntPair(x >> 4, z >> 4); ChunkCoordIntPair coords = new ChunkCoordIntPair(x >> 4, z >> 4);
radWorld.radiation.put(coords, MathHelper.clamp_float(rad, 0, maxRad)); radWorld.radiation.put(coords, MathHelper.clamp_float(rad, 0, maxRad));
world.getChunkFromBlockCoords(x, z).isModified = true; world.getChunkFromBlockCoords(x, z).isModified = true;
@ -69,28 +71,28 @@ public class ChunkRadiationHandlerSimple extends ChunkRadiationHandler {
@Override @Override
public void updateSystem() { public void updateSystem() {
for(Entry<World, SimpleRadiationPerWorld> entry : perWorld.entrySet()) { for(Entry<World, SimpleRadiationPerWorld> entry : perWorld.entrySet()) {
HashMap<ChunkCoordIntPair, Float> radiation = entry.getValue().radiation; HashMap<ChunkCoordIntPair, Float> radiation = entry.getValue().radiation;
HashMap<ChunkCoordIntPair, Float> buff = new HashMap(radiation); HashMap<ChunkCoordIntPair, Float> buff = new HashMap(radiation);
radiation.clear(); radiation.clear();
World world = entry.getKey(); World world = entry.getKey();
for(Entry<ChunkCoordIntPair, Float> chunk : buff.entrySet()) { for(Entry<ChunkCoordIntPair, Float> chunk : buff.entrySet()) {
if(chunk.getValue() == 0) if(chunk.getValue() == 0)
continue; continue;
ChunkCoordIntPair coord = chunk.getKey(); ChunkCoordIntPair coord = chunk.getKey();
for(int i = -1; i <= 1; i++) { for(int i = -1; i <= 1; i++) {
for(int j = -1; j<= 1; j++) { for(int j = -1; j<= 1; j++) {
int type = Math.abs(i) + Math.abs(j); int type = Math.abs(i) + Math.abs(j);
float percent = type == 0 ? 0.6F : type == 1 ? 0.075F : 0.025F; float percent = type == 0 ? 0.6F : type == 1 ? 0.075F : 0.025F;
ChunkCoordIntPair newCoord = new ChunkCoordIntPair(coord.chunkXPos + i, coord.chunkZPos + j); ChunkCoordIntPair newCoord = new ChunkCoordIntPair(coord.chunkXPos + i, coord.chunkZPos + j);
if(buff.containsKey(newCoord)) { if(buff.containsKey(newCoord)) {
Float val = radiation.get(newCoord); Float val = radiation.get(newCoord);
float rad = val == null ? 0 : val; float rad = val == null ? 0 : val;
@ -100,15 +102,20 @@ public class ChunkRadiationHandlerSimple extends ChunkRadiationHandler {
} else { } else {
radiation.put(newCoord, chunk.getValue() * percent); radiation.put(newCoord, chunk.getValue() * percent);
} }
float rad = radiation.get(newCoord); float rad = radiation.get(newCoord);
if(rad > RadiationConfig.fogRad && world != null && world.rand.nextInt(RadiationConfig.fogCh) == 0 && world.getChunkProvider().chunkExists(coord.chunkXPos, coord.chunkZPos)) { if(rad > RadiationConfig.fogRad && world != null && world.rand.nextInt(RadiationConfig.fogCh) == 0 && world.getChunkProvider().chunkExists(coord.chunkXPos, coord.chunkZPos)) {
int x = coord.chunkXPos * 16 + world.rand.nextInt(16); int x = coord.chunkXPos * 16 + world.rand.nextInt(16);
int z = coord.chunkZPos * 16 + world.rand.nextInt(16); int z = coord.chunkZPos * 16 + world.rand.nextInt(16);
int y = world.getHeightValue(x, z) + world.rand.nextInt(5); int y = world.getHeightValue(x, z) + world.rand.nextInt(5);
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacket(x, y, z, 3), new TargetPoint(world.provider.dimensionId, x, y, z, 100)); NBTTagCompound data = new NBTTagCompound();
data.setString("type", "radFog");
data.setDouble("posX", x);
data.setDouble("posY", y);
data.setDouble("posZ", z);
MainRegistry.proxy.effectNT(data);
} }
} }
} }
@ -119,7 +126,7 @@ public class ChunkRadiationHandlerSimple extends ChunkRadiationHandler {
@Override @Override
public void clearSystem(World world) { public void clearSystem(World world) {
SimpleRadiationPerWorld radWorld = perWorld.get(world); SimpleRadiationPerWorld radWorld = perWorld.get(world);
if(radWorld != null) { if(radWorld != null) {
radWorld.radiation.clear(); radWorld.radiation.clear();
} }
@ -136,15 +143,15 @@ public class ChunkRadiationHandlerSimple extends ChunkRadiationHandler {
if(!event.world.isRemote) if(!event.world.isRemote)
perWorld.remove(event.world); perWorld.remove(event.world);
} }
private static final String NBT_KEY_CHUNK_RADIATION = "hfr_simple_radiation"; private static final String NBT_KEY_CHUNK_RADIATION = "hfr_simple_radiation";
@Override @Override
public void receiveChunkLoad(ChunkDataEvent.Load event) { public void receiveChunkLoad(ChunkDataEvent.Load event) {
if(!event.world.isRemote) { if(!event.world.isRemote) {
SimpleRadiationPerWorld radWorld = perWorld.get(event.world); SimpleRadiationPerWorld radWorld = perWorld.get(event.world);
if(radWorld != null) { if(radWorld != null) {
radWorld.radiation.put(event.getChunk().getChunkCoordIntPair(), event.getData().getFloat(NBT_KEY_CHUNK_RADIATION)); radWorld.radiation.put(event.getChunk().getChunkCoordIntPair(), event.getData().getFloat(NBT_KEY_CHUNK_RADIATION));
} }
@ -153,10 +160,10 @@ public class ChunkRadiationHandlerSimple extends ChunkRadiationHandler {
@Override @Override
public void receiveChunkSave(ChunkDataEvent.Save event) { public void receiveChunkSave(ChunkDataEvent.Save event) {
if(!event.world.isRemote) { if(!event.world.isRemote) {
SimpleRadiationPerWorld radWorld = perWorld.get(event.world); SimpleRadiationPerWorld radWorld = perWorld.get(event.world);
if(radWorld != null) { if(radWorld != null) {
Float val = radWorld.radiation.get(event.getChunk().getChunkCoordIntPair()); Float val = radWorld.radiation.get(event.getChunk().getChunkCoordIntPair());
float rad = val == null ? 0F : val; float rad = val == null ? 0F : val;
@ -167,74 +174,74 @@ public class ChunkRadiationHandlerSimple extends ChunkRadiationHandler {
@Override @Override
public void receiveChunkUnload(ChunkEvent.Unload event) { public void receiveChunkUnload(ChunkEvent.Unload event) {
if(!event.world.isRemote) { if(!event.world.isRemote) {
SimpleRadiationPerWorld radWorld = perWorld.get(event.world); SimpleRadiationPerWorld radWorld = perWorld.get(event.world);
if(radWorld != null) { if(radWorld != null) {
radWorld.radiation.remove(event.getChunk()); radWorld.radiation.remove(event.getChunk());
} }
} }
} }
public static class SimpleRadiationPerWorld { public static class SimpleRadiationPerWorld {
public HashMap<ChunkCoordIntPair, Float> radiation = new HashMap(); public HashMap<ChunkCoordIntPair, Float> radiation = new HashMap();
} }
@Override @Override
public void handleWorldDestruction() { public void handleWorldDestruction() {
int count = 10; int count = 10;
int threshold = 10; int threshold = 10;
int chunks = 5; int chunks = 5;
//for all worlds //for all worlds
for(Entry<World, SimpleRadiationPerWorld> per : perWorld.entrySet()) { for(Entry<World, SimpleRadiationPerWorld> per : perWorld.entrySet()) {
World world = per.getKey(); World world = per.getKey();
SimpleRadiationPerWorld list = per.getValue(); SimpleRadiationPerWorld list = per.getValue();
Object[] entries = list.radiation.entrySet().toArray(); Object[] entries = list.radiation.entrySet().toArray();
if(entries.length == 0) if(entries.length == 0)
continue; continue;
//chose this many random chunks //chose this many random chunks
for(int c = 0; c < chunks; c++) { for(int c = 0; c < chunks; c++) {
Entry<ChunkCoordIntPair, Float> randEnt = (Entry<ChunkCoordIntPair, Float>) entries[world.rand.nextInt(entries.length)]; Entry<ChunkCoordIntPair, Float> randEnt = (Entry<ChunkCoordIntPair, Float>) entries[world.rand.nextInt(entries.length)];
ChunkCoordIntPair coords = randEnt.getKey(); ChunkCoordIntPair coords = randEnt.getKey();
WorldServer serv = (WorldServer) world; WorldServer serv = (WorldServer) world;
ChunkProviderServer provider = (ChunkProviderServer) serv.getChunkProvider(); ChunkProviderServer provider = (ChunkProviderServer) serv.getChunkProvider();
//choose this many random locations within the chunk //choose this many random locations within the chunk
for(int i = 0; i < count; i++) { for(int i = 0; i < count; i++) {
if(randEnt == null || randEnt.getValue() < threshold) if(randEnt == null || randEnt.getValue() < threshold)
continue; continue;
if(provider.chunkExists(coords.chunkXPos, coords.chunkZPos)) { if(provider.chunkExists(coords.chunkXPos, coords.chunkZPos)) {
for(int a = 0; a < 16; a++) { for(int a = 0; a < 16; a++) {
for(int b = 0; b < 16; b++) { for(int b = 0; b < 16; b++) {
if(world.rand.nextInt(3) != 0) if(world.rand.nextInt(3) != 0)
continue; continue;
int x = coords.getCenterXPos() - 8 + a; int x = coords.getCenterXPos() - 8 + a;
int z = coords.getCenterZPosition() - 8 + b; int z = coords.getCenterZPosition() - 8 + b;
int y = world.getHeightValue(x, z) - world.rand.nextInt(2); int y = world.getHeightValue(x, z) - world.rand.nextInt(2);
if(world.getBlock(x, y, z) == Blocks.grass) { if(world.getBlock(x, y, z) == Blocks.grass) {
world.setBlock(x, y, z, ModBlocks.waste_earth); world.setBlock(x, y, z, ModBlocks.waste_earth);
} else if(world.getBlock(x, y, z) == Blocks.tallgrass) { } else if(world.getBlock(x, y, z) == Blocks.tallgrass) {
world.setBlock(x, y, z, Blocks.air); world.setBlock(x, y, z, Blocks.air);
} else if(world.getBlock(x, y, z).getMaterial() == Material.leaves && !(world.getBlock(x, y, z) == ModBlocks.waste_leaves)) { } else if(world.getBlock(x, y, z).getMaterial() == Material.leaves && !(world.getBlock(x, y, z) == ModBlocks.waste_leaves)) {
if(world.rand.nextInt(7) <= 5) { if(world.rand.nextInt(7) <= 5) {
world.setBlock(x, y, z, ModBlocks.waste_leaves); world.setBlock(x, y, z, ModBlocks.waste_leaves);
} else { } else {

View File

@ -7,6 +7,7 @@ import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.PrecompiledPacket; import com.hbm.packet.PrecompiledPacket;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessage;
import net.minecraft.entity.player.EntityPlayerMP;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -71,7 +72,6 @@ public class PacketThreading {
// `message` can be precompiled or not. // `message` can be precompiled or not.
if(message instanceof PrecompiledPacket) if(message instanceof PrecompiledPacket)
((PrecompiledPacket) message).getPreBuf(); // Gets the precompiled buffer, doing nothing if it already exists. ((PrecompiledPacket) message).getPreBuf(); // Gets the precompiled buffer, doing nothing if it already exists.
totalCnt++; totalCnt++;
Runnable task = () -> { Runnable task = () -> {
@ -88,6 +88,31 @@ public class PacketThreading {
addTask(task); addTask(task);
} }
/**
* Adds a packet to the thread pool to be processed in the future. This is only compatible with the `sendTo` dispatch operation.
*
* @param message Message to process.
* @param player PlayerMP to send to.
*/
public static void createSendToThreadedPacket(IMessage message, EntityPlayerMP player) {
if(message instanceof PrecompiledPacket)
((PrecompiledPacket) message).getPreBuf();
totalCnt++;
Runnable task = () -> {
try {
lock.lock();
PacketDispatcher.wrapper.sendTo(message, player);
if (message instanceof PrecompiledPacket)
((PrecompiledPacket) message).getPreBuf().release();
} finally {
lock.unlock();
}
};
addTask(task);
}
private static void addTask(Runnable task) { private static void addTask(Runnable task) {
if(isTriggered()) if(isTriggered())
task.run(); task.run();
@ -107,7 +132,7 @@ public class PacketThreading {
for (Future<?> future : futureList) { for (Future<?> future : futureList) {
nanoTimeWaited = System.nanoTime() - startTime; nanoTimeWaited = System.nanoTime() - startTime;
future.get(50, TimeUnit.MILLISECONDS); // I HATE EVERYTHING future.get(50, TimeUnit.MILLISECONDS); // I HATE EVERYTHING
if(TimeUnit.NANOSECONDS.convert(nanoTimeWaited, TimeUnit.MILLISECONDS) > 50) throw new TimeoutException(); // >50ms total time? timeout? yes sir, ooh rah! if(TimeUnit.MILLISECONDS.convert(nanoTimeWaited, TimeUnit.NANOSECONDS) > 50) throw new TimeoutException(); // >50ms total time? timeout? yes sir, ooh rah!
} }
} }
} catch (ExecutionException ignored) { } catch (ExecutionException ignored) {

View File

@ -836,80 +836,6 @@ public class ClientProxy extends ServerProxy {
MinecraftForgeClient.registerItemRenderer(ModItems.missile_custom, new ItemRenderMissile()); MinecraftForgeClient.registerItemRenderer(ModItems.missile_custom, new ItemRenderMissile());
} }
@Deprecated
@Override
public void particleControl(double x, double y, double z, int type) {
World world = Minecraft.getMinecraft().theWorld;
TextureManager man = Minecraft.getMinecraft().renderEngine;
switch(type) {
case 0:
for(int i = 0; i < 10; i++) {
EntityCloudFX smoke = new EntityCloudFX(world, x + world.rand.nextGaussian(), y + world.rand.nextGaussian(), z + world.rand.nextGaussian(), 0.0, 0.0, 0.0);
Minecraft.getMinecraft().effectRenderer.addEffect(smoke);
}
break;
case 1:
EntityCloudFX smoke = new EntityCloudFX(world, x, y, z, 0.0, 0.1, 0.0);
Minecraft.getMinecraft().effectRenderer.addEffect(smoke);
break;
case 2:
ParticleContrail contrail = new ParticleContrail(man, world, x, y, z);
Minecraft.getMinecraft().effectRenderer.addEffect(contrail);
break;
case 3:
ParticleRadiationFog fog = new ParticleRadiationFog(man, world, x, y, z);
Minecraft.getMinecraft().effectRenderer.addEffect(fog);
break;
}
}
//version 2, now with strings!
@Deprecated
@Override
public void spawnParticle(double x, double y, double z, String type, float args[]) {
World world = Minecraft.getMinecraft().theWorld;
TextureManager man = Minecraft.getMinecraft().renderEngine;
if("launchsmoke".equals(type) && args.length == 3) {
ParticleSmokePlume contrail = new ParticleSmokePlume(man, world, x, y, z);
contrail.motionX = args[0];
contrail.motionY = args[1];
contrail.motionZ = args[2];
Minecraft.getMinecraft().effectRenderer.addEffect(contrail);
}
if("exKerosene".equals(type)) {
ParticleContrail contrail = new ParticleContrail(man, world, x, y, z, 0F, 0F, 0F, 1F);
Minecraft.getMinecraft().effectRenderer.addEffect(contrail);
}
if("exSolid".equals(type)) {
ParticleContrail contrail = new ParticleContrail(man, world, x, y, z, 0.3F, 0.2F, 0.05F, 1F);
Minecraft.getMinecraft().effectRenderer.addEffect(contrail);
}
if("exHydrogen".equals(type)) {
ParticleContrail contrail = new ParticleContrail(man, world, x, y, z, 0.7F, 0.7F, 0.7F, 1F);
Minecraft.getMinecraft().effectRenderer.addEffect(contrail);
}
if("exBalefire".equals(type)) {
ParticleContrail contrail = new ParticleContrail(man, world, x, y, z, 0.2F, 0.7F, 0.2F, 1F);
Minecraft.getMinecraft().effectRenderer.addEffect(contrail);
}
if("radSmoke".equals(type)) {
ParticleRadiationFog contrail = new ParticleRadiationFog(man, world, x, y, z);
Minecraft.getMinecraft().effectRenderer.addEffect(contrail);
}
}
//mk3, only use this one //mk3, only use this one
@Override @Override
public void effectNT(NBTTagCompound data) { public void effectNT(NBTTagCompound data) {
@ -933,6 +859,64 @@ public class ClientProxy extends ServerProxy {
return; return;
} }
// Old MK1 system ported to MK3:
if("waterSplash".equals(type)) {
for (int i = 0; i < 10; i++) {
EntityCloudFX smoke = new EntityCloudFX(world, x + world.rand.nextGaussian(), y + world.rand.nextGaussian(), z + world.rand.nextGaussian(), 0.0, 0.0, 0.0);
Minecraft.getMinecraft().effectRenderer.addEffect(smoke);
}
}
if("cloudFX2".equals(type)) { // i have genuinely no idea what used this
EntityCloudFX smoke = new EntityCloudFX(world, x, y, z, 0.0, 0.1, 0.0);
Minecraft.getMinecraft().effectRenderer.addEffect(smoke);
}
if("ABMContrail".equals(type)) {
ParticleContrail contrail = new ParticleContrail(man, world, x, y, z);
Minecraft.getMinecraft().effectRenderer.addEffect(contrail);
}
// End MK1 porting.
// Old MK2 system ported to MK3:
if("launchSmoke".equals(type)) {
ParticleSmokePlume contrail = new ParticleSmokePlume(man, world, x, y, z);
contrail.motionX = data.getDouble("moX");
contrail.motionY = data.getDouble("moY");
contrail.motionZ = data.getDouble("moZ");
Minecraft.getMinecraft().effectRenderer.addEffect(contrail);
}
if("exKerosene".equals(type)) {
ParticleContrail contrail = new ParticleContrail(man, world, x, y, z, 0F, 0F, 0F, 1F);
Minecraft.getMinecraft().effectRenderer.addEffect(contrail);
}
if("exSolid".equals(type)) {
ParticleContrail contrail = new ParticleContrail(man, world, x, y, z, 0.3F, 0.2F, 0.05F, 1F);
Minecraft.getMinecraft().effectRenderer.addEffect(contrail);
}
if("exHydrogen".equals(type)) {
ParticleContrail contrail = new ParticleContrail(man, world, x, y, z, 0.7F, 0.7F, 0.7F, 1F);
Minecraft.getMinecraft().effectRenderer.addEffect(contrail);
}
if("exBalefire".equals(type)) {
ParticleContrail contrail = new ParticleContrail(man, world, x, y, z, 0.2F, 0.7F, 0.2F, 1F);
Minecraft.getMinecraft().effectRenderer.addEffect(contrail);
}
if("radFog".equals(type)) {
ParticleRadiationFog contrail = new ParticleRadiationFog(man, world, x, y, z);
Minecraft.getMinecraft().effectRenderer.addEffect(contrail);
}
// End MK2 porting.
if("missileContrail".equals(type)) { if("missileContrail".equals(type)) {
if(Vec3.createVectorHelper(player.posX - x, player.posY - y, player.posZ - z).lengthVector() > 350) return; if(Vec3.createVectorHelper(player.posX - x, player.posY - y, player.posZ - z).lengthVector() > 350) return;

View File

@ -37,8 +37,6 @@ public class ServerProxy {
public void registerGunCfg() { } public void registerGunCfg() { }
public void handleNHNEICompat() { } public void handleNHNEICompat() { }
public void particleControl(double x, double y, double z, int type) { }
public void spawnParticle(double x, double y, double z, String type, float[] args) { } public void spawnParticle(double x, double y, double z, String type, float[] args) { }
public void effectNT(NBTTagCompound data) { } public void effectNT(NBTTagCompound data) { }

View File

@ -18,12 +18,8 @@ public class PacketDispatcher {
public static void registerPackets() { public static void registerPackets() {
int i = 0; int i = 0;
//Sound packet that keeps client and server separated
wrapper.registerMessage(LoopedSoundPacket.Handler.class, LoopedSoundPacket.class, i++, Side.CLIENT);
//Signals server to consume items and create template //Signals server to consume items and create template
wrapper.registerMessage(ItemFolderPacket.Handler.class, ItemFolderPacket.class, i++, Side.SERVER); wrapper.registerMessage(ItemFolderPacket.Handler.class, ItemFolderPacket.class, i++, Side.SERVER);
//Electricity gauge for GUI rendering
wrapper.registerMessage(AuxElectricityPacket.Handler.class, AuxElectricityPacket.class, i++, Side.CLIENT);
//Siren packet for looped sounds //Siren packet for looped sounds
wrapper.registerMessage(TESirenPacket.Handler.class, TESirenPacket.class, i++, Side.CLIENT); wrapper.registerMessage(TESirenPacket.Handler.class, TESirenPacket.class, i++, Side.CLIENT);
//Signals server to change ItemStacks //Signals server to change ItemStacks
@ -44,8 +40,6 @@ public class PacketDispatcher {
wrapper.registerMessage(TEFFPacket.Handler.class, TEFFPacket.class, i++, Side.CLIENT); wrapper.registerMessage(TEFFPacket.Handler.class, TEFFPacket.class, i++, Side.CLIENT);
//Sends button information for ItemGunBase //Sends button information for ItemGunBase
wrapper.registerMessage(GunButtonPacket.Handler.class, GunButtonPacket.class, i++, Side.SERVER); wrapper.registerMessage(GunButtonPacket.Handler.class, GunButtonPacket.class, i++, Side.SERVER);
//Packet to send block break particles
wrapper.registerMessage(AuxParticlePacket.Handler.class, AuxParticlePacket.class, i++, Side.CLIENT);
//Signals server to buy offer from bobmazon //Signals server to buy offer from bobmazon
wrapper.registerMessage(ItemBobmazonPacket.Handler.class, ItemBobmazonPacket.class, i++, Side.SERVER); wrapper.registerMessage(ItemBobmazonPacket.Handler.class, ItemBobmazonPacket.class, i++, Side.SERVER);
//Packet to send missile multipart information to TEs //Packet to send missile multipart information to TEs
@ -76,12 +70,8 @@ public class PacketDispatcher {
wrapper.registerMessage(PermaSyncPacket.Handler.class, PermaSyncPacket.class, i++, Side.CLIENT); wrapper.registerMessage(PermaSyncPacket.Handler.class, PermaSyncPacket.class, i++, Side.CLIENT);
//Syncs biome information for single positions or entire chunks //Syncs biome information for single positions or entire chunks
wrapper.registerMessage(BiomeSyncPacket.Handler.class, BiomeSyncPacket.class, i++, Side.CLIENT); wrapper.registerMessage(BiomeSyncPacket.Handler.class, BiomeSyncPacket.class, i++, Side.CLIENT);
//The not-so-convenient but not laggy one
//Tile sync wrapper.registerMessage(BufPacket.Handler.class, BufPacket.class, i++, Side.CLIENT);
wrapper.registerMessage(AuxGaugePacket.Handler.class, AuxGaugePacket.class, i++, Side.CLIENT); //The horrid one
// fucking DIE
//wrapper.registerMessage(NBTPacket.Handler.class, NBTPacket.class, i++, Side.CLIENT); //The convenient but laggy one
wrapper.registerMessage(BufPacket.Handler.class, BufPacket.class, i++, Side.CLIENT); //The not-so-convenient but not laggy one
} }
} }

View File

@ -1,67 +0,0 @@
package com.hbm.packet.toclient;
import api.hbm.energymk2.IEnergyHandlerMK2;
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.tileentity.TileEntity;
@Deprecated //use the NBT packet instead
public class AuxElectricityPacket implements IMessage {
int x;
int y;
int z;
long charge;
public AuxElectricityPacket()
{
}
public AuxElectricityPacket(int x, int y, int z, long charge)
{
this.x = x;
this.y = y;
this.z = z;
this.charge = charge;
}
@Override
public void fromBytes(ByteBuf buf) {
x = buf.readInt();
y = buf.readInt();
z = buf.readInt();
charge = buf.readLong();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(x);
buf.writeInt(y);
buf.writeInt(z);
buf.writeLong(charge);
}
public static class Handler implements IMessageHandler<AuxElectricityPacket, IMessage> {
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(AuxElectricityPacket m, MessageContext ctx) {
try {
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(m.x, m.y, m.z);
if (te instanceof IEnergyHandlerMK2) {
IEnergyHandlerMK2 gen = (IEnergyHandlerMK2) te;
gen.setPower(m.charge);
}
} catch (Exception x) { }
return null;
}
}
}

View File

@ -1,96 +0,0 @@
package com.hbm.packet.toclient;
import com.hbm.interfaces.Spaghetti;
import com.hbm.items.weapon.ItemCustomMissilePart.PartSize;
import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.tileentity.bomb.TileEntityCompactLauncher;
import com.hbm.tileentity.bomb.TileEntityLaunchTable;
import com.hbm.tileentity.machine.TileEntityMachineArcFurnace;
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.tileentity.TileEntity;
@Spaghetti("Changing all machines to use TileEntityMachineBase will reduce the total chaos in this class")
@Deprecated //use the NBT packet instead
public class AuxGaugePacket implements IMessage {
int x;
int y;
int z;
int value;
int id;
public AuxGaugePacket()
{
}
public AuxGaugePacket(int x, int y, int z, int value, int id)
{
this.x = x;
this.y = y;
this.z = z;
this.value = value;
this.id = id;
}
@Override
public void fromBytes(ByteBuf buf) {
x = buf.readInt();
y = buf.readInt();
z = buf.readInt();
value = buf.readInt();
id = buf.readInt();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(x);
buf.writeInt(y);
buf.writeInt(z);
buf.writeInt(value);
buf.writeInt(id);
}
public static class Handler implements IMessageHandler<AuxGaugePacket, IMessage> {
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(AuxGaugePacket m, MessageContext ctx) {
try {
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(m.x, m.y, m.z);
if (te instanceof TileEntityMachineArcFurnace) {
TileEntityMachineArcFurnace furn = (TileEntityMachineArcFurnace)te;
if(m.id == 0)
furn.dualCookTime = m.value;
}
if (te instanceof TileEntityCompactLauncher) {
TileEntityCompactLauncher launcher = (TileEntityCompactLauncher)te;
launcher.solid = m.value;
}
if (te instanceof TileEntityLaunchTable) {
TileEntityLaunchTable launcher = (TileEntityLaunchTable)te;
if(m.id == 0)
launcher.solid = m.value;
if(m.id == 1)
launcher.padSize = PartSize.values()[m.value];
}
if(te instanceof TileEntityMachineBase) {
((TileEntityMachineBase)te).processGauge(m.value, m.id);
}
} catch (Exception x) {}
return null;
}
}
}

View File

@ -1,60 +0,0 @@
package com.hbm.packet.toclient;
import com.hbm.main.MainRegistry;
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 io.netty.buffer.ByteBuf;
public class AuxParticlePacket implements IMessage {
double x;
double y;
double z;
int type;
public AuxParticlePacket()
{
}
public AuxParticlePacket(double x, double y, double z, int type)
{
this.x = x;
this.y = y;
this.z = z;
this.type = type;
}
@Override
public void fromBytes(ByteBuf buf) {
x = buf.readDouble();
y = buf.readDouble();
z = buf.readDouble();
type = buf.readInt();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeDouble(x);
buf.writeDouble(y);
buf.writeDouble(z);
buf.writeInt(type);
}
public static class Handler implements IMessageHandler<AuxParticlePacket, IMessage> {
@Override
public IMessage onMessage(AuxParticlePacket m, MessageContext ctx) {
try {
MainRegistry.proxy.particleControl(m.x, m.y, m.z, m.type);
} catch(Exception x) { }
return null;
}
}
}

View File

@ -3,44 +3,37 @@ package com.hbm.packet.toclient;
import com.hbm.extprop.HbmLivingProps; import com.hbm.extprop.HbmLivingProps;
import com.hbm.extprop.HbmPlayerProps; import com.hbm.extprop.HbmPlayerProps;
import com.hbm.packet.PrecompiledPacket;
import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.network.PacketBuffer;
public class ExtPropPacket implements IMessage { public class ExtPropPacket extends PrecompiledPacket {
ByteBuf buffer; HbmLivingProps props;
HbmPlayerProps pprps;
ByteBuf buf;
public ExtPropPacket() { } public ExtPropPacket() { }
public ExtPropPacket(ByteBuf buf) { public ExtPropPacket(HbmLivingProps props, HbmPlayerProps pprps) {
this.props = props;
this.buffer = Unpooled.buffer(); this.pprps = pprps;
buffer.writeBytes(buf);
} }
@Override @Override
public void fromBytes(ByteBuf buf) { public void fromBytes(ByteBuf buf) {
this.buf = buf;
if (buffer == null) {
buffer = new PacketBuffer(Unpooled.buffer());
}
buffer.writeBytes(buf);
} }
@Override @Override
public void toBytes(ByteBuf buf) { public void toBytes(ByteBuf buf) {
props.serialize(buf);
if (buffer == null) { pprps.serialize(buf);
buffer = new PacketBuffer(Unpooled.buffer());
}
buf.writeBytes(buffer);
} }
public static class Handler implements IMessageHandler<ExtPropPacket, IMessage> { public static class Handler implements IMessageHandler<ExtPropPacket, IMessage> {
@ -55,10 +48,10 @@ public class ExtPropPacket implements IMessage {
HbmLivingProps props = HbmLivingProps.getData(Minecraft.getMinecraft().thePlayer); HbmLivingProps props = HbmLivingProps.getData(Minecraft.getMinecraft().thePlayer);
HbmPlayerProps pprps = HbmPlayerProps.getData(Minecraft.getMinecraft().thePlayer); HbmPlayerProps pprps = HbmPlayerProps.getData(Minecraft.getMinecraft().thePlayer);
props.deserialize(m.buffer); props.deserialize(m.buf);
pprps.deserialize(m.buffer); pprps.deserialize(m.buf);
m.buffer.release(); m.buf.release();
return null; return null;
} }

View File

@ -1,122 +0,0 @@
package com.hbm.packet.toclient;
import com.hbm.interfaces.Spaghetti;
import com.hbm.sound.*;
import com.hbm.tileentity.machine.*;
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.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
@Spaghetti("this class should be destroyed")
public class LoopedSoundPacket implements IMessage {
int x;
int y;
int z;
public LoopedSoundPacket()
{
}
public LoopedSoundPacket(int x, int y, int z)
{
this.x = x;
this.y = y;
this.z = z;
}
@Override
public void fromBytes(ByteBuf buf) {
x = buf.readInt();
y = buf.readInt();
z = buf.readInt();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(x);
buf.writeInt(y);
buf.writeInt(z);
}
public static class Handler implements IMessageHandler<LoopedSoundPacket, IMessage> {
@Override
//Tamaized, I love you!
@SideOnly(Side.CLIENT)
public IMessage onMessage(LoopedSoundPacket m, MessageContext ctx) {
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(m.x, m.y, m.z);
if (te != null && te instanceof TileEntityMachineAssembler) {
boolean flag = true;
for(int i = 0; i < SoundLoopAssembler.list.size(); i++) {
if(SoundLoopAssembler.list.get(i).getTE() == te && !SoundLoopAssembler.list.get(i).isDonePlaying())
flag = false;
}
if(flag && te.getWorldObj().isRemote && ((TileEntityMachineAssembler)te).isProgressing)
Minecraft.getMinecraft().getSoundHandler().playSound(new SoundLoopAssembler(new ResourceLocation("hbm:block.assemblerOperate"), te));
}
if (te != null && te instanceof TileEntityMachineTurbofan) {
boolean flag = true;
for(int i = 0; i < SoundLoopTurbofan.list.size(); i++) {
if(SoundLoopTurbofan.list.get(i).getTE() == te && !SoundLoopTurbofan.list.get(i).isDonePlaying())
flag = false;
}
if(flag && te.getWorldObj().isRemote && ((TileEntityMachineTurbofan)te).wasOn)
Minecraft.getMinecraft().getSoundHandler().playSound(new SoundLoopTurbofan(new ResourceLocation("hbm:block.turbofanOperate"), te));
}
if (te != null && te instanceof TileEntityBroadcaster) {
boolean flag = true;
for(int i = 0; i < SoundLoopBroadcaster.list.size(); i++) {
if(SoundLoopBroadcaster.list.get(i).getTE() == te && !SoundLoopBroadcaster.list.get(i).isDonePlaying())
flag = false;
}
int j = te.xCoord + te.zCoord + te.yCoord;
if(flag && te.getWorldObj().isRemote)
Minecraft.getMinecraft().getSoundHandler().playSound(new SoundLoopBroadcaster(new ResourceLocation("hbm:block.broadcast" + (Math.abs(j) % 3 + 1)), te));
}
if (te != null && te instanceof TileEntityMachineCentrifuge) {
boolean flag = true;
for(int i = 0; i < SoundLoopCentrifuge.list.size(); i++) {
if(SoundLoopCentrifuge.list.get(i).getTE() == te && !SoundLoopCentrifuge.list.get(i).isDonePlaying())
flag = false;
}
if(flag && te.getWorldObj().isRemote && ((TileEntityMachineCentrifuge)te).isProgressing)
Minecraft.getMinecraft().getSoundHandler().playSound(new SoundLoopCentrifuge(new ResourceLocation("hbm:block.centrifugeOperate"), te));
}
if (te != null && te instanceof TileEntityMachineGasCent) {
boolean flag = true;
for(int i = 0; i < SoundLoopCentrifuge.list.size(); i++) {
if(SoundLoopCentrifuge.list.get(i).getTE() == te && !SoundLoopCentrifuge.list.get(i).isDonePlaying())
flag = false;
}
if(flag && te.getWorldObj().isRemote && ((TileEntityMachineGasCent)te).isProgressing)
Minecraft.getMinecraft().getSoundHandler().playSound(new SoundLoopCentrifuge(new ResourceLocation("hbm:block.centrifugeOperate"), te));
}
return null;
}
}
}

View File

@ -1,38 +0,0 @@
package com.hbm.sound;
import java.util.ArrayList;
import java.util.List;
import com.hbm.tileentity.machine.TileEntityMachineAssembler;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
public class SoundLoopAssembler extends SoundLoopMachine {
public static List<SoundLoopAssembler> list = new ArrayList<SoundLoopAssembler>();
public SoundLoopAssembler(ResourceLocation path, TileEntity te) {
super(path, te);
list.add(this);
}
@Override
public void update() {
super.update();
if(te instanceof TileEntityMachineAssembler) {
TileEntityMachineAssembler drill = (TileEntityMachineAssembler)te;
if(this.volume != 3)
volume = 3;
if(!drill.isProgressing)
this.donePlaying = true;
}
}
public TileEntity getTE() {
return te;
}
}

View File

@ -1,52 +0,0 @@
package com.hbm.sound;
import java.util.ArrayList;
import java.util.List;
import com.hbm.tileentity.machine.TileEntityBroadcaster;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.ISound;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
public class SoundLoopBroadcaster extends SoundLoopMachine {
public static List<SoundLoopBroadcaster> list = new ArrayList<SoundLoopBroadcaster>();
public float intendedVolume = 25.0F;
public SoundLoopBroadcaster(ResourceLocation path, TileEntity te) {
super(path, te);
list.add(this);
this.field_147666_i = ISound.AttenuationType.NONE;
}
@Override
public void update() {
super.update();
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
float f = 0;
if(player != null) {
f = (float)Math.sqrt(Math.pow(xPosF - player.posX, 2) + Math.pow(yPosF - player.posY, 2) + Math.pow(zPosF - player.posZ, 2));
volume = func(f, intendedVolume);
if(!(player.worldObj.getTileEntity((int)xPosF, (int)yPosF, (int)zPosF) instanceof TileEntityBroadcaster)) {
this.donePlaying = true;
volume = 0;
}
} else {
volume = intendedVolume;
}
}
public TileEntity getTE() {
return te;
}
public float func(float f, float v) {
return (f / v) * -2 + 2;
}
}

View File

@ -1,54 +0,0 @@
package com.hbm.sound;
import java.util.ArrayList;
import java.util.List;
import com.hbm.tileentity.machine.TileEntityMachineCentrifuge;
import com.hbm.tileentity.machine.TileEntityMachineGasCent;
import net.minecraft.client.Minecraft;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
public class SoundLoopCentrifuge extends SoundLoopMachine {
public static List<SoundLoopCentrifuge> list = new ArrayList<SoundLoopCentrifuge>();
public SoundLoopCentrifuge(ResourceLocation path, TileEntity te) {
super(path, te);
list.add(this);
}
@Override
public void update() {
super.update();
if(te instanceof TileEntityMachineCentrifuge) {
TileEntityMachineCentrifuge plant = (TileEntityMachineCentrifuge)te;
if(this.volume != 1)
volume = 1;
if(!plant.isProgressing)
this.donePlaying = true;
}
if(te instanceof TileEntityMachineGasCent) {
TileEntityMachineGasCent plant = (TileEntityMachineGasCent)te;
if(this.volume != 1)
volume = 1;
if(!plant.isProgressing)
this.donePlaying = true;
}
if(!Minecraft.getMinecraft().getSoundHandler().isSoundPlaying(this)) {
stop();
}
}
public TileEntity getTE() {
return te;
}
}

View File

@ -1,39 +0,0 @@
package com.hbm.sound;
import java.util.ArrayList;
import java.util.List;
import com.hbm.tileentity.machine.TileEntityMachineTurbofan;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
public class SoundLoopTurbofan extends SoundLoopMachine {
public static List<SoundLoopTurbofan> list = new ArrayList<SoundLoopTurbofan>();
public SoundLoopTurbofan(ResourceLocation path, TileEntity te) {
super(path, te);
list.add(this);
}
@Override
public void update() {
super.update();
if(te instanceof TileEntityMachineTurbofan) {
TileEntityMachineTurbofan drill = (TileEntityMachineTurbofan)te;
if(this.volume != 10)
volume = 10;
if(!drill.wasOn)
this.donePlaying = true;
}
}
public TileEntity getTE() {
return te;
}
}

View File

@ -1,10 +1,7 @@
package com.hbm.tileentity; package com.hbm.tileentity;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toclient.AuxGaugePacket;
import com.hbm.util.fauxpointtwelve.DirPos; import com.hbm.util.fauxpointtwelve.DirPos;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ISidedInventory;
@ -147,11 +144,6 @@ public abstract class TileEntityMachineBase extends TileEntityLoadedBase impleme
@Override @Override
public abstract void updateEntity(); public abstract void updateEntity();
@Deprecated public void updateGauge(int val, int id, int range) {
if(!worldObj.isRemote) PacketDispatcher.wrapper.sendToAllAround(new AuxGaugePacket(xCoord, yCoord, zCoord, val, id), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
}
@Deprecated public void processGauge(int val, int id) { }
@Deprecated @Deprecated
public void handleButtonPacket(int value, int meta) { } public void handleButtonPacket(int value, int meta) { }

View File

@ -220,7 +220,15 @@ public class TileEntityCompactLauncher extends TileEntityLoadedBase implements I
float moX = (float) (dir ? 0 : worldObj.rand.nextGaussian() * 0.5F); float moX = (float) (dir ? 0 : worldObj.rand.nextGaussian() * 0.5F);
float moZ = (float) (!dir ? 0 : worldObj.rand.nextGaussian() * 0.5F); float moZ = (float) (!dir ? 0 : worldObj.rand.nextGaussian() * 0.5F);
MainRegistry.proxy.spawnParticle(xCoord + 0.5, yCoord + 0.25, zCoord + 0.5, "launchsmoke", new float[] {moX, 0, moZ}); NBTTagCompound data = new NBTTagCompound();
data.setDouble("posX", xCoord + 0.5);
data.setDouble("posY", yCoord + 0.25);
data.setDouble("posZ", zCoord + 0.5);
data.setString("type", "launchSmoke");
data.setDouble("moX", moX);
data.setDouble("moY", 0);
data.setDouble("moZ", moZ);
MainRegistry.proxy.effectNT(data);
} }
break; break;

View File

@ -18,16 +18,16 @@ public class TileEntityLaunchPad extends TileEntityLaunchPadBase {
@Override public boolean isReadyForLaunch() { return delay <= 0; } @Override public boolean isReadyForLaunch() { return delay <= 0; }
@Override public double getLaunchOffset() { return 1D; } @Override public double getLaunchOffset() { return 1D; }
public int delay = 0; public int delay = 0;
@Override @Override
public void updateEntity() { public void updateEntity() {
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
if(this.delay > 0) delay--; if(this.delay > 0) delay--;
if(!this.isMissileValid() || !this.hasFuel()) { if(!this.isMissileValid() || !this.hasFuel()) {
this.delay = 100; this.delay = 100;
} }
@ -41,11 +41,11 @@ public class TileEntityLaunchPad extends TileEntityLaunchPadBase {
this.state = this.STATE_READY; this.state = this.STATE_READY;
} }
} }
} else { } else {
List<EntityMissileBaseNT> entities = worldObj.getEntitiesWithinAABB(EntityMissileBaseNT.class, AxisAlignedBB.getBoundingBox(xCoord - 0.5, yCoord, zCoord - 0.5, xCoord + 1.5, yCoord + 10, zCoord + 1.5)); List<EntityMissileBaseNT> entities = worldObj.getEntitiesWithinAABB(EntityMissileBaseNT.class, AxisAlignedBB.getBoundingBox(xCoord - 0.5, yCoord, zCoord - 0.5, xCoord + 1.5, yCoord + 10, zCoord + 1.5));
if(!entities.isEmpty()) { if(!entities.isEmpty()) {
for(int i = 0; i < 15; i++) { for(int i = 0; i < 15; i++) {
@ -54,12 +54,20 @@ public class TileEntityLaunchPad extends TileEntityLaunchPadBase {
if(worldObj.rand.nextBoolean()) dir = dir.getRotation(ForgeDirection.UP); if(worldObj.rand.nextBoolean()) dir = dir.getRotation(ForgeDirection.UP);
float moX = (float) (worldObj.rand.nextGaussian() * 0.15F + 0.75) * dir.offsetX; float moX = (float) (worldObj.rand.nextGaussian() * 0.15F + 0.75) * dir.offsetX;
float moZ = (float) (worldObj.rand.nextGaussian() * 0.15F + 0.75) * dir.offsetZ; float moZ = (float) (worldObj.rand.nextGaussian() * 0.15F + 0.75) * dir.offsetZ;
MainRegistry.proxy.spawnParticle(xCoord + 0.5, yCoord + 0.25, zCoord + 0.5, "launchsmoke", new float[] {moX, 0, moZ}); NBTTagCompound data = new NBTTagCompound();
data.setDouble("posX", xCoord + 0.5);
data.setDouble("posY", yCoord + 0.25);
data.setDouble("posZ", zCoord + 0.5);
data.setString("type", "launchSmoke");
data.setDouble("moX", moX);
data.setDouble("moY", 0);
data.setDouble("moZ", moZ);
MainRegistry.proxy.effectNT(data);
} }
} }
} }
super.updateEntity(); super.updateEntity();
} }
@ -68,7 +76,7 @@ public class TileEntityLaunchPad extends TileEntityLaunchPadBase {
super.finalizeLaunch(missile); super.finalizeLaunch(missile);
this.delay = 100; this.delay = 100;
} }
@Override @Override
public DirPos[] getConPos() { public DirPos[] getConPos() {
return new DirPos[] { return new DirPos[] {
@ -82,24 +90,24 @@ public class TileEntityLaunchPad extends TileEntityLaunchPadBase {
new DirPos(xCoord + 1, yCoord, zCoord - 2, Library.NEG_Z) new DirPos(xCoord + 1, yCoord, zCoord - 2, Library.NEG_Z)
}; };
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
this.delay = nbt.getInteger("delay"); this.delay = nbt.getInteger("delay");
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setInteger("delay", delay); nbt.setInteger("delay", delay);
} }
AxisAlignedBB bb = null; AxisAlignedBB bb = null;
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {
if(bb == null) { if(bb == null) {
bb = AxisAlignedBB.getBoundingBox( bb = AxisAlignedBB.getBoundingBox(
xCoord - 2, xCoord - 2,
@ -110,10 +118,10 @@ public class TileEntityLaunchPad extends TileEntityLaunchPadBase {
zCoord + 3 zCoord + 3
); );
} }
return bb; return bb;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public double getMaxRenderDistanceSquared() { public double getMaxRenderDistanceSquared() {

View File

@ -37,10 +37,10 @@ public class TileEntityLaunchPadLarge extends TileEntityLaunchPadBase {
private int sync; private int sync;
/** Delay between erector movements */ /** Delay between erector movements */
public int delay = 20; public int delay = 20;
private AudioWrapper audioLift; private AudioWrapper audioLift;
private AudioWrapper audioErector; private AudioWrapper audioErector;
protected boolean liftMoving = false; protected boolean liftMoving = false;
protected boolean erectorMoving = false; protected boolean erectorMoving = false;
@ -49,26 +49,26 @@ public class TileEntityLaunchPadLarge extends TileEntityLaunchPadBase {
@Override @Override
public void updateEntity() { public void updateEntity() {
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
this.prevLift = this.lift; this.prevLift = this.lift;
this.prevErector = this.erector; this.prevErector = this.erector;
float erectorSpeed = 1.5F; float erectorSpeed = 1.5F;
float liftSpeed = 0.025F; float liftSpeed = 0.025F;
if(this.isMissileValid()) { if(this.isMissileValid()) {
if(slots[0].getItem() instanceof ItemMissile) { if(slots[0].getItem() instanceof ItemMissile) {
ItemMissile missile = (ItemMissile) slots[0].getItem(); ItemMissile missile = (ItemMissile) slots[0].getItem();
this.formFactor = missile.formFactor.ordinal(); this.formFactor = missile.formFactor.ordinal();
if(missile.formFactor == MissileFormFactor.ATLAS || missile.formFactor == MissileFormFactor.HUGE) { if(missile.formFactor == MissileFormFactor.ATLAS || missile.formFactor == MissileFormFactor.HUGE) {
erectorSpeed /= 2F; erectorSpeed /= 2F;
liftSpeed /= 2F; liftSpeed /= 2F;
} }
} }
if(this.erector == 90F && this.lift == 1F) { if(this.erector == 90F && this.lift == 1F) {
this.readyToLoad = true; this.readyToLoad = true;
} }
@ -77,16 +77,16 @@ public class TileEntityLaunchPadLarge extends TileEntityLaunchPadBase {
erected = false; erected = false;
delay = 20; delay = 20;
} }
if(this.power >= 75_000) { if(this.power >= 75_000) {
if(delay > 0) { if(delay > 0) {
delay--; delay--;
if(delay < 10 && scheduleErect) { if(delay < 10 && scheduleErect) {
this.erected = true; this.erected = true;
this.scheduleErect = false; this.scheduleErect = false;
} }
// if there is no missile or the missile isn't ready (i.e. the erector hasn't returned to zero position yet), retract // if there is no missile or the missile isn't ready (i.e. the erector hasn't returned to zero position yet), retract
if(slots[0] == null || !readyToLoad) { if(slots[0] == null || !readyToLoad) {
//fold back erector //fold back erector
@ -103,13 +103,13 @@ public class TileEntityLaunchPadLarge extends TileEntityLaunchPadBase {
} }
} }
} }
} else { } else {
//only extend if the erector isn't up yet and the missile can be loaded //only extend if the erector isn't up yet and the missile can be loaded
if(!erected && readyToLoad) { if(!erected && readyToLoad) {
this.state = this.STATE_LOADING; this.state = this.STATE_LOADING;
//first, rotate the erector //first, rotate the erector
if(erector != 0F) { if(erector != 0F) {
erector = Math.max(erector - erectorSpeed, 0F); erector = Math.max(erector - erectorSpeed, 0F);
@ -140,7 +140,7 @@ public class TileEntityLaunchPadLarge extends TileEntityLaunchPadBase {
} }
} }
} }
if(!this.hasFuel() || !this.isMissileValid()) this.state = this.STATE_MISSING; if(!this.hasFuel() || !this.isMissileValid()) this.state = this.STATE_MISSING;
if(this.erected && this.canLaunch()) this.state = this.STATE_READY; if(this.erected && this.canLaunch()) this.state = this.STATE_READY;
@ -153,11 +153,11 @@ public class TileEntityLaunchPadLarge extends TileEntityLaunchPadBase {
if(prevLiftMoving && !this.liftMoving) worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:door.wgh_stop", 2F, 1F); if(prevLiftMoving && !this.liftMoving) worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:door.wgh_stop", 2F, 1F);
if(prevErectorMoving && !this.erectorMoving) worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:door.garage_stop", 2F, 1F); if(prevErectorMoving && !this.erectorMoving) worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:door.garage_stop", 2F, 1F);
} else { } else {
this.prevLift = this.lift; this.prevLift = this.lift;
this.prevErector = this.erector; this.prevErector = this.erector;
if(this.sync > 0) { if(this.sync > 0) {
this.lift = this.lift + ((this.syncLift - this.lift) / (float) this.sync); this.lift = this.lift + ((this.syncLift - this.lift) / (float) this.sync);
this.erector = this.erector + ((this.syncErector - this.erector) / (float) this.sync); this.erector = this.erector + ((this.syncErector - this.erector) / (float) this.sync);
@ -166,7 +166,7 @@ public class TileEntityLaunchPadLarge extends TileEntityLaunchPadBase {
this.lift = this.syncLift; this.lift = this.syncLift;
this.erector = this.syncErector; this.erector = this.syncErector;
} }
if(this.liftMoving) { if(this.liftMoving) {
if(this.audioLift == null || !this.audioLift.isPlaying()) { if(this.audioLift == null || !this.audioLift.isPlaying()) {
this.audioLift = MainRegistry.proxy.getLoopedSound("hbm:door.wgh_start", xCoord, yCoord, zCoord, 0.75F, 25F, 1.0F, 5); this.audioLift = MainRegistry.proxy.getLoopedSound("hbm:door.wgh_start", xCoord, yCoord, zCoord, 0.75F, 25F, 1.0F, 5);
@ -179,7 +179,7 @@ public class TileEntityLaunchPadLarge extends TileEntityLaunchPadBase {
this.audioLift = null; this.audioLift = null;
} }
} }
if(this.erectorMoving) { if(this.erectorMoving) {
if(this.audioErector == null || !this.audioErector.isPlaying()) { if(this.audioErector == null || !this.audioErector.isPlaying()) {
this.audioErector = MainRegistry.proxy.getLoopedSound("hbm:door.garage_move", xCoord, yCoord, zCoord, 1.5F, 25F, 1.0F, 5); this.audioErector = MainRegistry.proxy.getLoopedSound("hbm:door.garage_move", xCoord, yCoord, zCoord, 1.5F, 25F, 1.0F, 5);
@ -192,7 +192,7 @@ public class TileEntityLaunchPadLarge extends TileEntityLaunchPadBase {
this.audioErector = null; this.audioErector = null;
} }
} }
if(this.erected && (this.formFactor == MissileFormFactor.HUGE.ordinal() || this.formFactor == MissileFormFactor.ATLAS.ordinal()) && this.tanks[1].getFill() > 0) { if(this.erected && (this.formFactor == MissileFormFactor.HUGE.ordinal() || this.formFactor == MissileFormFactor.ATLAS.ordinal()) && this.tanks[1].getFill() > 0) {
NBTTagCompound data = new NBTTagCompound(); NBTTagCompound data = new NBTTagCompound();
data.setString("type", "tower"); data.setString("type", "tower");
@ -208,9 +208,9 @@ public class TileEntityLaunchPadLarge extends TileEntityLaunchPadBase {
data.setFloat("strafe", 0.05F); data.setFloat("strafe", 0.05F);
for(int i = 0; i < 3; i++) MainRegistry.proxy.effectNT(data); for(int i = 0; i < 3; i++) MainRegistry.proxy.effectNT(data);
} }
List<EntityMissileBaseNT> entities = worldObj.getEntitiesWithinAABB(EntityMissileBaseNT.class, AxisAlignedBB.getBoundingBox(xCoord - 0.5, yCoord, zCoord - 0.5, xCoord + 1.5, yCoord + 10, zCoord + 1.5)); List<EntityMissileBaseNT> entities = worldObj.getEntitiesWithinAABB(EntityMissileBaseNT.class, AxisAlignedBB.getBoundingBox(xCoord - 0.5, yCoord, zCoord - 0.5, xCoord + 1.5, yCoord + 10, zCoord + 1.5));
if(!entities.isEmpty()) { if(!entities.isEmpty()) {
for(int i = 0; i < 15; i++) { for(int i = 0; i < 15; i++) {
@ -218,19 +218,27 @@ public class TileEntityLaunchPadLarge extends TileEntityLaunchPadBase {
if(worldObj.rand.nextBoolean()) dir = dir.getOpposite(); if(worldObj.rand.nextBoolean()) dir = dir.getOpposite();
float moX = (float) (worldObj.rand.nextGaussian() * 0.15F + 0.75) * dir.offsetX; float moX = (float) (worldObj.rand.nextGaussian() * 0.15F + 0.75) * dir.offsetX;
float moZ = (float) (worldObj.rand.nextGaussian() * 0.15F + 0.75) * dir.offsetZ; float moZ = (float) (worldObj.rand.nextGaussian() * 0.15F + 0.75) * dir.offsetZ;
MainRegistry.proxy.spawnParticle(xCoord + 0.5, yCoord + 0.25, zCoord + 0.5, "launchsmoke", new float[] {moX, 0, moZ}); NBTTagCompound data = new NBTTagCompound();
data.setDouble("posX", xCoord + 0.5);
data.setDouble("posY", yCoord + 0.25);
data.setDouble("posZ", zCoord + 0.5);
data.setString("type", "launchSmoke");
data.setDouble("moX", moX);
data.setDouble("moY", 0);
data.setDouble("moZ", moZ);
MainRegistry.proxy.effectNT(data);
} }
} }
} }
super.updateEntity(); super.updateEntity();
} }
@Override @Override
public void serialize(ByteBuf buf) { public void serialize(ByteBuf buf) {
super.serialize(buf); super.serialize(buf);
buf.writeBoolean(this.liftMoving); buf.writeBoolean(this.liftMoving);
buf.writeBoolean(this.erectorMoving); buf.writeBoolean(this.erectorMoving);
buf.writeBoolean(this.erected); buf.writeBoolean(this.erected);
@ -239,7 +247,7 @@ public class TileEntityLaunchPadLarge extends TileEntityLaunchPadBase {
buf.writeFloat(this.lift); buf.writeFloat(this.lift);
buf.writeFloat(this.erector); buf.writeFloat(this.erector);
} }
@Override @Override
public void deserialize(ByteBuf buf) { public void deserialize(ByteBuf buf) {
super.deserialize(buf); super.deserialize(buf);
@ -251,12 +259,12 @@ public class TileEntityLaunchPadLarge extends TileEntityLaunchPadBase {
this.formFactor = buf.readByte(); this.formFactor = buf.readByte();
this.syncLift = buf.readFloat(); this.syncLift = buf.readFloat();
this.syncErector = buf.readFloat(); this.syncErector = buf.readFloat();
if(this.lift != this.syncLift || this.erector != this.syncErector) { if(this.lift != this.syncLift || this.erector != this.syncErector) {
this.sync = 3; this.sync = 3;
} }
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
@ -267,7 +275,7 @@ public class TileEntityLaunchPadLarge extends TileEntityLaunchPadBase {
this.erector = nbt.getFloat("erector"); this.erector = nbt.getFloat("erector");
this.formFactor = nbt.getInteger("formFactor"); this.formFactor = nbt.getInteger("formFactor");
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
@ -284,7 +292,7 @@ public class TileEntityLaunchPadLarge extends TileEntityLaunchPadBase {
super.finalizeLaunch(missile); super.finalizeLaunch(missile);
this.erected = false; this.erected = false;
} }
@Override @Override
public DirPos[] getConPos() { public DirPos[] getConPos() {
return new DirPos[] { return new DirPos[] {
@ -298,12 +306,12 @@ public class TileEntityLaunchPadLarge extends TileEntityLaunchPadBase {
new DirPos(xCoord + 2, yCoord, zCoord - 5, Library.NEG_Z) new DirPos(xCoord + 2, yCoord, zCoord - 5, Library.NEG_Z)
}; };
} }
AxisAlignedBB bb = null; AxisAlignedBB bb = null;
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {
if(bb == null) { if(bb == null) {
bb = AxisAlignedBB.getBoundingBox( bb = AxisAlignedBB.getBoundingBox(
xCoord - 10, xCoord - 10,
@ -314,10 +322,10 @@ public class TileEntityLaunchPadLarge extends TileEntityLaunchPadBase {
zCoord + 11 zCoord + 11
); );
} }
return bb; return bb;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public double getMaxRenderDistanceSquared() { public double getMaxRenderDistanceSquared() {

View File

@ -35,9 +35,9 @@ public class TileEntityLaunchPadRusted extends TileEntityMachineBase implements
public int prevRedstonePower; public int prevRedstonePower;
public int redstonePower; public int redstonePower;
public Set<BlockPos> activatedBlocks = new HashSet<>(4); public Set<BlockPos> activatedBlocks = new HashSet<>(4);
public boolean missileLoaded; public boolean missileLoaded;
public TileEntityLaunchPadRusted() { public TileEntityLaunchPadRusted() {
super(4); super(4);
} }
@ -49,19 +49,19 @@ public class TileEntityLaunchPadRusted extends TileEntityMachineBase implements
@Override @Override
public void updateEntity() { public void updateEntity() {
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
if(this.redstonePower > 0 && this.prevRedstonePower <= 0) { if(this.redstonePower > 0 && this.prevRedstonePower <= 0) {
this.launch(); this.launch();
} }
this.prevRedstonePower = this.redstonePower; this.prevRedstonePower = this.redstonePower;
this.networkPackNT(250); this.networkPackNT(250);
} else { } else {
List<EntityMissileBaseNT> entities = worldObj.getEntitiesWithinAABB(EntityMissileBaseNT.class, AxisAlignedBB.getBoundingBox(xCoord - 0.5, yCoord, zCoord - 0.5, xCoord + 1.5, yCoord + 10, zCoord + 1.5)); List<EntityMissileBaseNT> entities = worldObj.getEntitiesWithinAABB(EntityMissileBaseNT.class, AxisAlignedBB.getBoundingBox(xCoord - 0.5, yCoord, zCoord - 0.5, xCoord + 1.5, yCoord + 10, zCoord + 1.5));
if(!entities.isEmpty()) { if(!entities.isEmpty()) {
for(int i = 0; i < 15; i++) { for(int i = 0; i < 15; i++) {
@ -70,8 +70,17 @@ public class TileEntityLaunchPadRusted extends TileEntityMachineBase implements
if(worldObj.rand.nextBoolean()) dir = dir.getRotation(ForgeDirection.UP); if(worldObj.rand.nextBoolean()) dir = dir.getRotation(ForgeDirection.UP);
float moX = (float) (worldObj.rand.nextGaussian() * 0.15F + 0.75) * dir.offsetX; float moX = (float) (worldObj.rand.nextGaussian() * 0.15F + 0.75) * dir.offsetX;
float moZ = (float) (worldObj.rand.nextGaussian() * 0.15F + 0.75) * dir.offsetZ; float moZ = (float) (worldObj.rand.nextGaussian() * 0.15F + 0.75) * dir.offsetZ;
MainRegistry.proxy.spawnParticle(xCoord + 0.5, yCoord + 0.25, zCoord + 0.5, "launchsmoke", new float[] {moX, 0, moZ}); NBTTagCompound data = new NBTTagCompound();
data.setDouble("posX", xCoord + 0.5);
data.setDouble("posY", yCoord + 0.25);
data.setDouble("posZ", zCoord + 0.5);
data.setString("type", "launchSmoke");
data.setDouble("moX", moX);
data.setDouble("moY", 0);
data.setDouble("moZ", moZ);
MainRegistry.proxy.effectNT(data);
} }
} }
} }
@ -82,7 +91,7 @@ public class TileEntityLaunchPadRusted extends TileEntityMachineBase implements
super.serialize(buf); super.serialize(buf);
buf.writeBoolean(this.missileLoaded); buf.writeBoolean(this.missileLoaded);
} }
@Override @Override
public void deserialize(ByteBuf buf) { public void deserialize(ByteBuf buf) {
super.deserialize(buf); super.deserialize(buf);
@ -90,18 +99,18 @@ public class TileEntityLaunchPadRusted extends TileEntityMachineBase implements
} }
public BombReturnCode launch() { public BombReturnCode launch() {
if(slots[1] != null && slots[2] != null && slots[3] != null && this.missileLoaded) { if(slots[1] != null && slots[2] != null && slots[3] != null && this.missileLoaded) {
if(slots[1].getItem() == ModItems.launch_code && slots[2].getItem() == ModItems.launch_key) { if(slots[1].getItem() == ModItems.launch_code && slots[2].getItem() == ModItems.launch_key) {
if(slots[3] != null && slots[3].getItem() instanceof IDesignatorItem) { if(slots[3] != null && slots[3].getItem() instanceof IDesignatorItem) {
IDesignatorItem designator = (IDesignatorItem) slots[3].getItem(); IDesignatorItem designator = (IDesignatorItem) slots[3].getItem();
if(!designator.isReady(worldObj, slots[3], xCoord, yCoord, zCoord)) return BombReturnCode.ERROR_MISSING_COMPONENT; if(!designator.isReady(worldObj, slots[3], xCoord, yCoord, zCoord)) return BombReturnCode.ERROR_MISSING_COMPONENT;
Vec3 coords = designator.getCoords(worldObj, slots[3], xCoord, yCoord, zCoord); Vec3 coords = designator.getCoords(worldObj, slots[3], xCoord, yCoord, zCoord);
int targetX = (int) Math.floor(coords.xCoord); int targetX = (int) Math.floor(coords.xCoord);
int targetZ = (int) Math.floor(coords.zCoord); int targetZ = (int) Math.floor(coords.zCoord);
EntityMissileDoomsdayRusted missile = new EntityMissileDoomsdayRusted(worldObj, xCoord + 0.5F, yCoord + 1F, zCoord + 0.5F, targetX, targetZ); EntityMissileDoomsdayRusted missile = new EntityMissileDoomsdayRusted(worldObj, xCoord + 0.5F, yCoord + 1F, zCoord + 0.5F, targetX, targetZ);
worldObj.spawnEntityInWorld(missile); worldObj.spawnEntityInWorld(missile);
TrackerUtil.setTrackingRange(worldObj, missile, 500); TrackerUtil.setTrackingRange(worldObj, missile, 500);
@ -109,19 +118,19 @@ public class TileEntityLaunchPadRusted extends TileEntityMachineBase implements
this.missileLoaded = false; this.missileLoaded = false;
this.decrStackSize(1, 1); this.decrStackSize(1, 1);
this.markDirty(); this.markDirty();
return BombReturnCode.LAUNCHED; return BombReturnCode.LAUNCHED;
} }
} }
} }
return BombReturnCode.ERROR_MISSING_COMPONENT; return BombReturnCode.ERROR_MISSING_COMPONENT;
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
this.missileLoaded = nbt.getBoolean("missileLoaded"); this.missileLoaded = nbt.getBoolean("missileLoaded");
this.redstonePower = nbt.getInteger("redstonePower"); this.redstonePower = nbt.getInteger("redstonePower");
@ -132,11 +141,11 @@ public class TileEntityLaunchPadRusted extends TileEntityMachineBase implements
this.activatedBlocks.add(new BlockPos(activatedBlocks.getInteger("x" + i), activatedBlocks.getInteger("y" + i), activatedBlocks.getInteger("z" + i))); this.activatedBlocks.add(new BlockPos(activatedBlocks.getInteger("x" + i), activatedBlocks.getInteger("y" + i), activatedBlocks.getInteger("z" + i)));
} }
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setBoolean("missileLoaded", missileLoaded); nbt.setBoolean("missileLoaded", missileLoaded);
nbt.setInteger("redstonePower", redstonePower); nbt.setInteger("redstonePower", redstonePower);
@ -172,10 +181,10 @@ public class TileEntityLaunchPadRusted extends TileEntityMachineBase implements
} }
AxisAlignedBB bb = null; AxisAlignedBB bb = null;
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {
if(bb == null) { if(bb == null) {
bb = AxisAlignedBB.getBoundingBox( bb = AxisAlignedBB.getBoundingBox(
xCoord - 2, xCoord - 2,
@ -186,10 +195,10 @@ public class TileEntityLaunchPadRusted extends TileEntityMachineBase implements
zCoord + 3 zCoord + 3
); );
} }
return bb; return bb;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public double getMaxRenderDistanceSquared() { public double getMaxRenderDistanceSquared() {

View File

@ -226,7 +226,15 @@ public class TileEntityLaunchTable extends TileEntityLoadedBase implements ISide
float moX = (float) (dir ? 0 : worldObj.rand.nextGaussian() * 0.65F); float moX = (float) (dir ? 0 : worldObj.rand.nextGaussian() * 0.65F);
float moZ = (float) (!dir ? 0 : worldObj.rand.nextGaussian() * 0.65F); float moZ = (float) (!dir ? 0 : worldObj.rand.nextGaussian() * 0.65F);
MainRegistry.proxy.spawnParticle(xCoord + 0.5, yCoord + 0.25, zCoord + 0.5, "launchsmoke", new float[] {moX, 0, moZ}); NBTTagCompound data = new NBTTagCompound();
data.setDouble("posX", xCoord + 0.5);
data.setDouble("posY", yCoord + 0.25);
data.setDouble("posZ", zCoord + 0.5);
data.setString("type", "launchSmoke");
data.setDouble("moX", moX);
data.setDouble("moY", 0);
data.setDouble("moZ", moZ);
MainRegistry.proxy.effectNT(data);
} }
} }
} }

View File

@ -14,19 +14,19 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
public class TileEntityBlastDoor extends TileEntityLockableBase { public class TileEntityBlastDoor extends TileEntityLockableBase {
public boolean isOpening = false; public boolean isOpening = false;
//0: closed, 1: opening/closing, 2:open //0: closed, 1: opening/closing, 2:open
public int state = 0; public int state = 0;
public long sysTime; public long sysTime;
private int timer = 0; private int timer = 0;
public boolean redstoned = false; public boolean redstoned = false;
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {
return TileEntity.INFINITE_EXTENT_AABB; return TileEntity.INFINITE_EXTENT_AABB;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public double getMaxRenderDistanceSquared() public double getMaxRenderDistanceSquared()
@ -36,25 +36,25 @@ public class TileEntityBlastDoor extends TileEntityLockableBase {
@Override @Override
public void updateEntity() { public void updateEntity() {
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
if(!isLocked() && worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) || worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord + 6, zCoord)) { if(!isLocked() && worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) || worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord + 6, zCoord)) {
if(!redstoned) { if(!redstoned) {
this.tryToggle(); this.tryToggle();
} }
redstoned = true; redstoned = true;
} else { } else {
redstoned = false; redstoned = false;
} }
if(state != 1) { if(state != 1) {
timer = 0; timer = 0;
} else { } else {
timer++; timer++;
if(isOpening) { if(isOpening) {
if(timer >= 0) { if(timer >= 0) {
removeDummy(xCoord, yCoord + 1, zCoord); removeDummy(xCoord, yCoord + 1, zCoord);
@ -88,20 +88,20 @@ public class TileEntityBlastDoor extends TileEntityLockableBase {
placeDummy(xCoord, yCoord + 1, zCoord); placeDummy(xCoord, yCoord + 1, zCoord);
} }
} }
if(timer >= 100) { if(timer >= 100) {
if(isOpening) if(isOpening)
finishOpen(); finishOpen();
else else
finishClose(); finishClose();
} }
} }
PacketDispatcher.wrapper.sendToAllAround(new TEVaultPacket(xCoord, yCoord, zCoord, isOpening, state, 0, 0), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 250)); PacketDispatcher.wrapper.sendToAllAround(new TEVaultPacket(xCoord, yCoord, zCoord, isOpening, state, 0, 0), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 250));
} }
} }
public void open() { public void open() {
if(state == 0) { if(state == 0) {
PacketDispatcher.wrapper.sendToAllAround(new TEVaultPacket(xCoord, yCoord, zCoord, isOpening, state, 1, 0), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 250)); PacketDispatcher.wrapper.sendToAllAround(new TEVaultPacket(xCoord, yCoord, zCoord, isOpening, state, 1, 0), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 250));
@ -112,17 +112,17 @@ public class TileEntityBlastDoor extends TileEntityLockableBase {
0.75F); 0.75F);
} }
} }
public void finishOpen() { public void finishOpen() {
state = 2; state = 2;
this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "hbm:block.reactorStop", 0.5F, this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "hbm:block.reactorStop", 0.5F,
1.0F); 1.0F);
} }
public void close() { public void close() {
if(state == 2) { if(state == 2) {
PacketDispatcher.wrapper.sendToAll(new TEVaultPacket(xCoord, yCoord, zCoord, isOpening, state, 1, 0)); PacketDispatcher.wrapper.sendToAllAround(new TEVaultPacket(xCoord, yCoord, zCoord, isOpening, state, 1, 0), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 250));
isOpening = false; isOpening = false;
state = 1; state = 1;
@ -130,116 +130,116 @@ public class TileEntityBlastDoor extends TileEntityLockableBase {
0.75F); 0.75F);
} }
} }
public void finishClose() { public void finishClose() {
state = 0; state = 0;
this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "hbm:block.reactorStop", 0.5F, this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "hbm:block.reactorStop", 0.5F,
1.0F); 1.0F);
} }
public void openNeigh() { public void openNeigh() {
TileEntity te0 = worldObj.getTileEntity(xCoord + 1, yCoord, zCoord); TileEntity te0 = worldObj.getTileEntity(xCoord + 1, yCoord, zCoord);
TileEntity te1 = worldObj.getTileEntity(xCoord - 1, yCoord, zCoord); TileEntity te1 = worldObj.getTileEntity(xCoord - 1, yCoord, zCoord);
TileEntity te2 = worldObj.getTileEntity(xCoord, yCoord, zCoord + 1); TileEntity te2 = worldObj.getTileEntity(xCoord, yCoord, zCoord + 1);
TileEntity te3 = worldObj.getTileEntity(xCoord, yCoord, zCoord - 1); TileEntity te3 = worldObj.getTileEntity(xCoord, yCoord, zCoord - 1);
if(te0 instanceof TileEntityBlastDoor) { if(te0 instanceof TileEntityBlastDoor) {
if(((TileEntityBlastDoor)te0).canOpen() && (!((TileEntityBlastDoor)te0).isLocked() || ((TileEntityBlastDoor)te0).lock == lock)) { if(((TileEntityBlastDoor)te0).canOpen() && (!((TileEntityBlastDoor)te0).isLocked() || ((TileEntityBlastDoor)te0).lock == lock)) {
((TileEntityBlastDoor)te0).open(); ((TileEntityBlastDoor)te0).open();
((TileEntityBlastDoor)te0).openNeigh(); ((TileEntityBlastDoor)te0).openNeigh();
} }
} }
if(te1 instanceof TileEntityBlastDoor) { if(te1 instanceof TileEntityBlastDoor) {
if(((TileEntityBlastDoor)te1).canOpen() && (!((TileEntityBlastDoor)te1).isLocked() || ((TileEntityBlastDoor)te1).lock == lock)) { if(((TileEntityBlastDoor)te1).canOpen() && (!((TileEntityBlastDoor)te1).isLocked() || ((TileEntityBlastDoor)te1).lock == lock)) {
((TileEntityBlastDoor)te1).open(); ((TileEntityBlastDoor)te1).open();
((TileEntityBlastDoor)te1).openNeigh(); ((TileEntityBlastDoor)te1).openNeigh();
} }
} }
if(te2 instanceof TileEntityBlastDoor) { if(te2 instanceof TileEntityBlastDoor) {
if(((TileEntityBlastDoor)te2).canOpen() && (!((TileEntityBlastDoor)te2).isLocked() || ((TileEntityBlastDoor)te2).lock == lock)) { if(((TileEntityBlastDoor)te2).canOpen() && (!((TileEntityBlastDoor)te2).isLocked() || ((TileEntityBlastDoor)te2).lock == lock)) {
((TileEntityBlastDoor)te2).open(); ((TileEntityBlastDoor)te2).open();
((TileEntityBlastDoor)te2).openNeigh(); ((TileEntityBlastDoor)te2).openNeigh();
} }
} }
if(te3 instanceof TileEntityBlastDoor) { if(te3 instanceof TileEntityBlastDoor) {
if(((TileEntityBlastDoor)te3).canOpen() && (!((TileEntityBlastDoor)te3).isLocked() || ((TileEntityBlastDoor)te3).lock == lock)) { if(((TileEntityBlastDoor)te3).canOpen() && (!((TileEntityBlastDoor)te3).isLocked() || ((TileEntityBlastDoor)te3).lock == lock)) {
((TileEntityBlastDoor)te3).open(); ((TileEntityBlastDoor)te3).open();
((TileEntityBlastDoor)te3).openNeigh(); ((TileEntityBlastDoor)te3).openNeigh();
} }
} }
} }
@Override @Override
public void lock() { public void lock() {
super.lock(); super.lock();
lockNeigh(); lockNeigh();
} }
public void closeNeigh() { public void closeNeigh() {
TileEntity te0 = worldObj.getTileEntity(xCoord + 1, yCoord, zCoord); TileEntity te0 = worldObj.getTileEntity(xCoord + 1, yCoord, zCoord);
TileEntity te1 = worldObj.getTileEntity(xCoord - 1, yCoord, zCoord); TileEntity te1 = worldObj.getTileEntity(xCoord - 1, yCoord, zCoord);
TileEntity te2 = worldObj.getTileEntity(xCoord, yCoord, zCoord + 1); TileEntity te2 = worldObj.getTileEntity(xCoord, yCoord, zCoord + 1);
TileEntity te3 = worldObj.getTileEntity(xCoord, yCoord, zCoord - 1); TileEntity te3 = worldObj.getTileEntity(xCoord, yCoord, zCoord - 1);
if(te0 instanceof TileEntityBlastDoor) { if(te0 instanceof TileEntityBlastDoor) {
if(((TileEntityBlastDoor)te0).canClose() && (!((TileEntityBlastDoor)te0).isLocked() || ((TileEntityBlastDoor)te0).lock == lock)) { if(((TileEntityBlastDoor)te0).canClose() && (!((TileEntityBlastDoor)te0).isLocked() || ((TileEntityBlastDoor)te0).lock == lock)) {
((TileEntityBlastDoor)te0).close(); ((TileEntityBlastDoor)te0).close();
((TileEntityBlastDoor)te0).closeNeigh(); ((TileEntityBlastDoor)te0).closeNeigh();
} }
} }
if(te1 instanceof TileEntityBlastDoor) { if(te1 instanceof TileEntityBlastDoor) {
if(((TileEntityBlastDoor)te1).canClose() && (!((TileEntityBlastDoor)te1).isLocked() || ((TileEntityBlastDoor)te1).lock == lock)) { if(((TileEntityBlastDoor)te1).canClose() && (!((TileEntityBlastDoor)te1).isLocked() || ((TileEntityBlastDoor)te1).lock == lock)) {
((TileEntityBlastDoor)te1).close(); ((TileEntityBlastDoor)te1).close();
((TileEntityBlastDoor)te1).closeNeigh(); ((TileEntityBlastDoor)te1).closeNeigh();
} }
} }
if(te2 instanceof TileEntityBlastDoor) { if(te2 instanceof TileEntityBlastDoor) {
if(((TileEntityBlastDoor)te2).canClose() && (!((TileEntityBlastDoor)te2).isLocked() || ((TileEntityBlastDoor)te2).lock == lock)) { if(((TileEntityBlastDoor)te2).canClose() && (!((TileEntityBlastDoor)te2).isLocked() || ((TileEntityBlastDoor)te2).lock == lock)) {
((TileEntityBlastDoor)te2).close(); ((TileEntityBlastDoor)te2).close();
((TileEntityBlastDoor)te2).closeNeigh(); ((TileEntityBlastDoor)te2).closeNeigh();
} }
} }
if(te3 instanceof TileEntityBlastDoor) { if(te3 instanceof TileEntityBlastDoor) {
if(((TileEntityBlastDoor)te3).canClose() && (!((TileEntityBlastDoor)te3).isLocked() || ((TileEntityBlastDoor)te3).lock == lock)) { if(((TileEntityBlastDoor)te3).canClose() && (!((TileEntityBlastDoor)te3).isLocked() || ((TileEntityBlastDoor)te3).lock == lock)) {
((TileEntityBlastDoor)te3).close(); ((TileEntityBlastDoor)te3).close();
((TileEntityBlastDoor)te3).closeNeigh(); ((TileEntityBlastDoor)te3).closeNeigh();
} }
} }
} }
public void lockNeigh() { public void lockNeigh() {
TileEntity te0 = worldObj.getTileEntity(xCoord + 1, yCoord, zCoord); TileEntity te0 = worldObj.getTileEntity(xCoord + 1, yCoord, zCoord);
TileEntity te1 = worldObj.getTileEntity(xCoord - 1, yCoord, zCoord); TileEntity te1 = worldObj.getTileEntity(xCoord - 1, yCoord, zCoord);
TileEntity te2 = worldObj.getTileEntity(xCoord, yCoord, zCoord + 1); TileEntity te2 = worldObj.getTileEntity(xCoord, yCoord, zCoord + 1);
TileEntity te3 = worldObj.getTileEntity(xCoord, yCoord, zCoord - 1); TileEntity te3 = worldObj.getTileEntity(xCoord, yCoord, zCoord - 1);
if(te0 instanceof TileEntityBlastDoor) { if(te0 instanceof TileEntityBlastDoor) {
if(!((TileEntityBlastDoor)te0).isLocked()) { if(!((TileEntityBlastDoor)te0).isLocked()) {
((TileEntityBlastDoor)te0).setPins(this.lock); ((TileEntityBlastDoor)te0).setPins(this.lock);
((TileEntityBlastDoor)te0).lock(); ((TileEntityBlastDoor)te0).lock();
((TileEntityBlastDoor)te0).setMod(lockMod); ((TileEntityBlastDoor)te0).setMod(lockMod);
} }
} }
if(te1 instanceof TileEntityBlastDoor) { if(te1 instanceof TileEntityBlastDoor) {
if(!((TileEntityBlastDoor)te1).isLocked()) { if(!((TileEntityBlastDoor)te1).isLocked()) {
@ -248,7 +248,7 @@ public class TileEntityBlastDoor extends TileEntityLockableBase {
((TileEntityBlastDoor)te1).setMod(lockMod); ((TileEntityBlastDoor)te1).setMod(lockMod);
} }
} }
if(te2 instanceof TileEntityBlastDoor) { if(te2 instanceof TileEntityBlastDoor) {
if(!((TileEntityBlastDoor)te2).isLocked()) { if(!((TileEntityBlastDoor)te2).isLocked()) {
@ -257,7 +257,7 @@ public class TileEntityBlastDoor extends TileEntityLockableBase {
((TileEntityBlastDoor)te2).setMod(lockMod); ((TileEntityBlastDoor)te2).setMod(lockMod);
} }
} }
if(te3 instanceof TileEntityBlastDoor) { if(te3 instanceof TileEntityBlastDoor) {
if(!((TileEntityBlastDoor)te3).isLocked()) { if(!((TileEntityBlastDoor)te3).isLocked()) {
@ -267,15 +267,15 @@ public class TileEntityBlastDoor extends TileEntityLockableBase {
} }
} }
} }
public boolean canOpen() { public boolean canOpen() {
return state == 0; return state == 0;
} }
public boolean canClose() { public boolean canClose() {
return state == 2; return state == 2;
} }
public void tryToggle() { public void tryToggle() {
if(canOpen()) { if(canOpen()) {
@ -286,28 +286,28 @@ public class TileEntityBlastDoor extends TileEntityLockableBase {
closeNeigh(); closeNeigh();
} }
} }
public boolean placeDummy(int x, int y, int z) { public boolean placeDummy(int x, int y, int z) {
if(!worldObj.getBlock(x, y, z).isReplaceable(worldObj, x, y, z)) if(!worldObj.getBlock(x, y, z).isReplaceable(worldObj, x, y, z))
return false; return false;
worldObj.setBlock(x, y, z, ModBlocks.dummy_block_blast); worldObj.setBlock(x, y, z, ModBlocks.dummy_block_blast);
TileEntity te = worldObj.getTileEntity(x, y, z); TileEntity te = worldObj.getTileEntity(x, y, z);
if(te instanceof TileEntityDummy) { if(te instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te; TileEntityDummy dummy = (TileEntityDummy)te;
dummy.targetX = xCoord; dummy.targetX = xCoord;
dummy.targetY = yCoord; dummy.targetY = yCoord;
dummy.targetZ = zCoord; dummy.targetZ = zCoord;
} }
return true; return true;
} }
public void removeDummy(int x, int y, int z) { public void removeDummy(int x, int y, int z) {
if(worldObj.getBlock(x, y, z) == ModBlocks.dummy_block_blast) { if(worldObj.getBlock(x, y, z) == ModBlocks.dummy_block_blast) {
DummyBlockBlast.safeBreak = true; DummyBlockBlast.safeBreak = true;
worldObj.setBlock(x, y, z, Blocks.air); worldObj.setBlock(x, y, z, Blocks.air);
@ -317,7 +317,7 @@ public class TileEntityBlastDoor extends TileEntityLockableBase {
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
isOpening = nbt.getBoolean("isOpening"); isOpening = nbt.getBoolean("isOpening");
state = nbt.getInteger("state"); state = nbt.getInteger("state");
sysTime = nbt.getLong("sysTime"); sysTime = nbt.getLong("sysTime");

View File

@ -1,14 +1,17 @@
package com.hbm.tileentity.machine; package com.hbm.tileentity.machine;
import java.util.List; import java.util.List;
import java.util.Random;
import com.hbm.lib.ModDamageSource; import com.hbm.lib.ModDamageSource;
import com.hbm.packet.PacketDispatcher; import com.hbm.main.MainRegistry;
import com.hbm.packet.toclient.LoopedSoundPacket;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import com.hbm.sound.AudioWrapper;
import com.hbm.tileentity.TileEntityLoadedBase;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
@ -16,23 +19,25 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
public class TileEntityBroadcaster extends TileEntity { public class TileEntityBroadcaster extends TileEntityLoadedBase {
private AudioWrapper audio;
@Override @Override
public void updateEntity() { public void updateEntity() {
List<Entity> list = worldObj.getEntitiesWithinAABBExcludingEntity(null, AxisAlignedBB.getBoundingBox(xCoord + 0.5 - 25, yCoord + 0.5 - 25, zCoord + 0.5 - 25, xCoord + 0.5 + 25, yCoord + 0.5 + 25, zCoord + 0.5 + 25)); List<Entity> list = worldObj.getEntitiesWithinAABBExcludingEntity(null, AxisAlignedBB.getBoundingBox(xCoord + 0.5 - 25, yCoord + 0.5 - 25, zCoord + 0.5 - 25, xCoord + 0.5 + 25, yCoord + 0.5 + 25, zCoord + 0.5 + 25));
for(int i = 0; i < list.size(); i++) { for(int i = 0; i < list.size(); i++) {
if(list.get(i) instanceof EntityLivingBase) { if(list.get(i) instanceof EntityLivingBase) {
EntityLivingBase e = (EntityLivingBase)list.get(i); EntityLivingBase e = (EntityLivingBase)list.get(i);
double d = Math.sqrt(Math.pow(e.posX - (xCoord + 0.5), 2) + Math.pow(e.posY - (yCoord + 0.5), 2) + Math.pow(e.posZ - (zCoord + 0.5), 2)); double d = Math.sqrt(Math.pow(e.posX - (xCoord + 0.5), 2) + Math.pow(e.posY - (yCoord + 0.5), 2) + Math.pow(e.posZ - (zCoord + 0.5), 2));
if(d <= 25) { if(d <= 25) {
if(e.getActivePotionEffect(Potion.confusion) == null || e.getActivePotionEffect(Potion.confusion).getDuration() < 100) if(e.getActivePotionEffect(Potion.confusion) == null || e.getActivePotionEffect(Potion.confusion).getDuration() < 100)
e.addPotionEffect(new PotionEffect(Potion.confusion.id, 300, 0)); e.addPotionEffect(new PotionEffect(Potion.confusion.id, 300, 0));
} }
if(d <= 15) { if(d <= 15) {
double t = (15 - d) / 15 * 10; double t = (15 - d) / 15 * 10;
e.attackEntityFrom(ModDamageSource.broadcast, (float) t); e.attackEntityFrom(ModDamageSource.broadcast, (float) t);
@ -40,16 +45,59 @@ public class TileEntityBroadcaster extends TileEntity {
} }
} }
if(!worldObj.isRemote) { if (worldObj.isRemote) {
PacketDispatcher.wrapper.sendToAllAround(new LoopedSoundPacket(xCoord, yCoord, zCoord), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 150)); if(audio == null) {
audio = createAudioLoop();
audio.startSound();
} else if(!audio.isPlaying()) {
audio = rebootAudio(audio);
}
int intendedVolume = 25;
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
float volume;
if(player != null) {
float f = (float)Math.sqrt(Math.pow(xCoord - player.posX, 2) + Math.pow(yCoord - player.posY, 2) + Math.pow(zCoord - player.posZ, 2));
volume = (f / intendedVolume) * -2 + 2;
} else {
volume = intendedVolume;
}
audio.updateVolume(getVolume(volume));
audio.keepAlive();
} }
} }
@Override
public void onChunkUnload() {
super.onChunkUnload();
if(audio != null) {
audio.stopSound();
audio = null;
}
}
@Override
public void invalidate() {
super.invalidate();
if(audio != null) {
audio.stopSound();
audio = null;
}
}
@Override
public AudioWrapper createAudioLoop() {
Random rand = new Random(xCoord + yCoord + zCoord);
return MainRegistry.proxy.getLoopedSound("hbm:block.broadcast" + (rand.nextInt(3) + 1), xCoord, yCoord, zCoord, 1.0F, 10F, 1.0F);
}
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {
return TileEntity.INFINITE_EXTENT_AABB; return TileEntity.INFINITE_EXTENT_AABB;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public double getMaxRenderDistanceSquared() public double getMaxRenderDistanceSquared()

View File

@ -6,18 +6,15 @@ import com.hbm.inventory.container.ContainerMachineArcFurnace;
import com.hbm.inventory.gui.GUIMachineArcFurnace; import com.hbm.inventory.gui.GUIMachineArcFurnace;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.lib.Library; import com.hbm.lib.Library;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toclient.AuxElectricityPacket;
import com.hbm.packet.toclient.AuxGaugePacket;
import com.hbm.tileentity.IGUIProvider; import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityLoadedBase; import com.hbm.tileentity.TileEntityLoadedBase;
import com.hbm.util.CompatEnergyControl; import com.hbm.util.CompatEnergyControl;
import api.hbm.energymk2.IEnergyReceiverMK2; import api.hbm.energymk2.IEnergyReceiverMK2;
import api.hbm.tile.IInfoProviderEC; import api.hbm.tile.IInfoProviderEC;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ISidedInventory;
@ -31,12 +28,12 @@ import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityMachineArcFurnace extends TileEntityLoadedBase implements ISidedInventory, IEnergyReceiverMK2, IGUIProvider, IInfoProviderEC { public class TileEntityMachineArcFurnace extends TileEntityLoadedBase implements ISidedInventory, IEnergyReceiverMK2, IGUIProvider, IInfoProviderEC {
private ItemStack slots[]; private ItemStack slots[];
public int dualCookTime; public int dualCookTime;
public long power; public long power;
public static final long maxPower = 50000; public static final long maxPower = 50000;
public static final int processingSpeed = 20; public static final int processingSpeed = 20;
//0: i //0: i
//1: o //1: o
//2: 1 //2: 1
@ -44,9 +41,9 @@ public class TileEntityMachineArcFurnace extends TileEntityLoadedBase implements
//4: 3 //4: 3
//5: b //5: b
private static final int[] slots_io = new int[] {0, 1, 2, 3, 4, 5}; private static final int[] slots_io = new int[] {0, 1, 2, 3, 4, 5};
private String customName; private String customName;
public TileEntityMachineArcFurnace() { public TileEntityMachineArcFurnace() {
slots = new ItemStack[6]; slots = new ItemStack[6];
} }
@ -91,7 +88,7 @@ public class TileEntityMachineArcFurnace extends TileEntityLoadedBase implements
public boolean hasCustomInventoryName() { public boolean hasCustomInventoryName() {
return this.customName != null && this.customName.length() > 0; return this.customName != null && this.customName.length() > 0;
} }
public void setCustomName(String name) { public void setCustomName(String name) {
this.customName = name; this.customName = name;
} }
@ -110,7 +107,7 @@ public class TileEntityMachineArcFurnace extends TileEntityLoadedBase implements
return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <=64; return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <=64;
} }
} }
//You scrubs aren't needed for anything (right now) //You scrubs aren't needed for anything (right now)
@Override @Override
public void openInventory() {} public void openInventory() {}
@ -119,16 +116,16 @@ public class TileEntityMachineArcFurnace extends TileEntityLoadedBase implements
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack itemStack) { public boolean isItemValidForSlot(int i, ItemStack itemStack) {
if(i == 2 || i == 3 || i == 4) if(i == 2 || i == 3 || i == 4)
return itemStack.getItem() == ModItems.arc_electrode; return itemStack.getItem() == ModItems.arc_electrode;
if(i == 0) if(i == 0)
return FurnaceRecipes.smelting().getSmeltingResult(itemStack) != null; return FurnaceRecipes.smelting().getSmeltingResult(itemStack) != null;
return false; return false;
} }
@Override @Override
public ItemStack decrStackSize(int i, int j) { public ItemStack decrStackSize(int i, int j) {
if(slots[i] != null) if(slots[i] != null)
@ -144,22 +141,22 @@ public class TileEntityMachineArcFurnace extends TileEntityLoadedBase implements
{ {
slots[i] = null; slots[i] = null;
} }
return itemStack1; return itemStack1;
} else { } else {
return null; return null;
} }
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
NBTTagList list = nbt.getTagList("items", 10); NBTTagList list = nbt.getTagList("items", 10);
this.power = nbt.getLong("powerTime"); this.power = nbt.getLong("powerTime");
this.dualCookTime = nbt.getInteger("cookTime"); this.dualCookTime = nbt.getInteger("cookTime");
slots = new ItemStack[getSizeInventory()]; slots = new ItemStack[getSizeInventory()];
for(int i = 0; i < list.tagCount(); i++) for(int i = 0; i < list.tagCount(); i++)
{ {
NBTTagCompound nbt1 = list.getCompoundTagAt(i); NBTTagCompound nbt1 = list.getCompoundTagAt(i);
@ -170,14 +167,14 @@ public class TileEntityMachineArcFurnace extends TileEntityLoadedBase implements
} }
} }
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setLong("powerTime", power); nbt.setLong("powerTime", power);
nbt.setInteger("cookTime", dualCookTime); nbt.setInteger("cookTime", dualCookTime);
NBTTagList list = new NBTTagList(); NBTTagList list = new NBTTagList();
for(int i = 0; i < slots.length; i++) for(int i = 0; i < slots.length; i++)
{ {
if(slots[i] != null) if(slots[i] != null)
@ -190,7 +187,7 @@ public class TileEntityMachineArcFurnace extends TileEntityLoadedBase implements
} }
nbt.setTag("items", list); nbt.setTag("items", list);
} }
@Override @Override
public int[] getAccessibleSlotsFromSide(int side) { public int[] getAccessibleSlotsFromSide(int side) {
return slots_io; return slots_io;
@ -203,87 +200,87 @@ public class TileEntityMachineArcFurnace extends TileEntityLoadedBase implements
@Override @Override
public boolean canExtractItem(int i, ItemStack itemStack, int j) { public boolean canExtractItem(int i, ItemStack itemStack, int j) {
if(i == 1) if(i == 1)
return true; return true;
if(i == 2 || i == 3 || i == 4) if(i == 2 || i == 3 || i == 4)
return itemStack.getItem() == ModItems.arc_electrode_burnt; return itemStack.getItem() == ModItems.arc_electrode_burnt;
return false; return false;
} }
public int getDiFurnaceProgressScaled(int i) { public int getDiFurnaceProgressScaled(int i) {
return (dualCookTime * i) / processingSpeed; return (dualCookTime * i) / processingSpeed;
} }
public long getPowerRemainingScaled(long i) { public long getPowerRemainingScaled(long i) {
return (power * i) / maxPower; return (power * i) / maxPower;
} }
public boolean hasPower() { public boolean hasPower() {
return power >= 250; return power >= 250;
} }
public boolean isProcessing() { public boolean isProcessing() {
return this.dualCookTime > 0; return this.dualCookTime > 0;
} }
private boolean hasElectrodes() { private boolean hasElectrodes() {
if(slots[2] != null && slots[3] != null && slots[4] != null) { if(slots[2] != null && slots[3] != null && slots[4] != null) {
if((slots[2].getItem() == ModItems.arc_electrode) && if((slots[2].getItem() == ModItems.arc_electrode) &&
(slots[3].getItem() == ModItems.arc_electrode) && (slots[3].getItem() == ModItems.arc_electrode) &&
(slots[4].getItem() == ModItems.arc_electrode)) (slots[4].getItem() == ModItems.arc_electrode))
return true; return true;
} }
return false; return false;
} }
public boolean canProcess() { public boolean canProcess() {
if(!hasElectrodes()) if(!hasElectrodes())
return false; return false;
if(slots[0] == null) if(slots[0] == null)
{ {
return false; return false;
} }
ItemStack itemStack = FurnaceRecipes.smelting().getSmeltingResult(this.slots[0]); ItemStack itemStack = FurnaceRecipes.smelting().getSmeltingResult(this.slots[0]);
if(itemStack == null) if(itemStack == null)
{ {
return false; return false;
} }
if(slots[1] == null) if(slots[1] == null)
{ {
return true; return true;
} }
if(!slots[1].isItemEqual(itemStack)) { if(!slots[1].isItemEqual(itemStack)) {
return false; return false;
} }
if(slots[1].stackSize < getInventoryStackLimit() && slots[1].stackSize < slots[1].getMaxStackSize()) { if(slots[1].stackSize < getInventoryStackLimit() && slots[1].stackSize < slots[1].getMaxStackSize()) {
return true; return true;
}else{ }else{
return slots[1].stackSize < itemStack.getMaxStackSize(); return slots[1].stackSize < itemStack.getMaxStackSize();
} }
} }
private void processItem() { private void processItem() {
if(canProcess()) { if(canProcess()) {
ItemStack itemStack = FurnaceRecipes.smelting().getSmeltingResult(this.slots[0]); ItemStack itemStack = FurnaceRecipes.smelting().getSmeltingResult(this.slots[0]);
if(slots[1] == null) if(slots[1] == null)
{ {
slots[1] = itemStack.copy(); slots[1] = itemStack.copy();
}else if(slots[1].isItemEqual(itemStack)) { }else if(slots[1].isItemEqual(itemStack)) {
slots[1].stackSize += itemStack.stackSize; slots[1].stackSize += itemStack.stackSize;
} }
for(int i = 0; i < 1; i++) for(int i = 0; i < 1; i++)
{ {
if(slots[i].stackSize <= 0) if(slots[i].stackSize <= 0)
@ -299,26 +296,26 @@ public class TileEntityMachineArcFurnace extends TileEntityLoadedBase implements
} }
} }
} }
//TODO: fix this punjabi trash //TODO: fix this punjabi trash
@Override @Override
public void updateEntity() { public void updateEntity() {
boolean flag1 = false; boolean flag1 = false;
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
this.trySubscribe(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir); this.trySubscribe(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
if(hasPower() && canProcess()) if(hasPower() && canProcess())
{ {
dualCookTime++; dualCookTime++;
power -= 250; power -= 250;
if(power < 0) if(power < 0)
power = 0; power = 0;
if(this.dualCookTime == processingSpeed) if(this.dualCookTime == processingSpeed)
{ {
this.dualCookTime = 0; this.dualCookTime = 0;
@ -328,22 +325,22 @@ public class TileEntityMachineArcFurnace extends TileEntityLoadedBase implements
}else{ }else{
dualCookTime = 0; dualCookTime = 0;
} }
boolean trigger = true; boolean trigger = true;
if(hasPower() && canProcess() && this.dualCookTime == 0) if(hasPower() && canProcess() && this.dualCookTime == 0)
{ {
trigger = false; trigger = false;
} }
if(trigger) if(trigger)
{ {
flag1 = true; flag1 = true;
MachineArcFurnace.updateBlockState(this.dualCookTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); MachineArcFurnace.updateBlockState(this.dualCookTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
} }
if(worldObj.getBlock(xCoord, yCoord, zCoord) == ModBlocks.machine_arc_furnace_off) { if(worldObj.getBlock(xCoord, yCoord, zCoord) == ModBlocks.machine_arc_furnace_off) {
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
if(hasElectrodes() && meta <= 5) { if(hasElectrodes() && meta <= 5) {
@ -353,30 +350,42 @@ public class TileEntityMachineArcFurnace extends TileEntityLoadedBase implements
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, meta - 4, 2); worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, meta - 4, 2);
} }
} }
power = Library.chargeTEFromItems(slots, 5, power, maxPower); power = Library.chargeTEFromItems(slots, 5, power, maxPower);
PacketDispatcher.wrapper.sendToAllAround(new AuxElectricityPacket(xCoord, yCoord, zCoord, power), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50)); networkPackNT(50); // it makes no sense to refactor this to some, but I want to delete the AuxElectricityPacket already
PacketDispatcher.wrapper.sendToAllAround(new AuxGaugePacket(xCoord, yCoord, zCoord, dualCookTime, 0), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50));
} }
if(flag1) if(flag1)
{ {
this.markDirty(); this.markDirty();
} }
} }
@Override
public void serialize(ByteBuf buf) {
super.serialize(buf);
buf.writeLong(power);
buf.writeInt(dualCookTime);
}
@Override
public void deserialize(ByteBuf buf) {
super.deserialize(buf);
power = buf.readLong();
dualCookTime = buf.readInt();
}
@Override @Override
public void setPower(long i) { public void setPower(long i) {
power = i; power = i;
} }
@Override @Override
public long getPower() { public long getPower() {
return power; return power;
} }
@Override @Override

View File

@ -11,8 +11,8 @@ import com.hbm.inventory.recipes.GasCentrifugeRecipes.PseudoFluidType;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.machine.IItemFluidIdentifier; import com.hbm.items.machine.IItemFluidIdentifier;
import com.hbm.lib.Library; import com.hbm.lib.Library;
import com.hbm.packet.PacketDispatcher; import com.hbm.main.MainRegistry;
import com.hbm.packet.toclient.LoopedSoundPacket; import com.hbm.sound.AudioWrapper;
import com.hbm.tileentity.IGUIProvider; import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityMachineBase; import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.util.BufferUtil; import com.hbm.util.BufferUtil;
@ -23,7 +23,6 @@ import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.energymk2.IEnergyReceiverMK2; import api.hbm.energymk2.IEnergyReceiverMK2;
import api.hbm.fluid.IFluidStandardReceiver; import api.hbm.fluid.IFluidStandardReceiver;
import api.hbm.tile.IInfoProviderEC; import api.hbm.tile.IInfoProviderEC;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -33,57 +32,61 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
//epic! //epic!
public class TileEntityMachineGasCent extends TileEntityMachineBase implements IEnergyReceiverMK2, IFluidStandardReceiver, IGUIProvider, IInfoProviderEC { public class TileEntityMachineGasCent extends TileEntityMachineBase implements IEnergyReceiverMK2, IFluidStandardReceiver, IGUIProvider, IInfoProviderEC {
public long power; public long power;
public int progress; public int progress;
public boolean isProgressing; public boolean isProgressing;
public static final int maxPower = 100000; public static final int maxPower = 100000;
public static final int processingSpeed = 150; public static final int processingSpeed = 150;
public FluidTank tank; public FluidTank tank;
public PseudoFluidTank inputTank; public PseudoFluidTank inputTank;
public PseudoFluidTank outputTank; public PseudoFluidTank outputTank;
private int audioDuration = 0;
private AudioWrapper audio;
private static final int[] slots_io = new int[] { 0, 1, 2, 3 }; private static final int[] slots_io = new int[] { 0, 1, 2, 3 };
public TileEntityMachineGasCent() { public TileEntityMachineGasCent() {
super(7); super(7);
tank = new FluidTank(Fluids.UF6, 2000); tank = new FluidTank(Fluids.UF6, 2000);
inputTank = new PseudoFluidTank(PseudoFluidType.NUF6, 8000); inputTank = new PseudoFluidTank(PseudoFluidType.NUF6, 8000);
outputTank = new PseudoFluidTank(PseudoFluidType.LEUF6, 8000); outputTank = new PseudoFluidTank(PseudoFluidType.LEUF6, 8000);
} }
@Override @Override
public String getName() { public String getName() {
return "container.gasCentrifuge"; return "container.gasCentrifuge";
} }
@Override @Override
public boolean canExtractItem(int i, ItemStack itemStack, int j) { public boolean canExtractItem(int i, ItemStack itemStack, int j) {
return i < 4; return i < 4;
} }
@Override @Override
public int[] getAccessibleSlotsFromSide(int side) { public int[] getAccessibleSlotsFromSide(int side) {
return slots_io; return slots_io;
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
power = nbt.getLong("power"); power = nbt.getLong("power");
progress = nbt.getShort("progress"); progress = nbt.getShort("progress");
tank.readFromNBT(nbt, "tank"); tank.readFromNBT(nbt, "tank");
inputTank.readFromNBT(nbt, "inputTank"); inputTank.readFromNBT(nbt, "inputTank");
outputTank.readFromNBT(nbt, "outputTank"); outputTank.readFromNBT(nbt, "outputTank");
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
@ -93,127 +96,127 @@ public class TileEntityMachineGasCent extends TileEntityMachineBase implements I
inputTank.writeToNBT(nbt, "inputTank"); inputTank.writeToNBT(nbt, "inputTank");
outputTank.writeToNBT(nbt, "outputTank"); outputTank.writeToNBT(nbt, "outputTank");
} }
public int getCentrifugeProgressScaled(int i) { public int getCentrifugeProgressScaled(int i) {
return (progress * i) / getProcessingSpeed(); return (progress * i) / getProcessingSpeed();
} }
public long getPowerRemainingScaled(int i) { public long getPowerRemainingScaled(int i) {
return (power * i) / maxPower; return (power * i) / maxPower;
} }
private boolean canEnrich() { private boolean canEnrich() {
if(power > 0 && this.inputTank.getFill() >= inputTank.getTankType().getFluidConsumed() && this.outputTank.getFill() + this.inputTank.getTankType().getFluidProduced() <= outputTank.getMaxFill()) { if(power > 0 && this.inputTank.getFill() >= inputTank.getTankType().getFluidConsumed() && this.outputTank.getFill() + this.inputTank.getTankType().getFluidProduced() <= outputTank.getMaxFill()) {
ItemStack[] list = inputTank.getTankType().getOutput(); ItemStack[] list = inputTank.getTankType().getOutput();
if(this.inputTank.getTankType().getIfHighSpeed()) if(this.inputTank.getTankType().getIfHighSpeed())
if(!(slots[6] != null && slots[6].getItem() == ModItems.upgrade_gc_speed)) if(!(slots[6] != null && slots[6].getItem() == ModItems.upgrade_gc_speed))
return false; return false;
if(list == null) if(list == null)
return false; return false;
if(list.length < 1) if(list.length < 1)
return false; return false;
if(InventoryUtil.doesArrayHaveSpace(slots, 0, 3, list)) if(InventoryUtil.doesArrayHaveSpace(slots, 0, 3, list))
return true; return true;
} }
return false; return false;
} }
private void enrich() { private void enrich() {
ItemStack[] output = inputTank.getTankType().getOutput(); ItemStack[] output = inputTank.getTankType().getOutput();
this.progress = 0; this.progress = 0;
inputTank.setFill(inputTank.getFill() - inputTank.getTankType().getFluidConsumed()); inputTank.setFill(inputTank.getFill() - inputTank.getTankType().getFluidConsumed());
outputTank.setFill(outputTank.getFill() + inputTank.getTankType().getFluidProduced()); outputTank.setFill(outputTank.getFill() + inputTank.getTankType().getFluidProduced());
for(byte i = 0; i < output.length; i++) for(byte i = 0; i < output.length; i++)
InventoryUtil.tryAddItemToInventory(slots, 0, 3, output[i].copy()); //reference types almost got me again InventoryUtil.tryAddItemToInventory(slots, 0, 3, output[i].copy()); //reference types almost got me again
} }
private void attemptConversion() { private void attemptConversion() {
if(inputTank.getFill() < inputTank.getMaxFill() && tank.getFill() > 0) { if(inputTank.getFill() < inputTank.getMaxFill() && tank.getFill() > 0) {
int fill = Math.min(inputTank.getMaxFill() - inputTank.getFill(), tank.getFill()); int fill = Math.min(inputTank.getMaxFill() - inputTank.getFill(), tank.getFill());
tank.setFill(tank.getFill() - fill); tank.setFill(tank.getFill() - fill);
inputTank.setFill(inputTank.getFill() + fill); inputTank.setFill(inputTank.getFill() + fill);
} }
} }
private boolean attemptTransfer(TileEntity te) { private boolean attemptTransfer(TileEntity te) {
if(te instanceof TileEntityMachineGasCent) { if(te instanceof TileEntityMachineGasCent) {
TileEntityMachineGasCent cent = (TileEntityMachineGasCent) te; TileEntityMachineGasCent cent = (TileEntityMachineGasCent) te;
if(cent.tank.getFill() == 0 && cent.tank.getTankType() == tank.getTankType()) { if(cent.tank.getFill() == 0 && cent.tank.getTankType() == tank.getTankType()) {
if(cent.inputTank.getTankType() != outputTank.getTankType() && outputTank.getTankType() != PseudoFluidType.NONE) { if(cent.inputTank.getTankType() != outputTank.getTankType() && outputTank.getTankType() != PseudoFluidType.NONE) {
cent.inputTank.setTankType(outputTank.getTankType()); cent.inputTank.setTankType(outputTank.getTankType());
cent.outputTank.setTankType(outputTank.getTankType().getOutputType()); cent.outputTank.setTankType(outputTank.getTankType().getOutputType());
} }
//God, why did I forget about the entirety of the fucking math library? //God, why did I forget about the entirety of the fucking math library?
if(cent.inputTank.getFill() < cent.inputTank.getMaxFill() && outputTank.getFill() > 0) { if(cent.inputTank.getFill() < cent.inputTank.getMaxFill() && outputTank.getFill() > 0) {
int fill = Math.min(cent.inputTank.getMaxFill() - cent.inputTank.getFill(), outputTank.getFill()); int fill = Math.min(cent.inputTank.getMaxFill() - cent.inputTank.getFill(), outputTank.getFill());
outputTank.setFill(outputTank.getFill() - fill); outputTank.setFill(outputTank.getFill() - fill);
cent.inputTank.setFill(cent.inputTank.getFill() + fill); cent.inputTank.setFill(cent.inputTank.getFill() + fill);
} }
return true; return true;
} }
} }
return false; return false;
} }
@Override @Override
public void updateEntity() { public void updateEntity() {
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
updateConnections(); updateConnections();
power = Library.chargeTEFromItems(slots, 4, power, maxPower); power = Library.chargeTEFromItems(slots, 4, power, maxPower);
setTankType(5); setTankType(5);
if(GasCentrifugeRecipes.fluidConversions.containsValue(inputTank.getTankType())) { if(GasCentrifugeRecipes.fluidConversions.containsValue(inputTank.getTankType())) {
attemptConversion(); attemptConversion();
} }
if(canEnrich()) { if(canEnrich()) {
isProgressing = true; isProgressing = true;
this.progress++; this.progress++;
if(slots[6] != null && slots[6].getItem() == ModItems.upgrade_gc_speed) if(slots[6] != null && slots[6].getItem() == ModItems.upgrade_gc_speed)
this.power -= 300; this.power -= 300;
else else
this.power -= 200; this.power -= 200;
if(this.power < 0) { if(this.power < 0) {
power = 0; power = 0;
this.progress = 0; this.progress = 0;
} }
if(progress >= getProcessingSpeed()) if(progress >= getProcessingSpeed())
enrich(); enrich();
} else { } else {
isProgressing = false; isProgressing = false;
this.progress = 0; this.progress = 0;
} }
if(worldObj.getTotalWorldTime() % 10 == 0) { if(worldObj.getTotalWorldTime() % 10 == 0) {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
TileEntity te = worldObj.getTileEntity(this.xCoord - dir.offsetX, this.yCoord, this.zCoord - dir.offsetZ); TileEntity te = worldObj.getTileEntity(this.xCoord - dir.offsetX, this.yCoord, this.zCoord - dir.offsetZ);
//*AT THE MOMENT*, there's not really any need for a dedicated method for this. Yet. //*AT THE MOMENT*, there's not really any need for a dedicated method for this. Yet.
if(!attemptTransfer(te) && this.inputTank.getTankType() == PseudoFluidType.LEUF6) { if(!attemptTransfer(te) && this.inputTank.getTankType() == PseudoFluidType.LEUF6) {
ItemStack[] converted = new ItemStack[] { new ItemStack(ModItems.nugget_uranium_fuel, 6), new ItemStack(ModItems.fluorite) }; ItemStack[] converted = new ItemStack[] { new ItemStack(ModItems.nugget_uranium_fuel, 6), new ItemStack(ModItems.fluorite) };
if(this.outputTank.getFill() >= 600 && InventoryUtil.doesArrayHaveSpace(slots, 0, 3, converted)) { if(this.outputTank.getFill() >= 600 && InventoryUtil.doesArrayHaveSpace(slots, 0, 3, converted)) {
this.outputTank.setFill(this.outputTank.getFill() - 600); this.outputTank.setFill(this.outputTank.getFill() - 600);
for(ItemStack stack : converted) for(ItemStack stack : converted)
@ -221,13 +224,46 @@ public class TileEntityMachineGasCent extends TileEntityMachineBase implements I
} }
} }
} }
this.networkPackNT(50); this.networkPackNT(50);
PacketDispatcher.wrapper.sendToAllAround(new LoopedSoundPacket(xCoord, yCoord, zCoord), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50)); } else {
if(isProgressing) {
audioDuration += 2;
} else {
audioDuration -= 3;
}
audioDuration = MathHelper.clamp_int(audioDuration, 0, 60);
if(audioDuration > 10) {
if(audio == null) {
audio = createAudioLoop();
audio.startSound();
} else if(!audio.isPlaying()) {
audio = rebootAudio(audio);
}
audio.updateVolume(getVolume(1F));
audio.updatePitch((audioDuration - 10) / 100F + 0.5F);
} else {
if(audio != null) {
audio.stopSound();
audio = null;
}
}
} }
} }
@Override
public AudioWrapper createAudioLoop() {
return MainRegistry.proxy.getLoopedSound("hbm:block.centrifugeOperate", xCoord, yCoord, zCoord, 1.0F, 10F, 1.0F);
}
@Override @Override
public void serialize(ByteBuf buf) { public void serialize(ByteBuf buf) {
super.serialize(buf); super.serialize(buf);
@ -239,35 +275,35 @@ public class TileEntityMachineGasCent extends TileEntityMachineBase implements I
buf.writeInt(outputTank.getFill()); buf.writeInt(outputTank.getFill());
BufferUtil.writeString(buf, inputTank.getTankType().name); //cough cough BufferUtil.writeString(buf, inputTank.getTankType().name); //cough cough
BufferUtil.writeString(buf, outputTank.getTankType().name); BufferUtil.writeString(buf, outputTank.getTankType().name);
tank.serialize(buf); tank.serialize(buf);
} }
@Override @Override
public void deserialize(ByteBuf buf) { public void deserialize(ByteBuf buf) {
super.deserialize(buf); super.deserialize(buf);
power = buf.readLong(); power = buf.readLong();
progress = buf.readInt(); progress = buf.readInt();
isProgressing = buf.readBoolean(); isProgressing = buf.readBoolean();
inputTank.setFill(buf.readInt()); inputTank.setFill(buf.readInt());
outputTank.setFill(buf.readInt()); outputTank.setFill(buf.readInt());
inputTank.setTankType(PseudoFluidType.types.get(BufferUtil.readString(buf))); inputTank.setTankType(PseudoFluidType.types.get(BufferUtil.readString(buf)));
outputTank.setTankType(PseudoFluidType.types.get(BufferUtil.readString(buf))); outputTank.setTankType(PseudoFluidType.types.get(BufferUtil.readString(buf)));
tank.deserialize(buf); tank.deserialize(buf);
} }
private void updateConnections() { private void updateConnections() {
for(DirPos pos : getConPos()) { for(DirPos pos : getConPos()) {
this.trySubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); this.trySubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(GasCentrifugeRecipes.fluidConversions.containsValue(inputTank.getTankType())) { if(GasCentrifugeRecipes.fluidConversions.containsValue(inputTank.getTankType())) {
this.trySubscribe(tank.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); this.trySubscribe(tank.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
} }
} }
} }
private DirPos[] getConPos() { private DirPos[] getConPos() {
return new DirPos[] { return new DirPos[] {
new DirPos(xCoord, yCoord - 1, zCoord, Library.NEG_Y), new DirPos(xCoord, yCoord - 1, zCoord, Library.NEG_Y),
@ -286,40 +322,40 @@ public class TileEntityMachineGasCent extends TileEntityMachineBase implements I
@Override @Override
public long getPower() { public long getPower() {
return power; return power;
} }
@Override @Override
public long getMaxPower() { public long getMaxPower() {
return maxPower; return maxPower;
} }
public int getProcessingSpeed() { public int getProcessingSpeed() {
if(slots[6] != null && slots[6].getItem() == ModItems.upgrade_gc_speed) { if(slots[6] != null && slots[6].getItem() == ModItems.upgrade_gc_speed) {
return processingSpeed - 70; return processingSpeed - 70;
} }
return processingSpeed; return processingSpeed;
} }
public void setTankType(int in) { public void setTankType(int in) {
if(slots[in] != null && slots[in].getItem() instanceof IItemFluidIdentifier) { if(slots[in] != null && slots[in].getItem() instanceof IItemFluidIdentifier) {
IItemFluidIdentifier id = (IItemFluidIdentifier) slots[in].getItem(); IItemFluidIdentifier id = (IItemFluidIdentifier) slots[in].getItem();
FluidType newType = id.getType(worldObj, xCoord, yCoord, zCoord, slots[in]); FluidType newType = id.getType(worldObj, xCoord, yCoord, zCoord, slots[in]);
if(tank.getTankType() != newType) { if(tank.getTankType() != newType) {
PseudoFluidType pseudo = GasCentrifugeRecipes.fluidConversions.get(newType); PseudoFluidType pseudo = GasCentrifugeRecipes.fluidConversions.get(newType);
if(pseudo != null) { if(pseudo != null) {
inputTank.setTankType(pseudo); inputTank.setTankType(pseudo);
outputTank.setTankType(pseudo.getOutputType()); outputTank.setTankType(pseudo.getOutputType());
tank.setTankType(newType); tank.setTankType(newType);
} }
} }
} }
} }
@Override @Override
public FluidTank[] getReceivingTanks() { public FluidTank[] getReceivingTanks() {
return new FluidTank[] { tank }; return new FluidTank[] { tank };
@ -329,71 +365,71 @@ public class TileEntityMachineGasCent extends TileEntityMachineBase implements I
public FluidTank[] getAllTanks() { public FluidTank[] getAllTanks() {
return new FluidTank[] { tank }; return new FluidTank[] { tank };
} }
AxisAlignedBB bb = null; AxisAlignedBB bb = null;
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {
if(bb == null) { if(bb == null) {
bb = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 5, zCoord + 1); bb = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 5, zCoord + 1);
} }
return bb; return bb;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public double getMaxRenderDistanceSquared() { public double getMaxRenderDistanceSquared() {
return 65536.0D; return 65536.0D;
} }
public class PseudoFluidTank { public class PseudoFluidTank {
PseudoFluidType type; PseudoFluidType type;
int fluid; int fluid;
int maxFluid; int maxFluid;
public PseudoFluidTank(PseudoFluidType type, int maxFluid) { public PseudoFluidTank(PseudoFluidType type, int maxFluid) {
this.type = type; this.type = type;
this.maxFluid = maxFluid; this.maxFluid = maxFluid;
} }
public void setFill(int i) { public void setFill(int i) {
fluid = i; fluid = i;
} }
public void setTankType(PseudoFluidType type) { public void setTankType(PseudoFluidType type) {
if(this.type.equals(type)) if(this.type.equals(type))
return; return;
if(type == null) if(type == null)
this.type = PseudoFluidType.NONE; this.type = PseudoFluidType.NONE;
else else
this.type = type; this.type = type;
this.setFill(0); this.setFill(0);
} }
public PseudoFluidType getTankType() { public PseudoFluidType getTankType() {
return type; return type;
} }
public int getFill() { public int getFill() {
return fluid; return fluid;
} }
public int getMaxFill() { public int getMaxFill() {
return maxFluid; return maxFluid;
} }
//Called by TE to save fillstate //Called by TE to save fillstate
public void writeToNBT(NBTTagCompound nbt, String s) { public void writeToNBT(NBTTagCompound nbt, String s) {
nbt.setInteger(s, fluid); nbt.setInteger(s, fluid);
nbt.setInteger(s + "_max", maxFluid); nbt.setInteger(s + "_max", maxFluid);
nbt.setString(s + "_type", type.name); nbt.setString(s + "_type", type.name);
} }
//Called by TE to load fillstate //Called by TE to load fillstate
public void readFromNBT(NBTTagCompound nbt, String s) { public void readFromNBT(NBTTagCompound nbt, String s) {
fluid = nbt.getInteger(s); fluid = nbt.getInteger(s);
@ -402,7 +438,7 @@ public class TileEntityMachineGasCent extends TileEntityMachineBase implements I
type = PseudoFluidType.types.get(nbt.getString(s + "_type")); type = PseudoFluidType.types.get(nbt.getString(s + "_type"));
if(type == null) type = PseudoFluidType.NONE; if(type == null) type = PseudoFluidType.NONE;
} }
/* ______ ______ /* ______ ______
* _I____I_ _I____I_ * _I____I_ _I____I_
* / \\\ / \\\ * / \\\ / \\\

View File

@ -4,8 +4,6 @@ import com.hbm.config.VersatileConfig;
import com.hbm.inventory.container.ContainerMachineRTG; import com.hbm.inventory.container.ContainerMachineRTG;
import com.hbm.inventory.gui.GUIMachineRTG; import com.hbm.inventory.gui.GUIMachineRTG;
import com.hbm.items.machine.ItemRTGPellet; import com.hbm.items.machine.ItemRTGPellet;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toclient.AuxElectricityPacket;
import com.hbm.tileentity.IGUIProvider; import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityLoadedBase; import com.hbm.tileentity.TileEntityLoadedBase;
import com.hbm.util.CompatEnergyControl; import com.hbm.util.CompatEnergyControl;
@ -13,9 +11,9 @@ import com.hbm.util.RTGUtil;
import api.hbm.energymk2.IEnergyProviderMK2; import api.hbm.energymk2.IEnergyProviderMK2;
import api.hbm.tile.IInfoProviderEC; import api.hbm.tile.IInfoProviderEC;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ISidedInventory;
@ -28,16 +26,16 @@ import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityMachineRTG extends TileEntityLoadedBase implements ISidedInventory, IEnergyProviderMK2, IGUIProvider, IInfoProviderEC { public class TileEntityMachineRTG extends TileEntityLoadedBase implements ISidedInventory, IEnergyProviderMK2, IGUIProvider, IInfoProviderEC {
private ItemStack slots[]; private ItemStack slots[];
public int heat; public int heat;
public final int heatMax = VersatileConfig.rtgDecay() ? 600 : 200; public final int heatMax = VersatileConfig.rtgDecay() ? 600 : 200;
public long power; public long power;
public final long powerMax = 100000; public final long powerMax = 100000;
public static final int[] slot_io = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; public static final int[] slot_io = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
private String customName; private String customName;
public TileEntityMachineRTG() { public TileEntityMachineRTG() {
slots = new ItemStack[15]; slots = new ItemStack[15];
} }
@ -82,7 +80,7 @@ public class TileEntityMachineRTG extends TileEntityLoadedBase implements ISided
public boolean hasCustomInventoryName() { public boolean hasCustomInventoryName() {
return this.customName != null && this.customName.length() > 0; return this.customName != null && this.customName.length() > 0;
} }
public void setCustomName(String name) { public void setCustomName(String name) {
this.customName = name; this.customName = name;
} }
@ -101,7 +99,7 @@ public class TileEntityMachineRTG extends TileEntityLoadedBase implements ISided
return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <=64; return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <=64;
} }
} }
//You scrubs aren't needed for anything (right now) //You scrubs aren't needed for anything (right now)
@Override @Override
public void openInventory() {} public void openInventory() {}
@ -112,7 +110,7 @@ public class TileEntityMachineRTG extends TileEntityLoadedBase implements ISided
public boolean isItemValidForSlot(int i, ItemStack itemStack) { public boolean isItemValidForSlot(int i, ItemStack itemStack) {
return itemStack.getItem() instanceof ItemRTGPellet; return itemStack.getItem() instanceof ItemRTGPellet;
} }
@Override @Override
public ItemStack decrStackSize(int i, int j) { public ItemStack decrStackSize(int i, int j) {
if(slots[i] != null) if(slots[i] != null)
@ -128,13 +126,13 @@ public class TileEntityMachineRTG extends TileEntityLoadedBase implements ISided
{ {
slots[i] = null; slots[i] = null;
} }
return itemStack1; return itemStack1;
} else { } else {
return null; return null;
} }
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
@ -143,7 +141,7 @@ public class TileEntityMachineRTG extends TileEntityLoadedBase implements ISided
power = nbt.getLong("power"); power = nbt.getLong("power");
heat = nbt.getInteger("heat"); heat = nbt.getInteger("heat");
slots = new ItemStack[getSizeInventory()]; slots = new ItemStack[getSizeInventory()];
for(int i = 0; i < list.tagCount(); i++) for(int i = 0; i < list.tagCount(); i++)
{ {
NBTTagCompound nbt1 = list.getCompoundTagAt(i); NBTTagCompound nbt1 = list.getCompoundTagAt(i);
@ -154,14 +152,14 @@ public class TileEntityMachineRTG extends TileEntityLoadedBase implements ISided
} }
} }
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setLong("power", power); nbt.setLong("power", power);
nbt.setInteger("heat", heat); nbt.setInteger("heat", heat);
NBTTagList list = new NBTTagList(); NBTTagList list = new NBTTagList();
for(int i = 0; i < slots.length; i++) { for(int i = 0; i < slots.length; i++) {
if(slots[i] != null) { if(slots[i] != null) {
NBTTagCompound nbt1 = new NBTTagCompound(); NBTTagCompound nbt1 = new NBTTagCompound();
@ -172,7 +170,7 @@ public class TileEntityMachineRTG extends TileEntityLoadedBase implements ISided
} }
nbt.setTag("items", list); nbt.setTag("items", list);
} }
@Override @Override
public int[] getAccessibleSlotsFromSide(int p_94128_1_) { public int[] getAccessibleSlotsFromSide(int p_94128_1_) {
return slot_io; return slot_io;
@ -187,19 +185,19 @@ public class TileEntityMachineRTG extends TileEntityLoadedBase implements ISided
public boolean canExtractItem(int i, ItemStack itemStack, int j) { public boolean canExtractItem(int i, ItemStack itemStack, int j) {
return false; return false;
} }
public long getPowerScaled(long i) { public long getPowerScaled(long i) {
return (power * i) / powerMax; return (power * i) / powerMax;
} }
public int getHeatScaled(int i) { public int getHeatScaled(int i) {
return (heat * i) / heatMax; return (heat * i) / heatMax;
} }
public boolean hasPower() { public boolean hasPower() {
return power > 0; return power > 0;
} }
public boolean hasHeat() { public boolean hasHeat() {
return RTGUtil.hasHeat(slots, slot_io); return RTGUtil.hasHeat(slots, slot_io);
} }
@ -208,23 +206,35 @@ public class TileEntityMachineRTG extends TileEntityLoadedBase implements ISided
public void updateEntity() { public void updateEntity() {
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
this.tryProvide(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir); this.tryProvide(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
heat = RTGUtil.updateRTGs(slots, slot_io); heat = RTGUtil.updateRTGs(slots, slot_io);
if(heat > heatMax) if(heat > heatMax)
heat = heatMax; heat = heatMax;
power += heat * 5; power += heat * 5;
if(power > powerMax) if(power > powerMax)
power = powerMax; power = powerMax;
PacketDispatcher.wrapper.sendToAllAround(new AuxElectricityPacket(xCoord, yCoord, zCoord, power), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50)); networkPackNT(50);
} }
} }
@Override
public void serialize(ByteBuf buf) {
super.serialize(buf);
buf.writeLong(power);
}
@Override
public void deserialize(ByteBuf buf) {
super.deserialize(buf);
power = buf.readLong();
}
@Override @Override
public long getPower() { public long getPower() {
return power; return power;

View File

@ -5,16 +5,14 @@ import com.hbm.inventory.gui.GUIMachineShredder;
import com.hbm.inventory.recipes.ShredderRecipes; import com.hbm.inventory.recipes.ShredderRecipes;
import com.hbm.items.machine.ItemBlades; import com.hbm.items.machine.ItemBlades;
import com.hbm.lib.Library; import com.hbm.lib.Library;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toclient.AuxElectricityPacket;
import com.hbm.tileentity.IGUIProvider; import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityLoadedBase; import com.hbm.tileentity.TileEntityLoadedBase;
import api.hbm.energymk2.IBatteryItem; import api.hbm.energymk2.IBatteryItem;
import api.hbm.energymk2.IEnergyReceiverMK2; import api.hbm.energymk2.IEnergyReceiverMK2;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ISidedInventory;
@ -33,11 +31,11 @@ public class TileEntityMachineShredder extends TileEntityLoadedBase implements I
public int soundCycle = 0; public int soundCycle = 0;
public static final long maxPower = 10000; public static final long maxPower = 10000;
public static final int processingSpeed = 60; public static final int processingSpeed = 60;
private static final int[] slots_io = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29}; private static final int[] slots_io = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29};
private String customName; private String customName;
public TileEntityMachineShredder() { public TileEntityMachineShredder() {
slots = new ItemStack[30]; slots = new ItemStack[30];
} }
@ -82,7 +80,7 @@ public class TileEntityMachineShredder extends TileEntityLoadedBase implements I
public boolean hasCustomInventoryName() { public boolean hasCustomInventoryName() {
return this.customName != null && this.customName.length() > 0; return this.customName != null && this.customName.length() > 0;
} }
public void setCustomName(String name) { public void setCustomName(String name) {
this.customName = name; this.customName = name;
} }
@ -101,7 +99,7 @@ public class TileEntityMachineShredder extends TileEntityLoadedBase implements I
return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <=64; return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <=64;
} }
} }
//You scrubs aren't needed for anything (right now) //You scrubs aren't needed for anything (right now)
@Override @Override
public void openInventory() {} public void openInventory() {}
@ -113,10 +111,10 @@ public class TileEntityMachineShredder extends TileEntityLoadedBase implements I
if(i < 9) return ShredderRecipes.getShredderResult(stack) != null && !(stack.getItem() instanceof ItemBlades); if(i < 9) return ShredderRecipes.getShredderResult(stack) != null && !(stack.getItem() instanceof ItemBlades);
if(i == 29) return stack.getItem() instanceof IBatteryItem; if(i == 29) return stack.getItem() instanceof IBatteryItem;
if(i == 27 || i == 28) return stack.getItem() instanceof ItemBlades; if(i == 27 || i == 28) return stack.getItem() instanceof ItemBlades;
return false; return false;
} }
@Override @Override
public ItemStack decrStackSize(int i, int j) { public ItemStack decrStackSize(int i, int j) {
if(slots[i] != null) if(slots[i] != null)
@ -132,21 +130,21 @@ public class TileEntityMachineShredder extends TileEntityLoadedBase implements I
{ {
slots[i] = null; slots[i] = null;
} }
return itemStack1; return itemStack1;
} else { } else {
return null; return null;
} }
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
NBTTagList list = nbt.getTagList("items", 10); NBTTagList list = nbt.getTagList("items", 10);
this.power = nbt.getLong("powerTime"); this.power = nbt.getLong("powerTime");
slots = new ItemStack[getSizeInventory()]; slots = new ItemStack[getSizeInventory()];
for(int i = 0; i < list.tagCount(); i++) for(int i = 0; i < list.tagCount(); i++)
{ {
NBTTagCompound nbt1 = list.getCompoundTagAt(i); NBTTagCompound nbt1 = list.getCompoundTagAt(i);
@ -157,13 +155,13 @@ public class TileEntityMachineShredder extends TileEntityLoadedBase implements I
} }
} }
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setLong("powerTime", power); nbt.setLong("powerTime", power);
NBTTagList list = new NBTTagList(); NBTTagList list = new NBTTagList();
for(int i = 0; i < slots.length; i++) for(int i = 0; i < slots.length; i++)
{ {
if(slots[i] != null) if(slots[i] != null)
@ -176,7 +174,7 @@ public class TileEntityMachineShredder extends TileEntityLoadedBase implements I
} }
nbt.setTag("items", list); nbt.setTag("items", list);
} }
@Override @Override
public int[] getAccessibleSlotsFromSide(int side) { public int[] getAccessibleSlotsFromSide(int side) {
return slots_io; return slots_io;
@ -186,20 +184,20 @@ public class TileEntityMachineShredder extends TileEntityLoadedBase implements I
public boolean canInsertItem(int slot, ItemStack itemStack, int side) { public boolean canInsertItem(int slot, ItemStack itemStack, int side) {
if((slot >= 9 && slot != 27 && slot != 28) || !this.isItemValidForSlot(slot, itemStack)) if((slot >= 9 && slot != 27 && slot != 28) || !this.isItemValidForSlot(slot, itemStack))
return false; return false;
if(slots[slot] == null) if(slots[slot] == null)
return true; return true;
int size = slots[slot].stackSize; int size = slots[slot].stackSize;
for(int k = 0; k < 9; k++) { for(int k = 0; k < 9; k++) {
if(slots[k] == null) if(slots[k] == null)
return false; return false;
if(slots[k].getItem() == itemStack.getItem() && slots[k].getItemDamage() == itemStack.getItemDamage() && slots[k].stackSize < size) if(slots[k].getItem() == itemStack.getItem() && slots[k].getItemDamage() == itemStack.getItemDamage() && slots[k].stackSize < size)
return false; return false;
} }
return true; return true;
} }
@ -207,42 +205,42 @@ public class TileEntityMachineShredder extends TileEntityLoadedBase implements I
public boolean canExtractItem(int i, ItemStack itemStack, int j) { public boolean canExtractItem(int i, ItemStack itemStack, int j) {
if(i >= 9 && i <= 26) return true; if(i >= 9 && i <= 26) return true;
if(i >= 27 && i <= 28) if(itemStack.getItemDamage() == itemStack.getMaxDamage() && itemStack.getMaxDamage() > 0) return true; if(i >= 27 && i <= 28) if(itemStack.getItemDamage() == itemStack.getMaxDamage() && itemStack.getMaxDamage() > 0) return true;
return false; return false;
} }
public int getDiFurnaceProgressScaled(int i) { public int getDiFurnaceProgressScaled(int i) {
return (progress * i) / processingSpeed; return (progress * i) / processingSpeed;
} }
public boolean hasPower() { public boolean hasPower() {
return power > 0; return power > 0;
} }
public boolean isProcessing() { public boolean isProcessing() {
return this.progress > 0; return this.progress > 0;
} }
@Override @Override
public void updateEntity() { public void updateEntity() {
boolean flag1 = false; boolean flag1 = false;
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
this.updateConnections(); this.updateConnections();
if(hasPower() && canProcess()) if(hasPower() && canProcess())
{ {
progress++; progress++;
power -= 5; power -= 5;
if(this.progress == TileEntityMachineShredder.processingSpeed) if(this.progress == TileEntityMachineShredder.processingSpeed)
{ {
for(int i = 27; i <= 28; i++) for(int i = 27; i <= 28; i++)
if(slots[i].getMaxDamage() > 0) if(slots[i].getMaxDamage() > 0)
this.slots[i].setItemDamage(this.slots[i].getItemDamage() + 1); this.slots[i].setItemDamage(this.slots[i].getItemDamage() + 1);
this.progress = 0; this.progress = 0;
this.processItem(); this.processItem();
flag1 = true; flag1 = true;
@ -250,66 +248,78 @@ public class TileEntityMachineShredder extends TileEntityLoadedBase implements I
if(soundCycle == 0) if(soundCycle == 0)
this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "minecart.base", getVolume(1.0F), 0.75F); this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "minecart.base", getVolume(1.0F), 0.75F);
soundCycle++; soundCycle++;
if(soundCycle >= 50) if(soundCycle >= 50)
soundCycle = 0; soundCycle = 0;
}else{ }else{
progress = 0; progress = 0;
} }
boolean trigger = true; boolean trigger = true;
if(hasPower() && canProcess() && this.progress == 0) if(hasPower() && canProcess() && this.progress == 0)
{ {
trigger = false; trigger = false;
} }
if(trigger) if(trigger)
{ {
flag1 = true; flag1 = true;
} }
power = Library.chargeTEFromItems(slots, 29, power, maxPower); power = Library.chargeTEFromItems(slots, 29, power, maxPower);
PacketDispatcher.wrapper.sendToAllAround(new AuxElectricityPacket(xCoord, yCoord, zCoord, power), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50)); networkPackNT(50);
} }
if(flag1) if(flag1)
{ {
this.markDirty(); this.markDirty();
} }
} }
@Override
public void serialize(ByteBuf buf) {
super.serialize(buf);
buf.writeLong(power);
}
@Override
public void deserialize(ByteBuf buf) {
super.deserialize(buf);
power = buf.readLong();
}
private void updateConnections() { private void updateConnections() {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
this.trySubscribe(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir); this.trySubscribe(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
} }
public void processItem() { public void processItem() {
for(int inpSlot = 0; inpSlot < 9; inpSlot++) for(int inpSlot = 0; inpSlot < 9; inpSlot++)
{ {
if(slots[inpSlot] != null && hasSpace(slots[inpSlot])) if(slots[inpSlot] != null && hasSpace(slots[inpSlot]))
{ {
ItemStack inp = slots[inpSlot]; ItemStack inp = slots[inpSlot];
ItemStack outp = ShredderRecipes.getShredderResult(inp); ItemStack outp = ShredderRecipes.getShredderResult(inp);
boolean flag = false; boolean flag = false;
for (int outSlot = 9; outSlot < 27; outSlot++) for (int outSlot = 9; outSlot < 27; outSlot++)
{ {
if (slots[outSlot] != null && slots[outSlot].getItem() == outp.getItem() && if (slots[outSlot] != null && slots[outSlot].getItem() == outp.getItem() &&
slots[outSlot].getItemDamage() == outp.getItemDamage() && slots[outSlot].getItemDamage() == outp.getItemDamage() &&
slots[outSlot].stackSize + outp.stackSize <= outp.getMaxStackSize()) { slots[outSlot].stackSize + outp.stackSize <= outp.getMaxStackSize()) {
slots[outSlot].stackSize += outp.stackSize; slots[outSlot].stackSize += outp.stackSize;
slots[inpSlot].stackSize -= 1; slots[inpSlot].stackSize -= 1;
flag = true; flag = true;
break; break;
} }
} }
if(!flag) if(!flag)
for (int outSlot = 9; outSlot < 27; outSlot++) for (int outSlot = 9; outSlot < 27; outSlot++)
{ {
@ -319,18 +329,18 @@ public class TileEntityMachineShredder extends TileEntityLoadedBase implements I
break; break;
} }
} }
if(slots[inpSlot].stackSize <= 0) if(slots[inpSlot].stackSize <= 0)
slots[inpSlot] = null; slots[inpSlot] = null;
} }
} }
} }
public boolean canProcess() { public boolean canProcess() {
if(slots[27] != null && slots[28] != null && if(slots[27] != null && slots[28] != null &&
this.getGearLeft() > 0 && this.getGearLeft() < 3 && this.getGearLeft() > 0 && this.getGearLeft() < 3 &&
this.getGearRight() > 0 && this.getGearRight() < 3) { this.getGearRight() > 0 && this.getGearRight() < 3) {
for(int i = 0; i < 9; i++) for(int i = 0; i < 9; i++)
{ {
if(slots[i] != null && slots[i].stackSize > 0 && hasSpace(slots[i])) if(slots[i] != null && slots[i].stackSize > 0 && hasSpace(slots[i]))
@ -339,14 +349,14 @@ public class TileEntityMachineShredder extends TileEntityLoadedBase implements I
} }
} }
} }
return false; return false;
} }
public boolean hasSpace(ItemStack stack) { public boolean hasSpace(ItemStack stack) {
ItemStack result = ShredderRecipes.getShredderResult(stack); ItemStack result = ShredderRecipes.getShredderResult(stack);
if (result != null) if (result != null)
for (int i = 9; i < 27; i++) { for (int i = 9; i < 27; i++) {
if (slots[i] == null) { if (slots[i] == null) {
@ -358,16 +368,16 @@ public class TileEntityMachineShredder extends TileEntityLoadedBase implements I
return true; return true;
} }
} }
return false; return false;
} }
@Override @Override
public void setPower(long i) { public void setPower(long i) {
this.power = i; this.power = i;
} }
public long getPowerScaled(long i) { public long getPowerScaled(long i) {
return (power * i) / maxPower; return (power * i) / maxPower;
} }
@ -381,14 +391,14 @@ public class TileEntityMachineShredder extends TileEntityLoadedBase implements I
public long getMaxPower() { public long getMaxPower() {
return TileEntityMachineShredder.maxPower; return TileEntityMachineShredder.maxPower;
} }
public int getGearLeft() { public int getGearLeft() {
if(slots[27] != null && slots[27].getItem() instanceof ItemBlades) if(slots[27] != null && slots[27].getItem() instanceof ItemBlades)
{ {
if(slots[27].getMaxDamage() == 0) if(slots[27].getMaxDamage() == 0)
return 1; return 1;
if(slots[27].getItemDamage() < slots[27].getItem().getMaxDamage()/2) if(slots[27].getItemDamage() < slots[27].getItem().getMaxDamage()/2)
{ {
return 1; return 1;
@ -398,17 +408,17 @@ public class TileEntityMachineShredder extends TileEntityLoadedBase implements I
return 3; return 3;
} }
} }
return 0; return 0;
} }
public int getGearRight() { public int getGearRight() {
if(slots[28] != null && slots[28].getItem() instanceof ItemBlades) if(slots[28] != null && slots[28].getItem() instanceof ItemBlades)
{ {
if(slots[28].getMaxDamage() == 0) if(slots[28].getMaxDamage() == 0)
return 1; return 1;
if(slots[28].getItemDamage() < slots[28].getItem().getMaxDamage()/2) if(slots[28].getItemDamage() < slots[28].getItem().getMaxDamage()/2)
{ {
return 1; return 1;
@ -418,7 +428,7 @@ public class TileEntityMachineShredder extends TileEntityLoadedBase implements I
return 3; return 3;
} }
} }
return 0; return 0;
} }