From dc3df3edd5843bde0c1335d6a8e460b2c832aa48 Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Sat, 17 Jun 2017 08:12:18 +0300 Subject: full project files --- ihl/flexible_cable/PowerCableNodeEntity.java | 243 --------------------------- 1 file changed, 243 deletions(-) delete mode 100644 ihl/flexible_cable/PowerCableNodeEntity.java (limited to 'ihl/flexible_cable/PowerCableNodeEntity.java') diff --git a/ihl/flexible_cable/PowerCableNodeEntity.java b/ihl/flexible_cable/PowerCableNodeEntity.java deleted file mode 100644 index 346b86c..0000000 --- a/ihl/flexible_cable/PowerCableNodeEntity.java +++ /dev/null @@ -1,243 +0,0 @@ -package ihl.flexible_cable; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import ic2.core.IC2DamageSource; -import ic2.core.item.armor.ItemArmorHazmat; -import ihl.IHLMod; -import ihl.IHLModInfo; -import ihl.interfaces.IEnergyNetNode; -import ihl.utils.IHLUtils; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.play.server.S29PacketSoundEffect; -import net.minecraft.network.play.server.S2APacketParticles; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; - -public class PowerCableNodeEntity extends NodeEntity implements IEnergyNetNode{ - - private Set cableList; - private IHLCable cable; - private double soundRange=10d; - private final static float groundConductivity=0.005f; - private int lastCheckTimer=0; - - public PowerCableNodeEntity(World world) - { - super(world); - } - - @Override - public boolean canBeCollidedWith() - { - return !worldObj.isRemote && !this.noClip; - } - - @Override - public boolean canBePushed() - { - return !worldObj.isRemote && !this.noClip; - } - - @SuppressWarnings("unchecked") - @Override - public void onUpdate() - { - super.onUpdate(); - if(!worldObj.isRemote) - { - IHLGrid grid = IHLMod.enet.cablesToGrids.get(this.chainUniqueID); - if(grid!=null && grid.energy>0d) - { - double voltage = grid.getSinkVoltage(this); - if(this.onGround && voltage>=10d && this.getMaxAllowableVoltage() 10) - { - for(Object player:worldObj.getEntitiesWithinAABB(EntityPlayerMP.class, AxisAlignedBB.getBoundingBox(this.posX-soundRange,this.posY-soundRange,this.posZ-soundRange, this.posX+soundRange,this.posY+soundRange,this.posZ+soundRange))) - { - if(player instanceof EntityPlayerMP) - { - EntityPlayerMP playerMP = (EntityPlayerMP)player; - playerMP.playerNetServerHandler.sendPacket(new S2APacketParticles("largesmoke",(float)this.posX,(float)this.posY,(float)this.posZ,worldObj.rand.nextFloat()*0.1f-0.05f,0.1f,worldObj.rand.nextFloat()*0.1f-0.05f,0.1f,4)); - } - } - lastCheckTimer=checkTimer; - } - } - if(this.nextAnchorEntity!=null) - { - List entityList = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.boundingBox.expand(4d, 4d,4d)); - for(EntityLivingBase elb:entityList) - { - if(elb.boundingBox!=null) - { - if(IHLUtils.isSegmentInsideAABB(elb.boundingBox,this.posX,this.posY,this.posZ,this.nextAnchorEntity.posX,this.nextAnchorEntity.posY,this.nextAnchorEntity.posZ)) - { - this.applyEntityCollision(elb); - } - } - } - } - } - } - } - - @Override - public AxisAlignedBB getCollisionBox(Entity entity) - { - return boundingBox; - } - - - @Override - public void applyEntityCollision(Entity entity) - { - super.applyEntityCollision(entity); - IHLGrid grid = IHLMod.enet.cablesToGrids.get(this.chainUniqueID); - if(entity instanceof EntityLivingBase && grid!=null && grid.energy>=1d) - { - double voltage = grid.getSinkVoltage(this); - if(this.getMaxAllowableVoltage()1000) - { - sendSound(); - IHLMod.proxy.spawnParticleFromServer(3,worldObj, (float)this.posX,(float)this.posY,(float)this.posZ,0f,0f,0f,10f); - } - } - } - } - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbt) - { - super.readEntityFromNBT(nbt); - if(nbt.hasKey("cable")) - { - this.addCable(nbt.getCompoundTag("cable")); - } - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbt) - { - super.writeEntityToNBT(nbt); - if(this.cable!=null) - { - nbt.setTag("cable",this.cable.toNBT()); - } - } - - @Override - public IHLGrid getGrid() - { - return IHLMod.enet.cablesToGrids.get(this.chainUniqueID); - } - - @Override - public int getGridID() - { - return 0; - } - - @Override - public void setGrid(int newGridID) {} - - @Override - public double getMaxAllowableVoltage() - { - if(this.cable!=null) - { - return this.cable.maxVoltage; - } - else - { - return Integer.MAX_VALUE; - } - } - - @Override - public boolean addCable(NBTTagCompound cable1) - { - this.cable=IHLCable.fromNBT(cable1); - return true; - } - - @Override - public Set getCableList() { - if(cableList==null) - { - cableList=new HashSet(1); - if(this.cable!=null) - { - cableList.add(this.cable); - } - } - return cableList; - } - - @Override - public void removeAttachedChains() {} - - public void sendSound() - { - for(Object player:worldObj.getEntitiesWithinAABB(EntityPlayerMP.class, AxisAlignedBB.getBoundingBox(this.posX-soundRange,this.posY-soundRange,this.posZ-soundRange, this.posX+soundRange,this.posY+soundRange,this.posZ+soundRange))) - { - if(player instanceof EntityPlayerMP) - { - EntityPlayerMP playerMP = (EntityPlayerMP)player; - playerMP.playerNetServerHandler.sendPacket(new S29PacketSoundEffect(IHLModInfo.MODID+":electrocution",this.posX,this.posY,this.posZ,1f,1f)); - } - } - } - - @Override - public double[] getPortPos(EntityLivingBase player) - { - return new double[3]; - } - - @Override - public void remove(IHLCable cable) - { - this.cableList.remove(cable); - } - - @Override - public boolean isCableRemoved(int chainUniqueID) - { - return false; - } - - @Override - public void setCableCheck(boolean b) {} - - @Override - public double getEnergyAmountThisNodeWant() - { - return 0; - } - - @Override - public void injectEnergyInThisNode(double amount, double voltage) {} - - @Override - public boolean isTileEntityBaseInvalid() { - return this.isDead; - } - -} -- cgit v1.2.3