use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class EntityMissile method readEntityFromNBT.
/**
* (abstract) Protected helper method to read subclass entity additionalMissileData from NBT.
*/
@Override
public void readEntityFromNBT(NBTTagCompound nbt) {
super.readEntityFromNBT(nbt);
this.targetPos = new Pos(nbt.getCompoundTag(NBTConstants.TARGET));
this.launcherPos = new Pos(nbt.getCompoundTag(NBTConstants.LAUNCHER_POS));
this.acceleration = nbt.getFloat(NBTConstants.ACCELERATION);
this.targetHeight = nbt.getInteger(NBTConstants.TARGET_HEIGHT);
this.explosiveID = nbt.getInteger(NBTConstants.EXPLOSIVE_ID);
this.ticksInAir = nbt.getInteger(NBTConstants.TICKS_IN_AIR);
this.lockHeight = nbt.getDouble(NBTConstants.LOCK_HEIGHT);
this.missileType = MissileFlightType.get(nbt.getInteger(NBTConstants.MISSILE_TYPE));
this.preLaunchSmokeTimer = nbt.getInteger(NBTConstants.PRE_LAUNCH_SMOKE_TIMER);
this.blastData = nbt.getCompoundTag(NBTConstants.ADDITIONAL_MISSILE_DATA);
}
use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class MissileTrackerData method readFromNBT.
// Helper methods for saving and loading
public void readFromNBT(NBTTagCompound nbt) {
ticksLeftToTarget = nbt.getInteger(NBTConstants.TICKS);
targetPos = new Pos(nbt.getCompoundTag(NBTConstants.TARGET));
missileData = nbt.getCompoundTag(NBTConstants.DATA);
}
use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class TileLauncherScreen method receiveRadioWave.
@Override
public // TODO pack as message object
void receiveRadioWave(// TODO pack as message object
float hz, // TODO pack as message object
IRadioWaveSender sender, // TODO pack as message object
String messageHeader, // TODO pack as message object
Object[] data) {
// TODO make sure other launchers don't trigger when a laser designator is used
if (isServer()) {
// Floor frequency as we do not care about sub ranges
int frequency = (int) Math.floor(hz);
// Only tier 3 (2 for tier value) can be remotely fired
if (getTier() == EnumTier.THREE && frequency == getFrequency() && launcherBase != null) {
// Laser detonator signal
if (// TODO cache headers somewhere like API references
messageHeader.equals("activateLauncherWithTarget")) {
Pos pos = (Pos) data[0];
if (new Pos((IPos3D) this).distance(pos) < this.launcherBase.getRange()) {
setTarget(pos);
launch();
((FakeRadioSender) sender).player.sendMessage(new TextComponentString("Firing missile at " + pos));
}
} else // Remote detonator signal
if (messageHeader.equals("activateLauncher")) {
((FakeRadioSender) sender).player.sendMessage(new TextComponentString("Firing missile at " + getTarget()));
launch();
}
}
}
}
use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class TileLauncherScreen method update.
@Override
public void update() {
super.update();
if (this.launcherBase == null || this.launcherBase.isInvalid()) {
this.launcherBase = null;
for (EnumFacing rotation : EnumFacing.HORIZONTALS) {
final Pos position = new Pos((IPos3D) this).add(rotation);
final TileEntity tileEntity = position.getTileEntity(world);
if (tileEntity != null) {
if (tileEntity instanceof TileLauncherBase) {
this.launcherBase = (TileLauncherBase) tileEntity;
if (isServer()) {
setRotation(rotation.getOpposite());
updateClient = true;
}
}
}
}
}
if (isServer()) {
// Delay launch, basically acts as a reload time
if (launchDelay > 0) {
launchDelay--;
} else // Only launch if redstone
if (// TODO replace with countdown
ticks % 10 == 0 && world.getRedstonePowerFromNeighbors(getPos()) > 0) {
this.launch();
}
// Update packet TODO see if this is needed
if (ticks % 3 == 0) {
sendDescPacket();
}
}
}
use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class ItemLaserDetonator method read.
@Override
public boolean read(ByteBuf buf, int id, EntityPlayer player, IPacket packet) {
ItemStack stack = player.inventory.getCurrentItem();
if (stack != null && stack.getItem() == this) {
if (!player.world.isRemote) {
int x = buf.readInt();
int y = buf.readInt();
int z = buf.readInt();
LaserRemoteTriggerEvent event = new LaserRemoteTriggerEvent(player.world, new BlockPos(x, y, z), player);
if (// event was canceled
MinecraftForge.EVENT_BUS.post(event))
return false;
if (// someone set the pos in the event to null, use original data
event.pos == null)
RadioRegistry.popMessage(player.world, new FakeRadioSender(player, stack, 2000), getBroadCastHz(stack), "activateLauncherWithTarget", new Pos(x, y, z));
else
RadioRegistry.popMessage(player.world, new FakeRadioSender(player, stack, 2000), getBroadCastHz(stack), "activateLauncherWithTarget", new Pos(event.pos.getX(), event.pos.getY(), event.pos.getZ()));
} else {
player.sendMessage(new TextComponentString("Not encoded with launch data! Right click on launcher screen to encode."));
}
}
return true;
}
Aggregations