Search in sources :

Example 1 with AddRemoveTagMessage

use of com.ldtteam.structurize.network.messages.AddRemoveTagMessage in project Structurize by ldtteam.

the class WindowTagTool method removeTag.

/**
 * Removes a block pos
 *
 * @param button
 */
private void removeTag(final Button button) {
    int row = tagList.getListElementIndexByPane(button);
    BlockPos toRemove = positionsList.get(row);
    TileEntity te = world.getBlockEntity(anchorPos);
    if (te instanceof IBlueprintDataProvider) {
        IBlueprintDataProvider dataTE = (IBlueprintDataProvider) te;
        Map<BlockPos, List<String>> map = dataTE.getPositionedTags();
        if (map.containsKey(toRemove) && !map.get(toRemove).isEmpty()) {
            String tag = map.get(toRemove).get(map.get(toRemove).size() - 1);
            dataTE.removeTag(toRemove, tag);
            Network.getNetwork().sendToServer(new AddRemoveTagMessage(false, tag, toRemove, anchorPos));
        }
        updateResourceList();
    } else {
        close();
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AddRemoveTagMessage(com.ldtteam.structurize.network.messages.AddRemoveTagMessage) IBlueprintDataProvider(com.ldtteam.structurize.blocks.interfaces.IBlueprintDataProvider) BlockPos(net.minecraft.util.math.BlockPos) ScrollingList(com.ldtteam.blockout.views.ScrollingList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ScrollingList (com.ldtteam.blockout.views.ScrollingList)1 IBlueprintDataProvider (com.ldtteam.structurize.blocks.interfaces.IBlueprintDataProvider)1 AddRemoveTagMessage (com.ldtteam.structurize.network.messages.AddRemoveTagMessage)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1