use of com.ldtteam.blockout.controls.TextField in project minecolonies by ldtteam.
the class WindowPostBox method requestClicked.
/**
* Action executed when request is clicked.
*
* @param button the clicked button.
*/
private void requestClicked(final Button button) {
final int row = stackList.getListElementIndexByPane(button);
final ItemStack stack = allItems.get(row);
int qty = stack.getMaxStackSize();
for (final Pane child : button.getParent().getChildren()) {
if (child.getID().equals(INPUT_QTY)) {
try {
qty = Integer.parseInt(((TextField) child).getText());
} catch (final NumberFormatException ex) {
// Be quiet about it.
}
}
}
Network.getNetwork().sendToServer(new PostBoxRequestMessage(buildingView, stack.copy(), qty, deliverAvailable));
}
use of com.ldtteam.blockout.controls.TextField in project minecolonies by ldtteam.
the class WindowPermissionsPage method addBlock.
/**
* Called when the "addBlock" button has been triggered. Tries to add the content of the input field as block or position to the colony.
*/
private void addBlock() {
final TextField input = findPaneOfTypeByID(INPUT_BLOCK_NAME, TextField.class);
final String inputText = input.getText();
try {
final Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(inputText));
if (block != null) {
building.getColony().addFreeBlock(block);
Network.getNetwork().sendToServer(new ChangeFreeToInteractBlockMessage(building.getColony(), block, ChangeFreeToInteractBlockMessage.MessageType.ADD_BLOCK));
}
} catch (final ResourceLocationException e) {
// Do nothing.
}
final BlockPos pos = BlockPosUtil.getBlockPosOfString(inputText);
if (pos != null) {
Network.getNetwork().sendToServer(new ChangeFreeToInteractBlockMessage(building.getColony(), pos, ChangeFreeToInteractBlockMessage.MessageType.ADD_BLOCK));
building.getColony().addFreePosition(pos);
}
fillFreeBlockList();
input.setText("");
}
use of com.ldtteam.blockout.controls.TextField in project minecolonies by Minecolonies.
the class WindowHutCrusherModule method saveCrushingMode.
/**
* Save the crushing mode.
*/
private void saveCrushingMode() {
final TextField crushingSettingsInput = findPaneOfTypeByID(QTY_INPUT, TextField.class);
try {
final int qty = Integer.parseInt(crushingSettingsInput.getText());
building.setCrusherMode(mode, qty);
} catch (final NumberFormatException ex) {
Log.getLogger().warn("Wrong input!");
}
}
use of com.ldtteam.blockout.controls.TextField in project minecolonies by Minecolonies.
the class WindowPermissionsPage method addBlock.
/**
* Called when the "addBlock" button has been triggered. Tries to add the content of the input field as block or position to the colony.
*/
private void addBlock() {
final TextField input = findPaneOfTypeByID(INPUT_BLOCK_NAME, TextField.class);
final String inputText = input.getText();
try {
final Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(inputText));
if (block != null) {
building.getColony().addFreeBlock(block);
Network.getNetwork().sendToServer(new ChangeFreeToInteractBlockMessage(building.getColony(), block, ChangeFreeToInteractBlockMessage.MessageType.ADD_BLOCK));
}
} catch (final ResourceLocationException e) {
// Do nothing.
}
final BlockPos pos = BlockPosUtil.getBlockPosOfString(inputText);
if (pos != null) {
Network.getNetwork().sendToServer(new ChangeFreeToInteractBlockMessage(building.getColony(), pos, ChangeFreeToInteractBlockMessage.MessageType.ADD_BLOCK));
building.getColony().addFreePosition(pos);
}
fillFreeBlockList();
input.setText("");
}
use of com.ldtteam.blockout.controls.TextField in project minecolonies by Minecolonies.
the class WindowPostBox method requestClicked.
/**
* Action executed when request is clicked.
*
* @param button the clicked button.
*/
private void requestClicked(final Button button) {
final int row = stackList.getListElementIndexByPane(button);
final ItemStack stack = allItems.get(row);
int qty = stack.getMaxStackSize();
for (final Pane child : button.getParent().getChildren()) {
if (child.getID().equals(INPUT_QTY)) {
try {
qty = Integer.parseInt(((TextField) child).getText());
} catch (final NumberFormatException ex) {
// Be quiet about it.
}
}
}
Network.getNetwork().sendToServer(new PostBoxRequestMessage(buildingView, stack.copy(), qty, deliverAvailable));
}
Aggregations