Dynamic functions prototypes for defender
This commit is contained in:
parent
338d195240
commit
321b351354
@ -13,6 +13,7 @@ import fr.jackcartersmith.orbsat.client.render.particle.ParticleLaserBeam;
|
||||
import fr.jackcartersmith.orbsat.common.handler.FMLEventHandler;
|
||||
import fr.jackcartersmith.orbsat.common.lib.OSConstants;
|
||||
import fr.jackcartersmith.orbsat.common.lib.OSRefs;
|
||||
import fr.jackcartersmith.orbsat.common.network.PhotonPacket;
|
||||
import fr.jackcartersmith.orbsat.common.network.TileObjectPacket;
|
||||
import fr.jackcartersmith.orbsat.common.tileentities.TileDefender;
|
||||
import fr.jackcartersmith.orbsat.common.utils.OSLogHelper;
|
||||
@ -51,33 +52,8 @@ public class CommonProxy {
|
||||
OrbitalSatellite.network = NetworkRegistry.INSTANCE.newSimpleChannel(OrbitalSatellite.networkChannelName);
|
||||
OrbitalSatellite.network.registerMessage(TileObjectPacket.Handler.class, TileObjectPacket.class, 0, Side.SERVER);
|
||||
OrbitalSatellite.network.registerMessage(TileObjectPacket.Handler.class, TileObjectPacket.class, 1, Side.CLIENT);
|
||||
//OrbitalSatellite.network.registerMessage(OBNetwork.Handler.class, OBNetwork.class, 1, Side.SERVER);
|
||||
//OrbitalSatellite.network.registerMessage(OBNetworkClient.Handler.class, OBNetworkClient.class, 2, Side.CLIENT);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
DraconicEvolution.network.registerMessage(ButtonPacket.Handler.class, ButtonPacket.class, 0, Side.SERVER);
|
||||
DraconicEvolution.network.registerMessage(ParticleGenPacket.Handler.class, ParticleGenPacket.class, 1, Side.SERVER);
|
||||
DraconicEvolution.network.registerMessage(PlacedItemPacket.Handler.class, PlacedItemPacket.class, 2, Side.SERVER);
|
||||
DraconicEvolution.network.registerMessage(PlayerDetectorButtonPacket.Handler.class, PlayerDetectorButtonPacket.class, 3, Side.SERVER);
|
||||
DraconicEvolution.network.registerMessage(PlayerDetectorStringPacket.Handler.class, PlayerDetectorStringPacket.class, 4, Side.SERVER);
|
||||
DraconicEvolution.network.registerMessage(TeleporterPacket.Handler.class, TeleporterPacket.class, 5, Side.SERVER);
|
||||
DraconicEvolution.network.registerMessage(TileObjectPacket.Handler.class, TileObjectPacket.class, 6, Side.CLIENT);
|
||||
DraconicEvolution.network.registerMessage(MountUpdatePacket.Handler.class, MountUpdatePacket.class, 7, Side.CLIENT);
|
||||
DraconicEvolution.network.registerMessage(MountUpdatePacket.Handler.class, MountUpdatePacket.class, 8, Side.SERVER);
|
||||
DraconicEvolution.network.registerMessage(ItemConfigPacket.Handler.class, ItemConfigPacket.class, 9, Side.SERVER);
|
||||
DraconicEvolution.network.registerMessage(TileObjectPacket.Handler.class, TileObjectPacket.class, 10, Side.SERVER);
|
||||
DraconicEvolution.network.registerMessage(BlockUpdatePacket.Handler.class, BlockUpdatePacket.class, 11, Side.SERVER);
|
||||
DraconicEvolution.network.registerMessage(SpeedRequestPacket.Handler.class, SpeedRequestPacket.class, 12, Side.SERVER);
|
||||
DraconicEvolution.network.registerMessage(SpeedRequestPacket.Handler.class, SpeedRequestPacket.class, 13, Side.CLIENT);
|
||||
DraconicEvolution.network.registerMessage(ToolModePacket.Handler.class, ToolModePacket.class, 14, Side.SERVER);
|
||||
DraconicEvolution.network.registerMessage(GenericParticlePacket.Handler.class, GenericParticlePacket.class, 15, Side.CLIENT);
|
||||
DraconicEvolution.network.registerMessage(ShieldHitPacket.Handler.class, ShieldHitPacket.class, 16, Side.CLIENT);
|
||||
DraconicEvolution.network.registerMessage(ContributorPacket.Handler.class, ContributorPacket.class, 17, Side.CLIENT);
|
||||
DraconicEvolution.network.registerMessage(ContributorPacket.Handler.class, ContributorPacket.class, 18, Side.SERVER);
|
||||
*/
|
||||
|
||||
OrbitalSatellite.network.registerMessage(PhotonPacket.Handler.class, PhotonPacket.class, 10, Side.SERVER);
|
||||
OrbitalSatellite.network.registerMessage(PhotonPacket.Handler.class, PhotonPacket.class, 11, Side.CLIENT);
|
||||
}
|
||||
|
||||
public void registerTileEntities() {
|
||||
|
@ -111,6 +111,8 @@ public class Defender extends BlockOS {
|
||||
|
||||
//player.addChatComponentMessage(new ChatComponentText(Float.toString(tile.xAngle)));
|
||||
//FMLNetworkHandler.openGui(player, OrbitalSatellite.instance, GuiHandler.GUIID_ENERGY_INFUSER, world, x, y, z);
|
||||
} else {
|
||||
if (tile.firing != false) tile.firing = false; else tile.firing = true;
|
||||
}
|
||||
}
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
|
@ -0,0 +1,32 @@
|
||||
package fr.jackcartersmith.orbsat.common.interfaces;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class PhotonConsuming extends TileEntity {
|
||||
public int currentCharge = 0;
|
||||
public int maxCharge = 0;
|
||||
|
||||
public void addCharge(int incomingCharge) {
|
||||
this.currentCharge += incomingCharge;
|
||||
}
|
||||
|
||||
public void removeCharge(int outgoingCharge) {
|
||||
this.currentCharge -= outgoingCharge;
|
||||
}
|
||||
|
||||
public int getCurrentCharge() {
|
||||
return this.currentCharge;
|
||||
}
|
||||
|
||||
public void setCurrentCharge(int currentCharge) {
|
||||
this.currentCharge = currentCharge;
|
||||
}
|
||||
|
||||
public int getMaxCharge() {
|
||||
return this.maxCharge;
|
||||
}
|
||||
|
||||
public void setMaxCharge(int maxCharge) {
|
||||
this.maxCharge = maxCharge;
|
||||
}
|
||||
}
|
@ -0,0 +1,233 @@
|
||||
package fr.jackcartersmith.orbsat.common.interfaces;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import fr.jackcartersmith.orbsat.OrbitalSatellite;
|
||||
import fr.jackcartersmith.orbsat.common.network.PhotonPacket;
|
||||
import fr.jackcartersmith.orbsat.common.utils.OSLogHelper;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class PhotonProducing extends TileEntity {
|
||||
int chargeRate = 0;
|
||||
int currentCharge = 0;
|
||||
public long time = 0L;
|
||||
public int powerIncoming;
|
||||
public int scaledOutput;
|
||||
private int tickCount = 0;
|
||||
public float rotate = -3.141F;
|
||||
|
||||
public List<PhotonConsuming> getSurroundingPhotonConsumers()
|
||||
{
|
||||
ArrayList<PhotonConsuming> surroundingConsumers = new ArrayList<PhotonConsuming>();
|
||||
|
||||
try
|
||||
{
|
||||
if (this.worldObj.getTileEntity(this.xCoord + 1, this.yCoord, this.zCoord) instanceof PhotonConsuming)
|
||||
{
|
||||
surroundingConsumers.add((PhotonConsuming)this.worldObj.getTileEntity(this.xCoord + 1, this.yCoord, this.zCoord));
|
||||
}
|
||||
|
||||
if (this.worldObj.getTileEntity(this.xCoord - 1, this.yCoord, this.zCoord) instanceof PhotonConsuming)
|
||||
{
|
||||
surroundingConsumers.add((PhotonConsuming)this.worldObj.getTileEntity(this.xCoord - 1, this.yCoord, this.zCoord));
|
||||
}
|
||||
|
||||
if (this.worldObj.getTileEntity(this.xCoord, this.yCoord + 1, this.zCoord) instanceof PhotonConsuming)
|
||||
{
|
||||
surroundingConsumers.add((PhotonConsuming)this.worldObj.getTileEntity(this.xCoord, this.yCoord + 1, this.zCoord));
|
||||
}
|
||||
|
||||
if (this.worldObj.getTileEntity(this.xCoord, this.yCoord - 1, this.zCoord) instanceof PhotonConsuming)
|
||||
{
|
||||
surroundingConsumers.add((PhotonConsuming)this.worldObj.getTileEntity(this.xCoord, this.yCoord - 1, this.zCoord));
|
||||
}
|
||||
|
||||
if (this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord + 1) instanceof PhotonConsuming)
|
||||
{
|
||||
surroundingConsumers.add((PhotonConsuming)this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord + 1));
|
||||
}
|
||||
|
||||
if (this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord - 1) instanceof PhotonConsuming)
|
||||
{
|
||||
surroundingConsumers.add((PhotonConsuming)this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord - 1));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
OSLogHelper.error("Cannot cast entity into PhotonConsuming");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return surroundingConsumers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count
|
||||
* ticks and creates a new spawn inside its implementation.
|
||||
*/
|
||||
public void updateEntity()
|
||||
{
|
||||
/*
|
||||
if (this.getPowerIncoming() > 0)
|
||||
{
|
||||
this.rotate += 1.0E-4F * (float)this.getPowerIncoming();
|
||||
}
|
||||
|
||||
if (this.rotate >= 3.141F)
|
||||
{
|
||||
this.rotate = -3.141F;
|
||||
}
|
||||
*/
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
List<PhotonConsuming> surroundingPhotonConsumers = this.getSurroundingPhotonConsumers();
|
||||
this.addCharge(this.getChargeRate());
|
||||
int howMany = surroundingPhotonConsumers.size();
|
||||
int var8;
|
||||
|
||||
if (howMany == 0)
|
||||
{
|
||||
howMany = 1;
|
||||
var8 = this.getCurrentCharge() / howMany;
|
||||
}
|
||||
else
|
||||
{
|
||||
var8 = this.getCurrentCharge() / howMany;
|
||||
}
|
||||
|
||||
if (this.tickCount == 10)
|
||||
{
|
||||
this.sendPhotonPacket13();
|
||||
this.sendPhotonPacket15();
|
||||
|
||||
this.tickCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
++this.tickCount;
|
||||
}
|
||||
|
||||
this.setScaledOutput(var8);
|
||||
this.setPowerIncoming(this.getCurrentCharge());
|
||||
|
||||
if (var8 > 0)
|
||||
{
|
||||
Iterator<PhotonConsuming> i$ = surroundingPhotonConsumers.iterator();
|
||||
|
||||
while (i$.hasNext())
|
||||
{
|
||||
PhotonConsuming entity = (PhotonConsuming)i$.next();
|
||||
|
||||
try
|
||||
{
|
||||
if (entity.getCurrentCharge() < entity.getMaxCharge())
|
||||
{
|
||||
entity.addCharge(var8);
|
||||
}
|
||||
|
||||
var8 = this.getCurrentCharge() / howMany;
|
||||
entity.currentCharge += var8;
|
||||
}
|
||||
catch (Exception var7)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
this.removeCharge(this.getCurrentCharge());
|
||||
}
|
||||
}
|
||||
|
||||
this.time = this.worldObj.getWorldTime();
|
||||
this.time %= 24000L;
|
||||
}
|
||||
|
||||
public void addCharge(int incomingCharge)
|
||||
{
|
||||
this.currentCharge += incomingCharge;
|
||||
}
|
||||
|
||||
public void removeCharge(int outgoingCharge)
|
||||
{
|
||||
this.currentCharge -= outgoingCharge;
|
||||
}
|
||||
|
||||
public int getChargeRate()
|
||||
{
|
||||
return this.chargeRate;
|
||||
}
|
||||
|
||||
public void setChargeRate(int chargeRate)
|
||||
{
|
||||
this.chargeRate = chargeRate;
|
||||
}
|
||||
|
||||
public int getCurrentCharge()
|
||||
{
|
||||
return this.currentCharge;
|
||||
}
|
||||
|
||||
public void setCurrentCharge(int currentCharge)
|
||||
{
|
||||
this.currentCharge = currentCharge;
|
||||
}
|
||||
|
||||
public long getTime()
|
||||
{
|
||||
return this.time;
|
||||
}
|
||||
|
||||
public void setTime(long time)
|
||||
{
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public int getPowerIncoming()
|
||||
{
|
||||
return this.powerIncoming;
|
||||
}
|
||||
|
||||
public void setPowerIncoming(int powerIncoming)
|
||||
{
|
||||
this.powerIncoming = powerIncoming;
|
||||
}
|
||||
|
||||
public int getScaledOutput()
|
||||
{
|
||||
return this.scaledOutput;
|
||||
}
|
||||
|
||||
public void setScaledOutput(int scaledOutput)
|
||||
{
|
||||
this.scaledOutput = scaledOutput;
|
||||
}
|
||||
|
||||
public void sendPhotonPacket13()
|
||||
{
|
||||
List<Integer> bos = new ArrayList<Integer>();
|
||||
|
||||
bos.add(13);
|
||||
bos.add(this.xCoord);
|
||||
bos.add(this.yCoord);
|
||||
bos.add(this.zCoord);
|
||||
bos.add(this.getScaledOutput());
|
||||
|
||||
OrbitalSatellite.network.sendToAll(new PhotonPacket(bos));
|
||||
}
|
||||
|
||||
public void sendPhotonPacket15()
|
||||
{
|
||||
List<Integer> bos = new ArrayList<Integer>();
|
||||
|
||||
bos.add(15);
|
||||
bos.add(this.xCoord);
|
||||
bos.add(this.yCoord);
|
||||
bos.add(this.zCoord);
|
||||
bos.add(this.getPowerIncoming());
|
||||
|
||||
OrbitalSatellite.network.sendToAll(new PhotonPacket(bos));
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package fr.jackcartersmith.orbsat.common.interfaces;
|
||||
|
||||
public class PhotonRecieving extends PhotonProducing{
|
||||
public void recievePhotons(int power)
|
||||
{
|
||||
this.currentCharge += power;
|
||||
}
|
||||
}
|
@ -0,0 +1,203 @@
|
||||
package fr.jackcartersmith.orbsat.common.interfaces;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import fr.jackcartersmith.orbsat.OrbitalSatellite;
|
||||
import fr.jackcartersmith.orbsat.common.lib.OSConstants;
|
||||
import fr.jackcartersmith.orbsat.common.network.PhotonPacket;
|
||||
|
||||
public class PhotonSending extends PhotonConsuming {
|
||||
public int outputRate;
|
||||
public int listSize;
|
||||
public int scaledOutput;
|
||||
private int tickCount = 0;
|
||||
public float rotate = -3.141F;
|
||||
|
||||
public List<PhotonRecieving> getNearbyPhotonRecievingEntities()
|
||||
{
|
||||
int radius = OSConstants.PhotonSendingRadius;
|
||||
ArrayList<PhotonRecieving> entities = new ArrayList<PhotonRecieving>();
|
||||
int xC = this.xCoord;
|
||||
int yC = this.yCoord;
|
||||
int zC = this.zCoord;
|
||||
|
||||
for (int x = radius / 2 * -1; x <= radius / 2; ++x)
|
||||
{
|
||||
for (int y = radius / 2 * -1; y <= radius / 2; ++y)
|
||||
{
|
||||
for (int z = radius / 2 * -1; z <= radius / 2; ++z)
|
||||
{
|
||||
if (this.worldObj.getTileEntity(xC + x, yC + y, zC + z) instanceof PhotonRecieving && entities.size() <= 3)
|
||||
{
|
||||
entities.add((PhotonRecieving)this.worldObj.getTileEntity(xC + x, yC + y, zC + z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
public void sendPhotonsTo(PhotonRecieving entity, int power)
|
||||
{
|
||||
PhotonRecieving photonRecievingEntity = (PhotonRecieving)this.worldObj.getTileEntity(entity.xCoord, entity.yCoord, entity.zCoord);
|
||||
|
||||
if (photonRecievingEntity != null)
|
||||
{
|
||||
photonRecievingEntity.recievePhotons(power);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count
|
||||
* ticks and creates a new spawn inside its implementation.
|
||||
*/
|
||||
public void updateEntity()
|
||||
{
|
||||
this.rotate += 0.01F;
|
||||
|
||||
if (this.rotate >= 3.141F)
|
||||
{
|
||||
this.rotate = -3.141F;
|
||||
}
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
List<?> entitiesForPowerRecieving = this.getNearbyPhotonRecievingEntities();
|
||||
int scaledPowerOutput = 0;
|
||||
int howMany = entitiesForPowerRecieving.size();
|
||||
|
||||
if (howMany != 0)
|
||||
{
|
||||
scaledPowerOutput = this.getCurrentCharge() / howMany;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.scaledOutput = this.getCurrentCharge();
|
||||
}
|
||||
|
||||
if (entitiesForPowerRecieving.size() > 0 && this.getCurrentCharge() > 0)
|
||||
{
|
||||
Iterator<?> i$ = entitiesForPowerRecieving.iterator();
|
||||
|
||||
while (i$.hasNext())
|
||||
{
|
||||
PhotonRecieving entity = (PhotonRecieving)i$.next();
|
||||
this.sendPhotonsTo(entity, scaledPowerOutput);
|
||||
}
|
||||
}
|
||||
|
||||
this.setScaledOutput(scaledPowerOutput);
|
||||
this.setOutputRate(scaledPowerOutput * howMany);
|
||||
this.setListSize(howMany);
|
||||
|
||||
if (this.tickCount == 10)
|
||||
{
|
||||
this.sendPhotonPacket7();
|
||||
this.sendPhotonPacket9();
|
||||
this.sendPhotonPacket11();
|
||||
this.tickCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
++this.tickCount;
|
||||
}
|
||||
|
||||
this.setCurrentCharge(this.getCurrentCharge() - scaledPowerOutput * howMany);
|
||||
}
|
||||
}
|
||||
|
||||
public int getOutputRate()
|
||||
{
|
||||
return this.outputRate;
|
||||
}
|
||||
|
||||
public void setOutputRate(int outputRate)
|
||||
{
|
||||
this.outputRate = outputRate;
|
||||
}
|
||||
|
||||
public int getListSize()
|
||||
{
|
||||
return this.listSize;
|
||||
}
|
||||
|
||||
public void setListSize(int listSize)
|
||||
{
|
||||
this.listSize = listSize;
|
||||
}
|
||||
|
||||
public int getScaledOutput()
|
||||
{
|
||||
return this.scaledOutput;
|
||||
}
|
||||
|
||||
public void setScaledOutput(int scaledOutput)
|
||||
{
|
||||
this.scaledOutput = scaledOutput;
|
||||
}
|
||||
|
||||
public void sendPhotonPacket7()
|
||||
{
|
||||
List<Integer> bos = new ArrayList<Integer>();
|
||||
|
||||
bos.add(7);
|
||||
bos.add(this.xCoord);
|
||||
bos.add(this.yCoord);
|
||||
bos.add(this.zCoord);
|
||||
bos.add(this.getOutputRate());
|
||||
|
||||
OrbitalSatellite.network.sendToAll(new PhotonPacket(bos));
|
||||
}
|
||||
|
||||
public void sendPhotonPacket9()
|
||||
{
|
||||
List<Integer> bos = new ArrayList<Integer>();
|
||||
|
||||
bos.add(9);
|
||||
bos.add(this.xCoord);
|
||||
bos.add(this.yCoord);
|
||||
bos.add(this.zCoord);
|
||||
bos.add(this.getScaledOutput());
|
||||
|
||||
OrbitalSatellite.network.sendToAll(new PhotonPacket(bos));
|
||||
}
|
||||
|
||||
public void sendPhotonPacket11()
|
||||
{
|
||||
/*
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
|
||||
try
|
||||
{
|
||||
outputStream.writeInt(11);
|
||||
outputStream.writeInt(this.xCoord);
|
||||
outputStream.writeInt(this.yCoord);
|
||||
outputStream.writeInt(this.zCoord);
|
||||
outputStream.writeInt(this.getListSize());
|
||||
}
|
||||
catch (Exception var4)
|
||||
{
|
||||
var4.printStackTrace();
|
||||
}
|
||||
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.channel = "OB";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
PacketDispatcher.sendPacketToAllPlayers(packet);
|
||||
*/
|
||||
List<Integer> bos = new ArrayList<Integer>();
|
||||
|
||||
bos.add(11);
|
||||
bos.add(this.xCoord);
|
||||
bos.add(this.yCoord);
|
||||
bos.add(this.zCoord);
|
||||
bos.add(this.getListSize());
|
||||
|
||||
OrbitalSatellite.network.sendToAll(new PhotonPacket(bos));
|
||||
}
|
||||
}
|
@ -0,0 +1,357 @@
|
||||
package fr.jackcartersmith.orbsat.common.network;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
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 fr.jackcartersmith.orbsat.OrbitalSatellite;
|
||||
import fr.jackcartersmith.orbsat.common.interfaces.PhotonRecieving;
|
||||
import fr.jackcartersmith.orbsat.common.interfaces.PhotonSending;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.effect.EntityLightningBolt;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PhotonPacket implements IMessage {
|
||||
private List<Integer> dataArray = new ArrayList<Integer>();
|
||||
|
||||
public PhotonPacket() {}
|
||||
public PhotonPacket(List<Integer> dataArray) {
|
||||
this.dataArray = dataArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf){
|
||||
for (int i = 0; i < 5; i++){
|
||||
this.dataArray.add(buf.readInt());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf){
|
||||
for (int i = 0; i < 5; i++){
|
||||
buf.writeInt(this.dataArray.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<PhotonPacket, IMessage>{
|
||||
int function;
|
||||
int xCoord;
|
||||
int yCoord;
|
||||
int zCoord;
|
||||
int data_value;
|
||||
|
||||
public void sendChangeToClient(int xCoord, int yCoord, int zCoord, int chargeLevel)
|
||||
{
|
||||
List<Integer> bos = new ArrayList<Integer>();
|
||||
|
||||
bos.add(5);
|
||||
bos.add(xCoord);
|
||||
bos.add(yCoord);
|
||||
bos.add(zCoord);
|
||||
bos.add(chargeLevel);
|
||||
|
||||
//OrbitalSatellite.network.sendToAll(new OBNetworkClient(bos));
|
||||
OrbitalSatellite.network.sendToAll(new PhotonPacket(bos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PhotonPacket message, MessageContext ctx) {
|
||||
if (ctx.side == Side.CLIENT) {
|
||||
try{
|
||||
this.function = message.dataArray.get(0);
|
||||
this.xCoord = message.dataArray.get(1);
|
||||
this.yCoord = message.dataArray.get(2);
|
||||
this.zCoord = message.dataArray.get(3);
|
||||
this.data_value = message.dataArray.get(4);
|
||||
}catch(Exception var8){
|
||||
var8.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
System.out.println(this.function);
|
||||
System.out.println(this.x);
|
||||
System.out.println(this.y);
|
||||
System.out.println(this.zCoord);
|
||||
System.out.println(this.data_value);
|
||||
*/
|
||||
|
||||
try{
|
||||
/*
|
||||
if (this.function == 1){
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
OverriderBlockTileEntity overrider = (OverriderBlockTileEntity)player.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord);
|
||||
|
||||
if (overrider != null && overrider instanceof OverriderBlockTileEntity){
|
||||
overrider.currentCharge = this.data_value;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.function == 3){
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
ExtenderTileEntity extender = (ExtenderTileEntity)player.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord);
|
||||
|
||||
if (extender instanceof ExtenderTileEntity){
|
||||
extender.currentCharge = this.data_value;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.function == 5){
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
OverriderBlockTileEntity overrider = (OverriderBlockTileEntity)player.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord);
|
||||
|
||||
if (overrider instanceof OverriderBlockTileEntity){
|
||||
overrider.shotsLeft = this.data_value;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (this.function == 7)
|
||||
{
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
PhotonSending ext2 = (PhotonSending)player.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord);
|
||||
|
||||
if (ext2 instanceof PhotonSending)
|
||||
{
|
||||
ext2.setOutputRate(this.data_value);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.function == 9)
|
||||
{
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
PhotonSending ext2 = (PhotonSending)player.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord);
|
||||
|
||||
if (ext2 instanceof PhotonSending)
|
||||
{
|
||||
ext2.setScaledOutput(this.data_value);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.function == 11)
|
||||
{
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
PhotonSending ext2 = (PhotonSending)player.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord);
|
||||
|
||||
if (ext2 instanceof PhotonSending)
|
||||
{
|
||||
ext2.setListSize(this.data_value);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.function == 13)
|
||||
{
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
PhotonRecieving ext3 = (PhotonRecieving)player.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord);
|
||||
|
||||
if (ext3 instanceof PhotonRecieving)
|
||||
{
|
||||
ext3.setScaledOutput(this.data_value);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.function == 15)
|
||||
{
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
PhotonRecieving ext3 = (PhotonRecieving)player.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord);
|
||||
|
||||
if (ext3 instanceof PhotonRecieving)
|
||||
{
|
||||
ext3.setPowerIncoming(this.data_value);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.function == 17)
|
||||
{
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
PhotonRecieving ext3 = (PhotonRecieving)player.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord);
|
||||
|
||||
if (ext3 instanceof PhotonRecieving)
|
||||
{
|
||||
ext3.setCurrentCharge(this.data_value);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.function == 19)
|
||||
{
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
player.worldObj.playSoundEffect((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, "ob:defender_strike", 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
return null;
|
||||
}catch (Exception var7){
|
||||
//var7.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
EntityPlayer sender = ctx.getServerHandler().playerEntity;
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
|
||||
try{
|
||||
this.function = message.dataArray.get(0);
|
||||
}catch(Exception var22){
|
||||
var22.printStackTrace();
|
||||
}
|
||||
|
||||
try{
|
||||
|
||||
|
||||
if (this.function == 2){
|
||||
this.xCoord = message.dataArray.get(1);
|
||||
this.yCoord = message.dataArray.get(2);
|
||||
this.zCoord = message.dataArray.get(3);
|
||||
this.data_value = message.dataArray.get(4);
|
||||
|
||||
try{
|
||||
List<?> charge1 = player.worldObj.getEntitiesWithinAABB(EntityLiving.class,
|
||||
AxisAlignedBB.getBoundingBox((double)(this.xCoord - this.data_value / 3),
|
||||
(double)(this.yCoord - this.data_value / 3), (double)(this.zCoord - this.data_value / 3),
|
||||
(double)(this.xCoord + this.data_value / 3), (double)(this.yCoord + this.data_value / 3),
|
||||
(double)(this.zCoord + this.data_value / 3)));
|
||||
|
||||
if (charge1.size() > 0){
|
||||
for(int y = 0; y <= charge1.size() - 1; y++){
|
||||
Random next = new Random();
|
||||
EntityLiving e1 = (EntityLiving)charge1.get(y);
|
||||
e1.setHealth(0.5F);
|
||||
e1.motionY = (double)(this.data_value / 5);
|
||||
e1.motionX = next.nextGaussian() * 5.0D;
|
||||
e1.motionZ = next.nextGaussian() * 5.0D;
|
||||
}
|
||||
}
|
||||
}catch(Exception var27){
|
||||
var27.printStackTrace();
|
||||
}
|
||||
|
||||
if (this.data_value <= 10){
|
||||
player.worldObj.playSoundAtEntity(player, "ob:explode", 0.3F, 5.0F);
|
||||
}
|
||||
|
||||
if (this.data_value > 10 && this.data_value <= 40){
|
||||
player.worldObj.playSoundAtEntity(player, "ob:explode", 0.3F, 1.5F);
|
||||
}
|
||||
|
||||
if (this.data_value > 40){
|
||||
player.worldObj.playSoundAtEntity(player, "ob:explode", 0.4F, 0.3F);
|
||||
}
|
||||
|
||||
player.worldObj.createExplosion((Entity)null, (double)this.xCoord, (double)this.yCoord, (double)this.zCoord, (float)this.data_value, true);
|
||||
}
|
||||
|
||||
/* ---Meteor function
|
||||
if (this.function == 5 && message != null){
|
||||
this.xCoord = message.dataArray.get(1);
|
||||
this.yCoord = message.dataArray.get(2);
|
||||
this.zCoord = message.dataArray.get(3);
|
||||
Random rand = new Random();
|
||||
OBNetwork$1 obNetworkServerThread = new OBNetwork$1(rand, player,this.xCoord, this.yCoord, this.zCoord);
|
||||
obNetworkServerThread.start();
|
||||
}*/
|
||||
|
||||
if (this.function == 9){
|
||||
this.xCoord = message.dataArray.get(1);
|
||||
this.yCoord = message.dataArray.get(2);
|
||||
this.zCoord = message.dataArray.get(3);
|
||||
player.worldObj.spawnEntityInWorld(new EntityLightningBolt(player.worldObj, (double)this.xCoord, (double)this.yCoord, (double)this.zCoord));
|
||||
}
|
||||
|
||||
if (this.function == 12){
|
||||
synchronized (sender){
|
||||
this.xCoord = message.dataArray.get(1);
|
||||
this.yCoord = message.dataArray.get(2);
|
||||
this.zCoord = message.dataArray.get(3);
|
||||
this.data_value = message.dataArray.get(4);
|
||||
World world = player.worldObj;
|
||||
int var36 = this.yCoord + 1;
|
||||
world.playSoundAtEntity(player, "ob:digging", 0.7F, 0.3F);
|
||||
|
||||
do{
|
||||
--var36;
|
||||
|
||||
try{
|
||||
Block found = world.getBlock(this.xCoord, var36, this.zCoord);
|
||||
ItemStack itemBlock = new ItemStack(found);
|
||||
new Random();
|
||||
EntityItem droppedItem = new EntityItem(world, (double)this.xCoord, (double)this.yCoord, (double)this.zCoord, itemBlock);
|
||||
Random rand = new Random();
|
||||
droppedItem.motionX = rand.nextGaussian() / 10.0D;
|
||||
droppedItem.motionY = 0.8D;
|
||||
droppedItem.motionZ = rand.nextGaussian() / 10.0D;
|
||||
world.spawnEntityInWorld(droppedItem);
|
||||
world.setBlockToAir(this.xCoord, var36, this.zCoord);
|
||||
Thread.sleep(5L);
|
||||
}catch(NullPointerException var23){
|
||||
}catch(ConcurrentModificationException var24){
|
||||
break;
|
||||
}catch(Exception var25){}
|
||||
}while(world.getBlock(this.xCoord, var36 - 1, this.zCoord) != Blocks.bedrock
|
||||
&& world.getBlock(this.xCoord, var36 - 1, this.zCoord) != Blocks.flowing_lava
|
||||
&& world.getBlock(this.xCoord, var36 - 1, this.zCoord) != Blocks.lava
|
||||
&& world.getBlock(this.xCoord, var36 - 1, this.zCoord) != Blocks.flowing_water
|
||||
&& world.getBlock(this.xCoord, var36 - 1, this.zCoord) != Blocks.water);
|
||||
|
||||
world.setBlockToAir(this.xCoord, this.yCoord + 1, this.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (this.function == 15){
|
||||
this.xCoord = message.dataArray.get(1);
|
||||
this.yCoord = message.dataArray.get(2);
|
||||
this.zCoord = message.dataArray.get(3);
|
||||
this.data_value = message.dataArray.get(4);
|
||||
OverriderBlockTileEntity overrider = (OverriderBlockTileEntity)player.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord);
|
||||
overrider.currentCharge -= this.data_value;
|
||||
--overrider.shotsLeft;
|
||||
}
|
||||
|
||||
if (this.function == 18){
|
||||
this.xCoord = message.dataArray.get(1);
|
||||
this.yCoord = message.dataArray.get(2);
|
||||
this.zCoord = message.dataArray.get(3);
|
||||
this.data_value = message.dataArray.get(4);
|
||||
player.worldObj.playSoundAtEntity(player, "ob:satelliteLaunch", 1.0F, 1.0F);
|
||||
OverriderBlockTileEntity overrider = (OverriderBlockTileEntity)player.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord);
|
||||
overrider.shotsLeft += this.data_value;
|
||||
overrider.currentCharge -= OSConstants.SateliteLaunchPUCost;
|
||||
this.sendChangeToClient(this.xCoord, this.yCoord, this.zCoord, this.data_value);
|
||||
}*/
|
||||
|
||||
if (this.function == 21){
|
||||
this.xCoord = message.dataArray.get(1);
|
||||
this.yCoord = message.dataArray.get(2);
|
||||
this.zCoord = message.dataArray.get(3);
|
||||
this.data_value = message.dataArray.get(4);
|
||||
player.worldObj.removeTileEntity(this.xCoord, this.yCoord, this.zCoord);
|
||||
player.worldObj.setBlockToAir(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
|
||||
if (this.function == 24){
|
||||
player.worldObj.playSoundAtEntity(player, "ob:start", 1.0F, 1.0F);
|
||||
player.worldObj.playSoundAtEntity(player, "ob:middle", 1.0F, 0.7F);
|
||||
}
|
||||
|
||||
}catch(Exception var28){}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +1,95 @@
|
||||
package fr.jackcartersmith.orbsat.common.tileentities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import fr.jackcartersmith.orbsat.OrbitalSatellite;
|
||||
import fr.jackcartersmith.orbsat.client.render.particle.ParticleLaserBeam;
|
||||
import fr.jackcartersmith.orbsat.common.OSBlocks;
|
||||
import fr.jackcartersmith.orbsat.common.interfaces.PhotonRecieving;
|
||||
import fr.jackcartersmith.orbsat.common.lib.OSConstants;
|
||||
import fr.jackcartersmith.orbsat.common.network.PhotonPacket;
|
||||
import net.minecraft.entity.monster.EntityMob;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
//public class TileDefender extends TileObjectSync implements IEnergyReceiver, ISidedInventory {
|
||||
public class TileDefender extends TileEntity {
|
||||
public float modelIllumination = 30F;
|
||||
public class TileDefender extends PhotonRecieving {
|
||||
public int ticksCount = 0;
|
||||
public static float modelIllumination = 30F;
|
||||
public int facingDirection = ForgeDirection.UP.ordinal();
|
||||
public boolean firing = false;
|
||||
public int beamPow = 100;
|
||||
private static int beamPow = 125;
|
||||
public float rotationSpeed = 4.0F;
|
||||
public float crystalBrightness = 1.0F;
|
||||
|
||||
private float xTarget = this.xCoord + 2F;
|
||||
private float yTarget = this.yCoord;
|
||||
private float zTarget = this.zCoord + 4F;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private ParticleLaserBeam beam;
|
||||
private ParticleLaserBeam beam_turret;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private ParticleLaserBeam beam_target;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
++ticksCount;
|
||||
|
||||
if (worldObj.isRemote)
|
||||
beam = OrbitalSatellite.proxy.energyBeam(worldObj, this.xCoord + 0.52F, this.yCoord, this.zCoord + 0.48F, this.xCoord, this.yCoord + 1024, this.zCoord, beamPow, 8, beam, true, 0);
|
||||
if (worldObj.isRemote) {
|
||||
updateBeam();
|
||||
}
|
||||
|
||||
//if (!this.worldObj.isRemote && this.getCurrentCharge() > 500)
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (ticksCount > 75) {
|
||||
firing = false;
|
||||
ticksCount = 0; //Reset tick counter
|
||||
}
|
||||
|
||||
if (ticksCount > 35 && !firing)
|
||||
{
|
||||
sendPhotonPacket17();
|
||||
List<?> entities = getNearByEntities();
|
||||
int thisX = xCoord;
|
||||
int thisY = yCoord;
|
||||
int thisZ = zCoord;
|
||||
Random random = new Random();
|
||||
|
||||
if (entities.size() > 0)
|
||||
{
|
||||
worldObj.playSoundEffect((double)thisX, (double)thisY, (double)thisZ, "ob:defenderLock", 1.0F, 1.0F);
|
||||
EntityMob mob = (EntityMob)entities.get(random.nextInt(entities.size()));
|
||||
|
||||
xTarget = (int)mob.lastTickPosX;
|
||||
yTarget = (int)mob.lastTickPosY;
|
||||
zTarget = (int)mob.lastTickPosZ;
|
||||
firing = true;
|
||||
//this.worldObj.setBlock((int)this.xTarget, (int)this.yTarget, (int)this.zTarget, OSBlocks.defender);
|
||||
//this.worldObj.setBlock(thisX, thisY + 1, thisZ, OSBlocks.laserDef);
|
||||
/*
|
||||
if (this.getCurrentCharge() > 500)
|
||||
{
|
||||
this.removeCharge(500);
|
||||
this.xTarget = (int)mob.lastTickPosX;
|
||||
this.yTarget = (int)mob.lastTickPosY;
|
||||
this.zTarget = (int)mob.lastTickPosZ;
|
||||
this.firing = true;
|
||||
//this.worldObj.setBlock((int)this.xTarget, (int)this.yTarget, (int)this.zTarget, OSBlocks.defender);
|
||||
//this.worldObj.setBlock(thisX, thisY + 1, thisZ, OSBlocks.laserDef);
|
||||
this.removeCharge(500);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -75,6 +135,20 @@ public class TileDefender extends TileEntity {
|
||||
*/
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void updateBeam() {
|
||||
if (worldObj.isRemote) {
|
||||
if (firing) {
|
||||
crystalBrightness = 0.95F;
|
||||
} else {
|
||||
crystalBrightness = 0.0F;
|
||||
}
|
||||
|
||||
beam_turret = OrbitalSatellite.proxy.energyBeam(worldObj, xCoord + 0.51F, yCoord, zCoord + 0.5F, xCoord + 0.51F, yCoord + 1024, zCoord + 0.5F, beamPow, 8, beam_turret, firing, 0);
|
||||
beam_target = OrbitalSatellite.proxy.energyBeam(worldObj, xTarget + 0.51F, yTarget + 1024, zTarget + 0.5F, xTarget + 0.51F, yTarget, zTarget + 0.5F, beamPow, 8, beam_target, firing, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private boolean tryStartOrStop() {
|
||||
if (items[0] != null && items[0].stackSize == 1 && items[0] != null && items[0].getItem() instanceof IEnergyContainerItem) {
|
||||
@ -92,16 +166,51 @@ public class TileDefender extends TileEntity {
|
||||
}
|
||||
*/
|
||||
|
||||
public List<?> getNearByEntities()
|
||||
{
|
||||
int radius = OSConstants.DefenderRadius;
|
||||
List<?> entities = this.worldObj.getEntitiesWithinAABB(EntityMob.class, AxisAlignedBB.getBoundingBox((double)(this.xCoord - radius), (double)(this.yCoord - radius), (double)(this.zCoord - radius), (double)(this.xCoord + radius), (double)(this.yCoord + radius), (double)(this.zCoord + radius)));
|
||||
return entities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
this.writeToNBT(tagCompound);
|
||||
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound);
|
||||
tagCompound.setBoolean("IsFiring", firing);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
readFromNBT(pkt.getNbtCompound());
|
||||
NBTTagCompound compound = pkt.getNbtCompound();
|
||||
firing = compound.getBoolean("IsFiring");
|
||||
super.onDataPacket(net, pkt);
|
||||
}
|
||||
|
||||
public void sendPhotonPacket17()
|
||||
{
|
||||
List<Integer> bos = new ArrayList<Integer>();
|
||||
|
||||
bos.add(17);
|
||||
bos.add(this.xCoord);
|
||||
bos.add(this.yCoord);
|
||||
bos.add(this.zCoord);
|
||||
bos.add(this.getCurrentCharge());
|
||||
|
||||
OrbitalSatellite.network.sendToAll(new PhotonPacket(bos));
|
||||
}
|
||||
|
||||
public void sendPhotonPacket19()
|
||||
{
|
||||
List<Integer> bos = new ArrayList<Integer>();
|
||||
|
||||
bos.add(19);
|
||||
bos.add(this.xCoord);
|
||||
bos.add(this.yCoord);
|
||||
bos.add(this.zCoord);
|
||||
bos.add(0);
|
||||
|
||||
OrbitalSatellite.network.sendToAll(new PhotonPacket(bos));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -116,27 +225,18 @@ public class TileDefender extends TileEntity {
|
||||
public void receiveObjectFromServer(int index, Object object) {
|
||||
if (index == 0) running = (Boolean) object;
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
super.writeToNBT(compound);
|
||||
|
||||
masterLocation.writeToNBT(compound, "Master");
|
||||
compound.setInteger("Facing", facingDirection);
|
||||
compound.setBoolean("IsValid", isValid);
|
||||
compound.setInteger("RedstoneMode", redstoneMode);
|
||||
compound.setBoolean("IsFiring", this.firing);
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
super.readFromNBT(compound);
|
||||
/*
|
||||
masterLocation.readFromNBT(compound, "Master");
|
||||
facingDirection = compound.getInteger("Facing");
|
||||
isValid = compound.getBoolean("IsValid");
|
||||
redstoneMode = compound.getInteger("RedstoneMode");
|
||||
*/
|
||||
this.firing = compound.getBoolean("IsFiring");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user