Add command stack, Move butcher to entities category
This commit is contained in:
@@ -8,24 +8,13 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class Categories
|
||||
{
|
||||
public static final Category MAIN;
|
||||
public static final Category ENTITIES;
|
||||
public static final Category ITEMS;
|
||||
public static final Category BLOCKS;
|
||||
public static final Category WORLD;
|
||||
public static final Category PLAYER;
|
||||
public static final Category SCOREBOARD;
|
||||
|
||||
static
|
||||
{
|
||||
MAIN = Categories.getRegisteredCategory("main");
|
||||
ENTITIES = Categories.getRegisteredCategory("entities");
|
||||
ITEMS = Categories.getRegisteredCategory("items");
|
||||
BLOCKS = Categories.getRegisteredCategory("blocks");
|
||||
WORLD = Categories.getRegisteredCategory("world");
|
||||
PLAYER = Categories.getRegisteredCategory("player");
|
||||
SCOREBOARD = Categories.getRegisteredCategory("scoreboard");
|
||||
}
|
||||
public static final Category MAIN = Categories.getRegisteredCategory("main");
|
||||
public static final Category ENTITIES = Categories.getRegisteredCategory("entities");
|
||||
public static final Category ITEMS = Categories.getRegisteredCategory("items");
|
||||
public static final Category BLOCKS = Categories.getRegisteredCategory("blocks");
|
||||
public static final Category WORLD = Categories.getRegisteredCategory("world");
|
||||
public static final Category PLAYER = Categories.getRegisteredCategory("player");
|
||||
public static final Category SCOREBOARD = Categories.getRegisteredCategory("scoreboard");
|
||||
|
||||
public static Category getRegisteredCategory(String name)
|
||||
{
|
||||
|
||||
@@ -93,7 +93,7 @@ public class Category extends ForgeRegistryEntry<Category>
|
||||
public static void register(Register<Category> event)
|
||||
{
|
||||
RegistryHelper.register(event.getRegistry(), "main", new Category("main", "containers", "multiplayer"));
|
||||
RegistryHelper.register(event.getRegistry(), "entities", new Category("summon"));
|
||||
RegistryHelper.register(event.getRegistry(), "entities", new Category("summon", "butcher"));
|
||||
RegistryHelper.register(event.getRegistry(), "items", new Category("custom_item", "enchantment", "recipes"));
|
||||
RegistryHelper.register(event.getRegistry(), "blocks", new Category("edit_blocks", "sign_editor", "note_editor"));
|
||||
RegistryHelper.register(event.getRegistry(), "world", new Category("world", "gamerules"));
|
||||
|
||||
@@ -9,6 +9,7 @@ import exopandora.worldhandler.gui.content.impl.ContentAdvancements;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentButcher;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentButcherSettings;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentChangeWorld;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentCommandStack;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentContainers;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentContinue;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentCustomItem;
|
||||
@@ -100,6 +101,7 @@ public abstract class Content extends ForgeRegistryEntry<Content> implements ICo
|
||||
|
||||
//NO CATEGORY
|
||||
RegistryHelper.register(event.getRegistry(), "potions", new ContentPotions());
|
||||
RegistryHelper.register(event.getRegistry(), "command_stack", new ContentCommandStack());
|
||||
RegistryHelper.register(event.getRegistry(), "butcher", new ContentButcher());
|
||||
RegistryHelper.register(event.getRegistry(), "butcher_settings", new ContentButcherSettings());
|
||||
RegistryHelper.register(event.getRegistry(), "settings", new ContentSettings());
|
||||
@@ -130,14 +132,6 @@ public abstract class Content extends ForgeRegistryEntry<Content> implements ICo
|
||||
this.persistence = new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
if(this.persistence.containsKey(id))
|
||||
{
|
||||
return (T) this.persistence.get(id);
|
||||
}
|
||||
|
||||
T object = supplier.get();
|
||||
this.persistence.put(id, object);
|
||||
|
||||
return object;
|
||||
return (T) this.persistence.computeIfAbsent(id, key -> supplier.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,74 +10,39 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class Contents
|
||||
{
|
||||
public static final Content MAIN;
|
||||
public static final Content CONTAINERS;
|
||||
public static final Content MULTIPLAYER;
|
||||
public static final Content MAIN = Contents.getRegisteredContent("main");
|
||||
public static final Content CONTAINERS = Contents.getRegisteredContent("containers");
|
||||
public static final Content MULTIPLAYER = Contents.getRegisteredContent("multiplayer");
|
||||
|
||||
public static final Content SUMMON;
|
||||
public static final Content SUMMON = Contents.getRegisteredContent("summon");
|
||||
|
||||
public static final Content CUSTOM_ITEM;
|
||||
public static final Content ENCHANTMENT;
|
||||
public static final Content CUSTOM_ITEM = Contents.getRegisteredContent("custom_item");
|
||||
public static final Content ENCHANTMENT = Contents.getRegisteredContent("enchantment");
|
||||
|
||||
public static final Content EDIT_BLOCKS;
|
||||
public static final Content SIGN_EDITOR;
|
||||
public static final Content NOTE_EDITOR;
|
||||
public static final Content EDIT_BLOCKS = Contents.getRegisteredContent("edit_blocks");
|
||||
public static final Content SIGN_EDITOR = Contents.getRegisteredContent("sign_editor");
|
||||
public static final Content NOTE_EDITOR = Contents.getRegisteredContent("note_editor");
|
||||
|
||||
public static final Content WORLD_INFO;
|
||||
public static final Content GAMERULES;
|
||||
public static final Content RECIPES;
|
||||
public static final Content WORLD_INFO = Contents.getRegisteredContent("world");
|
||||
public static final Content GAMERULES = Contents.getRegisteredContent("gamerules");
|
||||
public static final Content RECIPES = Contents.getRegisteredContent("recipes");
|
||||
|
||||
public static final Content PLAYER;
|
||||
public static final Content EXPERIENCE;
|
||||
public static final Content ADVANCEMENTS;
|
||||
public static final Content PLAYER = Contents.getRegisteredContent("player");
|
||||
public static final Content EXPERIENCE = Contents.getRegisteredContent("experience");
|
||||
public static final Content ADVANCEMENTS = Contents.getRegisteredContent("advancements");
|
||||
|
||||
public static final Content SCOREBOARD_OBJECTIVES;
|
||||
public static final Content SCOREBOARD_TEAMS;
|
||||
public static final Content SCOREBOARD_PLAYERS;
|
||||
public static final Content SCOREBOARD_OBJECTIVES = Contents.getRegisteredContent("scoreboard_objectives");
|
||||
public static final Content SCOREBOARD_TEAMS = Contents.getRegisteredContent("scoreboard_teams");
|
||||
public static final Content SCOREBOARD_PLAYERS = Contents.getRegisteredContent("scoreboard_players");
|
||||
|
||||
public static final ContentChild CHANGE_WORLD;
|
||||
public static final ContentContinue CONTINUE;
|
||||
public static final ContentChild CHANGE_WORLD = (ContentChild) Contents.getRegisteredContent("change_world");
|
||||
public static final ContentContinue CONTINUE = (ContentContinue) Contents.getRegisteredContent("continue");
|
||||
|
||||
public static final ContentChild POTIONS;
|
||||
public static final ContentChild BUTCHER;
|
||||
public static final ContentChild BUTCHER_SETTINGS;
|
||||
public static final ContentChild SETTINGS;
|
||||
|
||||
static
|
||||
{
|
||||
MAIN = Contents.getRegisteredContent("main");
|
||||
CONTAINERS = Contents.getRegisteredContent("containers");
|
||||
MULTIPLAYER = Contents.getRegisteredContent("multiplayer");
|
||||
|
||||
SUMMON = Contents.getRegisteredContent("summon");
|
||||
|
||||
CUSTOM_ITEM = Contents.getRegisteredContent("custom_item");
|
||||
ENCHANTMENT = Contents.getRegisteredContent("enchantment");
|
||||
|
||||
EDIT_BLOCKS = Contents.getRegisteredContent("edit_blocks");
|
||||
SIGN_EDITOR = Contents.getRegisteredContent("sign_editor");
|
||||
NOTE_EDITOR = Contents.getRegisteredContent("note_editor");
|
||||
|
||||
WORLD_INFO = Contents.getRegisteredContent("world");
|
||||
GAMERULES = Contents.getRegisteredContent("gamerules");
|
||||
RECIPES = Contents.getRegisteredContent("recipes");
|
||||
|
||||
PLAYER = Contents.getRegisteredContent("player");
|
||||
EXPERIENCE = Contents.getRegisteredContent("experience");
|
||||
ADVANCEMENTS = Contents.getRegisteredContent("advancements");
|
||||
|
||||
SCOREBOARD_OBJECTIVES = Contents.getRegisteredContent("scoreboard_objectives");
|
||||
SCOREBOARD_TEAMS = Contents.getRegisteredContent("scoreboard_teams");
|
||||
SCOREBOARD_PLAYERS = Contents.getRegisteredContent("scoreboard_players");
|
||||
|
||||
CHANGE_WORLD = (ContentChild) Contents.getRegisteredContent("change_world");
|
||||
CONTINUE = (ContentContinue) Contents.getRegisteredContent("continue");
|
||||
|
||||
POTIONS = (ContentChild) Contents.getRegisteredContent("potions");
|
||||
BUTCHER = (ContentChild) Contents.getRegisteredContent("butcher");
|
||||
BUTCHER_SETTINGS = (ContentChild) Contents.getRegisteredContent("butcher_settings");
|
||||
SETTINGS = (ContentChild) Contents.getRegisteredContent("settings");
|
||||
}
|
||||
public static final ContentChild POTIONS = (ContentChild) Contents.getRegisteredContent("potions");
|
||||
public static final ContentChild COMMAND_STACK = (ContentChild) Contents.getRegisteredContent("command_stack");
|
||||
public static final Content BUTCHER = Contents.getRegisteredContent("butcher");
|
||||
public static final ContentChild BUTCHER_SETTINGS = (ContentChild) Contents.getRegisteredContent("butcher_settings");
|
||||
public static final ContentChild SETTINGS = (ContentChild) Contents.getRegisteredContent("settings");
|
||||
|
||||
public static Content getRegisteredContent(String name)
|
||||
{
|
||||
|
||||
@@ -5,8 +5,11 @@ import exopandora.worldhandler.builder.impl.BuilderButcher;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.container.impl.GuiWorldHandler;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
@@ -17,7 +20,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentButcher extends ContentChild
|
||||
public class ContentButcher extends Content
|
||||
{
|
||||
private GuiTextFieldTooltip radiusField;
|
||||
private String radius;
|
||||
@@ -109,9 +112,27 @@ public class ContentButcher extends ContentChild
|
||||
this.radiusField.renderButton(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory()
|
||||
{
|
||||
return Categories.ENTITIES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.butcher");
|
||||
return I18n.format("gui.worldhandler.title.entities.butcher");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.tab.entities.butcher");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getActiveContent()
|
||||
{
|
||||
return Contents.BUTCHER;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,271 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.component.impl.EntityNBT;
|
||||
import exopandora.worldhandler.builder.impl.BuilderButcher;
|
||||
import exopandora.worldhandler.builder.impl.BuilderFill;
|
||||
import exopandora.worldhandler.builder.impl.BuilderSetBlock;
|
||||
import exopandora.worldhandler.builder.impl.BuilderSetBlock.EnumMode;
|
||||
import exopandora.worldhandler.builder.impl.BuilderSummon;
|
||||
import exopandora.worldhandler.builder.types.BlockResourceLocation;
|
||||
import exopandora.worldhandler.builder.types.Coordinate.EnumType;
|
||||
import exopandora.worldhandler.builder.types.CoordinateDouble;
|
||||
import exopandora.worldhandler.builder.types.CoordinateInt;
|
||||
import exopandora.worldhandler.gui.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonIcon;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ContentCommandStack extends ContentChild
|
||||
{
|
||||
private static final int HEAD_LENGTH = 1;
|
||||
private static final int TAIL_LENGTH = 2;
|
||||
|
||||
private final List<GuiTextFieldTooltip> textfields = new ArrayList<GuiTextFieldTooltip>();
|
||||
private int scroll;
|
||||
private GuiButtonBase buttonCopy;
|
||||
|
||||
private final BuilderSummon builderCommandStack = new BuilderSummon();
|
||||
|
||||
public ContentCommandStack()
|
||||
{
|
||||
this.builderCommandStack.setEntity(EntityType.FALLING_BLOCK.getRegistryName());
|
||||
this.builderCommandStack.setX(new CoordinateDouble(0.0D, EnumType.GLOBAL));
|
||||
this.builderCommandStack.setY(new CoordinateDouble(0.5D, EnumType.GLOBAL));
|
||||
this.builderCommandStack.setZ(new CoordinateDouble(0.0D, EnumType.GLOBAL));
|
||||
this.builderCommandStack.setMotion(0.0D, 0.315D, 0.0D);
|
||||
this.builderCommandStack.setTime(1);
|
||||
this.builderCommandStack.setBlockState(Blocks.ACTIVATOR_RAIL.getDefaultState());
|
||||
|
||||
EntityNBT redstoneBlock = new EntityNBT(EntityType.FALLING_BLOCK.getRegistryName());
|
||||
redstoneBlock.setTime(1);
|
||||
redstoneBlock.setBlockState(Blocks.REDSTONE_BLOCK.getDefaultState());
|
||||
this.builderCommandStack.addPassenger(redstoneBlock);
|
||||
|
||||
this.addCommand(0);
|
||||
|
||||
EntityNBT blockRemover = new EntityNBT(EntityType.COMMAND_BLOCK_MINECART.getRegistryName());
|
||||
BuilderSetBlock builder = new BuilderSetBlock(new CoordinateInt(EnumType.GLOBAL), new CoordinateInt(-2, EnumType.GLOBAL), new CoordinateInt(EnumType.GLOBAL), Blocks.REPEATING_COMMAND_BLOCK.getRegistryName(), EnumMode.DESTROY);
|
||||
CompoundNBT commandBlock = new CompoundNBT();
|
||||
commandBlock.putByte("auto", (byte) 1);
|
||||
commandBlock.putString("Command", new BuilderFill(new CoordinateInt(EnumType.GLOBAL), new CoordinateInt(EnumType.GLOBAL), new CoordinateInt(EnumType.GLOBAL), new CoordinateInt(EnumType.GLOBAL), new CoordinateInt(2, EnumType.GLOBAL), new CoordinateInt(EnumType.GLOBAL), new BlockResourceLocation(Blocks.AIR.getRegistryName())).toActualCommand());
|
||||
builder.setBlockNBT(commandBlock);
|
||||
blockRemover.setCommand(builder.toActualCommand());
|
||||
this.builderCommandStack.addPassenger(blockRemover);
|
||||
|
||||
EntityNBT entityRemover = new EntityNBT(EntityType.COMMAND_BLOCK_MINECART.getRegistryName());
|
||||
entityRemover.setCommand(new BuilderButcher(EntityType.COMMAND_BLOCK_MINECART.getRegistryName(), 1).toActualCommand());
|
||||
this.builderCommandStack.addPassenger(entityRemover);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return this.builderCommandStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.textfields.clear();
|
||||
|
||||
for(int index = 0; index < 3; index++)
|
||||
{
|
||||
int command = index + this.scroll;
|
||||
|
||||
GuiTextFieldTooltip textfield = new GuiTextFieldTooltip(x, y + 24 * index, 232 - 48, 20, I18n.format("gui.worldhandler.command_stack.command_n", command + 1));
|
||||
textfield.setValidator(Predicates.notNull());
|
||||
textfield.setText(command < this.getCommandCount() ? this.getCommand(command) : null);
|
||||
textfield.setResponder(text ->
|
||||
{
|
||||
this.setCommand(command, text);
|
||||
this.updateCopyButton();
|
||||
});
|
||||
this.textfields.add(textfield);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
GuiButtonBase buttonScrollUp;
|
||||
GuiButtonBase buttonScrollDown;
|
||||
|
||||
container.add(new GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.back"), () -> ActionHelper.back(this)));
|
||||
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
|
||||
|
||||
this.iterate(index ->
|
||||
{
|
||||
GuiButtonBase buttonUp;
|
||||
GuiButtonBase buttonDown;
|
||||
GuiButtonBase buttonRemove;
|
||||
|
||||
container.add(buttonUp = new GuiButtonIcon(x + 232 - 20 - 24, y + index * 24 - 1, 20, 10, EnumIcon.ARROW_UP, I18n.format("gui.worldhandler.actions.move_up"), () ->
|
||||
{
|
||||
this.swapCommands(index + this.scroll, index + this.scroll - 1);
|
||||
container.init();
|
||||
}));
|
||||
container.add(buttonDown = new GuiButtonIcon(x + 232 - 20 - 24, y + index * 24 + 11, 20, 10, EnumIcon.ARROW_DOWN, I18n.format("gui.worldhandler.actions.move_down"), () ->
|
||||
{
|
||||
this.swapCommands(index + this.scroll, index + this.scroll + 1);
|
||||
container.init();
|
||||
}));
|
||||
container.add(buttonRemove = new GuiButtonTooltip(x + 232 - 20, y + index * 24 - 1, 20, 10, "-", I18n.format("gui.worldhandler.command_stack.remove_command"), () ->
|
||||
{
|
||||
int pos = index + this.scroll;
|
||||
this.removeCommand(pos);
|
||||
|
||||
if(this.scroll + 3 > this.getCommandCount())
|
||||
{
|
||||
this.scrollUp();
|
||||
}
|
||||
|
||||
container.init();
|
||||
}));
|
||||
container.add(new GuiButtonTooltip(x + 232 - 20, y + index * 24 + 11, 20, 10, "+", I18n.format("gui.worldhandler.command_stack.insert_command"), () ->
|
||||
{
|
||||
int pos = index + this.scroll + 1;
|
||||
this.addCommand(pos);
|
||||
|
||||
if(index == 2)
|
||||
{
|
||||
this.scrollDown();
|
||||
}
|
||||
|
||||
container.init();
|
||||
}));
|
||||
container.add(this.textfields.get(index));
|
||||
|
||||
buttonRemove.active = this.getCommandCount() > 1;
|
||||
buttonUp.active = index + this.scroll > 0;
|
||||
buttonDown.active = index + this.scroll + 1 < this.getCommandCount();
|
||||
});
|
||||
|
||||
container.add(this.buttonCopy = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.command_stack.copy_command"), () ->
|
||||
{
|
||||
Minecraft.getInstance().keyboardListener.setClipboardString(this.builderCommandStack.toActualCommand());
|
||||
}));
|
||||
container.add(buttonScrollUp = new GuiButtonIcon(x + 118, y + 72, 56, 20, EnumIcon.ARROW_UP, I18n.format("gui.worldhandler.actions.move_up"), () ->
|
||||
{
|
||||
this.scrollUp();
|
||||
container.init();
|
||||
}));
|
||||
container.add(buttonScrollDown = new GuiButtonIcon(x + 118 + 60, y + 72, 54, 20, EnumIcon.ARROW_DOWN, I18n.format("gui.worldhandler.actions.move_down"), () ->
|
||||
{
|
||||
this.scrollDown();
|
||||
container.init();
|
||||
}));
|
||||
|
||||
this.updateCopyButton();
|
||||
buttonScrollUp.active = this.scroll > 0;
|
||||
buttonScrollDown.active = this.scroll < this.getCommandCount() - 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(Container container)
|
||||
{
|
||||
this.iterate(index ->
|
||||
{
|
||||
this.textfields.get(index).tick();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.iterate(index ->
|
||||
{
|
||||
this.textfields.get(index).renderButton(mouseX, mouseY, partialTicks);
|
||||
});
|
||||
}
|
||||
|
||||
private void iterate(Consumer<Integer> consumer)
|
||||
{
|
||||
for(int x = 0; x < this.textfields.size() && x + this.scroll < this.getCommandCount(); x++)
|
||||
{
|
||||
consumer.accept(x);
|
||||
}
|
||||
}
|
||||
|
||||
private void scrollUp()
|
||||
{
|
||||
this.scroll = Math.max(0, this.scroll - (Screen.hasShiftDown() ? 10 : 1));
|
||||
}
|
||||
|
||||
private void scrollDown()
|
||||
{
|
||||
this.scroll = Math.min(this.getCommandCount() - 3, this.scroll + (Screen.hasShiftDown() ? 10 : 1));
|
||||
}
|
||||
|
||||
private void updateCopyButton()
|
||||
{
|
||||
boolean active = false;
|
||||
|
||||
for(int x = 0; x < this.getCommandCount() && !active; x++)
|
||||
{
|
||||
String command = this.getCommand(x);
|
||||
|
||||
if(command != null && !command.isEmpty())
|
||||
{
|
||||
active = true;
|
||||
}
|
||||
}
|
||||
|
||||
this.buttonCopy.active = active;
|
||||
}
|
||||
|
||||
private void setCommand(int index, String command)
|
||||
{
|
||||
this.builderCommandStack.getPassenger(index + HEAD_LENGTH).setCommand(command);
|
||||
}
|
||||
|
||||
private void addCommand(int index)
|
||||
{
|
||||
this.builderCommandStack.addPassenger(index + HEAD_LENGTH, new EntityNBT(EntityType.COMMAND_BLOCK_MINECART.getRegistryName()));
|
||||
}
|
||||
|
||||
private void removeCommand(int index)
|
||||
{
|
||||
this.builderCommandStack.removePassenger(index + HEAD_LENGTH);
|
||||
}
|
||||
|
||||
private String getCommand(int index)
|
||||
{
|
||||
return this.builderCommandStack.getPassenger(index + HEAD_LENGTH).getCommand();
|
||||
}
|
||||
|
||||
private int getCommandCount()
|
||||
{
|
||||
return this.builderCommandStack.getPassengerCount() - HEAD_LENGTH - TAIL_LENGTH;
|
||||
}
|
||||
|
||||
private void swapCommands(int i, int j)
|
||||
{
|
||||
Collections.swap(this.builderCommandStack.getPassengers(), i + HEAD_LENGTH, j + HEAD_LENGTH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("gui.worldhandler.title.command_stack");
|
||||
}
|
||||
}
|
||||
@@ -40,14 +40,14 @@ public class ContentMain extends Content
|
||||
container.add(new GuiButtonIcon(x, y + 24, 22, 20, EnumIcon.WEATHER_SUN, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.clear")), ActionHelper::weatherClear));
|
||||
container.add(new GuiButtonIcon(x + 26, y + 24, 22, 20, EnumIcon.WEATHER_RAIN, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.rainy")), ActionHelper::weatherRain));
|
||||
container.add(new GuiButtonIcon(x + 26 * 2, y + 24, 22, 20, EnumIcon.WEATHER_STORM, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.thunder")), ActionHelper::weatherThunder));
|
||||
container.add(new GuiButtonIcon(x + 26 * 3, y + 24, 23, 20, EnumIcon.BUTCHER, I18n.format("gui.worldhandler.shortcuts.tooltip.butcher"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.BUTCHER.withParent(Contents.MAIN)));
|
||||
}));
|
||||
container.add(new GuiButtonIcon(x + 26 * 4, y + 24, 24, 20, EnumIcon.POTION, I18n.format("gui.worldhandler.shortcuts.tooltip.potions"), () ->
|
||||
container.add(new GuiButtonIcon(x + 26 * 3, y + 24, 23, 20, EnumIcon.POTION, I18n.format("gui.worldhandler.shortcuts.tooltip.potions"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.POTIONS.withParent(Contents.MAIN)));
|
||||
}));
|
||||
container.add(new GuiButtonIcon(x + 26 * 4, y + 24, 24, 20, EnumIcon.COMMAND_STACK, I18n.format("gui.worldhandler.shortcuts.tooltip.command_stack"), () ->
|
||||
{
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.COMMAND_STACK.withParent(Contents.MAIN)));
|
||||
}));
|
||||
container.add(new GuiButtonIcon(x + 26 * 5 + 2, y + 24, 23, 20, EnumIcon.GAMEMODE_SURVIVAL, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.survival")), ActionHelper::gamemodeSurvival));
|
||||
container.add(new GuiButtonIcon(x + 26 * 6 + 2, y + 24, 22, 20, EnumIcon.GAMEMODE_CREATIVE, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.creative")), ActionHelper::gamemodeCreative));
|
||||
container.add(new GuiButtonIcon(x + 26 * 7 + 2, y + 24, 22, 20, EnumIcon.GAMEMODE_ADVENTURE, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.adventure")), ActionHelper::gamemodeAdventure));
|
||||
|
||||
@@ -105,7 +105,7 @@ public class ContentSummon extends Content
|
||||
this.mobField.setResponder(text ->
|
||||
{
|
||||
this.mob = text;
|
||||
this.builderSummon.setEntity(this.mob);
|
||||
this.builderSummon.setName(this.mob);
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
@@ -125,7 +125,7 @@ public class ContentSummon extends Content
|
||||
this.passengerField.setResponder(text ->
|
||||
{
|
||||
this.passenger = this.passengerField.getText();
|
||||
this.builderSummon.setPassenger(this.passenger);
|
||||
this.builderSummon.setPassenger(0, this.passenger);
|
||||
container.initButtons();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user