use of icbm.classic.lib.network.packet.PacketTile in project ICBM-Classic by BuiltBrokenModding.
the class TileMachine method getDescPacket.
public PacketTile getDescPacket() {
PacketTile packetTile = new PacketTile("desc", DESC_PACKET_ID, this);
// Should call back to IByteBufWriter
packetTile.addData(this);
return packetTile;
}
use of icbm.classic.lib.network.packet.PacketTile in project ICBM-Classic by BuiltBrokenModding.
the class TileMachine method update.
@Override
public void update() {
// Trigger first tick
if (ticks == -1) {
onFirstTick();
}
// Increase tick
ticks++;
if (ticks >= Integer.MAX_VALUE - 1) {
ticks = 0;
}
if (isServer()) {
// Sync client(s) if needed
if (updateClient) {
updateClient = false;
sendDescPacket();
}
// Sync GUI data to client(s)
if (ticks % 3 == 0 && getPlayersUsing().size() > 0) {
PacketTile packet = getGUIPacket();
if (packet != null) {
sendPacketToGuiUsers(packet);
}
}
}
}
use of icbm.classic.lib.network.packet.PacketTile in project ICBM-Classic by BuiltBrokenModding.
the class GuiLauncherScreen method keyTyped.
/**
* Call this method from you GuiScreen to process the keys into textbox.
*/
@Override
public void keyTyped(char par1, int par2) throws IOException {
super.keyTyped(par1, par2);
this.target_xCoord_field.textboxKeyTyped(par1, par2);
this.target_zCoord_field.textboxKeyTyped(par1, par2);
if (tileEntity.getTier().ordinal() >= 1) {
this.target_yCoord_field.textboxKeyTyped(par1, par2);
this.lock_height_field.textboxKeyTyped(par1, par2);
if (tileEntity.getTier().ordinal() > 1) {
this.target_freq_field.textboxKeyTyped(par1, par2);
}
}
try {
Pos newTarget = new Pos(parseInt(this.target_xCoord_field.getText()), max(parseInt(this.target_yCoord_field.getText()), 0), parseInt(this.target_zCoord_field.getText()));
this.tileEntity.setTarget(newTarget);
ICBMClassic.packetHandler.sendToServer(new PacketTile("target_C>S", TileLauncherScreen.SET_TARGET_PACKET_ID, this.tileEntity).addData(this.tileEntity.getTarget().xi(), this.tileEntity.getTarget().yi(), this.tileEntity.getTarget().zi()));
} catch (NumberFormatException e) {
}
try {
short newFrequency = (short) Math.max(Short.parseShort(this.target_freq_field.getText()), 0);
this.tileEntity.setFrequency(newFrequency);
ICBMClassic.packetHandler.sendToServer(new PacketTile("frequency_C>S", TileLauncherScreen.SET_FREQUENCY_PACKET_ID, this.tileEntity).addData(this.tileEntity.getFrequency()));
} catch (NumberFormatException e) {
}
try {
short newHeight = (short) Math.max(Math.min(Short.parseShort(this.lock_height_field.getText()), Short.MAX_VALUE), 3);
this.tileEntity.lockHeight = newHeight;
ICBMClassic.packetHandler.sendToServer(new PacketTile("lock_height_C>S", TileLauncherScreen.LOCK_HEIGHT_PACKET_ID, this.tileEntity).addData(this.tileEntity.lockHeight));
} catch (NumberFormatException e) {
}
}
use of icbm.classic.lib.network.packet.PacketTile 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.network.packet.PacketTile in project ICBM-Classic by BuiltBrokenModding.
the class GuiRadarStation method keyTyped.
/**
* Call this method from you GuiScreen to process the keys into textbox.
*/
@Override
public void keyTyped(char par1, int par2) throws IOException {
super.keyTyped(par1, par2);
this.textFieldTriggerRange.textboxKeyTyped(par1, par2);
this.textFieldDetectionRange.textboxKeyTyped(par1, par2);
this.textFieldFrequency.textboxKeyTyped(par1, par2);
try {
int newSafetyRadius = Math.min(TileRadarStation.MAX_DETECTION_RANGE, Math.max(0, Integer.parseInt(this.textFieldTriggerRange.getText())));
this.tileEntity.safetyRange = newSafetyRadius;
ICBMClassic.packetHandler.sendToServer(new PacketTile("safeRange_C>S", TileRadarStation.SET_SAFETY_RANGE_PACKET_ID, this.tileEntity).addData(this.tileEntity.safetyRange));
} catch (NumberFormatException e) {
}
try {
int newAlarmRadius = Math.min(TileRadarStation.MAX_DETECTION_RANGE, Math.max(0, Integer.parseInt(this.textFieldDetectionRange.getText())));
this.tileEntity.alarmRange = newAlarmRadius;
ICBMClassic.packetHandler.sendToServer(new PacketTile("alarmRange_C>S", TileRadarStation.SET_ALARM_RANGE_PACKET_ID, this.tileEntity).addData(this.tileEntity.alarmRange));
} catch (NumberFormatException e) {
}
try {
this.tileEntity.setFrequency(Integer.parseInt(this.textFieldFrequency.getText()));
ICBMClassic.packetHandler.sendToServer(new PacketTile("frequency_C>S", TileRadarStation.SET_FREQUENCY_PACKET_ID, this.tileEntity).addData(this.tileEntity.getFrequency()));
} catch (NumberFormatException e) {
}
}
Aggregations