use of com.builtbroken.mc.core.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) {
super.keyTyped(par1, par2);
this.textFieldSafetyZone.textboxKeyTyped(par1, par2);
this.textFieldAlarmRange.textboxKeyTyped(par1, par2);
this.textFieldFrequency.textboxKeyTyped(par1, par2);
try {
int newSafetyRadius = Math.min(TileRadarStation.MAX_DETECTION_RANGE, Math.max(0, Integer.parseInt(this.textFieldSafetyZone.getText())));
this.tileEntity.safetyRange = newSafetyRadius;
Engine.instance.packetHandler.sendToServer(new PacketTile(this.tileEntity, 2, this.tileEntity.safetyRange));
} catch (NumberFormatException e) {
}
try {
int newAlarmRadius = Math.min(TileRadarStation.MAX_DETECTION_RANGE, Math.max(0, Integer.parseInt(this.textFieldAlarmRange.getText())));
this.tileEntity.alarmRange = newAlarmRadius;
Engine.instance.packetHandler.sendToServer(new PacketTile(this.tileEntity, 3, this.tileEntity.alarmRange));
} catch (NumberFormatException e) {
}
try {
this.tileEntity.setFrequency(Integer.parseInt(this.textFieldFrequency.getText()));
Engine.instance.packetHandler.sendToServer(new PacketTile(this.tileEntity, 4, this.tileEntity.getFrequency()));
} catch (NumberFormatException e) {
}
}
use of com.builtbroken.mc.core.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) {
super.keyTyped(par1, par2);
this.target_xCoord_field.textboxKeyTyped(par1, par2);
this.target_zCoord_field.textboxKeyTyped(par1, par2);
if (tileEntity.getTier() >= 1) {
this.target_yCoord_field.textboxKeyTyped(par1, par2);
this.target_height_field.textboxKeyTyped(par1, par2);
if (tileEntity.getTier() > 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);
Engine.instance.packetHandler.sendToServer(new PacketTile(this.tileEntity, 2, 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);
Engine.instance.packetHandler.sendToServer(new PacketTile(this.tileEntity, 1, this.tileEntity.getFrequency()));
} catch (NumberFormatException e) {
}
try {
short newGaoDu = (short) Math.max(Math.min(Short.parseShort(this.target_height_field.getText()), Short.MAX_VALUE), 3);
this.tileEntity.targetHeight = newGaoDu;
Engine.instance.packetHandler.sendToServer(new PacketTile(this.tileEntity, 3, this.tileEntity.targetHeight));
} catch (NumberFormatException e) {
}
}
use of com.builtbroken.mc.core.network.packet.PacketTile in project ICBM-Classic by BuiltBrokenModding.
the class GuiCruiseLauncher method keyTyped.
@Override
public void keyTyped(char par1, int par2) {
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);
Engine.instance.packetHandler.sendToServer(new PacketTile(tileEntity, 2, 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);
Engine.instance.packetHandler.sendToServer(new PacketTile(tileEntity, 1, tileEntity.getFrequency()));
} catch (NumberFormatException e) {
}
}
use of com.builtbroken.mc.core.network.packet.PacketTile in project Engine by VoltzEngine-Project.
the class AbstractTileTest method testSendpacketToServer.
@Test
public void testSendpacketToServer() {
FakeWorld world = FakeWorld.newWorld("TestSendpacketToServer");
world.setBlock(0, 0, 0, block);
Tile tile = ((Tile) world.getTileEntity(0, 0, 0));
tile.sendPacketToServer(new PacketTile(tile));
}
use of com.builtbroken.mc.core.network.packet.PacketTile in project ICBM-Classic by BuiltBrokenModding.
the class TileICBMMachine method doUpdateGuiUsers.
@Override
public void doUpdateGuiUsers() {
if (isServer()) {
//Sync client(s) if needed
if (updateClient) {
updateClient = false;
sendDescPacket();
}
//Sync GUI data to client(s)
if (ticks % 3 == 0) {
PacketTile packet = getGUIPacket();
if (packet != null) {
sendPacketToGuiUsers(packet);
}
}
}
}
Aggregations