use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class GuiCruiseLauncher method keyTyped.
@Override
public void keyTyped(char par1, int par2) throws IOException {
super.keyTyped(par1, par2);
this.textFieldX.textboxKeyTyped(par1, par2);
this.textFieldZ.textboxKeyTyped(par1, par2);
this.textFieldY.textboxKeyTyped(par1, par2);
this.textFieldFreq.textboxKeyTyped(par1, par2);
try {
Pos newTarget = new Pos(parseInt(this.textFieldX.getText()), parseInt(this.textFieldY.getText()), parseInt(this.textFieldZ.getText()));
this.tileEntity.setTarget(newTarget);
ICBMClassic.packetHandler.sendToServer(new PacketTile("target_C>S", TileCruiseLauncher.SET_TARGET_PACKET_ID, tileEntity).addData(tileEntity.getTarget().xi(), this.tileEntity.getTarget().yi(), this.tileEntity.getTarget().zi()));
} catch (NumberFormatException e) {
}
try {
short newFrequency = (short) Math.max(Short.parseShort(this.textFieldFreq.getText()), 0);
this.tileEntity.setFrequency(newFrequency);
ICBMClassic.packetHandler.sendToServer(new PacketTile("frequency_C>S", TileCruiseLauncher.SET_FREQUENCY_PACKET_ID, tileEntity).addData(tileEntity.getFrequency()));
} catch (NumberFormatException e) {
}
}
use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class TileCruiseLauncher 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) {
// Floor frequency as we do not care about sub ranges
final int frequency = (int) Math.floor(hz);
if (isServer() && frequency == this.getFrequency()) {
// Laser detonator signal
if (// TODO cache headers somewhere like API references
messageHeader.equals("activateLauncherWithTarget")) {
final Pos pos = (Pos) data[0];
if (!isTooClose(pos)) {
setTarget(pos);
((FakeRadioSender) sender).player.sendMessage(new TextComponentString("Aiming 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 TileCruiseLauncher method readDescPacket.
@Override
public void readDescPacket(ByteBuf buf) {
super.readDescPacket(buf);
if (buf.readBoolean()) {
cachedMissileStack = ByteBufUtils.readItemStack(buf);
} else {
cachedMissileStack = ItemStack.EMPTY;
}
setTarget(new Pos(buf.readInt(), buf.readInt(), buf.readInt()));
currentAim.setYaw(buf.readDouble());
currentAim.setPitch(buf.readDouble());
}
use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class GuiRadarStation method drawGuiContainerBackgroundLayer.
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
drawDefaultBackground();
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.containerPosX = (this.width - this.xSize) / 2;
this.containerPosY = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(containerPosX, containerPosY, 0, 0, this.xSize, this.ySize);
this.radarCenter = new Point(this.containerPosX + this.xSize / 3 - 10, this.containerPosY + this.ySize / 2 + 4);
this.radarMapRadius = TileRadarStation.MAX_DETECTION_RANGE / 71f;
this.info = "";
this.info2 = "";
if (this.tileEntity.hasPower()) {
int range = 4;
for (Pos pos : tileEntity.guiDrawPoints) {
final RadarObjectType type = RadarObjectType.get(pos.zi());
final double x = pos.x();
final double z = pos.y();
Point position = new Point(radarCenter.x() + (x - this.tileEntity.getPos().getX()) / this.radarMapRadius, radarCenter.y() - (z - this.tileEntity.getPos().getZ()) / this.radarMapRadius);
switch(type) {
case MISSILE:
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_YELLOW_DOT);
break;
case MISSILE_IMPACT:
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_RED_DOT);
break;
case OTHER:
default:
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_WHITE_DOT);
break;
}
this.drawTexturedModalRect(position.xi(), position.yi(), 0, 0, 2, 2);
// Hover Detection
Point minPosition = position.add(-range);
Point maxPosition = position.add(range);
if (new Rectangle(minPosition, maxPosition).isWithin(this.mousePosition)) {
if (type == RadarObjectType.OTHER) {
this.info = String.format(LanguageUtility.getLocal("gui.misc.object"), (int) x, (int) z);
} else {
this.info = (type == RadarObjectType.MISSILE ? "\u00a76" : "\u00a74") + String.format(LanguageUtility.getLocal("gui.misc.missile"), (int) x, (int) z);
}
}
}
}
// Draw energy bar
if (tileEntity.getEnergy() > 0) {
float energyScale = tileEntity.getEnergy() / (float) tileEntity.getEnergyBufferSize();
final int textureWidth = 8;
final int textureHeight = 142 / 2;
final int height = (int) Math.min(textureHeight, Math.floor(textureHeight * energyScale));
this.drawTexturedModalRect(containerPosX + 248, containerPosY + 65 + (textureHeight - height), 0, (332 / 2) + textureHeight - height, textureWidth, height);
}
}
use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class TileEntityExplosive method trigger.
public void trigger(boolean setFire) {
if (!hasBeenTriggered) {
hasBeenTriggered = true;
EntityExplosive entityExplosive = new EntityExplosive(world, new Pos(pos).add(0.5), getDirection(), capabilityExplosive.toStack());
if (setFire) {
entityExplosive.setFire(100);
}
world.spawnEntity(entityExplosive);
world.setBlockToAir(pos);
ICBMClassic.logger().info("TileEntityExplosive: Triggered ITEM{" + capabilityExplosive.toStack() + "] " + capabilityExplosive.getExplosiveData().getRegistryName() + " at location " + getPos());
}
}
Aggregations