use of com.minecolonies.coremod.network.messages.server.colony.ChangeFreeToInteractBlockMessage in project minecolonies by ldtteam.
the class ItemScepterPermission method handleAddBlockType.
@NotNull
private static ActionResultType handleAddBlockType(final PlayerEntity playerIn, final World worldIn, final BlockPos pos, final IColonyView iColonyView) {
final BlockState blockState = iColonyView.getWorld().getBlockState(pos);
final Block block = blockState.getBlock();
final ChangeFreeToInteractBlockMessage message = new ChangeFreeToInteractBlockMessage(iColonyView, block, ChangeFreeToInteractBlockMessage.MessageType.ADD_BLOCK);
Network.getNetwork().sendToServer(message);
return ActionResultType.SUCCESS;
}
use of com.minecolonies.coremod.network.messages.server.colony.ChangeFreeToInteractBlockMessage 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.minecolonies.coremod.network.messages.server.colony.ChangeFreeToInteractBlockMessage in project minecolonies by Minecolonies.
the class ItemScepterPermission method handleAddLocation.
@NotNull
private static ActionResultType handleAddLocation(final PlayerEntity playerIn, final World worldIn, final BlockPos pos, final IColonyView iColonyView) {
final ChangeFreeToInteractBlockMessage message = new ChangeFreeToInteractBlockMessage(iColonyView, pos, ChangeFreeToInteractBlockMessage.MessageType.ADD_BLOCK);
Network.getNetwork().sendToServer(message);
return ActionResultType.SUCCESS;
}
use of com.minecolonies.coremod.network.messages.server.colony.ChangeFreeToInteractBlockMessage in project minecolonies by Minecolonies.
the class ItemScepterPermission method handleAddBlockType.
@NotNull
private static ActionResultType handleAddBlockType(final PlayerEntity playerIn, final World worldIn, final BlockPos pos, final IColonyView iColonyView) {
final BlockState blockState = iColonyView.getWorld().getBlockState(pos);
final Block block = blockState.getBlock();
final ChangeFreeToInteractBlockMessage message = new ChangeFreeToInteractBlockMessage(iColonyView, block, ChangeFreeToInteractBlockMessage.MessageType.ADD_BLOCK);
Network.getNetwork().sendToServer(message);
return ActionResultType.SUCCESS;
}
use of com.minecolonies.coremod.network.messages.server.colony.ChangeFreeToInteractBlockMessage in project minecolonies by Minecolonies.
the class WindowPermissionsPage method removeBlock.
private void removeBlock(final Button button) {
final int row = freeBlocksList.getListElementIndexByPane(button);
if (row >= 0) {
@NotNull final List<Block> freeBlocks = building.getColony().getFreeBlocks();
@NotNull final List<BlockPos> freePositions = building.getColony().getFreePositions();
if (row < freeBlocks.size()) {
Network.getNetwork().sendToServer(new ChangeFreeToInteractBlockMessage(building.getColony(), freeBlocks.get(row), ChangeFreeToInteractBlockMessage.MessageType.REMOVE_BLOCK));
building.getColony().removeFreeBlock(freeBlocks.get(row));
} else if (row < freeBlocks.size() + freePositions.size()) {
final BlockPos freePos = freePositions.get(row - freeBlocks.size());
Network.getNetwork().sendToServer(new ChangeFreeToInteractBlockMessage(building.getColony(), freePos, ChangeFreeToInteractBlockMessage.MessageType.REMOVE_BLOCK));
building.getColony().removeFreePosition(freePos);
}
fillFreeBlockList();
}
}
Aggregations