2.0
This commit is contained in:
83
build.gradle
Normal file
83
build.gradle
Normal file
@@ -0,0 +1,83 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven { url = "http://files.minecraftforge.net/maven" }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
|
||||
|
||||
|
||||
version = "1.12.2-2.0"
|
||||
group = "src.worldhandler.main.WorldHandler" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "WorldHandler"
|
||||
|
||||
sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
|
||||
compileJava {
|
||||
sourceCompatibility = targetCompatibility = '1.8'
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Main-Class': 'exopandora.worldhandler.main.Main'
|
||||
}
|
||||
}
|
||||
|
||||
minecraft {
|
||||
version = "1.12.2-14.23.2.2611"
|
||||
runDir = "run"
|
||||
|
||||
// the mappings can be changed at any time, and must be in the following format.
|
||||
// snapshot_YYYYMMDD snapshot are built nightly.
|
||||
// stable_# stables are built at the discretion of the MCP team.
|
||||
// Use non-default mappings at your own risk. they may not always work.
|
||||
// simply re-run your setup task after changing the mappings to update your workspace.
|
||||
mappings = "snapshot_20171003"
|
||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// you may put jars on which you depend on in ./libs
|
||||
// or you may define them like so..
|
||||
//compile "some.group:artifact:version:classifier"
|
||||
//compile "some.group:artifact:version"
|
||||
|
||||
// real examples
|
||||
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
|
||||
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
|
||||
|
||||
// the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
|
||||
//provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
|
||||
|
||||
// the deobf configurations: 'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
|
||||
// except that these dependencies get remapped to your current MCP mappings
|
||||
//deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
|
||||
//deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
|
||||
|
||||
// for more info...
|
||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||
|
||||
}
|
||||
|
||||
processResources {
|
||||
// this will ensure that this task is redone when the versions change.
|
||||
inputs.property "version", project.version
|
||||
inputs.property "mcversion", project.minecraft.version
|
||||
|
||||
// replace stuff in mcmod.info, nothing else
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
|
||||
// replace version and mcversion
|
||||
expand 'version':project.version, 'mcversion':project.minecraft.version
|
||||
}
|
||||
|
||||
// copy everything else except the mcmod.info
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.Syntax.SyntaxEntry;
|
||||
import exopandora.worldhandler.builder.types.Coordinate;
|
||||
import exopandora.worldhandler.builder.types.Level;
|
||||
import exopandora.worldhandler.builder.types.TargetSelector;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class CommandBuilder implements ICommandBuilderSyntax
|
||||
{
|
||||
private List<Entry<SyntaxEntry, String>> command;
|
||||
|
||||
public CommandBuilder()
|
||||
{
|
||||
this.updateSyntax(this.getSyntax());
|
||||
}
|
||||
|
||||
protected void setNode(int index, String node)
|
||||
{
|
||||
this.set(index, node != null ? (node.isEmpty() ? null : node) : null, Type.STRING);
|
||||
}
|
||||
|
||||
protected void setNode(int index, boolean node)
|
||||
{
|
||||
this.set(index, node, Type.BOOLEAN);
|
||||
}
|
||||
|
||||
protected void setNode(int index, short node)
|
||||
{
|
||||
this.set(index, node, Type.SHORT);
|
||||
}
|
||||
|
||||
protected void setNode(int index, byte node)
|
||||
{
|
||||
this.set(index, node, Type.BYTE);
|
||||
}
|
||||
|
||||
protected void setNode(int index, int node)
|
||||
{
|
||||
this.set(index, node, Type.INT);
|
||||
}
|
||||
|
||||
protected void setNode(int index, float node)
|
||||
{
|
||||
this.set(index, node, Type.FLOAT);
|
||||
}
|
||||
|
||||
protected void setNode(int index, double node)
|
||||
{
|
||||
this.set(index, node, Type.DOUBLE);
|
||||
}
|
||||
|
||||
protected void setNode(int index, long node)
|
||||
{
|
||||
this.set(index, node, Type.LONG);
|
||||
}
|
||||
|
||||
protected void setNode(int index, ResourceLocation node)
|
||||
{
|
||||
this.set(index, node, Type.RESOURCE_LOCATION);
|
||||
}
|
||||
|
||||
protected void setNode(int index, NBTTagCompound nbt)
|
||||
{
|
||||
this.set(index, nbt, Type.NBT);
|
||||
}
|
||||
|
||||
protected void setNode(int index, Coordinate coordinate)
|
||||
{
|
||||
this.set(index, coordinate, Type.COORDINATE);
|
||||
}
|
||||
|
||||
protected void setNode(int index, TargetSelector target)
|
||||
{
|
||||
this.set(index, target, Type.TARGET_SELECTOR);
|
||||
}
|
||||
|
||||
protected void setNode(int index, Level level)
|
||||
{
|
||||
this.set(index, level, Type.LEVEL);
|
||||
}
|
||||
|
||||
private void set(int index, Object value, Type type)
|
||||
{
|
||||
if(index < this.command.size())
|
||||
{
|
||||
SyntaxEntry entry = this.command.get(index).getKey();
|
||||
Type expected = entry.getType();
|
||||
boolean flag = expected.equals(type);
|
||||
|
||||
if(value != null && flag)
|
||||
{
|
||||
this.command.get(index).setValue(value.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.command.get(index).setValue(entry.toString());
|
||||
|
||||
if(!flag)
|
||||
{
|
||||
this.warn("set", expected, type, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldHandler.LOGGER.warn("Tried to set invalid index \"" + index + "\" for command \"" + this.getCommandName() + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getNodeAsString(int index)
|
||||
{
|
||||
return this.get(index, Type.STRING);
|
||||
}
|
||||
|
||||
protected boolean getNodeAsBoolean(int index)
|
||||
{
|
||||
return this.get(index, Type.BOOLEAN);
|
||||
}
|
||||
|
||||
protected short getNodeAsShort(int index)
|
||||
{
|
||||
return this.get(index, Type.SHORT);
|
||||
}
|
||||
|
||||
protected byte getNodeAsByte(int index)
|
||||
{
|
||||
return this.get(index, Type.BYTE);
|
||||
}
|
||||
|
||||
protected int getNodeAsInt(int index)
|
||||
{
|
||||
return this.get(index, Type.INT);
|
||||
}
|
||||
|
||||
protected float getNodeAsFloat(int index)
|
||||
{
|
||||
return this.get(index, Type.FLOAT);
|
||||
}
|
||||
|
||||
protected double getNodeAsDouble(int index)
|
||||
{
|
||||
return this.get(index, Type.DOUBLE);
|
||||
}
|
||||
|
||||
protected long getNodeAsLong(int index)
|
||||
{
|
||||
return this.get(index, Type.LONG);
|
||||
}
|
||||
|
||||
protected Coordinate getNodeAsCoordinate(int index)
|
||||
{
|
||||
return this.get(index, Type.COORDINATE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ResourceLocation getNodeAsResourceLocation(int index)
|
||||
{
|
||||
return this.get(index, Type.RESOURCE_LOCATION);
|
||||
}
|
||||
|
||||
protected TargetSelector getNodeAsTargetSelector(int index)
|
||||
{
|
||||
return this.get(index, Type.TARGET_SELECTOR);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Level getNodeAsLevel(int index)
|
||||
{
|
||||
return this.get(index, Type.LEVEL);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected NBTTagCompound getNodeAsNBT(int index)
|
||||
{
|
||||
return this.get(index, Type.NBT);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private <T> T get(int index, Type type)
|
||||
{
|
||||
if(index < this.command.size())
|
||||
{
|
||||
Entry<SyntaxEntry, String> entry = this.command.get(index);
|
||||
Type expected = entry.getKey().getType();
|
||||
String value = entry.getValue();
|
||||
|
||||
if(expected.equals(type))
|
||||
{
|
||||
if(value.equals(entry.getKey().toString()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return expected.<T>parse(value);
|
||||
}
|
||||
|
||||
this.warn("get", expected, type, index);
|
||||
|
||||
return type.<T>parse(value);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void warn(String function, Type expected, Type type, int index)
|
||||
{
|
||||
WorldHandler.LOGGER.warn("[" + function.toUpperCase() + "] Expected \"" + expected + "\" instead of \"" + type + "\" at index \"" + index + "\" for command \"" + this.getCommandName() + "\"");
|
||||
}
|
||||
|
||||
private boolean isDefaultEntry(Entry<SyntaxEntry, String> entry)
|
||||
{
|
||||
return entry.getKey().getDefault() != null ? entry.getValue().equals(entry.getKey().getDefault().toString()) : false;
|
||||
}
|
||||
|
||||
protected void updateSyntax(Syntax syntax)
|
||||
{
|
||||
if(syntax != null)
|
||||
{
|
||||
this.command = syntax.getSyntaxEntries().stream().map(entry -> new AbstractMap.SimpleEntry<SyntaxEntry, String>(entry, entry.toString())).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toCommand()
|
||||
{
|
||||
return "/" + this.getCommandName() + " " + String.join(" ", this.command.stream().map(entry -> this.isDefaultEntry(entry) ? entry.getKey().toString() : entry.getValue()).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toActualCommand()
|
||||
{
|
||||
List<String> command = new ArrayList<String>();
|
||||
|
||||
for(Entry<SyntaxEntry, String> entry : this.command)
|
||||
{
|
||||
if(!entry.getKey().isRequired() && (entry.getKey().toString().equals(entry.getValue()) || this.isDefaultEntry(entry)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
command.add(entry.getValue());
|
||||
}
|
||||
|
||||
return "/" + this.getCommandName() + " " + String.join(" ", command);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class CommandBuilderNBT extends CommandBuilder implements ICommandBuilderNBT
|
||||
{
|
||||
private final List<IBuilderComponent> TAG_TO_COMPONENT = new ArrayList<IBuilderComponent>();
|
||||
|
||||
@Override
|
||||
public String toCommand()
|
||||
{
|
||||
this.setNBT(this.buildNBT());
|
||||
return super.toCommand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toActualCommand()
|
||||
{
|
||||
this.setNBT(this.buildNBT());
|
||||
return super.toActualCommand();
|
||||
}
|
||||
|
||||
private NBTTagCompound buildNBT()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
|
||||
for(IBuilderComponent component : this.TAG_TO_COMPONENT)
|
||||
{
|
||||
NBTBase serialized = component.serialize();
|
||||
|
||||
if(serialized != null)
|
||||
{
|
||||
if(!nbt.hasKey(component.getTag()))
|
||||
{
|
||||
nbt.setTag(component.getTag(), serialized);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(nbt.hasNoTags())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
protected <T extends IBuilderComponent> T registerNBTComponent(T component, String id)
|
||||
{
|
||||
this.TAG_TO_COMPONENT.add(component);
|
||||
return component;
|
||||
}
|
||||
|
||||
protected <T extends IBuilderComponent> T registerNBTComponent(T component)
|
||||
{
|
||||
return this.registerNBTComponent(component, component.getTag());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ICommandBuilder
|
||||
{
|
||||
static final int MAX_COMMAND_LENGTH = 256;
|
||||
|
||||
String toCommand();
|
||||
|
||||
default boolean needsCommandBlock()
|
||||
{
|
||||
return this.toCommand().length() > MAX_COMMAND_LENGTH;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ICommandBuilderNBT extends ICommandBuilder
|
||||
{
|
||||
void setNBT(NBTTagCompound nbt);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ICommandBuilderSyntax extends ICommandBuilder
|
||||
{
|
||||
String getCommandName();
|
||||
String toActualCommand();
|
||||
Syntax getSyntax();
|
||||
|
||||
@Override
|
||||
default boolean needsCommandBlock()
|
||||
{
|
||||
return this.toActualCommand().length() > MAX_COMMAND_LENGTH;
|
||||
}
|
||||
}
|
||||
93
src/main/java/exopandora/worldhandler/builder/Syntax.java
Normal file
93
src/main/java/exopandora/worldhandler/builder/Syntax.java
Normal file
@@ -0,0 +1,93 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class Syntax
|
||||
{
|
||||
private List<SyntaxEntry> syntax = new ArrayList<SyntaxEntry>();
|
||||
|
||||
public Syntax addRequired(String key, Type type)
|
||||
{
|
||||
this.syntax.add(new SyntaxEntry(key, type, true, null));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Syntax addRequired(String key, Type type, Object def)
|
||||
{
|
||||
this.syntax.add(new SyntaxEntry(key, type, true, def));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Syntax addOptional(String key, Type type)
|
||||
{
|
||||
this.syntax.add(new SyntaxEntry(key, type, false, null));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Syntax addOptional(String key, Type type, Object def)
|
||||
{
|
||||
this.syntax.add(new SyntaxEntry(key, type, false, def));
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<SyntaxEntry> getSyntaxEntries()
|
||||
{
|
||||
return this.syntax;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static class SyntaxEntry
|
||||
{
|
||||
private final String key;
|
||||
private final Type type;
|
||||
private final boolean required;
|
||||
private final Object def;
|
||||
|
||||
public SyntaxEntry(String key, Type type, boolean required, Object def)
|
||||
{
|
||||
this.key = key;
|
||||
this.type = type;
|
||||
this.required = required;
|
||||
this.def = def;
|
||||
}
|
||||
|
||||
public String getKey()
|
||||
{
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public Type getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public boolean isRequired()
|
||||
{
|
||||
return this.required;
|
||||
}
|
||||
|
||||
public Object getDefault()
|
||||
{
|
||||
return this.def;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if(this.required)
|
||||
{
|
||||
return "<" + this.key + ">";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "[" + this.key + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package exopandora.worldhandler.builder.component;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IBuilderComponent
|
||||
{
|
||||
@Nullable
|
||||
NBTBase serialize();
|
||||
String getTag();
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package exopandora.worldhandler.builder.component.abstr;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class ComponentAttribute implements IBuilderComponent
|
||||
{
|
||||
protected Map<EnumAttributes, Float> attributes = new HashMap<EnumAttributes, Float>();
|
||||
protected Function<EnumAttributes, Boolean> applyable;
|
||||
|
||||
public ComponentAttribute(Function<EnumAttributes, Boolean> applyable)
|
||||
{
|
||||
this.applyable = applyable;
|
||||
}
|
||||
|
||||
public void set(EnumAttributes attribute, float ammount)
|
||||
{
|
||||
this.attributes.put(attribute, ammount);
|
||||
}
|
||||
|
||||
public void remove(EnumAttributes attribute)
|
||||
{
|
||||
this.attributes.remove(attribute);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
package exopandora.worldhandler.builder.component.abstr;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class ComponentPotion implements IBuilderComponent
|
||||
{
|
||||
protected final Map<Potion, PotionMetadata> potions = Potion.REGISTRY.getKeys().stream().collect(Collectors.toMap(Potion.REGISTRY::getObject, key -> new PotionMetadata()));
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public NBTBase serialize()
|
||||
{
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for(Entry<Potion, PotionMetadata> entry : this.potions.entrySet())
|
||||
{
|
||||
PotionMetadata potion = entry.getValue();
|
||||
|
||||
if(potion.getAmplifier() > 0)
|
||||
{
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
|
||||
compound.setByte("Id", (byte) Potion.getIdFromPotion(entry.getKey()));
|
||||
compound.setByte("Amplifier", (byte) (potion.getAmplifier() - 1));
|
||||
compound.setInteger("Duration", potion.getDuration() > 0 ? Math.min(potion.getDuration(), 1000000) : 1000000);
|
||||
compound.setBoolean("Ambient", potion.getAmbient());
|
||||
compound.setBoolean("ShowParticles", potion.getShowParticles());
|
||||
|
||||
list.appendTag(compound);
|
||||
}
|
||||
}
|
||||
|
||||
if(!list.hasNoTags())
|
||||
{
|
||||
return list;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void set(Potion potion, PotionMetadata metadata)
|
||||
{
|
||||
this.potions.put(potion, metadata);
|
||||
}
|
||||
|
||||
public void set(Potion potion, byte amplifier, int seconds, int minutes, int hours, boolean showParticles, boolean ambient)
|
||||
{
|
||||
this.set(potion, new PotionMetadata(amplifier, seconds, minutes, hours, showParticles, ambient));
|
||||
}
|
||||
|
||||
public void setAmplifier(Potion potion, byte amplifier)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
this.potions.get(potion).setAmplifier(amplifier);
|
||||
}
|
||||
}
|
||||
|
||||
public byte getAmplifier(Potion potion)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
return this.potions.get(potion).getAmplifier();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setSeconds(Potion potion, int seconds)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
this.potions.get(potion).setSeconds(seconds);;
|
||||
}
|
||||
}
|
||||
|
||||
public int getSeconds(Potion potion)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
return this.potions.get(potion).getSeconds();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setMinutes(Potion potion, int minutes)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
this.potions.get(potion).setSeconds(minutes);;
|
||||
}
|
||||
}
|
||||
|
||||
public int getMinutes(Potion potion)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
return this.potions.get(potion).getMinutes();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setHours(Potion potion, int hours)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
this.potions.get(potion).setSeconds(hours);;
|
||||
}
|
||||
}
|
||||
|
||||
public int getHours(Potion potion)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
return this.potions.get(potion).getHours();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setShowParticles(Potion potion, boolean showParticles)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
this.potions.get(potion).setShowParticles(showParticles);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getShowParticles(Potion potion)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
return this.potions.get(potion).getShowParticles();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setAmbient(Potion potion, boolean ambient)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
this.potions.get(potion).setAmbient(ambient);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getAmbient(Potion potion)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
return this.potions.get(potion).getAmbient();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PotionMetadata get(Potion potion)
|
||||
{
|
||||
return this.potions.get(potion);
|
||||
}
|
||||
|
||||
public void remove(Potion potion)
|
||||
{
|
||||
this.potions.remove(potion);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package exopandora.worldhandler.builder.component.abstr;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class PotionMetadata
|
||||
{
|
||||
private byte amplifier;
|
||||
private int seconds;
|
||||
private int minutes;
|
||||
private int hours;
|
||||
private boolean showParticles;
|
||||
private boolean ambient;
|
||||
|
||||
public PotionMetadata()
|
||||
{
|
||||
this((byte) 0, 0, 0, 0, true, false);
|
||||
}
|
||||
|
||||
public PotionMetadata(byte amplifier, int seconds, int minutes, int hours, boolean showParticles, boolean ambient)
|
||||
{
|
||||
this.amplifier = amplifier;
|
||||
this.seconds = seconds;
|
||||
this.minutes = minutes;
|
||||
this.hours = hours;
|
||||
this.showParticles = showParticles;
|
||||
this.ambient = ambient;
|
||||
}
|
||||
|
||||
public byte getAmplifier()
|
||||
{
|
||||
return this.amplifier;
|
||||
}
|
||||
|
||||
public void setAmplifier(byte amplifier)
|
||||
{
|
||||
this.amplifier = amplifier;
|
||||
}
|
||||
|
||||
public int getSeconds()
|
||||
{
|
||||
return this.seconds;
|
||||
}
|
||||
|
||||
public void setSeconds(int seconds)
|
||||
{
|
||||
this.seconds = seconds;
|
||||
}
|
||||
|
||||
public int getMinutes()
|
||||
{
|
||||
return this.minutes;
|
||||
}
|
||||
|
||||
public void setMinutes(int minutes)
|
||||
{
|
||||
this.minutes = minutes;
|
||||
}
|
||||
|
||||
public int getHours()
|
||||
{
|
||||
return this.hours;
|
||||
}
|
||||
|
||||
public void setHours(int hours)
|
||||
{
|
||||
this.hours = hours;
|
||||
}
|
||||
|
||||
public boolean getShowParticles()
|
||||
{
|
||||
return this.showParticles;
|
||||
}
|
||||
|
||||
public void setShowParticles(boolean showParticles)
|
||||
{
|
||||
this.showParticles = showParticles;
|
||||
}
|
||||
|
||||
public boolean getAmbient()
|
||||
{
|
||||
return this.ambient;
|
||||
}
|
||||
|
||||
public void setAmbient(boolean ambient)
|
||||
{
|
||||
this.ambient = ambient;
|
||||
}
|
||||
|
||||
public int getDuration()
|
||||
{
|
||||
return PotionMetadata.getDuration(this.seconds, this.minutes, this.hours);
|
||||
}
|
||||
|
||||
public static int getDuration(int seconds, int minutes, int hours)
|
||||
{
|
||||
return seconds * 20 + minutes * 1200 + hours * 72000;
|
||||
}
|
||||
|
||||
public PotionMetadata withAmplifier(byte amplifier)
|
||||
{
|
||||
this.amplifier = amplifier;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PotionMetadata withShowParticles(boolean showParticles)
|
||||
{
|
||||
this.showParticles = showParticles;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PotionMetadata withSeconds(int seconds)
|
||||
{
|
||||
this.seconds = seconds;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PotionMetadata withMinutes(int minutes)
|
||||
{
|
||||
this.minutes = minutes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PotionMetadata withHours(int hours)
|
||||
{
|
||||
this.hours = hours;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PotionMetadata withAmbient(boolean ambient)
|
||||
{
|
||||
this.ambient = ambient;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.component.abstr.ComponentAttribute;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ComponentAttributeItem extends ComponentAttribute
|
||||
{
|
||||
public ComponentAttributeItem(Function<EnumAttributes, Boolean> applyable)
|
||||
{
|
||||
super(applyable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public NBTBase serialize()
|
||||
{
|
||||
NBTTagList attributes = new NBTTagList();
|
||||
|
||||
for(Entry<EnumAttributes, Float> entry : this.attributes.entrySet())
|
||||
{
|
||||
if(this.applyable.apply(entry.getKey()) && entry.getValue() != 0)
|
||||
{
|
||||
NBTTagCompound attribute = new NBTTagCompound();
|
||||
|
||||
attribute.setString("AttributeName", entry.getKey().getAttribute());
|
||||
attribute.setString("Name", entry.getKey().getAttribute());
|
||||
attribute.setDouble("Amount", entry.getKey().calculate(entry.getValue()));
|
||||
attribute.setInteger("Operation", entry.getKey().getOperation().ordinal());
|
||||
attribute.setLong("UUIDLeast", UUID.nameUUIDFromBytes(entry.getKey().getAttribute().getBytes()).getLeastSignificantBits());
|
||||
attribute.setLong("UUIDMost", UUID.nameUUIDFromBytes(entry.getKey().getAttribute().getBytes()).getMostSignificantBits());
|
||||
|
||||
attributes.appendTag(attribute);
|
||||
}
|
||||
}
|
||||
|
||||
if(!attributes.hasNoTags())
|
||||
{
|
||||
return attributes;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "AttributeModifiers";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.component.abstr.ComponentAttribute;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ComponentAttributeMob extends ComponentAttribute
|
||||
{
|
||||
public ComponentAttributeMob(Function<EnumAttributes, Boolean> applyable)
|
||||
{
|
||||
super(applyable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public NBTBase serialize()
|
||||
{
|
||||
NBTTagList attributes = new NBTTagList();
|
||||
|
||||
for(Entry<EnumAttributes, Float> entry : this.attributes.entrySet())
|
||||
{
|
||||
if(this.applyable.apply(entry.getKey()) && entry.getValue() != 0)
|
||||
{
|
||||
NBTTagCompound attribute = new NBTTagCompound();
|
||||
|
||||
attribute.setString("Name", entry.getKey().getAttribute());
|
||||
attribute.setDouble("Base", entry.getKey().calculate(entry.getValue()));
|
||||
|
||||
attributes.appendTag(attribute);
|
||||
}
|
||||
}
|
||||
|
||||
if(!attributes.hasNoTags())
|
||||
{
|
||||
return attributes;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "Attributes";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import exopandora.worldhandler.format.text.ColoredString;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ComponentDisplay implements IBuilderComponent
|
||||
{
|
||||
private ColoredString name = new ColoredString();
|
||||
private String[] lore = new String[2];
|
||||
|
||||
@Override
|
||||
public NBTBase serialize()
|
||||
{
|
||||
NBTTagCompound display = new NBTTagCompound();
|
||||
|
||||
String name = this.name.getText();
|
||||
|
||||
if(name != null && !name.isEmpty())
|
||||
{
|
||||
display.setString("Name", this.name.toString());
|
||||
}
|
||||
|
||||
NBTTagList lore = new NBTTagList();
|
||||
|
||||
for(int x = 0; x < this.lore.length; x++)
|
||||
{
|
||||
if(this.lore[x] != null && !this.lore[x].isEmpty())
|
||||
{
|
||||
lore.appendTag(new NBTTagString(this.lore[x]));
|
||||
}
|
||||
}
|
||||
|
||||
if(!lore.hasNoTags())
|
||||
{
|
||||
display.setTag("Lore", lore);
|
||||
}
|
||||
|
||||
if(!display.hasNoTags())
|
||||
{
|
||||
return display;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setName(ColoredString name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ColoredString getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setLore(String[] lore)
|
||||
{
|
||||
this.lore = lore;
|
||||
}
|
||||
|
||||
public String[] getLore()
|
||||
{
|
||||
return this.lore;
|
||||
}
|
||||
|
||||
public void setLore1(String lore)
|
||||
{
|
||||
this.lore[0] = lore;
|
||||
}
|
||||
|
||||
public String getLore1()
|
||||
{
|
||||
return this.lore[0];
|
||||
}
|
||||
|
||||
public void setLore2(String lore)
|
||||
{
|
||||
this.lore[1] = lore;
|
||||
}
|
||||
|
||||
public String getLore2()
|
||||
{
|
||||
return this.lore[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "display";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ComponentEnchantment implements IBuilderComponent
|
||||
{
|
||||
private Map<Enchantment, Short> enchantments = Enchantment.REGISTRY.getKeys().stream().collect(Collectors.toMap(Enchantment.REGISTRY::getObject, key -> (short) 0));
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public NBTBase serialize()
|
||||
{
|
||||
NBTTagList enchantments = new NBTTagList();
|
||||
|
||||
for(Entry<Enchantment, Short> entry : this.enchantments.entrySet())
|
||||
{
|
||||
if(entry.getValue() > 0)
|
||||
{
|
||||
NBTTagCompound enchantment = new NBTTagCompound();
|
||||
|
||||
enchantment.setShort("id", (short) Enchantment.getEnchantmentID(entry.getKey()));
|
||||
enchantment.setShort("lvl", entry.getValue());
|
||||
|
||||
enchantments.appendTag(enchantment);
|
||||
}
|
||||
}
|
||||
|
||||
if(!enchantments.hasNoTags())
|
||||
{
|
||||
return enchantments;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setLevel(Enchantment enchantment, short level)
|
||||
{
|
||||
this.enchantments.put(enchantment, level);
|
||||
}
|
||||
|
||||
public int getLevel(Enchantment enchantment)
|
||||
{
|
||||
return this.enchantments.get(enchantment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "ench";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.component.abstr.ComponentPotion;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ComponentPotionItem extends ComponentPotion
|
||||
{
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "CustomPotionEffects";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.component.abstr.ComponentPotion;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ComponentPotionMob extends ComponentPotion
|
||||
{
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "ActiveEffects";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import exopandora.worldhandler.helper.EntityHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
import net.minecraft.entity.boss.EntityWither;
|
||||
import net.minecraft.entity.item.EntityMinecart;
|
||||
import net.minecraft.entity.item.EntityMinecartChest;
|
||||
import net.minecraft.entity.item.EntityMinecartCommandBlock;
|
||||
import net.minecraft.entity.item.EntityMinecartFurnace;
|
||||
import net.minecraft.entity.item.EntityMinecartHopper;
|
||||
import net.minecraft.entity.item.EntityMinecartMobSpawner;
|
||||
import net.minecraft.entity.item.EntityMinecartTNT;
|
||||
import net.minecraft.entity.monster.EntityEvoker;
|
||||
import net.minecraft.entity.monster.EntityGhast;
|
||||
import net.minecraft.entity.monster.EntityIronGolem;
|
||||
import net.minecraft.entity.monster.EntityMagmaCube;
|
||||
import net.minecraft.entity.monster.EntityPigZombie;
|
||||
import net.minecraft.entity.monster.EntitySkeleton;
|
||||
import net.minecraft.entity.monster.EntitySnowman;
|
||||
import net.minecraft.entity.monster.EntitySpider;
|
||||
import net.minecraft.entity.monster.EntityVindicator;
|
||||
import net.minecraft.entity.monster.EntityZombie;
|
||||
import net.minecraft.entity.passive.EntityChicken;
|
||||
import net.minecraft.entity.passive.EntityHorse;
|
||||
import net.minecraft.entity.passive.EntityMooshroom;
|
||||
import net.minecraft.entity.passive.EntityOcelot;
|
||||
import net.minecraft.entity.passive.EntitySquid;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.passive.EntityWolf;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ComponentSummon implements IBuilderComponent
|
||||
{
|
||||
private final Random random = new Random();
|
||||
|
||||
private String tag;
|
||||
private String name;
|
||||
private ResourceLocation entity;
|
||||
private boolean hasPassenger;
|
||||
|
||||
public void setEntity(ResourceLocation entityName)
|
||||
{
|
||||
this.entity = entityName;
|
||||
}
|
||||
|
||||
public ResourceLocation getEntity()
|
||||
{
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
public void setHasPassenger(boolean hasPassenger)
|
||||
{
|
||||
this.hasPassenger = hasPassenger;
|
||||
}
|
||||
|
||||
public boolean hasPassenger()
|
||||
{
|
||||
return this.hasPassenger;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTBase serialize()
|
||||
{
|
||||
if(this.name != null)
|
||||
{
|
||||
if(this.name.equalsIgnoreCase("Cat"))
|
||||
{
|
||||
this.tag = "CatType";
|
||||
return new NBTTagInt(this.random.nextInt(3) + 1);
|
||||
}
|
||||
else if(this.name.equalsIgnoreCase("Farmer") || this.name.equalsIgnoreCase("Fisherman") || this.name.equalsIgnoreCase("Shepherd") || this.name.equalsIgnoreCase("Fletcher"))
|
||||
{
|
||||
this.tag = "Profession";
|
||||
return new NBTTagInt(0);
|
||||
}
|
||||
else if(this.name.equalsIgnoreCase("Librarian") || this.name.equalsIgnoreCase("Carthographer"))
|
||||
{
|
||||
this.tag = "Profession";
|
||||
return new NBTTagInt(1);
|
||||
}
|
||||
else if(this.name.equalsIgnoreCase("Cleric") || this.name.equalsIgnoreCase("Priest"))
|
||||
{
|
||||
this.tag = "Profession";
|
||||
return new NBTTagInt(2);
|
||||
}
|
||||
else if(this.name.equalsIgnoreCase("Armorer") || this.name.equalsIgnoreCase("Blacksmith") || this.name.equalsIgnoreCase("WeaponSmith") || this.name.equalsIgnoreCase("ToolSmith"))
|
||||
{
|
||||
this.tag = "Profession";
|
||||
return new NBTTagInt(3);
|
||||
}
|
||||
else if(this.name.equalsIgnoreCase("Butcher") || this.name.equalsIgnoreCase("Leatherworker"))
|
||||
{
|
||||
this.tag = "Profession";
|
||||
return new NBTTagInt(4);
|
||||
}
|
||||
else if(this.name.equalsIgnoreCase("Nitwit"))
|
||||
{
|
||||
this.tag = "Profession";
|
||||
return new NBTTagInt(5);
|
||||
}
|
||||
|
||||
if(this.entity != null)
|
||||
{
|
||||
if(this.entity.equals(EntityHelper.getResourceLocation(EntityZombie.class)))
|
||||
{
|
||||
if(StringUtils.containsIgnoreCase(this.name, "Baby"))
|
||||
{
|
||||
this.tag = "IsBaby";
|
||||
return new NBTTagByte((byte) 1);
|
||||
}
|
||||
}
|
||||
else if(this.entity.equals(EntityHelper.getResourceLocation(EntityChicken.class)))
|
||||
{
|
||||
if(StringUtils.containsIgnoreCase(this.name, "Jockey") && !this.hasPassenger)
|
||||
{
|
||||
NBTTagCompound passenger = new NBTTagCompound();
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
passenger.setString("id", EntityHelper.getResourceLocation(EntityZombie.class).toString());
|
||||
passenger.setBoolean("IsBaby", true);
|
||||
list.appendTag(passenger);
|
||||
|
||||
this.tag = "Passengers";
|
||||
return list;
|
||||
}
|
||||
}
|
||||
else if(this.entity.equals(EntityHelper.getResourceLocation(EntitySpider.class)))
|
||||
{
|
||||
if(StringUtils.containsIgnoreCase(this.name, "Jockey") && !this.hasPassenger)
|
||||
{
|
||||
NBTTagCompound passenger = new NBTTagCompound();
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
passenger.setString("id", EntityHelper.getResourceLocation(EntitySkeleton.class).toString());
|
||||
list.appendTag(passenger);
|
||||
|
||||
this.tag = "Passengers";
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return this.tag;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ResourceLocation resolve(String entityName)
|
||||
{
|
||||
String entity = entityName.replaceAll("_| ", "");
|
||||
|
||||
for(ResourceLocation location : EntityList.ENTITY_EGGS.keySet())
|
||||
{
|
||||
if(entityName.equalsIgnoreCase(I18n.format("entity." + EntityHelper.getEntityName(location) + ".name")))
|
||||
{
|
||||
entity = location.getResourcePath();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(entity.equalsIgnoreCase("RedCow"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMooshroom.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("ChickenJockey"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityChicken.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Pigman") || entity.equalsIgnoreCase("ZombiePig") || entity.equalsIgnoreCase("ZombiePigman"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityPigZombie.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Wither"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityWither.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Dog"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityWolf.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Dragon"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityDragon.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("minecraft:SnowGolem"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntitySnowman.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Horse") || entity.equalsIgnoreCase("ZombieHorse") || entity.equalsIgnoreCase("SkeletonHorse"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityHorse.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("LavaCube")|| entity.equalsIgnoreCase("MagmaSlime") || entity.equalsIgnoreCase("MagmaCube"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMagmaCube.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("SpiderJockey"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntitySpider.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("IronGolem"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityIronGolem.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Ozelot") || entity.equals("Ocelot") || entity.equalsIgnoreCase("Cat") || entity.equalsIgnoreCase("Kitty") || entity.equalsIgnoreCase("Kitten"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityOcelot.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("TESTIFICATE") || entity.equalsIgnoreCase("Blacksmith") || entity.equalsIgnoreCase("Farmer") || entity.equalsIgnoreCase("Fisherman") || entity.equalsIgnoreCase("Shepherd") || entity.equalsIgnoreCase("Fletcher") || entity.equalsIgnoreCase("Librarian") || entity.equalsIgnoreCase("Cleric") || entity.equalsIgnoreCase("Priest") || entity.equalsIgnoreCase("Armorer") || entity.equalsIgnoreCase("WeaponSmith") || entity.equalsIgnoreCase("ToolSmith") || entity.equalsIgnoreCase("Butcher") || entity.equalsIgnoreCase("Leatherworker") || entity.equalsIgnoreCase("Carthographer") || entity.equalsIgnoreCase("Nitwit"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityVillager.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Octopus") || entity.equalsIgnoreCase("Kraken"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntitySquid.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Exwife"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityGhast.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("TNTMinecart"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMinecartTNT.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Minecart"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMinecart.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("HopperMinecart"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMinecartHopper.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("ChestMinecart"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMinecartChest.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("SpawnerMinecart"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMinecartMobSpawner.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("FurnaceMinecart"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMinecartFurnace.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("CommandBlockMinecart") || entity.equalsIgnoreCase("MinecartCommand") || entity.equalsIgnoreCase("CommandMinecart"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMinecartCommandBlock.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Wizard"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityEvoker.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Johnny"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityVindicator.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("BabyZombie"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityZombie.class);
|
||||
}
|
||||
|
||||
if(entity == null || entity.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ResourceLocation(entity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagByteArray;
|
||||
import net.minecraft.nbt.NBTTagDouble;
|
||||
import net.minecraft.nbt.NBTTagFloat;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.nbt.NBTTagIntArray;
|
||||
import net.minecraft.nbt.NBTTagLong;
|
||||
import net.minecraft.nbt.NBTTagLongArray;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ComponentTag<T> implements IBuilderComponent
|
||||
{
|
||||
private final Function<T, NBTBase> serializer;
|
||||
private final String tag;
|
||||
private T value;
|
||||
|
||||
public ComponentTag(String tag, T value, Function<T, NBTBase> serializer)
|
||||
{
|
||||
this.tag = tag;
|
||||
this.value = value;
|
||||
this.serializer = serializer;
|
||||
}
|
||||
|
||||
public ComponentTag(String tag, Function<T, NBTBase> serializer)
|
||||
{
|
||||
this(tag, null, serializer);
|
||||
}
|
||||
|
||||
public ComponentTag(String tag, T value)
|
||||
{
|
||||
this(tag, value, null);
|
||||
}
|
||||
|
||||
public ComponentTag(String tag)
|
||||
{
|
||||
this(tag, null, null);
|
||||
}
|
||||
|
||||
public void setValue(T value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T getValue()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public NBTBase serialize()
|
||||
{
|
||||
if(this.value != null)
|
||||
{
|
||||
if(this.serializer != null)
|
||||
{
|
||||
return this.serializer.apply(this.value);
|
||||
}
|
||||
else if(this.value instanceof String)
|
||||
{
|
||||
String string = (String) this.value;
|
||||
|
||||
if(string.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new NBTTagString(string);
|
||||
}
|
||||
else if(this.value instanceof NBTBase)
|
||||
{
|
||||
NBTBase base = (NBTBase) this.value;
|
||||
|
||||
if(base.hasNoTags())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (NBTBase) this.value;
|
||||
}
|
||||
else if(this.value instanceof Integer)
|
||||
{
|
||||
return new NBTTagInt((Integer) this.value);
|
||||
}
|
||||
else if(this.value instanceof Byte)
|
||||
{
|
||||
return new NBTTagByte((Byte) this.value);
|
||||
}
|
||||
else if(this.value instanceof Float)
|
||||
{
|
||||
return new NBTTagFloat((Float) this.value);
|
||||
}
|
||||
else if(this.value instanceof Double)
|
||||
{
|
||||
return new NBTTagDouble((Double) this.value);
|
||||
}
|
||||
else if(this.value instanceof Long)
|
||||
{
|
||||
return new NBTTagLong((Long) this.value);
|
||||
}
|
||||
else if(this.value instanceof Short)
|
||||
{
|
||||
return new NBTTagLong((Short) this.value);
|
||||
}
|
||||
else if(this.value instanceof Byte[])
|
||||
{
|
||||
return new NBTTagByteArray((byte[]) this.value);
|
||||
}
|
||||
else if(this.value instanceof Integer[])
|
||||
{
|
||||
return new NBTTagIntArray((int[]) this.value);
|
||||
}
|
||||
else if(this.value instanceof Long[])
|
||||
{
|
||||
return new NBTTagLongArray((long[]) this.value);
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldHandler.LOGGER.warn("Tag \"" + this.tag + "\" has no serializer");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return this.tag;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import exopandora.worldhandler.helper.EnumHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderAdvancement extends CommandBuilder
|
||||
{
|
||||
public BuilderAdvancement(EnumMode mode)
|
||||
{
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
public BuilderAdvancement(EnumActionType action, String player, EnumMode mode, ResourceLocation advancement)
|
||||
{
|
||||
this(mode);
|
||||
this.setActionType(action);
|
||||
this.setPlayer(player);
|
||||
this.setAdvancement(advancement);
|
||||
}
|
||||
|
||||
public void setActionType(EnumActionType action)
|
||||
{
|
||||
this.setNode(0, action != null ? action.toString() : null);
|
||||
}
|
||||
|
||||
public EnumActionType getActionType()
|
||||
{
|
||||
return EnumHelper.valueOf(EnumActionType.class, this.getNodeAsString(1));
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(1, player);
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
this.setNode(2, mode != null ? mode.toString() : null);
|
||||
}
|
||||
|
||||
public EnumMode getMode()
|
||||
{
|
||||
return EnumHelper.valueOf(EnumMode.class, this.getNodeAsString(2));
|
||||
}
|
||||
|
||||
public void setAdvancement(ResourceLocation advancement)
|
||||
{
|
||||
this.setNode(3, advancement);
|
||||
}
|
||||
|
||||
public ResourceLocation getAdvancement()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(3);
|
||||
}
|
||||
|
||||
public BuilderAdvancement getBuilderForAction(EnumActionType action)
|
||||
{
|
||||
return this.getBuilder(action, this.getMode());
|
||||
}
|
||||
|
||||
public BuilderAdvancement getBuilder(EnumActionType action, EnumMode mode)
|
||||
{
|
||||
return new BuilderAdvancement(action, this.getPlayer(), mode, (mode != null && !mode.equals(EnumMode.EVERYTHING)) ? this.getAdvancement() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "advancement";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("grant|revoke|test", Type.STRING);
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addRequired("only|until|from|through|everything", Type.STRING);
|
||||
syntax.addOptional("advancement", Type.RESOURCE_LOCATION);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumActionType
|
||||
{
|
||||
GRANT,
|
||||
REVOKE;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
ONLY,
|
||||
UNTIL,
|
||||
FROM,
|
||||
THROUGH,
|
||||
EVERYTHING;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.impl.abstr.BuilderBlockPos;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderBlockdata extends BuilderBlockPos
|
||||
{
|
||||
@Override
|
||||
public void setNBT(NBTTagCompound nbt)
|
||||
{
|
||||
this.setNode(3, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "blockdata";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("x", Type.COORDINATE);
|
||||
syntax.addRequired("y", Type.COORDINATE);
|
||||
syntax.addRequired("z", Type.COORDINATE);
|
||||
syntax.addRequired("nbt", Type.NBT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.TargetSelector;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderButcher extends CommandBuilder
|
||||
{
|
||||
private final TargetSelector targetSelector;
|
||||
|
||||
public BuilderButcher()
|
||||
{
|
||||
this(new ResourceLocation("<entity_name>"), 0);
|
||||
}
|
||||
|
||||
public BuilderButcher(ResourceLocation entity, int radius)
|
||||
{
|
||||
this.targetSelector = new TargetSelector();
|
||||
this.setEntity(entity);
|
||||
this.setRadius(radius);
|
||||
}
|
||||
|
||||
public void setRadius(int radius)
|
||||
{
|
||||
this.targetSelector.set("r", radius);
|
||||
this.setNode(0, this.targetSelector);
|
||||
}
|
||||
|
||||
public int getRadius()
|
||||
{
|
||||
return this.targetSelector.<Integer>get("r");
|
||||
}
|
||||
|
||||
public void setEntity(ResourceLocation entity)
|
||||
{
|
||||
this.targetSelector.set("type", entity.toString());
|
||||
this.setNode(0, this.targetSelector);
|
||||
}
|
||||
|
||||
public ResourceLocation getEntity()
|
||||
{
|
||||
return this.targetSelector.<ResourceLocation>get("type");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "kill";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("entity_name", Type.TARGET_SELECTOR);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.impl.abstr.BuilderDoubleBlockPos;
|
||||
import exopandora.worldhandler.builder.types.Coordinate;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import exopandora.worldhandler.helper.EnumHelper;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderClone extends BuilderDoubleBlockPos
|
||||
{
|
||||
public BuilderClone()
|
||||
{
|
||||
this.setX(new Coordinate());
|
||||
this.setY(new Coordinate());
|
||||
this.setZ(new Coordinate());
|
||||
this.setMask(EnumMask.values()[0]);
|
||||
this.setNode(10, "force");
|
||||
}
|
||||
|
||||
public void setPosition(BlockPos pos)
|
||||
{
|
||||
this.setX(pos.getX());
|
||||
this.setY(pos.getY());
|
||||
this.setZ(pos.getZ());
|
||||
}
|
||||
|
||||
public void setX(float x)
|
||||
{
|
||||
this.setX(new Coordinate(x));
|
||||
}
|
||||
|
||||
public void setY(float y)
|
||||
{
|
||||
this.setY(new Coordinate(y));
|
||||
}
|
||||
|
||||
public void setZ(float z)
|
||||
{
|
||||
this.setZ(new Coordinate(z));
|
||||
}
|
||||
|
||||
public void setX(Coordinate x)
|
||||
{
|
||||
this.setNode(6, x);
|
||||
}
|
||||
|
||||
public void setY(Coordinate y)
|
||||
{
|
||||
this.setNode(7, y);
|
||||
}
|
||||
|
||||
public void setZ(Coordinate z)
|
||||
{
|
||||
this.setNode(8, z);
|
||||
}
|
||||
|
||||
public Coordinate getXCoordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(6);
|
||||
}
|
||||
|
||||
public Coordinate getYCoordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(7);
|
||||
}
|
||||
|
||||
public Coordinate getZCoordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(8);
|
||||
}
|
||||
|
||||
public double getX()
|
||||
{
|
||||
return this.getXCoordiante().getValue();
|
||||
}
|
||||
|
||||
public double getY()
|
||||
{
|
||||
return this.getYCoordiante().getValue();
|
||||
}
|
||||
|
||||
public double getZ()
|
||||
{
|
||||
return this.getZCoordiante().getValue();
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos()
|
||||
{
|
||||
return new BlockPos(this.getX(), this.getY(), this.getZ());
|
||||
}
|
||||
|
||||
public void setMask(EnumMask mask)
|
||||
{
|
||||
this.setNode(9, mask != null ? mask.toString() : null);
|
||||
}
|
||||
|
||||
public EnumMask getMask()
|
||||
{
|
||||
return EnumHelper.valueOf(EnumMask.class, this.getNodeAsString(9));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "clone";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("x1", Type.COORDINATE);
|
||||
syntax.addRequired("y1", Type.COORDINATE);
|
||||
syntax.addRequired("z1", Type.COORDINATE);
|
||||
syntax.addRequired("x2", Type.COORDINATE);
|
||||
syntax.addRequired("y2", Type.COORDINATE);
|
||||
syntax.addRequired("z2", Type.COORDINATE);
|
||||
syntax.addRequired("x", Type.COORDINATE);
|
||||
syntax.addRequired("y", Type.COORDINATE);
|
||||
syntax.addRequired("z", Type.COORDINATE);
|
||||
syntax.addOptional("mask_mode", Type.STRING);
|
||||
syntax.addOptional("clone_mode", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMask
|
||||
{
|
||||
REPLACE,
|
||||
MASKED,
|
||||
FILTERED;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentAttributeItem;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentDisplay;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentEnchantment;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes.Applyable;
|
||||
import exopandora.worldhandler.format.text.ColoredString;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderCustomItem extends BuilderGive
|
||||
{
|
||||
private final ComponentAttributeItem attribute;
|
||||
private final ComponentDisplay display;
|
||||
private final ComponentEnchantment enchantment;
|
||||
|
||||
public BuilderCustomItem()
|
||||
{
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public BuilderCustomItem(String username, ResourceLocation item)
|
||||
{
|
||||
this.setPlayer(username);
|
||||
this.setItem(item);
|
||||
this.setAmount(1);
|
||||
this.setMetadata(0);
|
||||
this.attribute = this.registerNBTComponent(new ComponentAttributeItem(attribute -> attribute.getApplyable().equals(Applyable.BOTH) || attribute.getApplyable().equals(Applyable.PLAYER)));
|
||||
this.display = this.registerNBTComponent(new ComponentDisplay());
|
||||
this.enchantment = this.registerNBTComponent(new ComponentEnchantment());
|
||||
}
|
||||
|
||||
public void setEnchantment(Enchantment enchantment, short level)
|
||||
{
|
||||
this.enchantment.setLevel(enchantment, level);
|
||||
}
|
||||
|
||||
public void setAttribute(EnumAttributes attribute, float ammount)
|
||||
{
|
||||
this.attribute.set(attribute, ammount);
|
||||
}
|
||||
|
||||
public void removeAttribute(EnumAttributes attribute)
|
||||
{
|
||||
this.attribute.remove(attribute);
|
||||
}
|
||||
|
||||
public void setName(ColoredString name)
|
||||
{
|
||||
this.display.setName(name);
|
||||
}
|
||||
|
||||
public ColoredString getName()
|
||||
{
|
||||
return this.display.getName();
|
||||
}
|
||||
|
||||
public void setLore1(String lore)
|
||||
{
|
||||
this.display.setLore1(lore);
|
||||
}
|
||||
|
||||
public String getLore1()
|
||||
{
|
||||
return this.display.getLore1();
|
||||
}
|
||||
|
||||
public void setLore2(String lore)
|
||||
{
|
||||
this.display.setLore2(lore);
|
||||
}
|
||||
|
||||
public String getLore2()
|
||||
{
|
||||
return this.display.getLore2();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
|
||||
public class BuilderDifficulty extends CommandBuilder
|
||||
{
|
||||
public BuilderDifficulty()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BuilderDifficulty(EnumDifficulty difficulty)
|
||||
{
|
||||
this.setDifficulty(difficulty);
|
||||
}
|
||||
|
||||
public void setDifficulty(EnumDifficulty difficulty)
|
||||
{
|
||||
this.setNode(0, difficulty.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "difficulty";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("peaceful|easy|normal|hard", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumDifficulty
|
||||
{
|
||||
PEACEFUL,
|
||||
EASY,
|
||||
NORMAL,
|
||||
HARD;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderEnchantment extends CommandBuilder
|
||||
{
|
||||
public void getPlayer(String player)
|
||||
{
|
||||
this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(0, player);
|
||||
}
|
||||
|
||||
public ResourceLocation getEnchantment()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(1);
|
||||
}
|
||||
|
||||
public void setEnchantment(ResourceLocation enchantment)
|
||||
{
|
||||
this.setNode(1, enchantment);
|
||||
}
|
||||
|
||||
public void setLevel(int level)
|
||||
{
|
||||
this.setNode(2, level);
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
return this.getNodeAsInt(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "enchant";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addRequired("enchantment", Type.RESOURCE_LOCATION);
|
||||
syntax.addOptional("level", Type.INT, 1);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Level;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderExperience extends CommandBuilder
|
||||
{
|
||||
public BuilderExperience()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BuilderExperience(int level, String player)
|
||||
{
|
||||
this.setLevel(level);
|
||||
this.setPlayer(player);
|
||||
}
|
||||
|
||||
public void setLevel(int level)
|
||||
{
|
||||
this.setNode(0, new Level(level));
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
Level level = this.getNodeAsLevel(0);
|
||||
|
||||
if(level != null)
|
||||
{
|
||||
return level.getLevel();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(1, player);
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "xp";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("amount", Type.LEVEL, new Level(0));
|
||||
syntax.addOptional("player", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.impl.abstr.BuilderDoubleBlockPos;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import exopandora.worldhandler.helper.BlockHelper;
|
||||
import exopandora.worldhandler.helper.EnumHelper;
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderFill extends BuilderDoubleBlockPos
|
||||
{
|
||||
public BuilderFill(ResourceLocation block1, EnumBlockHandling handling, ResourceLocation block2)
|
||||
{
|
||||
this.setPosition1(BlockHelper.getPos1());
|
||||
this.setPosition2(BlockHelper.getPos2());
|
||||
this.setBlock1(block1);
|
||||
this.setMeta1(0);
|
||||
this.setBlockHandling(handling);
|
||||
this.setBlock2(block2);
|
||||
}
|
||||
|
||||
public BuilderFill()
|
||||
{
|
||||
this.init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
this.setMeta1(0);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setMeta1(int meta)
|
||||
{
|
||||
this.setNode(7, meta);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setMeta2(int meta)
|
||||
{
|
||||
this.setNode(10, meta);
|
||||
}
|
||||
|
||||
public void setBlock1(String block)
|
||||
{
|
||||
this.setBlock1(ResourceHelper.stringToResourceLocationNullable(block, ResourceHelper::isRegisteredBlock));
|
||||
}
|
||||
|
||||
public void setBlock1(ResourceLocation location)
|
||||
{
|
||||
this.setNode(6, location);
|
||||
}
|
||||
|
||||
public ResourceLocation getBlock1()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(6);
|
||||
}
|
||||
|
||||
public String getBlock1String()
|
||||
{
|
||||
ResourceLocation location = this.getBlock1();
|
||||
|
||||
if(location != null)
|
||||
{
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setBlockHandling(EnumBlockHandling blockHandling)
|
||||
{
|
||||
this.setNode(8, blockHandling != null ? blockHandling.toString() : null);
|
||||
}
|
||||
|
||||
public void setBlock2(String block)
|
||||
{
|
||||
this.setBlock2(ResourceHelper.stringToResourceLocationNullable(block, ResourceHelper::isRegisteredBlock));
|
||||
}
|
||||
|
||||
public void setBlock2(ResourceLocation location)
|
||||
{
|
||||
this.setNode(9, location);
|
||||
}
|
||||
|
||||
public String getBlock2String()
|
||||
{
|
||||
ResourceLocation location = this.getBlock2();
|
||||
|
||||
if(location != null)
|
||||
{
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ResourceLocation getBlock2()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(9);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumBlockHandling getBlockHandling()
|
||||
{
|
||||
return EnumHelper.valueOf(EnumBlockHandling.class, this.getNodeAsString(8));
|
||||
}
|
||||
|
||||
public BuilderFill getBuilderForFill()
|
||||
{
|
||||
return new BuilderFill(this.getBlock1(), null, null);
|
||||
}
|
||||
|
||||
public BuilderFill getBuilderForReplace()
|
||||
{
|
||||
return new BuilderFill(this.getBlock2(), EnumBlockHandling.REPLACE, this.getBlock1());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "fill";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("x1", Type.COORDINATE);
|
||||
syntax.addRequired("y1", Type.COORDINATE);
|
||||
syntax.addRequired("z1", Type.COORDINATE);
|
||||
syntax.addRequired("x2", Type.COORDINATE);
|
||||
syntax.addRequired("y2", Type.COORDINATE);
|
||||
syntax.addRequired("z2", Type.COORDINATE);
|
||||
syntax.addRequired("block", Type.RESOURCE_LOCATION);
|
||||
syntax.addOptional("data_value", Type.INT);
|
||||
syntax.addOptional("old_block_handling", Type.STRING);
|
||||
syntax.addOptional("block_2|nbt", Type.RESOURCE_LOCATION, "block_2|nbt");
|
||||
syntax.addOptional("data_value", Type.INT, "data_value");
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumBlockHandling
|
||||
{
|
||||
REPLACE,
|
||||
DESTROY,
|
||||
KEEP,
|
||||
HOLLOW,
|
||||
OUTLINE;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
|
||||
public class BuilderGamemode extends CommandBuilder
|
||||
{
|
||||
public BuilderGamemode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BuilderGamemode(EnumGamemode mode)
|
||||
{
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
public BuilderGamemode(EnumGamemode mode, String player)
|
||||
{
|
||||
this(mode);
|
||||
this.setPlayer(player);
|
||||
}
|
||||
|
||||
public void setMode(EnumGamemode mode)
|
||||
{
|
||||
this.setNode(0, mode.toString());
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(1, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "gamemode";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("mode", Type.STRING);
|
||||
syntax.addOptional("player", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumGamemode
|
||||
{
|
||||
SURVIVAL,
|
||||
CREATIVE,
|
||||
ADVENTURE,
|
||||
SPECTATOR;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderGamerule extends CommandBuilder
|
||||
{
|
||||
public BuilderGamerule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BuilderGamerule(String rule, String value)
|
||||
{
|
||||
this.setRule(rule);
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public void setRule(String rule)
|
||||
{
|
||||
this.setNode(0, rule);
|
||||
}
|
||||
|
||||
public String getRule()
|
||||
{
|
||||
return this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
public void setValue(String value)
|
||||
{
|
||||
this.setNode(1, value);
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
public BuilderGamerule getBuilderForValue(String value)
|
||||
{
|
||||
return new BuilderGamerule(this.getRule(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "gamerule";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addOptional("rule", Type.STRING);
|
||||
syntax.addOptional("true|false|value", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderGeneric implements ICommandBuilder
|
||||
{
|
||||
private final String command;
|
||||
private final String[] arguments;
|
||||
|
||||
public BuilderGeneric(String command, String... arguments)
|
||||
{
|
||||
this.command = command;
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toCommand()
|
||||
{
|
||||
return "/" + this.command + " " + String.join(" ", this.arguments);
|
||||
}
|
||||
|
||||
public String toActualCommand()
|
||||
{
|
||||
return this.toCommand();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilderNBT;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderGive extends CommandBuilderNBT
|
||||
{
|
||||
public BuilderGive(String player, ResourceLocation item)
|
||||
{
|
||||
this.setPlayer(player);
|
||||
this.setItem(item);
|
||||
this.setMetadata(0);
|
||||
}
|
||||
|
||||
public BuilderGive()
|
||||
{
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public void setPlayer(String username)
|
||||
{
|
||||
this.setNode(0, username);
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
public void setItem(String item)
|
||||
{
|
||||
this.setItem(ResourceHelper.stringToResourceLocationNullable(item, ResourceHelper::isRegisteredItem));
|
||||
}
|
||||
|
||||
public void setItem(ResourceLocation item)
|
||||
{
|
||||
this.setNode(1, item);
|
||||
}
|
||||
|
||||
public ResourceLocation getItem()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(1);
|
||||
}
|
||||
|
||||
public void setAmount(int ammount)
|
||||
{
|
||||
this.setNode(2, ammount);
|
||||
}
|
||||
|
||||
public int getAmount()
|
||||
{
|
||||
return this.getNodeAsInt(2);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setMetadata(int metadata)
|
||||
{
|
||||
this.setNode(3, metadata);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getMetadata()
|
||||
{
|
||||
return this.getNodeAsInt(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNBT(NBTTagCompound nbt)
|
||||
{
|
||||
this.setNode(4, nbt);
|
||||
}
|
||||
|
||||
public NBTTagCompound getNBT()
|
||||
{
|
||||
return this.getNodeAsNBT(4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "give";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addRequired("item", Type.RESOURCE_LOCATION);
|
||||
syntax.addRequired("amount", Type.INT);
|
||||
syntax.addRequired("data_value", Type.INT);
|
||||
syntax.addOptional("nbt", Type.NBT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderMultiCommand implements ICommandBuilder
|
||||
{
|
||||
private final ICommandBuilder[] builders;
|
||||
|
||||
public BuilderMultiCommand(ICommandBuilder... builder)
|
||||
{
|
||||
this.builders = builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toCommand()
|
||||
{
|
||||
return String.join(" | ", Arrays.stream(this.builders).map(ICommandBuilder::toCommand).toArray(String[]::new));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentTag;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderNoteEditor extends BuilderBlockdata
|
||||
{
|
||||
private final ComponentTag<Byte> note;
|
||||
|
||||
public BuilderNoteEditor()
|
||||
{
|
||||
this.note = this.registerNBTComponent(new ComponentTag<Byte>("note"));
|
||||
}
|
||||
|
||||
public BuilderNoteEditor(byte note)
|
||||
{
|
||||
this();
|
||||
this.setNote(note);
|
||||
}
|
||||
|
||||
public BuilderNoteEditor(byte note, BlockPos pos)
|
||||
{
|
||||
this(note);
|
||||
this.setPosition(pos);
|
||||
}
|
||||
|
||||
public void setNote(byte note)
|
||||
{
|
||||
this.note.setValue(note);
|
||||
}
|
||||
|
||||
public BuilderNoteEditor getBuilderForNote(byte note)
|
||||
{
|
||||
return new BuilderNoteEditor(note, this.getBlockPos());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderPlayer extends CommandBuilder
|
||||
{
|
||||
private final String command;
|
||||
|
||||
public BuilderPlayer(String command)
|
||||
{
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(0, player);
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return this.command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderPlayerReason extends CommandBuilder
|
||||
{
|
||||
private final String command;
|
||||
|
||||
public BuilderPlayerReason(String command)
|
||||
{
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(0, player);
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
public void setReason(String reason)
|
||||
{
|
||||
this.setNode(1, reason);
|
||||
}
|
||||
|
||||
public String getReason()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return this.command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addOptional("reason", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.component.abstr.PotionMetadata;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderPotionEffect extends CommandBuilder
|
||||
{
|
||||
private int seconds;
|
||||
private int minutes;
|
||||
private int hours;
|
||||
|
||||
public BuilderPotionEffect()
|
||||
{
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public BuilderPotionEffect(String player, ResourceLocation effect)
|
||||
{
|
||||
this(player, effect, 0, (byte) 0, false);
|
||||
}
|
||||
|
||||
public BuilderPotionEffect(String player, ResourceLocation effect, int duration, byte amplifier, boolean hideParticles)
|
||||
{
|
||||
this.setPlayer(player);
|
||||
this.setEffect(effect);
|
||||
this.setDuration(duration);
|
||||
this.setAmplifier(amplifier);
|
||||
this.setHideParticles(hideParticles);
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(0, player);
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
public void setEffect(ResourceLocation effect)
|
||||
{
|
||||
this.setNode(1, effect);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Potion getEffectAsPotion()
|
||||
{
|
||||
ResourceLocation location = this.getNodeAsResourceLocation(1);
|
||||
|
||||
if(location != null)
|
||||
{
|
||||
return Potion.getPotionFromResourceLocation(location.toString());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ResourceLocation getEffect()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(1);
|
||||
}
|
||||
|
||||
public void setDuration(int duration)
|
||||
{
|
||||
this.setNode(2, Math.min(duration, 1000000));
|
||||
}
|
||||
|
||||
public int getDuration()
|
||||
{
|
||||
return this.getNodeAsInt(2);
|
||||
}
|
||||
|
||||
public void setAmplifier(byte amplifier)
|
||||
{
|
||||
this.setNode(3, (byte) (amplifier - 1));
|
||||
}
|
||||
|
||||
public int getAmplifier()
|
||||
{
|
||||
return this.getNodeAsByte(3);
|
||||
}
|
||||
|
||||
public void setHideParticles(boolean hideParticles)
|
||||
{
|
||||
this.setNode(4, hideParticles);
|
||||
}
|
||||
|
||||
public boolean getHideParticles()
|
||||
{
|
||||
return this.getNodeAsBoolean(4);
|
||||
}
|
||||
|
||||
public int getSeconds()
|
||||
{
|
||||
return this.seconds;
|
||||
}
|
||||
|
||||
public void setSeconds(int seconds)
|
||||
{
|
||||
this.seconds = seconds;
|
||||
this.setDuration(PotionMetadata.getDuration(this.seconds, this.minutes, this.hours));
|
||||
}
|
||||
|
||||
public int getMinutes()
|
||||
{
|
||||
return this.minutes;
|
||||
}
|
||||
|
||||
public void setMinutes(int minutes)
|
||||
{
|
||||
this.minutes = minutes;
|
||||
this.setDuration(PotionMetadata.getDuration(this.seconds, this.minutes, this.hours));
|
||||
}
|
||||
|
||||
public int getHours()
|
||||
{
|
||||
return this.hours;
|
||||
}
|
||||
|
||||
public void setHours(int hours)
|
||||
{
|
||||
this.hours = hours;
|
||||
this.setDuration(PotionMetadata.getDuration(this.seconds, this.minutes, this.hours));
|
||||
}
|
||||
|
||||
public BuilderGeneric getRemoveCommand()
|
||||
{
|
||||
return new BuilderGeneric(this.getCommandName(), this.getPlayer(), this.getEffect().toString(), "0");
|
||||
}
|
||||
|
||||
public BuilderGeneric getClearCommand()
|
||||
{
|
||||
return new BuilderGeneric(this.getCommandName(), this.getPlayer(), "clear");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addRequired("effect", Type.RESOURCE_LOCATION);
|
||||
syntax.addOptional("seconds", Type.INT, 0);
|
||||
syntax.addOptional("amplifier", Type.BYTE, (byte) -1);
|
||||
syntax.addOptional("hideParticles", Type.BOOLEAN, false);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentPotionItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderPotionItem extends BuilderGive
|
||||
{
|
||||
private final ComponentPotionItem potion;
|
||||
|
||||
public BuilderPotionItem()
|
||||
{
|
||||
this(null, null, new ComponentPotionItem());
|
||||
}
|
||||
|
||||
public BuilderPotionItem(ResourceLocation item, String player, ComponentPotionItem potion)
|
||||
{
|
||||
this.setItem(item);
|
||||
this.setPlayer(player);
|
||||
this.setAmount(1);
|
||||
this.potion = this.registerNBTComponent(potion);
|
||||
}
|
||||
|
||||
public void setAmplifier(Potion potion, byte amplifier)
|
||||
{
|
||||
this.potion.get(potion).setAmplifier(amplifier);
|
||||
}
|
||||
|
||||
public void setSeconds(Potion potion, int seconds)
|
||||
{
|
||||
this.potion.get(potion).setSeconds(seconds);
|
||||
}
|
||||
|
||||
public void setMinutes(Potion potion, int minutes)
|
||||
{
|
||||
this.potion.get(potion).setMinutes(minutes);
|
||||
}
|
||||
|
||||
public void setHours(Potion potion, int hours)
|
||||
{
|
||||
this.potion.get(potion).setHours(hours);
|
||||
}
|
||||
|
||||
public void setShowParticles(Potion potion, boolean showParticles)
|
||||
{
|
||||
this.potion.get(potion).setShowParticles(showParticles);
|
||||
}
|
||||
|
||||
public void setAmbient(Potion potion, boolean ambient)
|
||||
{
|
||||
this.potion.get(potion).setAmbient(ambient);
|
||||
}
|
||||
|
||||
public byte getAmplifier(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getAmplifier();
|
||||
}
|
||||
|
||||
public int getSeconds(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getSeconds();
|
||||
}
|
||||
|
||||
public int getMinutes(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getMinutes();
|
||||
}
|
||||
|
||||
public int getHours(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getHours();
|
||||
}
|
||||
|
||||
public boolean getShowParticles(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getShowParticles();
|
||||
}
|
||||
|
||||
public boolean getAmbient(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getAmbient();
|
||||
}
|
||||
|
||||
public BuilderPotionItem getBuilderForPotion(Item item)
|
||||
{
|
||||
return new BuilderPotionItem(item.getRegistryName(), this.getPlayer(), this.potion);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.impl.abstr.BuilderScoreboard;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderScoreboardObjectives extends BuilderScoreboard
|
||||
{
|
||||
public BuilderScoreboardObjectives()
|
||||
{
|
||||
this.init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
this.setNode(0, "objectives");
|
||||
}
|
||||
|
||||
public void setMode(String mode)
|
||||
{
|
||||
String objective = this.getObjective();
|
||||
|
||||
if(mode.equals("add") || mode.equals("remove") || mode.equals("setdisplay"))
|
||||
{
|
||||
this.updateSyntax(this.getSyntax(mode));
|
||||
this.setNode(1, mode);
|
||||
|
||||
if(objective != null)
|
||||
{
|
||||
this.setObjective(objective);
|
||||
}
|
||||
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
|
||||
public String getMode()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
public void setObjective(String name)
|
||||
{
|
||||
String mode = this.getMode();
|
||||
String objective = name != null ? name.replaceAll(" ", "_") : null;
|
||||
|
||||
if(mode != null)
|
||||
{
|
||||
if(mode.equals("add") || mode.equals("remove"))
|
||||
{
|
||||
this.setNode(2, objective);
|
||||
|
||||
if(mode.equals("add"))
|
||||
{
|
||||
this.setNode(4, name);
|
||||
}
|
||||
}
|
||||
else if(mode.equals("setdisplay"))
|
||||
{
|
||||
this.setNode(3, objective);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCriteria(String criteria)
|
||||
{
|
||||
if(this.getMode() == null || !this.getMode().equals("add"))
|
||||
{
|
||||
this.setMode("add");
|
||||
}
|
||||
this.setNode(3, criteria.replaceAll("[:]", "."));
|
||||
}
|
||||
|
||||
public void setSlot(String slot)
|
||||
{
|
||||
if(this.getMode() == null || !this.getMode().equals("setdisplay"))
|
||||
{
|
||||
this.setMode("setdisplay");
|
||||
}
|
||||
this.setNode(2, slot);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSlot()
|
||||
{
|
||||
if(this.getMode() != null && this.getMode().equals("setdisplay"))
|
||||
{
|
||||
return this.getNodeAsString(2);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getObjective()
|
||||
{
|
||||
String mode = this.getMode();
|
||||
|
||||
if(mode != null)
|
||||
{
|
||||
if(mode.equals("add") || mode.equals("remove"))
|
||||
{
|
||||
return this.getNodeAsString(2);
|
||||
}
|
||||
else if(mode.equals("setdisplay"))
|
||||
{
|
||||
return this.getNodeAsString(3);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Syntax getSyntax(String mode)
|
||||
{
|
||||
if(mode.equals("add"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("objectives", Type.STRING);
|
||||
syntax.addRequired("add", Type.STRING);
|
||||
syntax.addRequired("name", Type.STRING);
|
||||
syntax.addRequired("criteria_type", Type.STRING);
|
||||
syntax.addOptional("display_name...", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
else if(mode.equals("remove"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("objectives", Type.STRING);
|
||||
syntax.addRequired("remove", Type.STRING);
|
||||
syntax.addRequired("name", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
else if(mode.equals("setdisplay"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("objectives", Type.STRING);
|
||||
syntax.addRequired("setdisplay", Type.STRING);
|
||||
syntax.addRequired("slot", Type.STRING);
|
||||
syntax.addOptional("objective", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("objectives", Type.STRING);
|
||||
syntax.addRequired("list|add|remove|setdisplay", Type.STRING);
|
||||
syntax.addOptional("...", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.impl.abstr.BuilderScoreboard;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderScoreboardPlayers extends BuilderScoreboard
|
||||
{
|
||||
public BuilderScoreboardPlayers()
|
||||
{
|
||||
this.init();
|
||||
}
|
||||
|
||||
public String getMode()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
public void setMode(String mode)
|
||||
{
|
||||
String objective = this.getObjective();
|
||||
String player = this.getPlayer();
|
||||
String tag = this.getTag();
|
||||
int points = this.getPoints();
|
||||
|
||||
if(mode.equals("add|set|remove") || mode.equals("tag") || mode.equals("enable"))
|
||||
{
|
||||
this.updateSyntax(this.getSyntax(mode));
|
||||
this.setNode(1, mode);
|
||||
this.setNode(2, player);
|
||||
|
||||
if(mode.equals("add|set|remove") || mode.equals("enable"))
|
||||
{
|
||||
this.setObjective(objective);
|
||||
}
|
||||
|
||||
if(mode.equals("add|set|remove"))
|
||||
{
|
||||
this.setPoints(points);
|
||||
}
|
||||
else if(mode.equals("tag"))
|
||||
{
|
||||
this.setTag(tag);
|
||||
}
|
||||
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
this.setNode(0, "players");
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(2, player);
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(2);
|
||||
}
|
||||
|
||||
public void setObjective(String name)
|
||||
{
|
||||
String mode = this.getMode();
|
||||
String objective = name != null ? name.replaceAll(" ", "_") : null;
|
||||
|
||||
if(mode != null)
|
||||
{
|
||||
if(mode.equals("add|set|remove") || mode.equals("enable"))
|
||||
{
|
||||
this.setNode(3, objective);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getObjective()
|
||||
{
|
||||
String mode = this.getMode();
|
||||
|
||||
if(mode != null)
|
||||
{
|
||||
if(mode.equals("add|set|remove") || mode.equals("enable"))
|
||||
{
|
||||
return this.getNodeAsString(3);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setPoints(int points)
|
||||
{
|
||||
if(this.getMode() == null || !this.getMode().equals("add|set|remove"))
|
||||
{
|
||||
this.setMode("add|set|remove");
|
||||
}
|
||||
this.setNode(4, points);
|
||||
}
|
||||
|
||||
public int getPoints()
|
||||
{
|
||||
if(this.getMode() != null && this.getMode().equals("add|set|remove"))
|
||||
{
|
||||
return this.getNodeAsInt(4);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setTag(String name)
|
||||
{
|
||||
String tag = name != null ? name.replaceAll(" ", "_") : null;
|
||||
|
||||
if(this.getMode() == null || !this.getMode().equals("tag"))
|
||||
{
|
||||
this.setMode("tag");
|
||||
}
|
||||
this.setNode(4, tag);
|
||||
}
|
||||
|
||||
public String getTag()
|
||||
{
|
||||
if(this.getMode() != null && this.getMode().equals("tag"))
|
||||
{
|
||||
return this.getNodeAsString(4);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Syntax getSyntax(String mode)
|
||||
{
|
||||
if(mode.equals("add|set|remove"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("players", Type.STRING);
|
||||
syntax.addRequired("add|set|remove", Type.STRING, "add|set|remove");
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addRequired("objective", Type.STRING);
|
||||
syntax.addRequired("count", Type.INT, 0);
|
||||
syntax.addOptional("nbt", Type.NBT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
else if(mode.equals("tag"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("players", Type.STRING);
|
||||
syntax.addRequired("tag", Type.STRING);
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addRequired("add|remove|list", Type.STRING);
|
||||
syntax.addRequired("tag_name", Type.STRING);
|
||||
syntax.addOptional("nbt", Type.NBT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
else if(mode.equals("enable"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("players", Type.STRING);
|
||||
syntax.addRequired("enable", Type.STRING);
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addRequired("trigger", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public BuilderGeneric getBuilderForTag(EnumTag tag)
|
||||
{
|
||||
return new BuilderGeneric(this.getCommandName(), "players", this.getMode(), this.getPlayer(), tag.toString(), this.getTag());
|
||||
}
|
||||
|
||||
public BuilderGeneric getBuilderForPoints(EnumPoints mode)
|
||||
{
|
||||
return this.getBuilderForPoints(mode, this.getPoints());
|
||||
}
|
||||
|
||||
public BuilderGeneric getBuilderForPoints(EnumPoints mode, int points)
|
||||
{
|
||||
return new BuilderGeneric(this.getCommandName(), "players", mode.toString(), this.getPlayer(), this.getObjective(), String.valueOf(points));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("players", Type.STRING);
|
||||
syntax.addRequired("add|enable|list|operation|remove|reset|set|tag|test", Type.STRING);
|
||||
syntax.addOptional("...", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumTag
|
||||
{
|
||||
ADD,
|
||||
REMOVE;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
public static enum EnumPoints
|
||||
{
|
||||
ADD,
|
||||
REMOVE,
|
||||
SET;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.impl.abstr.BuilderScoreboard;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderScoreboardTeams extends BuilderScoreboard
|
||||
{
|
||||
public BuilderScoreboardTeams()
|
||||
{
|
||||
this.init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
this.setNode(0, "teams");
|
||||
}
|
||||
|
||||
public void setTeam(String name)
|
||||
{
|
||||
String mode = this.getMode();
|
||||
String team = name != null ? name.replaceAll(" ", "_") : null;
|
||||
|
||||
if(mode != null)
|
||||
{
|
||||
if(mode.equals("add"))
|
||||
{
|
||||
this.setNode(3, name);
|
||||
}
|
||||
}
|
||||
|
||||
this.setNode(2, team);
|
||||
}
|
||||
|
||||
public String getMode()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTeam()
|
||||
{
|
||||
return this.getNodeAsString(2);
|
||||
}
|
||||
|
||||
public void setMode(String mode)
|
||||
{
|
||||
String team = this.getTeam();
|
||||
String player = this.getPlayer();
|
||||
|
||||
if(mode.equals("add") || mode.equals("remove|empty") || mode.equals("join|leave") || mode.equals("option"))
|
||||
{
|
||||
this.updateSyntax(this.getSyntax(mode));
|
||||
this.setNode(1, mode);
|
||||
|
||||
if(team != null)
|
||||
{
|
||||
this.setTeam(team);
|
||||
}
|
||||
|
||||
if(player != null && (mode.equals("join|leave")))
|
||||
{
|
||||
this.setPlayer(player);
|
||||
}
|
||||
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
String mode = this.getMode();
|
||||
|
||||
if(mode != null)
|
||||
{
|
||||
if(mode.equals("join|leave"))
|
||||
{
|
||||
this.setNode(3, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPlayer()
|
||||
{
|
||||
String mode = this.getMode();
|
||||
|
||||
if(mode != null)
|
||||
{
|
||||
if(mode.equals("join|leave"))
|
||||
{
|
||||
return this.getNodeAsString(3);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setRule(String rule)
|
||||
{
|
||||
if(this.getMode() == null || !this.getMode().equals("option"))
|
||||
{
|
||||
this.setMode("option");
|
||||
}
|
||||
|
||||
this.setNode(3, rule);
|
||||
}
|
||||
|
||||
public String getRule()
|
||||
{
|
||||
if(this.getMode() == null || this.getMode().equals("option"))
|
||||
{
|
||||
return this.getNodeAsString(3);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setValue(String value)
|
||||
{
|
||||
if(this.getMode() == null || !this.getMode().equals("option"))
|
||||
{
|
||||
this.setMode("option");
|
||||
}
|
||||
|
||||
this.setNode(4, value);
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
if(this.getMode() == null || this.getMode().equals("option"))
|
||||
{
|
||||
return this.getNodeAsString(4);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Syntax getSyntax(String mode)
|
||||
{
|
||||
if(mode.equals("add"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("teams", Type.STRING);
|
||||
syntax.addRequired("add", Type.STRING);
|
||||
syntax.addRequired("name", Type.STRING);
|
||||
syntax.addOptional("display_name...", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
else if(mode.equals("remove|empty"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("teams", Type.STRING);
|
||||
syntax.addRequired("remove|empty", Type.STRING, "remove|empty");
|
||||
syntax.addRequired("name", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
else if(mode.equals("join|leave"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("teams", Type.STRING);
|
||||
syntax.addRequired("join|leave", Type.STRING, "join|leave");
|
||||
syntax.addRequired("name", Type.STRING);
|
||||
syntax.addOptional("player", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
else if(mode.equals("option"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("teams", Type.STRING);
|
||||
syntax.addRequired("option", Type.STRING);
|
||||
syntax.addRequired("team", Type.STRING);
|
||||
syntax.addRequired("friendlyfire|color|seeFriendlyInvisibles|nametagVisibility|deathMessageVisibility|collisionRule", Type.STRING);
|
||||
syntax.addRequired("value", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public BuilderScoreboardTeams getBuilderForMode(EnumMode mode)
|
||||
{
|
||||
BuilderScoreboardTeams builder = new BuilderScoreboardTeams();
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case JOIN:
|
||||
case LEAVE:
|
||||
builder.setNode(1, mode.toString());
|
||||
builder.setTeam(this.getTeam());
|
||||
builder.setPlayer(this.getPlayer());
|
||||
break;
|
||||
case REMOVE:
|
||||
case EMPTY:
|
||||
builder.setNode(1, mode.toString());
|
||||
builder.setTeam(this.getTeam());
|
||||
break;
|
||||
case ADD:
|
||||
builder.setMode(mode.toString());
|
||||
builder.setTeam(this.getTeam());
|
||||
break;
|
||||
case OPTION:
|
||||
builder.setMode(mode.toString());
|
||||
builder.setTeam(this.getTeam());
|
||||
builder.setRule(this.getRule());
|
||||
builder.setValue(this.getValue());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("teams", Type.STRING);
|
||||
syntax.addRequired("list|add|remove|empty|join|leave|option", Type.STRING);
|
||||
syntax.addOptional("...", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
JOIN,
|
||||
LEAVE,
|
||||
REMOVE,
|
||||
EMPTY,
|
||||
ADD,
|
||||
OPTION;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.impl.abstr.BuilderBlockPos;
|
||||
import exopandora.worldhandler.builder.types.Coordinate;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class BuilderSetblock extends BuilderBlockPos
|
||||
{
|
||||
@Deprecated
|
||||
public BuilderSetblock(BlockPos pos, ResourceLocation block, int meta, String mode)
|
||||
{
|
||||
this.setPosition(pos);
|
||||
this.setBlock(block);
|
||||
this.setMetadata(meta);
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BuilderSetblock(Coordinate x, Coordinate y, Coordinate z, ResourceLocation block, int meta, String mode)
|
||||
{
|
||||
this.setX(x);
|
||||
this.setY(y);
|
||||
this.setZ(z);
|
||||
this.setBlock(block);
|
||||
this.setMetadata(meta);
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
public BuilderSetblock(Coordinate x, Coordinate y, Coordinate z, ResourceLocation block, String mode)
|
||||
{
|
||||
this(x, y, z, block, 0, mode);
|
||||
}
|
||||
|
||||
public void setBlock(ResourceLocation block)
|
||||
{
|
||||
this.setNode(3, block);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setMetadata(int meta)
|
||||
{
|
||||
this.setNode(4, meta);
|
||||
}
|
||||
|
||||
public void setMode(String mode)
|
||||
{
|
||||
this.setNode(5, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNBT(NBTTagCompound nbt)
|
||||
{
|
||||
this.setNode(6, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "setblock";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("x", Type.COORDINATE);
|
||||
syntax.addRequired("y", Type.COORDINATE);
|
||||
syntax.addRequired("z", Type.COORDINATE);
|
||||
syntax.addRequired("block", Type.RESOURCE_LOCATION);
|
||||
syntax.addOptional("data_value", Type.INT);
|
||||
syntax.addOptional("mode", Type.STRING);
|
||||
syntax.addOptional("nbt", Type.NBT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentTag;
|
||||
import exopandora.worldhandler.format.text.ColoredString;
|
||||
import exopandora.worldhandler.format.text.SignText;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderSignEditor extends BuilderBlockdata
|
||||
{
|
||||
private final ComponentTag<SignText>[] sign = new ComponentTag[4];
|
||||
|
||||
public BuilderSignEditor()
|
||||
{
|
||||
for(int x = 0; x < 4; x++)
|
||||
{
|
||||
this.sign[x] = this.registerNBTComponent(new ComponentTag<SignText>("Text" + (x + 1), new SignText(x), text -> new NBTTagString(text.toString())));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSpecial()
|
||||
{
|
||||
boolean special = false;
|
||||
|
||||
for(int x = 0; x < this.sign.length; x++)
|
||||
{
|
||||
special = special || this.getColoredString(x).isSpecial();
|
||||
}
|
||||
|
||||
return special;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ColoredString getColoredString(int line)
|
||||
{
|
||||
if(this.checkBounds(line))
|
||||
{
|
||||
return this.sign[line].getValue().getColoredString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getCommand(int line)
|
||||
{
|
||||
if(this.checkBounds(line))
|
||||
{
|
||||
return this.sign[line].getValue().getCommand();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public void setCommand(int line, String command)
|
||||
{
|
||||
if(this.checkBounds(line))
|
||||
{
|
||||
this.sign[line].getValue().setCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkBounds(int line)
|
||||
{
|
||||
return line >= 0 && line < this.sign.length;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Coordinate;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderSpawnpoint extends CommandBuilder
|
||||
{
|
||||
public BuilderSpawnpoint(String player)
|
||||
{
|
||||
this.setX(new Coordinate(0, true));
|
||||
this.setY(new Coordinate(0, true));
|
||||
this.setZ(new Coordinate(0, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "spawnpoint";
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(0, player);
|
||||
}
|
||||
|
||||
public void setX(Coordinate x)
|
||||
{
|
||||
this.setNode(1, x);
|
||||
}
|
||||
|
||||
public void setY(Coordinate y)
|
||||
{
|
||||
this.setNode(2, y);
|
||||
}
|
||||
|
||||
public void setZ(Coordinate z)
|
||||
{
|
||||
this.setNode(3, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addRequired("x", Type.COORDINATE);
|
||||
syntax.addRequired("y", Type.COORDINATE);
|
||||
syntax.addRequired("z", Type.COORDINATE);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,407 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilderNBT;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentAttributeMob;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentPotionMob;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentSummon;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentTag;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes.Applyable;
|
||||
import exopandora.worldhandler.builder.types.Coordinate;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import exopandora.worldhandler.format.text.ColoredString;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderSummon extends CommandBuilderNBT
|
||||
{
|
||||
private final ComponentAttributeMob attribute;
|
||||
private final ComponentTag<ColoredString> customName;
|
||||
private final ComponentTag<NBTTagList> passengers;
|
||||
private final ComponentTag<NBTTagList> armorItems;
|
||||
private final ComponentTag<NBTTagList> handItems;
|
||||
private final ComponentPotionMob potion;
|
||||
private final ComponentSummon summon;
|
||||
private final ResourceLocation[] armorItemsArray = {Blocks.AIR.getRegistryName(), Blocks.AIR.getRegistryName(), Blocks.AIR.getRegistryName(), Blocks.AIR.getRegistryName()};
|
||||
private final ResourceLocation[] handItemsArray = {Blocks.AIR.getRegistryName(), Blocks.AIR.getRegistryName()};
|
||||
|
||||
public BuilderSummon()
|
||||
{
|
||||
this.attribute = this.registerNBTComponent(new ComponentAttributeMob(attribute -> attribute.getApplyable().equals(Applyable.BOTH) || attribute.getApplyable().equals(Applyable.MOB)));
|
||||
this.customName = this.registerNBTComponent(new ComponentTag<ColoredString>("CustomName", new ColoredString(), this::colorStringSerializer));
|
||||
this.passengers = this.registerNBTComponent(new ComponentTag<NBTTagList>("Passengers"));
|
||||
this.armorItems = this.registerNBTComponent(new ComponentTag<NBTTagList>("ArmorItems", this::itemListSerializer));
|
||||
this.handItems = this.registerNBTComponent(new ComponentTag<NBTTagList>("HandItems", this::itemListSerializer));
|
||||
this.summon = this.registerNBTComponent(new ComponentSummon(), "summon");
|
||||
this.potion = this.registerNBTComponent(new ComponentPotionMob());
|
||||
}
|
||||
|
||||
public BuilderSummon(int direction)
|
||||
{
|
||||
this();
|
||||
this.setDirection(direction);
|
||||
}
|
||||
|
||||
public void setDirection(int direction)
|
||||
{
|
||||
if(direction == 0)
|
||||
{
|
||||
this.setX(new Coordinate(0, true));
|
||||
this.setY(new Coordinate(0, true));
|
||||
this.setZ(new Coordinate(2, true));
|
||||
}
|
||||
else if(direction == 1)
|
||||
{
|
||||
this.setX(new Coordinate(-2, true));
|
||||
this.setY(new Coordinate(0, true));
|
||||
this.setZ(new Coordinate(0, true));
|
||||
}
|
||||
else if(direction == 2)
|
||||
{
|
||||
this.setX(new Coordinate(0, true));
|
||||
this.setY(new Coordinate(0, true));
|
||||
this.setZ(new Coordinate(-2, true));
|
||||
}
|
||||
else if(direction == 3)
|
||||
{
|
||||
this.setX(new Coordinate(2, true));
|
||||
this.setY(new Coordinate(0, true));
|
||||
this.setZ(new Coordinate(0, true));
|
||||
}
|
||||
}
|
||||
|
||||
public void setEntity(String entityName)
|
||||
{
|
||||
ResourceLocation location = this.summon.resolve(entityName);
|
||||
|
||||
this.summon.setName(entityName);
|
||||
this.summon.setEntity(location);
|
||||
|
||||
this.setNode(0, location);
|
||||
}
|
||||
|
||||
public ResourceLocation getEntity()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(0);
|
||||
}
|
||||
|
||||
public void setX(Coordinate x)
|
||||
{
|
||||
this.setNode(1, x);
|
||||
}
|
||||
|
||||
public Coordinate getX()
|
||||
{
|
||||
return this.getNodeAsCoordinate(1);
|
||||
}
|
||||
|
||||
public void setY(Coordinate y)
|
||||
{
|
||||
this.setNode(2, y);
|
||||
}
|
||||
|
||||
public Coordinate getY()
|
||||
{
|
||||
return this.getNodeAsCoordinate(2);
|
||||
}
|
||||
|
||||
public void setZ(Coordinate z)
|
||||
{
|
||||
this.setNode(3, z);
|
||||
}
|
||||
|
||||
public Coordinate getZ()
|
||||
{
|
||||
return this.getNodeAsCoordinate(3);
|
||||
}
|
||||
|
||||
public void setAttribute(EnumAttributes attribute, float ammount)
|
||||
{
|
||||
this.attribute.set(attribute, ammount);
|
||||
}
|
||||
|
||||
public void removeAttribute(EnumAttributes attribute)
|
||||
{
|
||||
this.attribute.remove(attribute);
|
||||
}
|
||||
|
||||
public void setCustomName(ColoredString name)
|
||||
{
|
||||
this.customName.setValue(name);
|
||||
}
|
||||
|
||||
public void setCustomName(String name)
|
||||
{
|
||||
this.customName.getValue().setText(name);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ColoredString getCustomName()
|
||||
{
|
||||
if(this.customName.getValue() != null)
|
||||
{
|
||||
return this.customName.getValue();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setPassenger(String entityName)
|
||||
{
|
||||
this.setPassenger(this.summon.resolve(entityName));
|
||||
}
|
||||
|
||||
public void setPassenger(ResourceLocation entityName)
|
||||
{
|
||||
if(entityName != null)
|
||||
{
|
||||
NBTTagCompound passenger = new NBTTagCompound();
|
||||
passenger.setString("id", entityName.toString());
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
list.appendTag(passenger);
|
||||
|
||||
this.passengers.setValue(list);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.passengers.setValue(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ResourceLocation getPassenger()
|
||||
{
|
||||
NBTTagList list = this.passengers.getValue();
|
||||
|
||||
if(list != null && !list.hasNoTags())
|
||||
{
|
||||
return new ResourceLocation(list.getCompoundTagAt(0).getString("id"));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setArmorItem(int index, Block block)
|
||||
{
|
||||
this.setArmorItem(index, block.getRegistryName());
|
||||
}
|
||||
|
||||
public void setArmorItem(int index, Item item)
|
||||
{
|
||||
this.setArmorItem(index, item.getRegistryName());
|
||||
}
|
||||
|
||||
public void setArmorItem(int index, ResourceLocation location)
|
||||
{
|
||||
this.changeNBTList(index, location, this.armorItemsArray, this::setArmorItems);
|
||||
}
|
||||
|
||||
public void setArmorItems(ResourceLocation[] armor)
|
||||
{
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for(ResourceLocation item : armor)
|
||||
{
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setString("id", item.toString());
|
||||
compound.setInteger("Count", 1);
|
||||
list.appendTag(compound);
|
||||
}
|
||||
|
||||
this.armorItems.setValue(list);
|
||||
}
|
||||
|
||||
public ResourceLocation getArmorItem(int slot)
|
||||
{
|
||||
if(slot < this.armorItemsArray.length)
|
||||
{
|
||||
return this.armorItemsArray[slot];
|
||||
}
|
||||
|
||||
return Blocks.AIR.getRegistryName();
|
||||
}
|
||||
|
||||
public void setHandItem(int index, Block block)
|
||||
{
|
||||
this.setHandItem(index, block.getRegistryName());
|
||||
}
|
||||
|
||||
public void setHandItem(int index, Item item)
|
||||
{
|
||||
this.setHandItem(index, item.getRegistryName());
|
||||
}
|
||||
|
||||
public void setHandItem(int index, ResourceLocation location)
|
||||
{
|
||||
this.changeNBTList(index, location, this.handItemsArray, this::setHandItems);
|
||||
}
|
||||
|
||||
private void changeNBTList(int index, ResourceLocation location, ResourceLocation[] array, Consumer<ResourceLocation[]> consumer)
|
||||
{
|
||||
if(index < array.length)
|
||||
{
|
||||
array[index] = location;
|
||||
consumer.accept(array);
|
||||
}
|
||||
}
|
||||
|
||||
public void setHandItems(ResourceLocation[] armor)
|
||||
{
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for(ResourceLocation item : armor)
|
||||
{
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setString("id", item.toString());
|
||||
compound.setInteger("Count", 1);
|
||||
list.appendTag(compound);
|
||||
}
|
||||
|
||||
this.handItems.setValue(list);
|
||||
}
|
||||
|
||||
public ResourceLocation getHandItem(int slot)
|
||||
{
|
||||
if(slot < this.handItemsArray.length)
|
||||
{
|
||||
return this.handItemsArray[slot];
|
||||
}
|
||||
|
||||
return Blocks.AIR.getRegistryName();
|
||||
}
|
||||
|
||||
public void setAmplifier(Potion potion, byte amplifier)
|
||||
{
|
||||
this.potion.get(potion).setAmplifier(amplifier);
|
||||
}
|
||||
|
||||
public void setSeconds(Potion potion, int seconds)
|
||||
{
|
||||
this.potion.get(potion).setSeconds(seconds);
|
||||
}
|
||||
|
||||
public void setMinutes(Potion potion, int minutes)
|
||||
{
|
||||
this.potion.get(potion).setMinutes(minutes);
|
||||
}
|
||||
|
||||
public void setHours(Potion potion, int hours)
|
||||
{
|
||||
this.potion.get(potion).setHours(hours);
|
||||
}
|
||||
|
||||
public void setShowParticles(Potion potion, boolean showParticles)
|
||||
{
|
||||
this.potion.get(potion).setShowParticles(showParticles);
|
||||
}
|
||||
|
||||
public void setAmbient(Potion potion, boolean ambient)
|
||||
{
|
||||
this.potion.get(potion).setAmbient(ambient);
|
||||
}
|
||||
|
||||
public byte getAmplifier(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getAmplifier();
|
||||
}
|
||||
|
||||
public int getSeconds(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getSeconds();
|
||||
}
|
||||
|
||||
public int getMinutes(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getMinutes();
|
||||
}
|
||||
|
||||
public int getHours(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getHours();
|
||||
}
|
||||
|
||||
public boolean getShowParticles(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getShowParticles();
|
||||
}
|
||||
|
||||
public boolean getAmbient(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getAmbient();
|
||||
}
|
||||
|
||||
private NBTBase itemListSerializer(NBTTagList list)
|
||||
{
|
||||
for(int x = 0; x < list.tagCount(); x++)
|
||||
{
|
||||
if(!list.getCompoundTagAt(x).getString("id").equals(Blocks.AIR.getRegistryName().toString()))
|
||||
{
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private NBTBase colorStringSerializer(ColoredString string)
|
||||
{
|
||||
if(string.getText() != null && !string.getText().isEmpty())
|
||||
{
|
||||
return new NBTTagString(string.toString());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNBT(NBTTagCompound nbt)
|
||||
{
|
||||
this.setNode(4, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "summon";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("entity_name", Type.RESOURCE_LOCATION);
|
||||
syntax.addOptional("x", Type.COORDINATE);
|
||||
syntax.addOptional("y", Type.COORDINATE);
|
||||
syntax.addOptional("z", Type.COORDINATE);
|
||||
syntax.addOptional("nbt", Type.NBT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toCommand()
|
||||
{
|
||||
this.summon.setEntity(this.getEntity());
|
||||
this.summon.setHasPassenger(this.getPassenger() != null);
|
||||
|
||||
return super.toCommand();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
|
||||
public class BuilderTime extends CommandBuilder
|
||||
{
|
||||
public BuilderTime()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BuilderTime(EnumMode mode)
|
||||
{
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
public BuilderTime(EnumMode mode, int value)
|
||||
{
|
||||
this(mode);
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
this.setNode(0, mode.toString());
|
||||
}
|
||||
|
||||
public void setValue(int value)
|
||||
{
|
||||
this.setNode(1, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "time";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("set|add|query", Type.STRING);
|
||||
syntax.addOptional("value", Type.INT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
ADD,
|
||||
SET,
|
||||
QUERY;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderWH extends CommandBuilder
|
||||
{
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "wh";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("pos1|pos2|fill|replace", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
|
||||
public class BuilderWeather extends CommandBuilder
|
||||
{
|
||||
public BuilderWeather()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BuilderWeather(EnumWeather weather)
|
||||
{
|
||||
this.setWeather(weather);
|
||||
}
|
||||
|
||||
public BuilderWeather(EnumWeather weather, int value)
|
||||
{
|
||||
this(weather);
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public void setWeather(EnumWeather weather)
|
||||
{
|
||||
this.setNode(0, weather.toString());
|
||||
}
|
||||
|
||||
public void setValue(int value)
|
||||
{
|
||||
this.setNode(1, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "weather";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("clear|rain|thunde", Type.STRING);
|
||||
syntax.addOptional("duration", Type.INT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumWeather
|
||||
{
|
||||
CLEAR,
|
||||
RAIN,
|
||||
THUNDER;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderWhitelist extends CommandBuilder
|
||||
{
|
||||
public BuilderWhitelist()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BuilderWhitelist(EnumMode mode)
|
||||
{
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
public BuilderWhitelist(EnumMode mode, String player)
|
||||
{
|
||||
this(mode);
|
||||
this.setPlayer(player);
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
this.setNode(0, mode.toString());
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(1, player);
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "whitelist";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BuilderWhitelist getBuilder(EnumMode mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case ADD:
|
||||
case REMOVE:
|
||||
return new BuilderWhitelist(mode, this.getPlayer());
|
||||
case RELOAD:
|
||||
case ON:
|
||||
case OFF:
|
||||
return new BuilderWhitelist(mode);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("add|remove|reload|on|off", Type.STRING);
|
||||
syntax.addOptional("player", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
ADD,
|
||||
REMOVE,
|
||||
RELOAD,
|
||||
ON,
|
||||
OFF;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderWorldHandler extends CommandBuilder
|
||||
{
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "worldhandler";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("help|display|version", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package exopandora.worldhandler.builder.impl.abstr;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilderNBT;
|
||||
import exopandora.worldhandler.builder.types.Coordinate;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public abstract class BuilderBlockPos extends CommandBuilderNBT
|
||||
{
|
||||
public void setPosition(BlockPos pos)
|
||||
{
|
||||
this.setX(pos.getX());
|
||||
this.setY(pos.getY());
|
||||
this.setZ(pos.getZ());
|
||||
}
|
||||
|
||||
public void setX(float x)
|
||||
{
|
||||
this.setX(new Coordinate(x));
|
||||
}
|
||||
|
||||
public void setY(float y)
|
||||
{
|
||||
this.setY(new Coordinate(y));
|
||||
}
|
||||
|
||||
public void setZ(float z)
|
||||
{
|
||||
this.setZ(new Coordinate(z));
|
||||
}
|
||||
|
||||
public void setX(Coordinate x)
|
||||
{
|
||||
this.setNode(0, x);
|
||||
}
|
||||
|
||||
public void setY(Coordinate y)
|
||||
{
|
||||
this.setNode(1, y);
|
||||
}
|
||||
|
||||
public void setZ(Coordinate z)
|
||||
{
|
||||
this.setNode(2, z);
|
||||
}
|
||||
|
||||
public Coordinate getXCoordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(0);
|
||||
}
|
||||
|
||||
public Coordinate getYCoordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(1);
|
||||
}
|
||||
|
||||
public Coordinate getZCoordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(2);
|
||||
}
|
||||
|
||||
public double getX()
|
||||
{
|
||||
return this.getXCoordiante().getValue();
|
||||
}
|
||||
|
||||
public double getY()
|
||||
{
|
||||
return this.getYCoordiante().getValue();
|
||||
}
|
||||
|
||||
public double getZ()
|
||||
{
|
||||
return this.getZCoordiante().getValue();
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos()
|
||||
{
|
||||
return new BlockPos(this.getX(), this.getY(), this.getZ());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package exopandora.worldhandler.builder.impl.abstr;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.types.Coordinate;
|
||||
import exopandora.worldhandler.helper.BlockHelper;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class BuilderDoubleBlockPos extends CommandBuilder
|
||||
{
|
||||
public BuilderDoubleBlockPos()
|
||||
{
|
||||
this.setPosition1(BlockHelper.getPos1());
|
||||
this.setPosition2(BlockHelper.getPos2());
|
||||
}
|
||||
|
||||
public void setPosition1(BlockPos pos)
|
||||
{
|
||||
this.setX1(pos.getX());
|
||||
this.setY1(pos.getY());
|
||||
this.setZ1(pos.getZ());
|
||||
}
|
||||
|
||||
public void setX1(float x)
|
||||
{
|
||||
this.setX1(new Coordinate(x));
|
||||
}
|
||||
|
||||
public void setY1(float y)
|
||||
{
|
||||
this.setY1(new Coordinate(y));
|
||||
}
|
||||
|
||||
public void setZ1(float z)
|
||||
{
|
||||
this.setZ1(new Coordinate(z));
|
||||
}
|
||||
|
||||
public void setX1(Coordinate x)
|
||||
{
|
||||
this.setNode(0, x);
|
||||
BlockHelper.setPos1(BlockHelper.setX(BlockHelper.getPos1(), x.getValue()));
|
||||
}
|
||||
|
||||
public void setY1(Coordinate y)
|
||||
{
|
||||
this.setNode(1, y);
|
||||
BlockHelper.setPos1(BlockHelper.setY(BlockHelper.getPos1(), y.getValue()));
|
||||
}
|
||||
|
||||
public void setZ1(Coordinate z)
|
||||
{
|
||||
this.setNode(2, z);
|
||||
BlockHelper.setPos1(BlockHelper.setZ(BlockHelper.getPos1(), z.getValue()));
|
||||
}
|
||||
|
||||
public Coordinate getX1Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(0);
|
||||
}
|
||||
|
||||
public Coordinate getY1Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(1);
|
||||
}
|
||||
|
||||
public Coordinate getZ1Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(2);
|
||||
}
|
||||
|
||||
public double getX1()
|
||||
{
|
||||
return this.getX1Coordiante().getValue();
|
||||
}
|
||||
|
||||
public double getY1()
|
||||
{
|
||||
return this.getY1Coordiante().getValue();
|
||||
}
|
||||
|
||||
public double getZ1()
|
||||
{
|
||||
return this.getZ1Coordiante().getValue();
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos1()
|
||||
{
|
||||
return new BlockPos(this.getX1(), this.getY1(), this.getZ1());
|
||||
}
|
||||
|
||||
public void setPosition2(BlockPos pos)
|
||||
{
|
||||
this.setX2(pos.getX());
|
||||
this.setY2(pos.getY());
|
||||
this.setZ2(pos.getZ());
|
||||
}
|
||||
|
||||
public void setX2(float x)
|
||||
{
|
||||
this.setX2(new Coordinate(x));
|
||||
}
|
||||
|
||||
public void setY2(float y)
|
||||
{
|
||||
this.setY2(new Coordinate(y));
|
||||
}
|
||||
|
||||
public void setZ2(float z)
|
||||
{
|
||||
this.setZ2(new Coordinate(z));
|
||||
}
|
||||
|
||||
public void setX2(Coordinate x)
|
||||
{
|
||||
this.setNode(3, x);
|
||||
BlockHelper.setPos2(BlockHelper.setX(BlockHelper.getPos2(), x.getValue()));
|
||||
}
|
||||
|
||||
public void setY2(Coordinate y)
|
||||
{
|
||||
this.setNode(4, y);
|
||||
BlockHelper.setPos2(BlockHelper.setY(BlockHelper.getPos2(), y.getValue()));
|
||||
}
|
||||
|
||||
public void setZ2(Coordinate z)
|
||||
{
|
||||
this.setNode(5, z);
|
||||
BlockHelper.setPos2(BlockHelper.setZ(BlockHelper.getPos2(), z.getValue()));
|
||||
}
|
||||
|
||||
public Coordinate getX2Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(3);
|
||||
}
|
||||
|
||||
public Coordinate getY2Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(4);
|
||||
}
|
||||
|
||||
public Coordinate getZ2Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(5);
|
||||
}
|
||||
|
||||
public double getX2()
|
||||
{
|
||||
return this.getX2Coordiante().getValue();
|
||||
}
|
||||
|
||||
public double getY2()
|
||||
{
|
||||
return this.getY2Coordiante().getValue();
|
||||
}
|
||||
|
||||
public double getZ2()
|
||||
{
|
||||
return this.getZ2Coordiante().getValue();
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos2()
|
||||
{
|
||||
return new BlockPos(this.getX2(), this.getY2(), this.getZ2());
|
||||
}
|
||||
|
||||
public <T extends BuilderDoubleBlockPos> T addPositionObservers()
|
||||
{
|
||||
BlockHelper.addPos1Observer(this::setPosition1);
|
||||
BlockHelper.addPos2Observer(this::setPosition2);
|
||||
|
||||
return (T) this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package exopandora.worldhandler.builder.impl.abstr;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class BuilderScoreboard extends CommandBuilder
|
||||
{
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "scoreboard";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package exopandora.worldhandler.builder.impl.abstr;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public enum EnumAttributes
|
||||
{
|
||||
MAX_HEALTH("generic.maxHealth", EnumOperation.ADDITIVE, 0, 100, 0, Applyable.BOTH),
|
||||
FOLLOW_RANGE("generic.followRange", EnumOperation.ADDITIVE, 0, 100, 0, Applyable.MOB),
|
||||
KNOCKBACK_RESISTANCE("generic.knockbackResistance", EnumOperation.PERCENTAGE, 0, 100, 0, Applyable.BOTH),
|
||||
MOVEMENT_SPEED("generic.movementSpeed", EnumOperation.PERCENTAGE, 0, 100, 0, Applyable.BOTH),
|
||||
ATTACK_DAMAGE("generic.attackDamage", EnumOperation.ADDITIVE, 0, 100, 0, Applyable.BOTH),
|
||||
ARMOR("generic.armor", EnumOperation.ADDITIVE, 0, 100, 0, Applyable.BOTH),
|
||||
ARMOR_TOUGHNESS("generic.armorToughness", EnumOperation.ADDITIVE, 0, 100, 0, Applyable.BOTH),
|
||||
ATTACK_SPEED("generic.attackSpeed", EnumOperation.PERCENTAGE, 0, 100, 0, Applyable.BOTH),
|
||||
LUCK("generic.luck", EnumOperation.PERCENTAGE, -100, 100, 0, Applyable.PLAYER),
|
||||
HORSE_JUMP_STRENGTH("horse.jumpStrength", EnumOperation.PERCENTAGE, 0, 100, 0, Applyable.MOB),
|
||||
ZOMBIE_SPAWN_REINFORCEMENTS("zombie.spawnReinforcements", EnumOperation.PERCENTAGE, 0, 100, 0, Applyable.MOB);
|
||||
|
||||
private String attribute;
|
||||
private EnumOperation operation;
|
||||
private float min;
|
||||
private float max;
|
||||
private float start;
|
||||
private Applyable applyable;
|
||||
|
||||
public enum Applyable
|
||||
{
|
||||
BOTH,
|
||||
PLAYER,
|
||||
MOB
|
||||
}
|
||||
|
||||
private EnumAttributes(String attribute, EnumOperation operation, float min, float max, float start, Applyable applyable)
|
||||
{
|
||||
this.attribute = attribute;
|
||||
this.operation = operation;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.start = start;
|
||||
this.applyable = applyable;
|
||||
}
|
||||
|
||||
public String getAttribute()
|
||||
{
|
||||
return this.attribute;
|
||||
}
|
||||
|
||||
public String getTranslationKey()
|
||||
{
|
||||
return "attribute.name." + this.attribute;
|
||||
}
|
||||
|
||||
public String getTranslation()
|
||||
{
|
||||
return I18n.format(this.getTranslationKey(), new Object[0]);
|
||||
}
|
||||
|
||||
public EnumOperation getOperation()
|
||||
{
|
||||
return this.operation;
|
||||
}
|
||||
|
||||
public float getMin()
|
||||
{
|
||||
return this.min;
|
||||
}
|
||||
|
||||
public float getMax()
|
||||
{
|
||||
return this.max;
|
||||
}
|
||||
|
||||
public float getStart()
|
||||
{
|
||||
return this.start;
|
||||
}
|
||||
|
||||
public Applyable getApplyable()
|
||||
{
|
||||
return this.applyable;
|
||||
}
|
||||
|
||||
public double calculate(Float value)
|
||||
{
|
||||
return this.operation.getOperation().apply(value.doubleValue());
|
||||
}
|
||||
|
||||
public enum EnumOperation
|
||||
{
|
||||
ADDITIVE(value -> value, "(+)"),
|
||||
PERCENTAGE(value -> value / 100, "%");
|
||||
|
||||
private final Function<Double, Double> operation;
|
||||
private final String declaration;
|
||||
|
||||
private EnumOperation(Function<Double, Double> operation, String declaration)
|
||||
{
|
||||
this.operation = operation;
|
||||
this.declaration = declaration;
|
||||
}
|
||||
|
||||
public Function<Double, Double> getOperation()
|
||||
{
|
||||
return this.operation;
|
||||
}
|
||||
|
||||
public String getDeclaration()
|
||||
{
|
||||
return this.declaration;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<EnumAttributes> getAttributesFor(Applyable applyable)
|
||||
{
|
||||
return Arrays.stream(EnumAttributes.values()).filter(attribute -> attribute.getApplyable().equals(applyable)).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class Coordinate
|
||||
{
|
||||
private double value;
|
||||
private boolean relative;
|
||||
|
||||
public Coordinate()
|
||||
{
|
||||
this(0, true);
|
||||
}
|
||||
|
||||
public Coordinate(double value)
|
||||
{
|
||||
this(value, false);
|
||||
}
|
||||
|
||||
public Coordinate(double value, boolean relative)
|
||||
{
|
||||
this.relative = relative;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setValue(double value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public double getValue()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setRelative(boolean relative)
|
||||
{
|
||||
this.relative = relative;
|
||||
}
|
||||
|
||||
public boolean isRelative()
|
||||
{
|
||||
return this.relative;
|
||||
}
|
||||
|
||||
public static Coordinate valueOf(String value)
|
||||
{
|
||||
if(value.startsWith("~"))
|
||||
{
|
||||
return new Coordinate(Double.parseDouble(value.substring(1)), true);
|
||||
}
|
||||
|
||||
return new Coordinate(Double.parseDouble(value), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.valueOf(this.relative ? (this.value != 0 ? "~" + this.value : "~") : this.value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class Level
|
||||
{
|
||||
private int level;
|
||||
|
||||
public Level()
|
||||
{
|
||||
this(0);
|
||||
}
|
||||
|
||||
public Level(int level)
|
||||
{
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
return this.level;
|
||||
}
|
||||
|
||||
public void setLevel(int level)
|
||||
{
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public static Level valueOf(String value)
|
||||
{
|
||||
if(value != null)
|
||||
{
|
||||
if(value.matches("[-]?[0-9]+[Ll]?"))
|
||||
{
|
||||
return new Level(Integer.valueOf(value.replaceAll("[lL]$", "")));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.level + "L";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TargetSelector
|
||||
{
|
||||
private final Map<String, Object> values = new HashMap<String, Object>();
|
||||
private static final String REGEX = "@e\\[(.*)\\]";
|
||||
|
||||
public void set(String id, Object value)
|
||||
{
|
||||
this.values.put(id.toLowerCase(), value);
|
||||
}
|
||||
|
||||
public <T> T get(String id)
|
||||
{
|
||||
return (T) this.values.get(id);
|
||||
}
|
||||
|
||||
public Object remove(String id)
|
||||
{
|
||||
return this.values.remove(id.toLowerCase());
|
||||
}
|
||||
|
||||
public static TargetSelector valueOf(String input)
|
||||
{
|
||||
if(input.matches(REGEX));
|
||||
{
|
||||
TargetSelector result = new TargetSelector();
|
||||
|
||||
for(String keys : input.replaceFirst(REGEX, "$1").split(","))
|
||||
{
|
||||
String[] pair = keys.split("=");
|
||||
|
||||
if(pair.length > 1)
|
||||
{
|
||||
result.set(pair[0], pair[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new TargetSelector();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "@e[" + String.join(",", this.values.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue().toString()).collect(Collectors.toList())) + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public enum Type
|
||||
{
|
||||
SHORT(Short::valueOf),
|
||||
BYTE(Byte::valueOf),
|
||||
INT(Integer::valueOf),
|
||||
FLOAT(Float::valueOf),
|
||||
DOUBLE(Double::valueOf),
|
||||
LONG(Long::valueOf),
|
||||
BOOLEAN(Boolean::valueOf),
|
||||
STRING(String::valueOf),
|
||||
RESOURCE_LOCATION(Type::parseResourceLocation),
|
||||
NBT(Type::parseNBTTagCompound),
|
||||
COORDINATE(Coordinate::valueOf),
|
||||
TARGET_SELECTOR(TargetSelector::valueOf),
|
||||
LEVEL(Level::valueOf);
|
||||
|
||||
private final Function<String, Object> parser;
|
||||
|
||||
private Type(Function<String, Object> parser)
|
||||
{
|
||||
this.parser = parser;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <T> T parse(String object)
|
||||
{
|
||||
return (T) this.parser.apply(object);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ResourceLocation parseResourceLocation(String value)
|
||||
{
|
||||
return value != null ? new ResourceLocation(value) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static NBTTagCompound parseNBTTagCompound(String value)
|
||||
{
|
||||
if(value != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonToNBT.getTagFromJson(value);
|
||||
}
|
||||
catch(NBTException nbtexception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
231
src/main/java/exopandora/worldhandler/command/CommandWH.java
Normal file
231
src/main/java/exopandora/worldhandler/command/CommandWH.java
Normal file
@@ -0,0 +1,231 @@
|
||||
package exopandora.worldhandler.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import exopandora.worldhandler.builder.impl.BuilderClone;
|
||||
import exopandora.worldhandler.builder.impl.BuilderClone.EnumMask;
|
||||
import exopandora.worldhandler.builder.impl.BuilderFill;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWH;
|
||||
import exopandora.worldhandler.helper.BlockHelper;
|
||||
import exopandora.worldhandler.helper.EnumHelper;
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.NumberInvalidException;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class CommandWH extends CommandBase
|
||||
{
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "wh";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
|
||||
{
|
||||
if(args.length > 0)
|
||||
{
|
||||
if(args[0].equals("pos1"))
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
|
||||
sender.sendMessage(new TextComponentString("Set first position to " + BlockHelper.getPos1().getX() + ", " + BlockHelper.getPos1().getY() + ", " + BlockHelper.getPos1().getZ() + " (" + Block.REGISTRY.getNameForObject(BlockHelper.getFocusedBlock()) + ")"));
|
||||
}
|
||||
else if(args[0].equals("pos2"))
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
|
||||
sender.sendMessage(new TextComponentString("Set second position to " + BlockHelper.getPos2().getX() + ", " + BlockHelper.getPos2().getY() + ", " + BlockHelper.getPos2().getZ() + " (" + Block.REGISTRY.getNameForObject(BlockHelper.getFocusedBlock()) + ")"));
|
||||
}
|
||||
else if(args[0].equals("fill"))
|
||||
{
|
||||
final String usage = "/wh fill <block> [meta]";
|
||||
|
||||
if(args.length > 1)
|
||||
{
|
||||
ResourceLocation id = new ResourceLocation(args[1]);
|
||||
int meta = 0;
|
||||
|
||||
if(args.length > 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
meta = Integer.parseInt(args[2]);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
throw new WrongUsageException(usage);
|
||||
}
|
||||
}
|
||||
|
||||
if(!ResourceHelper.isRegisteredBlock(id.toString()))
|
||||
{
|
||||
throw new NumberInvalidException(usage);
|
||||
}
|
||||
|
||||
BuilderFill builder = new BuilderFill();
|
||||
builder.setBlock1(id);
|
||||
builder.setMeta1(meta);
|
||||
|
||||
WorldHandler.sendCommand(builder);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(usage);
|
||||
}
|
||||
}
|
||||
else if(args[0].equals("replace"))
|
||||
{
|
||||
final String usage = "/wh replace <block1> <meta1> <block2> [meta2]";
|
||||
|
||||
if(args.length > 1)
|
||||
{
|
||||
ResourceLocation id1 = new ResourceLocation(args[1]);
|
||||
|
||||
if(args.length > 2)
|
||||
{
|
||||
ResourceLocation id2 = new ResourceLocation(args[3]);
|
||||
int meta1 = 0;
|
||||
int meta2 = 0;
|
||||
|
||||
try
|
||||
{
|
||||
meta1 = Integer.parseInt(args[2]);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
throw new WrongUsageException(usage);
|
||||
}
|
||||
|
||||
if(args.length > 4)
|
||||
{
|
||||
try
|
||||
{
|
||||
meta2 = Integer.parseInt(args[4]);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
throw new WrongUsageException(usage);
|
||||
}
|
||||
}
|
||||
|
||||
if(!ResourceHelper.isRegisteredBlock(id1.toString()) || !ResourceHelper.isRegisteredBlock(id2.toString()))
|
||||
{
|
||||
throw new WrongUsageException(usage);
|
||||
}
|
||||
|
||||
BuilderFill builder = new BuilderFill();
|
||||
builder.setPosition1(BlockHelper.getPos1());
|
||||
builder.setPosition2(BlockHelper.getPos2());
|
||||
builder.setBlock1(id1);
|
||||
builder.setMeta1(meta1);
|
||||
builder.setBlock2(id2);
|
||||
builder.setMeta2(meta2);
|
||||
|
||||
Minecraft.getMinecraft().player.sendChatMessage(builder.getBuilderForReplace().toActualCommand());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(usage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(usage);
|
||||
}
|
||||
}
|
||||
else if(args[0].equals("clone"))
|
||||
{
|
||||
final String usage = "/wh clone [" + String.join("|", Arrays.stream(EnumMask.MASKED.values()).map(EnumMask::toString).collect(Collectors.toList())) + "]";
|
||||
EnumMask mask = EnumMask.MASKED;
|
||||
|
||||
if(args.length > 1)
|
||||
{
|
||||
mask = EnumHelper.valueOf(EnumMask.class, args[1]);
|
||||
}
|
||||
|
||||
if(mask == null)
|
||||
{
|
||||
throw new WrongUsageException(usage);
|
||||
}
|
||||
|
||||
BuilderClone builder = new BuilderClone();
|
||||
builder.setPosition1(BlockHelper.getPos1());
|
||||
builder.setPosition2(BlockHelper.getPos2());
|
||||
builder.setMask(mask);
|
||||
|
||||
Minecraft.getMinecraft().player.sendChatMessage(builder.toActualCommand());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(new BuilderWH().toCommand());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(new BuilderWH().toCommand());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos)
|
||||
{
|
||||
if(args.length == 1)
|
||||
{
|
||||
return this.getListOfStringsMatchingLastWord(args, new String[]{"pos1", "pos2", "fill", "replace", "clone"});
|
||||
}
|
||||
else if(args.length == 2)
|
||||
{
|
||||
if(args[0].equals("fill") || args[0].equals("replace"))
|
||||
{
|
||||
return this.getListOfStringsMatchingLastWord(args, Block.REGISTRY.getKeys());
|
||||
}
|
||||
else if(args[0].equals("clone"))
|
||||
{
|
||||
return this.getListOfStringsMatchingLastWord(args, new String[]{"replace", "masked", "filtered"});
|
||||
}
|
||||
}
|
||||
else if(args.length == 3)
|
||||
{
|
||||
if(args[0].equals("fill") || args[0].equals("replace"))
|
||||
{
|
||||
return this.getListOfStringsMatchingLastWord(args, new String[] {"0"});
|
||||
}
|
||||
}
|
||||
else if(args.length == 4)
|
||||
{
|
||||
if(args[0].equals("replace"))
|
||||
{
|
||||
return this.getListOfStringsMatchingLastWord(args, Block.REGISTRY.getKeys());
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.<String>emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage(ICommandSender sender)
|
||||
{
|
||||
return new BuilderWH().toCommand();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package exopandora.worldhandler.command;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.builder.impl.BuilderWorldHandler;
|
||||
import exopandora.worldhandler.event.EventHandler;
|
||||
import exopandora.worldhandler.main.Main;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.common.ForgeVersion;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.versioning.ComparableVersion;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class CommandWorldHandler extends CommandBase
|
||||
{
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "worldhandler";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
|
||||
{
|
||||
if(args.length > 0)
|
||||
{
|
||||
if(args[0].equalsIgnoreCase("help"))
|
||||
{
|
||||
this.printHelp(sender);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("display"))
|
||||
{
|
||||
new Thread(() -> Minecraft.getMinecraft().addScheduledTask(EventHandler::displayGui)).start();
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("version"))
|
||||
{
|
||||
sender.sendMessage(new TextComponentString("Installed: " + Main.MC_VERSION + "-" + Main.VERSION));
|
||||
ComparableVersion target = ForgeVersion.getResult(Loader.instance().getIndexedModList().get(Main.MODID)).target;
|
||||
sender.sendMessage(new TextComponentString("Latest: " + Main.MC_VERSION + "-" + (target != null ? target : Main.VERSION)));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(this.getUsage(sender));
|
||||
}
|
||||
}
|
||||
else if(args.length == 0)
|
||||
{
|
||||
this.printHelp(sender);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(this.getUsage(sender));
|
||||
}
|
||||
}
|
||||
|
||||
private void printHelp(ICommandSender player)
|
||||
{
|
||||
player.sendMessage(new TextComponentString(ChatFormatting.DARK_GREEN + "--- Showing help page 1 of 1 (/worldhandler help) ---"));
|
||||
player.sendMessage(new TextComponentString("/worldhandler help"));
|
||||
player.sendMessage(new TextComponentString("/worldhandler display"));
|
||||
player.sendMessage(new TextComponentString("/worldhandler version"));
|
||||
player.sendMessage(new TextComponentString(ChatFormatting.GREEN + "Tip: Press '" + WorldHandler.KEY_WORLD_HANDLER.getDisplayName() + "' to open the World Handler"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos)
|
||||
{
|
||||
if(args.length == 1)
|
||||
{
|
||||
return this.getListOfStringsMatchingLastWord(args, new String[]{"help", "display", "version"});
|
||||
}
|
||||
|
||||
return Collections.<String>emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage(ICommandSender sender)
|
||||
{
|
||||
return new BuilderWorldHandler().toCommand();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package exopandora.worldhandler.command;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.command.CommandHandler;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.client.event.ClientChatEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class FakeCommandHandler extends CommandHandler
|
||||
{
|
||||
@Override
|
||||
protected MinecraftServer getServer()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private void fakeCommand(ICommand command, ClientChatEvent event)
|
||||
{
|
||||
Minecraft.getMinecraft().ingameGUI.getChatGUI().addToSentMessages(event.getMessage());
|
||||
this.tryExecute(Minecraft.getMinecraft().player, dropFirstString(event.getMessage().split(" ")), command, event.getMessage());
|
||||
|
||||
if(event != null && event.isCancelable())
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] dropFirstString(String[] input)
|
||||
{
|
||||
String[] string = new String[input.length - 1];
|
||||
System.arraycopy(input, 1, string, 0, input.length - 1);
|
||||
return string;
|
||||
}
|
||||
|
||||
public void tryCommand(ICommand command, ClientChatEvent event)
|
||||
{
|
||||
if(event.getMessage().startsWith("/" + command.getName()) || event.getMessage().startsWith("/" + command.getName() + " "))
|
||||
{
|
||||
this.fakeCommand(command, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package exopandora.worldhandler.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import exopandora.worldhandler.helper.EntityHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ConfigButcher
|
||||
{
|
||||
private static Map<String, Boolean> ENTITIES = new HashMap<String, Boolean>();
|
||||
|
||||
public static final String CATEGORY = "butcher";
|
||||
|
||||
public static void load(Configuration config)
|
||||
{
|
||||
for(ResourceLocation location : EntityList.ENTITY_EGGS.keySet())
|
||||
{
|
||||
String entity = EntityHelper.getEntityName(location);
|
||||
String translationKey = "entity." + entity + ".name";
|
||||
String translation = I18n.format(translationKey);
|
||||
|
||||
if(!translation.equals(translationKey))
|
||||
{
|
||||
ENTITIES.put(entity, config.getBoolean(entity, CATEGORY, false, I18n.format("gui.worldhandler.config.comment.butcher", translation), translationKey));
|
||||
}
|
||||
}
|
||||
|
||||
if(config.hasChanged())
|
||||
{
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, Boolean> getEntitiyMap()
|
||||
{
|
||||
return ENTITIES;
|
||||
}
|
||||
}
|
||||
129
src/main/java/exopandora/worldhandler/config/ConfigSettings.java
Normal file
129
src/main/java/exopandora/worldhandler/config/ConfigSettings.java
Normal file
@@ -0,0 +1,129 @@
|
||||
package exopandora.worldhandler.config;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ConfigSettings
|
||||
{
|
||||
private static boolean BIOME_INDICATOR;
|
||||
private static boolean COMMAND_SYNTAX;
|
||||
private static boolean SHORTCUTS;
|
||||
private static boolean SHORTCUT_KEYS;
|
||||
private static boolean TOOLTIPS;
|
||||
private static boolean WATCH;
|
||||
private static boolean SMOOTH_WATCH;
|
||||
private static boolean PAUSE;
|
||||
private static boolean CUSTOM_TIMES;
|
||||
private static boolean PERMISSION_QEURY;
|
||||
|
||||
private static int DAWN;
|
||||
private static int NOON;
|
||||
private static int SUNSET;
|
||||
private static int MIDNIGHT;
|
||||
|
||||
private static String BLOCK_PLACING_MODE;
|
||||
|
||||
public static final String CATEGORY = "settings";
|
||||
|
||||
public static void load(Configuration config)
|
||||
{
|
||||
BIOME_INDICATOR = config.getBoolean("biome_indicator", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.biome_indicator"), "gui.worldhandler.config.key.settings.biome_indicator");
|
||||
COMMAND_SYNTAX = config.getBoolean("command_syntax", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.command_syntax"), "gui.worldhandler.config.key.settings.command_syntax");
|
||||
SHORTCUTS = config.getBoolean("shortcuts", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.shortcuts"), "gui.worldhandler.config.key.settings.shortcuts");
|
||||
SHORTCUT_KEYS = config.getBoolean("key_shortcuts", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.key_shortcuts"), "gui.worldhandler.config.key.settings.key_shortcuts");
|
||||
TOOLTIPS = config.getBoolean("tooltips", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.tooltips"), "gui.worldhandler.config.key.settings.tooltips");
|
||||
WATCH = config.getBoolean("watch", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.watch"), "gui.worldhandler.config.key.settings.watch");
|
||||
SMOOTH_WATCH = config.getBoolean("smooth_watch", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.smooth_watch"), "gui.worldhandler.config.key.settings.smooth_watch");
|
||||
PAUSE = config.getBoolean("pause_game", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.pause_game"), "gui.worldhandler.config.key.settings.pause_game");
|
||||
CUSTOM_TIMES = config.getBoolean("custom_times", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.custom_times"), "gui.worldhandler.config.key.settings.custom_times");
|
||||
PERMISSION_QEURY = config.getBoolean("permission_query", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.permission_query"), "gui.worldhandler.config.key.settings.permission_query");
|
||||
DAWN = config.getInt("custom_time_dawn", CATEGORY, 1000, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_dawn"), "gui.worldhandler.config.key.settings.custom_time_dawn");
|
||||
NOON = config.getInt("custom_time_noon", CATEGORY, 6000, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_noon"), "gui.worldhandler.config.key.settings.custom_time_noon");
|
||||
SUNSET = config.getInt("custom_time_sunset", CATEGORY, 12500, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_sunset"), "gui.worldhandler.config.key.settings.custom_time_sunset");
|
||||
MIDNIGHT = config.getInt("custom_time_midnight", CATEGORY, 18000, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_midnight"), "gui.worldhandler.config.key.settings.custom_time_midnight");
|
||||
BLOCK_PLACING_MODE = config.getString("block_placing_mode", CATEGORY, "keep", I18n.format("gui.worldhandler.config.comment.settings.block_placing_mode"), new String[]{"keep", "replace", "destroy"}, "gui.worldhandler.config.key.settings.block_placing_mode");
|
||||
|
||||
if(config.hasChanged())
|
||||
{
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBiomeIndicatorEnabled()
|
||||
{
|
||||
return BIOME_INDICATOR;
|
||||
}
|
||||
|
||||
public static boolean isCommandSyntaxEnabled()
|
||||
{
|
||||
return COMMAND_SYNTAX;
|
||||
}
|
||||
|
||||
public static boolean areShortcutsEnabled()
|
||||
{
|
||||
return SHORTCUTS;
|
||||
}
|
||||
|
||||
public static boolean arePosShortcutsEnabled()
|
||||
{
|
||||
return SHORTCUT_KEYS;
|
||||
}
|
||||
|
||||
public static boolean areTooltipsEnabled()
|
||||
{
|
||||
return TOOLTIPS;
|
||||
}
|
||||
|
||||
public static boolean isWatchEnabled()
|
||||
{
|
||||
return WATCH;
|
||||
}
|
||||
|
||||
public static boolean isSmoothWatchEnabled()
|
||||
{
|
||||
return SMOOTH_WATCH;
|
||||
}
|
||||
|
||||
public static boolean isPauseEnabled()
|
||||
{
|
||||
return PAUSE;
|
||||
}
|
||||
|
||||
public static boolean isCustomTimeEnabled()
|
||||
{
|
||||
return CUSTOM_TIMES;
|
||||
}
|
||||
|
||||
public static boolean isPermissionQueryEnabled()
|
||||
{
|
||||
return PERMISSION_QEURY;
|
||||
}
|
||||
|
||||
public static int getDawn()
|
||||
{
|
||||
return DAWN;
|
||||
}
|
||||
|
||||
public static int getNoon()
|
||||
{
|
||||
return NOON;
|
||||
}
|
||||
|
||||
public static int getSunset()
|
||||
{
|
||||
return SUNSET;
|
||||
}
|
||||
|
||||
public static int getMidnight()
|
||||
{
|
||||
return MIDNIGHT;
|
||||
}
|
||||
|
||||
public static String getMode()
|
||||
{
|
||||
return BLOCK_PLACING_MODE;
|
||||
}
|
||||
}
|
||||
127
src/main/java/exopandora/worldhandler/config/ConfigSkin.java
Normal file
127
src/main/java/exopandora/worldhandler/config/ConfigSkin.java
Normal file
@@ -0,0 +1,127 @@
|
||||
package exopandora.worldhandler.config;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ConfigSkin
|
||||
{
|
||||
private static int ICON_SIZE;
|
||||
private static int LABEL_COLOR;
|
||||
private static int HEADLINE_COLOR;
|
||||
|
||||
private static int BACKGROUND_RED;
|
||||
private static int BACKGROUND_GREEN;
|
||||
private static int BACKGROUND_BLUE;
|
||||
private static int BACKGROUND_ALPHA;
|
||||
|
||||
private static int BUTTON_RED;
|
||||
private static int BUTTON_GREEN;
|
||||
private static int BUTTON_BLUE;
|
||||
private static int BUTTON_ALPHA;
|
||||
|
||||
private static String TYPE;
|
||||
|
||||
private static boolean SHARP_EDGES;
|
||||
private static boolean DRAW_BACKGROUND;
|
||||
|
||||
public static final String CATEGORY = "skin";
|
||||
|
||||
public static void load(Configuration config)
|
||||
{
|
||||
ICON_SIZE = Integer.valueOf(config.getString("icon_size", CATEGORY, "16", I18n.format("gui.worldhandler.config.comment.skin.icons"), new String[]{"16", "32", "64"}, "gui.worldhandler.config.key.skin.icons"));
|
||||
LABEL_COLOR = config.getInt("label_color", CATEGORY, 0x1F1F1F, 0x80000000, 0x7FFFFFFF, I18n.format("gui.worldhandler.config.comment.skin.label_color"), "gui.worldhandler.config.key.skin.label_color");
|
||||
HEADLINE_COLOR = config.getInt("headline_color", CATEGORY, 0x4F4F4F, 0x80000000, 0x7FFFFFFF, I18n.format("gui.worldhandler.config.comment.skin.headline_color"), "gui.worldhandler.config.key.skin.headline_color");
|
||||
|
||||
BACKGROUND_RED = config.getInt("background_red", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.background_red"), "gui.worldhandler.config.key.skin.background_red");
|
||||
BACKGROUND_GREEN = config.getInt("background_green", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.background_green"), "gui.worldhandler.config.key.skin.background_green");
|
||||
BACKGROUND_BLUE = config.getInt("background_blue", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.background_blue"), "gui.worldhandler.config.key.skin.background_blue");
|
||||
BACKGROUND_ALPHA = config.getInt("background_alpha", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.background_alpha"), "gui.worldhandler.config.key.skin.background_alpha");
|
||||
|
||||
BUTTON_RED = config.getInt("button_red", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.button_red"), "gui.worldhandler.config.key.skin.button_red");
|
||||
BUTTON_GREEN = config.getInt("button_green", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.button_green"), "gui.worldhandler.config.key.skin.button_green");
|
||||
BUTTON_BLUE = config.getInt("button_blue", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.button_blue"), "gui.worldhandler.config.key.skin.button_blue");
|
||||
BUTTON_ALPHA = config.getInt("button_alpha", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.button_alpha"), "gui.worldhandler.config.key.skin.button_alpha");
|
||||
|
||||
TYPE = config.getString("textures", CATEGORY, "resourcepack", I18n.format("gui.worldhandler.config.comment.skin.textures"), new String[]{"resourcepack", "vanilla"}, "gui.worldhandler.config.key.skin.textures");
|
||||
SHARP_EDGES = config.getBoolean("sharp_tab_edges", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.skin.sharp_tab_edges"), "gui.worldhandler.config.key.skin.sharp_tab_edges");
|
||||
DRAW_BACKGROUND = config.getBoolean("draw_background", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.skin.draw_background"), "gui.worldhandler.config.key.skin.draw_background");
|
||||
|
||||
if(config.hasChanged())
|
||||
{
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
|
||||
public static int getIconSize()
|
||||
{
|
||||
return ICON_SIZE;
|
||||
}
|
||||
|
||||
public static int getLabelColor()
|
||||
{
|
||||
return LABEL_COLOR;
|
||||
}
|
||||
|
||||
public static int getHeadlineColor()
|
||||
{
|
||||
return HEADLINE_COLOR;
|
||||
}
|
||||
|
||||
public static int getBackgroundRed()
|
||||
{
|
||||
return BACKGROUND_RED;
|
||||
}
|
||||
|
||||
public static int getBackgroundGreen()
|
||||
{
|
||||
return BACKGROUND_GREEN;
|
||||
}
|
||||
|
||||
public static int getBackgroundBlue()
|
||||
{
|
||||
return BACKGROUND_BLUE;
|
||||
}
|
||||
|
||||
public static int getButtonRed()
|
||||
{
|
||||
return BUTTON_RED;
|
||||
}
|
||||
|
||||
public static int getButtonGreen()
|
||||
{
|
||||
return BUTTON_GREEN;
|
||||
}
|
||||
|
||||
public static int getButtonBlue()
|
||||
{
|
||||
return BUTTON_BLUE;
|
||||
}
|
||||
|
||||
public static String getTextureType()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static boolean areSharpEdgesEnabled()
|
||||
{
|
||||
return SHARP_EDGES;
|
||||
}
|
||||
|
||||
public static boolean isBackgroundDrawingEnabled()
|
||||
{
|
||||
return DRAW_BACKGROUND;
|
||||
}
|
||||
|
||||
public static int getBackgroundAlpha()
|
||||
{
|
||||
return BACKGROUND_ALPHA;
|
||||
}
|
||||
|
||||
public static int getButtonAlpha()
|
||||
{
|
||||
return BUTTON_ALPHA;
|
||||
}
|
||||
}
|
||||
103
src/main/java/exopandora/worldhandler/event/EventHandler.java
Normal file
103
src/main/java/exopandora/worldhandler/event/EventHandler.java
Normal file
@@ -0,0 +1,103 @@
|
||||
package exopandora.worldhandler.event;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.command.FakeCommandHandler;
|
||||
import exopandora.worldhandler.config.ConfigSettings;
|
||||
import exopandora.worldhandler.gui.container.impl.GuiWorldHandlerContainer;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.helper.BlockHelper;
|
||||
import exopandora.worldhandler.hud.BiomeIndicator;
|
||||
import exopandora.worldhandler.main.Main;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import exopandora.worldhandler.util.UtilPlayer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.client.event.ClientChatEvent;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class EventHandler
|
||||
{
|
||||
private final FakeCommandHandler commandHandler = new FakeCommandHandler();
|
||||
|
||||
@SubscribeEvent
|
||||
public void clientTickEvent(TickEvent.ClientTickEvent event)
|
||||
{
|
||||
if(Minecraft.getMinecraft().inGameHasFocus && event.phase.equals(Phase.START))
|
||||
{
|
||||
if(ConfigSettings.isBiomeIndicatorEnabled())
|
||||
{
|
||||
BiomeIndicator.tick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void keyInputEvent(KeyInputEvent event)
|
||||
{
|
||||
if(WorldHandler.KEY_WORLD_HANDLER.isPressed())
|
||||
{
|
||||
displayGui();
|
||||
}
|
||||
else if(WorldHandler.KEY_WORLD_HANDLER_POS1.isPressed() && ConfigSettings.arePosShortcutsEnabled())
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
|
||||
}
|
||||
else if(WorldHandler.KEY_WORLD_HANDLER_POS2.isPressed() && ConfigSettings.arePosShortcutsEnabled())
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onConfigChanged(OnConfigChangedEvent event)
|
||||
{
|
||||
if(event.getModID().equals(Main.MODID))
|
||||
{
|
||||
WorldHandler.updateConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void clientChatEvent(ClientChatEvent event)
|
||||
{
|
||||
if(!Minecraft.getMinecraft().isSingleplayer())
|
||||
{
|
||||
this.commandHandler.tryCommand(WorldHandler.COMMAND_WORLD_HANDLER, event);
|
||||
this.commandHandler.tryCommand(WorldHandler.COMMAND_WH, event);
|
||||
}
|
||||
}
|
||||
|
||||
public static void displayGui()
|
||||
{
|
||||
if(!UtilPlayer.canIssueCommand() && ConfigSettings.isPermissionQueryEnabled())
|
||||
{
|
||||
Minecraft.getMinecraft().player.sendMessage(new TextComponentString(ChatFormatting.RED + I18n.format("worldhandler.permission.refused")));
|
||||
Minecraft.getMinecraft().player.sendMessage(new TextComponentString(ChatFormatting.RED + I18n.format("worldhandler.permission.refused.change", I18n.format("gui.worldhandler.config.key.settings.permission_query"))));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(BlockHelper.isFocusedBlockEqualTo(Blocks.STANDING_SIGN) || BlockHelper.isFocusedBlockEqualTo(Blocks.WALL_SIGN))
|
||||
{
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.SIGN_EDITOR));
|
||||
}
|
||||
else if(BlockHelper.isFocusedBlockEqualTo(Blocks.NOTEBLOCK))
|
||||
{
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.NOTE_EDITOR));
|
||||
}
|
||||
else
|
||||
{
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.MAIN));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
67
src/main/java/exopandora/worldhandler/format/EnumColor.java
Normal file
67
src/main/java/exopandora/worldhandler/format/EnumColor.java
Normal file
@@ -0,0 +1,67 @@
|
||||
package exopandora.worldhandler.format;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public enum EnumColor
|
||||
{
|
||||
DEFAULT("reset", "r"),
|
||||
YELLOW("yellow", "e"),
|
||||
GOLD("gold", "6"),
|
||||
DARK_RED("dark_red", "4"),
|
||||
RED("red", "c"),
|
||||
LIGHT_PURPLE("light_purple", "d"),
|
||||
DARK_PURPLE("dark_purple", "5"),
|
||||
BLUE("blue", "9"),
|
||||
DARK_BLUE("dark_blue", "1"),
|
||||
DARK_AQUA("dark_aqua", "3"),
|
||||
AQUA("aqua", "b"),
|
||||
GREEN("green", "a"),
|
||||
DARK_GREEN("dark_green", "2"),
|
||||
BLACK("black", "0"),
|
||||
DARK_GRAY("dark_gray", "8"),
|
||||
GRAY("gray", "7"),
|
||||
WHITE("white", "f"),
|
||||
|
||||
OBFUSCATED("obfuscated", "k"),
|
||||
BOLD("bold", "l"),
|
||||
STRIKETHROUGH("strikethrough", "m"),
|
||||
UNDERLINED("underlined", "n"),
|
||||
ITALIC("italic", "o");
|
||||
|
||||
private String format;
|
||||
private String prefix;
|
||||
|
||||
private EnumColor(String format, String prefix)
|
||||
{
|
||||
this.format = format;
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public String getFormat()
|
||||
{
|
||||
return this.format;
|
||||
}
|
||||
|
||||
public String getPrefix()
|
||||
{
|
||||
return this.prefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "\u00A7" + this.prefix;
|
||||
}
|
||||
|
||||
public static EnumColor getColorFromId(int id)
|
||||
{
|
||||
if(id >= 0 && id < EnumColor.values().length)
|
||||
{
|
||||
return EnumColor.values()[id];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
169
src/main/java/exopandora/worldhandler/format/TextFormatting.java
Normal file
169
src/main/java/exopandora/worldhandler/format/TextFormatting.java
Normal file
@@ -0,0 +1,169 @@
|
||||
package exopandora.worldhandler.format;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TextFormatting
|
||||
{
|
||||
public static String getFormatting(int id)
|
||||
{
|
||||
if(id >= 0 && id < EnumColor.values().length)
|
||||
{
|
||||
return EnumColor.values()[id].getFormat();
|
||||
}
|
||||
|
||||
return EnumColor.DEFAULT.getFormat();
|
||||
}
|
||||
|
||||
public static String getPrefix(int id)
|
||||
{
|
||||
if(id >= 0 && id < EnumColor.values().length)
|
||||
{
|
||||
return EnumColor.values()[id].getPrefix();
|
||||
}
|
||||
|
||||
return EnumColor.DEFAULT.getPrefix();
|
||||
}
|
||||
|
||||
public static String format(String text, int color, boolean obfuscated, boolean bold, boolean strikethrough, boolean underlined, boolean italic)
|
||||
{
|
||||
String formattedText = text;
|
||||
|
||||
if(italic)
|
||||
{
|
||||
formattedText = ChatFormatting.ITALIC + formattedText;
|
||||
}
|
||||
|
||||
if(underlined)
|
||||
{
|
||||
formattedText = ChatFormatting.UNDERLINE + formattedText;
|
||||
}
|
||||
|
||||
if(strikethrough)
|
||||
{
|
||||
formattedText = ChatFormatting.STRIKETHROUGH + formattedText;
|
||||
}
|
||||
|
||||
if(bold)
|
||||
{
|
||||
formattedText = ChatFormatting.BOLD + formattedText;
|
||||
}
|
||||
|
||||
if(obfuscated)
|
||||
{
|
||||
formattedText = ChatFormatting.OBFUSCATED + formattedText;
|
||||
}
|
||||
|
||||
if(color >= 0 && color < EnumColor.values().length)
|
||||
{
|
||||
formattedText = "\u00A7" + EnumColor.values()[color].getPrefix() + formattedText;
|
||||
}
|
||||
|
||||
return formattedText;
|
||||
}
|
||||
|
||||
public static String formatFinal(String text, Integer color, boolean obfuscated, boolean bold, boolean strikethrough, boolean underlined, boolean italic)
|
||||
{
|
||||
String formattedText = format(ChatFormatting.stripFormatting(text), color, obfuscated, bold, strikethrough, underlined, italic);
|
||||
|
||||
if(!formattedText.equals(text))
|
||||
{
|
||||
formattedText += ChatFormatting.RESET;
|
||||
}
|
||||
|
||||
return formattedText;
|
||||
}
|
||||
|
||||
public static String shortenString(String str, int maxWidth, FontRenderer fontRenderer)
|
||||
{
|
||||
return TextFormatting.shortenString(str, "", maxWidth, fontRenderer);
|
||||
}
|
||||
|
||||
public static String shortenString(String str, String prefix, int maxWidth, FontRenderer fontRenderer)
|
||||
{
|
||||
String display = prefix;
|
||||
|
||||
if(fontRenderer.getStringWidth(prefix + str) > (maxWidth - fontRenderer.getStringWidth(prefix)))
|
||||
{
|
||||
for(int x = 0; x < str.length(); x++)
|
||||
{
|
||||
if(fontRenderer.getStringWidth(display + str.charAt(x) + "...") < maxWidth)
|
||||
{
|
||||
display += str.charAt(x);
|
||||
}
|
||||
else
|
||||
{
|
||||
display += "...";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
display += str;
|
||||
}
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
public static String getTotalTimePlayed(long tick)
|
||||
{
|
||||
int days = 0;
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
int seconds = 0;
|
||||
|
||||
seconds = (int) (tick / 20);
|
||||
|
||||
if(seconds > 60)
|
||||
{
|
||||
int min = MathHelper.floor(seconds / 60);
|
||||
seconds = seconds % 60;
|
||||
minutes = min;
|
||||
}
|
||||
|
||||
if(minutes > 60)
|
||||
{
|
||||
int hrs = MathHelper.floor(minutes / 60);
|
||||
minutes = minutes % 60;
|
||||
hours = hrs;
|
||||
}
|
||||
|
||||
if(hours > 24)
|
||||
{
|
||||
int day = MathHelper.floor(hours / 24);
|
||||
hours = hours % 24;
|
||||
days = day;
|
||||
}
|
||||
|
||||
return String.format("%d:%02d:%02d:%02d", days, hours, minutes, seconds);
|
||||
}
|
||||
|
||||
public static int getHour(long tick)
|
||||
{
|
||||
int hour = MathHelper.floor((tick + 6000) / 1000F) % 24;
|
||||
|
||||
return hour;
|
||||
}
|
||||
|
||||
public static int getMinute(long tick)
|
||||
{
|
||||
int hour = MathHelper.floor((tick + 6000F) / 1000F);
|
||||
int minute = MathHelper.floor((tick + 6000F - hour * 1000) * 6 / 100);
|
||||
|
||||
return minute;
|
||||
}
|
||||
|
||||
public static String getWorldTime(long tick)
|
||||
{
|
||||
int hour = TextFormatting.getHour(tick);
|
||||
int minute = TextFormatting.getMinute(tick);
|
||||
|
||||
return String.format("%02d:%02d", hour, minute);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package exopandora.worldhandler.format.text;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.format.EnumColor;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ColoredString extends FormattedString
|
||||
{
|
||||
private EnumColor color = EnumColor.DEFAULT;
|
||||
private static final String EMPTY_STRING = "(\u00A7[a-f0-9k-or]?)*";
|
||||
|
||||
public ColoredString(String string)
|
||||
{
|
||||
this.text = string;
|
||||
}
|
||||
|
||||
public ColoredString()
|
||||
{
|
||||
this("");
|
||||
}
|
||||
|
||||
public void setText(String string)
|
||||
{
|
||||
this.text = ChatFormatting.stripFormatting(string);
|
||||
}
|
||||
|
||||
public EnumColor getColor()
|
||||
{
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public void setColor(EnumColor color)
|
||||
{
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public void setColor(int color)
|
||||
{
|
||||
this.color = EnumColor.getColorFromId(color);
|
||||
}
|
||||
|
||||
public boolean isSpecial()
|
||||
{
|
||||
if(this.text != null && !this.text.isEmpty())
|
||||
{
|
||||
return this.toString().contains("\u00A7");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private String getFormattedString(String string)
|
||||
{
|
||||
String result = string;
|
||||
|
||||
if(result != null)
|
||||
{
|
||||
if(this.italic)
|
||||
{
|
||||
result = ChatFormatting.ITALIC + result;
|
||||
}
|
||||
|
||||
if(this.underlined)
|
||||
{
|
||||
result = ChatFormatting.UNDERLINE + result;
|
||||
}
|
||||
|
||||
if(this.strikethrough)
|
||||
{
|
||||
result = ChatFormatting.STRIKETHROUGH + result;
|
||||
}
|
||||
|
||||
if(this.bold)
|
||||
{
|
||||
result = ChatFormatting.BOLD + result;
|
||||
}
|
||||
|
||||
if(this.obfuscated)
|
||||
{
|
||||
result = ChatFormatting.OBFUSCATED + result;
|
||||
}
|
||||
|
||||
if(this.color != null && !this.color.equals(EnumColor.DEFAULT))
|
||||
{
|
||||
result = this.color + result;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getTextFieldString()
|
||||
{
|
||||
if(this.text != null)
|
||||
{
|
||||
return this.getFormattedString(super.getPreformattedString(this.text));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if(this.text != null)
|
||||
{
|
||||
String result = super.getPreformattedString(this.text);
|
||||
|
||||
if(!result.matches(EMPTY_STRING))
|
||||
{
|
||||
result = this.getFormattedString(result);
|
||||
}
|
||||
|
||||
if(result.contains("\u00A7"))
|
||||
{
|
||||
result += ChatFormatting.RESET;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package exopandora.worldhandler.format.text;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class FormattedString
|
||||
{
|
||||
protected String text;
|
||||
|
||||
protected boolean underlined;
|
||||
protected boolean bold;
|
||||
protected boolean italic;
|
||||
protected boolean strikethrough;
|
||||
protected boolean obfuscated;
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public void setText(String string)
|
||||
{
|
||||
this.text = string;
|
||||
}
|
||||
|
||||
public boolean isUnderlined()
|
||||
{
|
||||
return this.underlined;
|
||||
}
|
||||
|
||||
public void setUnderlined(boolean underlined)
|
||||
{
|
||||
this.underlined = underlined;
|
||||
}
|
||||
|
||||
public boolean isBold()
|
||||
{
|
||||
return this.bold;
|
||||
}
|
||||
|
||||
public void setBold(boolean bold)
|
||||
{
|
||||
this.bold = bold;
|
||||
}
|
||||
|
||||
public boolean isItalic()
|
||||
{
|
||||
return this.italic;
|
||||
}
|
||||
|
||||
public void setItalic(boolean italic)
|
||||
{
|
||||
this.italic = italic;
|
||||
}
|
||||
|
||||
public boolean isStriked()
|
||||
{
|
||||
return this.strikethrough;
|
||||
}
|
||||
|
||||
public void setStriked(boolean striked)
|
||||
{
|
||||
this.strikethrough = striked;
|
||||
}
|
||||
|
||||
public boolean isObfuscated()
|
||||
{
|
||||
return this.obfuscated;
|
||||
}
|
||||
|
||||
public void setObfuscated(boolean obfuscated)
|
||||
{
|
||||
this.obfuscated = obfuscated;
|
||||
}
|
||||
|
||||
public static String getPreformattedString(String string)
|
||||
{
|
||||
if(string != null)
|
||||
{
|
||||
return string.replaceAll("\u0026", "\u00A7").replaceAll("\u00A7\u00A7", "\u0026");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package exopandora.worldhandler.format.text;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class JsonClickEvent
|
||||
{
|
||||
private String action;
|
||||
private String value;
|
||||
|
||||
public JsonClickEvent()
|
||||
{
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public JsonClickEvent(String action, String value)
|
||||
{
|
||||
this.action = action;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getAction()
|
||||
{
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public void setAction(String action)
|
||||
{
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(String value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package exopandora.worldhandler.format.text;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class JsonSignLine extends FormattedString
|
||||
{
|
||||
private String color;
|
||||
private JsonClickEvent clickEvent;
|
||||
|
||||
public JsonSignLine()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public JsonSignLine(ColoredString string)
|
||||
{
|
||||
this.text = super.getPreformattedString(string.getText());
|
||||
this.color = string.getColor().getFormat();
|
||||
this.bold = string.isBold();
|
||||
this.strikethrough = string.isStriked();
|
||||
this.underlined = string.isUnderlined();
|
||||
this.italic = string.isItalic();
|
||||
this.obfuscated = string.isObfuscated();
|
||||
}
|
||||
|
||||
public JsonClickEvent getClickEvent()
|
||||
{
|
||||
return this.clickEvent;
|
||||
}
|
||||
|
||||
public void setClickEvent(JsonClickEvent clickEvent)
|
||||
{
|
||||
this.clickEvent = clickEvent;
|
||||
}
|
||||
|
||||
public String getColor()
|
||||
{
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public void setColor(String color)
|
||||
{
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package exopandora.worldhandler.format.text;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import exopandora.worldhandler.format.EnumColor;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class JsonSignLineSerializer implements JsonSerializer<JsonSignLine>
|
||||
{
|
||||
@Override
|
||||
public JsonElement serialize(JsonSignLine src, Type typeOfSrc, JsonSerializationContext context)
|
||||
{
|
||||
JsonObject object = (JsonObject) new Gson().toJsonTree(src);
|
||||
|
||||
if(src.getClickEvent() == null)
|
||||
{
|
||||
object.remove("clickEvent");
|
||||
}
|
||||
|
||||
if(!src.isBold())
|
||||
{
|
||||
object.remove("bold");
|
||||
}
|
||||
|
||||
if(!src.isStriked())
|
||||
{
|
||||
object.remove("strikethrough");
|
||||
}
|
||||
|
||||
if(!src.isUnderlined())
|
||||
{
|
||||
object.remove("underlined");
|
||||
}
|
||||
|
||||
if(!src.isItalic())
|
||||
{
|
||||
object.remove("italic");
|
||||
}
|
||||
|
||||
if(!src.isObfuscated())
|
||||
{
|
||||
object.remove("obfuscated");
|
||||
}
|
||||
|
||||
if(src.getColor() != null)
|
||||
{
|
||||
if(src.getColor().equals(EnumColor.DEFAULT.getFormat()))
|
||||
{
|
||||
object.remove("color");
|
||||
}
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package exopandora.worldhandler.format.text;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class SignText
|
||||
{
|
||||
private static final Gson GSON = new GsonBuilder().registerTypeAdapter(JsonSignLine.class, new JsonSignLineSerializer()).create();
|
||||
|
||||
private ColoredString text = new ColoredString();
|
||||
private String command;
|
||||
private final int line;
|
||||
|
||||
public SignText(int line)
|
||||
{
|
||||
this.line = line;
|
||||
}
|
||||
|
||||
public int getLine()
|
||||
{
|
||||
return this.line;
|
||||
}
|
||||
|
||||
public ColoredString getColoredString()
|
||||
{
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public void setColoredString(ColoredString coloredString)
|
||||
{
|
||||
this.text = coloredString;
|
||||
}
|
||||
|
||||
public String getCommand()
|
||||
{
|
||||
return this.command;
|
||||
}
|
||||
|
||||
public void setCommand(String command)
|
||||
{
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public boolean hasCommand()
|
||||
{
|
||||
return this.command != null && !this.command.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if(!this.text.isSpecial() && !this.hasCommand())
|
||||
{
|
||||
return this.text.getText();
|
||||
}
|
||||
|
||||
JsonSignLine line = new JsonSignLine(this.text);
|
||||
|
||||
if(this.hasCommand())
|
||||
{
|
||||
line.setClickEvent(new JsonClickEvent("run_command", FormattedString.getPreformattedString(this.command)));
|
||||
}
|
||||
|
||||
return GSON.toJson(line);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public enum EnumIcon
|
||||
{
|
||||
WEATHER_SUN(0, 0),
|
||||
WEATHER_RAIN(0, 1),
|
||||
WEATHER_STORM(0, 2),
|
||||
DIFFICULTY_PEACEFUL(1, 0),
|
||||
DIFFICULTY_EASY(1, 1),
|
||||
DIFFICULTY_NORMAL(1, 2),
|
||||
DIFFICULTY_HARD(1, 3),
|
||||
TIME_DAWN(2, 0),
|
||||
TIME_NOON(2, 1),
|
||||
TIME_SUNSET(2, 2),
|
||||
TIME_MIDNIGHT(2, 3),
|
||||
GAMEMODE_SURVIVAL(3, 0),
|
||||
GAMEMODE_CREATIVE(3, 1),
|
||||
GAMEMODE_ADVENTURE(3, 2),
|
||||
GAMEMODE_SPECTATOR(3, 3),
|
||||
BUTCHER(4, 0),
|
||||
POTION(4, 1),
|
||||
ACHIEVEMNTS(4, 2),
|
||||
HOME(5, 0),
|
||||
SETTINGS(5, 1),
|
||||
RELOAD(5, 2);
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
|
||||
private EnumIcon(int x, int y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getY()
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public enum EnumTooltip
|
||||
{
|
||||
TOP_RIGHT,
|
||||
TOP_LEFT,
|
||||
BOTTOM_RIGHT,
|
||||
BOTTOM_LEFT,
|
||||
RIGHT,
|
||||
LEFT
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiButtonItem extends GuiButtonWorldHandler
|
||||
{
|
||||
private final ItemStack item;
|
||||
|
||||
public GuiButtonItem(int id, int x, int y, int width, int height, Item item)
|
||||
{
|
||||
this(id, x, y, width, height, new ItemStack(item));
|
||||
}
|
||||
|
||||
public GuiButtonItem(int id, int x, int y, int width, int height, ItemStack item)
|
||||
{
|
||||
super(id, x, y, width, height, null);
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.visible)
|
||||
{
|
||||
super.drawBackground(minecraft, mouseX, mouseY);
|
||||
|
||||
GlStateManager.enableRescaleNormal();
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(this.item, this.x + this.width / 2 - 8, this.y + 2);
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.disableRescaleNormal();
|
||||
GlStateManager.disableBlend();
|
||||
|
||||
this.isActive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import exopandora.worldhandler.config.ConfigSkin;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.main.Main;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.audio.SoundHandler;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiButtonKeyboard extends GuiButtonWorldHandler
|
||||
{
|
||||
private static final ResourceLocation NOTE = new ResourceLocation(Main.MODID, "textures/misc/note.png");
|
||||
private final Orientation orientation;
|
||||
private final float pitch;
|
||||
|
||||
private boolean lastMousePressed;
|
||||
|
||||
private final BlockPos pos;
|
||||
private final SoundEvent sound;
|
||||
private final Content content;
|
||||
private final Container container;
|
||||
|
||||
public GuiButtonKeyboard(int id, int x, int y, int width, int height, String displayString, Orientation orientation, float pitch, Container container, Content content, BlockPos pos, SoundEvent sound)
|
||||
{
|
||||
super(id, x, y, width, height, displayString);
|
||||
this.orientation = orientation;
|
||||
this.pitch = pitch;
|
||||
this.pos = pos;
|
||||
this.sound = sound;
|
||||
this.content = content;
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.visible)
|
||||
{
|
||||
FontRenderer fontRenderer = minecraft.fontRenderer;
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, (float) ConfigSkin.getButtonAlpha() / 255);
|
||||
minecraft.renderEngine.bindTexture(NOTE);
|
||||
|
||||
switch(this.orientation)
|
||||
{
|
||||
case LEFT:
|
||||
this.hovered = this.isHoveringLeft(mouseX, mouseY);
|
||||
break;
|
||||
case NORMAL:
|
||||
this.hovered = this.isHoveringNormal(mouseX, mouseY);
|
||||
break;
|
||||
case RIGHT:
|
||||
this.hovered = this.isHoveringRight(mouseX, mouseY);
|
||||
break;
|
||||
case BLACK:
|
||||
this.hovered = this.isHoveringBlack(mouseX, mouseY);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int hoverstate = this.getHoverState(this.hovered);
|
||||
|
||||
switch(this.orientation)
|
||||
{
|
||||
case BLACK:
|
||||
this.drawTexturedModalRect(this.x, this.y, 55 + hoverstate * -9 + 18, 0, 9, 58);
|
||||
break;
|
||||
case LEFT:
|
||||
case NORMAL:
|
||||
case RIGHT:
|
||||
default:
|
||||
int textColor = 0x000000;
|
||||
|
||||
if(!this.enabled)
|
||||
{
|
||||
textColor = 0xA0A0A0;
|
||||
}
|
||||
else if(this.hovered)
|
||||
{
|
||||
textColor = 0x8B8B8B;
|
||||
}
|
||||
|
||||
this.drawTexturedModalRect(this.x, this.y, 25 + hoverstate * 15 - 15, 0, 15, 92);
|
||||
fontRenderer.drawString(this.displayString, this.x + this.width / 2 - fontRenderer.getStringWidth(this.displayString) / 2, this.y + (this.height - 8) / 2 + 36, textColor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.mouseDragged(minecraft, mouseX, mouseY);
|
||||
}
|
||||
|
||||
private boolean isHoveringBlack(int mouseX, int mouseY)
|
||||
{
|
||||
return mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||
}
|
||||
|
||||
private boolean isHoveringLeft(int mouseX, int mouseY)
|
||||
{
|
||||
return (mouseX >= this.x && mouseY >= this.y && mouseX < this.x + 10 && mouseY < this.y + 60) || (mouseX >= this.x && mouseY >= this.y + 58 && mouseX < this.x + 14 && mouseY < this.y + 93);
|
||||
}
|
||||
|
||||
private boolean isHoveringNormal(int mouseX, int mouseY)
|
||||
{
|
||||
return (mouseX >= this.x + 4 && mouseY >= this.y && mouseX < this.x + 10 && mouseY < this.y + 60) || (mouseX >= this.x && mouseY >= this.y + 58 && mouseX < this.x + 14 && mouseY < this.y + 93);
|
||||
}
|
||||
|
||||
private boolean isHoveringRight(int mouseX, int mouseY)
|
||||
{
|
||||
return (mouseX >= this.x + 4 && mouseY >= this.y && mouseX < this.x + 14 && mouseY < this.y + 60) || (mouseX >= this.x && mouseY >= this.y + 58 && mouseX < this.x + 14 && mouseY < this.y + 93);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft minecraft, int mouseX, int mouseY)
|
||||
{
|
||||
switch(this.orientation)
|
||||
{
|
||||
case LEFT:
|
||||
return this.enabled && this.visible && this.isHoveringLeft(mouseX, mouseY);
|
||||
case NORMAL:
|
||||
return this.enabled && this.visible && this.isHoveringNormal(mouseX, mouseY);
|
||||
case RIGHT:
|
||||
return this.enabled && this.visible && this.isHoveringRight(mouseX, mouseY);
|
||||
case BLACK:
|
||||
return this.enabled && this.visible && this.isHoveringBlack(mouseX, mouseY);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseDragged(Minecraft minecraft, int mouseX, int mouseY)
|
||||
{
|
||||
if(this.visible)
|
||||
{
|
||||
if(this.lastMousePressed != mousePressed(minecraft, mouseX, mouseY))
|
||||
{
|
||||
if(mousePressed(minecraft, mouseX, mouseY) && Mouse.isButtonDown(0))
|
||||
{
|
||||
this.playPressSound(minecraft.getSoundHandler());
|
||||
this.content.actionPerformed(this.container, this);
|
||||
}
|
||||
|
||||
this.lastMousePressed = mousePressed(minecraft, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playPressSound(SoundHandler soundHandlerIn)
|
||||
{
|
||||
soundHandlerIn.playSound(PositionedSoundRecord.getMasterRecord(this.sound, this.pitch));
|
||||
}
|
||||
|
||||
public static enum Orientation
|
||||
{
|
||||
LEFT,
|
||||
NORMAL,
|
||||
RIGHT,
|
||||
BLACK;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.format.TextFormatting;
|
||||
import exopandora.worldhandler.gui.button.logic.IListButtonLogic;
|
||||
import exopandora.worldhandler.gui.button.storage.ButtonStorage;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiButtonList<T> extends GuiButtonWorldHandler
|
||||
{
|
||||
private final IListButtonLogic<T> logic;
|
||||
private final ButtonStorage<T> storage;
|
||||
private int mouseX;
|
||||
private int mouseY;
|
||||
|
||||
public GuiButtonList(int id, int x, int y, int width, int height, Content container, IListButtonLogic<T> logic)
|
||||
{
|
||||
this(id, x, y, width, height, null, container, logic);
|
||||
}
|
||||
|
||||
public GuiButtonList(int id, int x, int y, int width, int height, EnumTooltip tooltipType, Content container, IListButtonLogic<T> logic)
|
||||
{
|
||||
super(id, x, y, width, height, null, null, tooltipType);
|
||||
this.logic = logic;
|
||||
this.storage = container.getStorage(this.logic.getId());
|
||||
this.updateStorageObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
super.drawBackground(minecraft, mouseX, mouseY);
|
||||
|
||||
if(this.visible)
|
||||
{
|
||||
FontRenderer fontRenderer = minecraft.fontRenderer;
|
||||
|
||||
this.mouseX = mouseX;
|
||||
this.mouseY = mouseY;
|
||||
|
||||
this.displayString = this.logic.getDisplayString(this.storage);
|
||||
|
||||
if(this.displayString != null && !this.displayString.isEmpty())
|
||||
{
|
||||
String leftArrow = this.isHoveringLeft(mouseX, mouseY) ? ChatFormatting.BOLD + "<" + ChatFormatting.RESET : "<";
|
||||
String rightArrow = this.isHoveringRight(mouseX, mouseY) ? ChatFormatting.BOLD + ">" + ChatFormatting.RESET : ">";
|
||||
|
||||
int leftArrowWidth = fontRenderer.getStringWidth(leftArrow);
|
||||
int rightArrowWidth = fontRenderer.getStringWidth(rightArrow);
|
||||
|
||||
int maxWidth = Math.max(0, this.width - (fontRenderer.getStringWidth("< >")));
|
||||
int spaceWidth = fontRenderer.getCharWidth(' ');
|
||||
|
||||
String display = TextFormatting.shortenString(this.displayString, maxWidth, fontRenderer);
|
||||
int displayWidth = fontRenderer.getStringWidth(display);
|
||||
int yPos = this.y + (this.height - 8) / 2;
|
||||
|
||||
this.drawCenteredString(fontRenderer, display, this.x + this.width / 2, yPos, this.getTextColor());
|
||||
this.drawCenteredString(fontRenderer, leftArrow, this.x + this.width / 2 - maxWidth / 2 - spaceWidth, yPos, this.getTextColor());
|
||||
this.drawCenteredString(fontRenderer, rightArrow, this.x + this.width / 2 + maxWidth / 2 + spaceWidth, yPos, this.getTextColor());
|
||||
}
|
||||
|
||||
this.isActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTooltip(int mouseX, int mouseY, int width, int height)
|
||||
{
|
||||
if(this.tooltipType != null)
|
||||
{
|
||||
this.displayTooltip = this.logic.getTooltipString(this.storage);
|
||||
}
|
||||
|
||||
super.drawTooltip(mouseX, mouseY, width, height);
|
||||
}
|
||||
|
||||
private boolean isHoveringLeft(int mouseX, int mouseY)
|
||||
{
|
||||
return this.isHoveringVertical(mouseY) && mouseX >= this.x && mouseX < this.x + Math.ceil(this.width / 2);
|
||||
}
|
||||
|
||||
private boolean isHoveringRight(int mouseX, int mouseY)
|
||||
{
|
||||
return this.isHoveringVertical(mouseY) && mouseX >= this.x + Math.ceil(this.width / 2) && mouseX < this.x + this.width;
|
||||
}
|
||||
|
||||
private boolean isHoveringVertical(int mouseY)
|
||||
{
|
||||
return mouseY >= this.y && mouseY < this.y + this.height;
|
||||
}
|
||||
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
if(this.isHoveringLeft(this.mouseX, this.mouseY))
|
||||
{
|
||||
if(this.storage.getIndex() > 0)
|
||||
{
|
||||
this.storage.decrementIndex();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.storage.setIndex(this.logic.getMax() - 1);
|
||||
}
|
||||
}
|
||||
else if(this.isHoveringRight(this.mouseX, this.mouseY))
|
||||
{
|
||||
if(this.storage.getIndex() < this.logic.getMax() - 1)
|
||||
{
|
||||
this.storage.incrementIndex();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.storage.setIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
this.updateStorageObject();
|
||||
this.logic.actionPerformed(container, button, this.storage);
|
||||
}
|
||||
|
||||
private void updateStorageObject()
|
||||
{
|
||||
this.storage.setObject(this.logic.getObject(this.storage.getIndex()));
|
||||
}
|
||||
|
||||
public IListButtonLogic<T> getLogic()
|
||||
{
|
||||
return this.logic;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.SoundHandler;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiButtonTab extends GuiButton
|
||||
{
|
||||
private final int index;
|
||||
|
||||
public GuiButtonTab(int buttonId, int x, int y, int widthIn, int heightIn, int index)
|
||||
{
|
||||
super(buttonId, x, y, widthIn, heightIn, null);
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playPressSound(SoundHandler soundHandlerIn)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int getIndex()
|
||||
{
|
||||
return this.index;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import exopandora.worldhandler.config.ConfigSkin;
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiButtonWorldHandler extends GuiButton
|
||||
{
|
||||
protected String displayTooltip;
|
||||
protected EnumTooltip tooltipType;
|
||||
protected EnumIcon icon;
|
||||
protected boolean isActive;
|
||||
|
||||
public GuiButtonWorldHandler(int id, int x, int y, int width, int height, String displayString)
|
||||
{
|
||||
this(id, x, y, width, height, displayString, null, null);
|
||||
}
|
||||
|
||||
public GuiButtonWorldHandler(int id, int x, int y, int width, int height, String displayString, String tooltip, EnumTooltip tooltipType)
|
||||
{
|
||||
this(id, x, y, width, height, displayString, tooltip, tooltipType, null);
|
||||
}
|
||||
|
||||
public GuiButtonWorldHandler(int id, int x, int y, int width, int height, String displayString, EnumIcon icon)
|
||||
{
|
||||
this(id, x, y, width, height, displayString, null, null, icon);
|
||||
}
|
||||
|
||||
public GuiButtonWorldHandler(int id, int x, int y, int width, int height, String displayString, String tooltip, EnumTooltip tooltipType, EnumIcon icon)
|
||||
{
|
||||
super(id, x, y, width, height, displayString);
|
||||
this.displayTooltip = tooltip;
|
||||
this.tooltipType = tooltipType;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.visible)
|
||||
{
|
||||
this.drawBackground(minecraft, mouseX, mouseY);
|
||||
this.drawCenteredString(minecraft.fontRenderer, this.displayString, this.x + this.width / 2, this.y + (this.height - 8) / 2, this.getTextColor());
|
||||
|
||||
if(this.icon != null)
|
||||
{
|
||||
this.drawIcons();
|
||||
}
|
||||
|
||||
this.isActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected int getTextColor()
|
||||
{
|
||||
int textColor = 0xE0E0E0;
|
||||
|
||||
if(!this.enabled)
|
||||
{
|
||||
textColor = 0xA0A0A0;
|
||||
}
|
||||
else if(this.hovered)
|
||||
{
|
||||
textColor = 0xFFFFA0;
|
||||
}
|
||||
|
||||
return textColor;
|
||||
}
|
||||
|
||||
protected void drawBackground(Minecraft minecraft, int mouseX, int mouseY)
|
||||
{
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.color((float) ConfigSkin.getButtonRed() / 255, (float) ConfigSkin.getButtonGreen() / 255, (float) ConfigSkin.getButtonBlue() / 255, (float) ConfigSkin.getButtonAlpha() / 255);
|
||||
|
||||
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||
int hovered = this.getHoverState(this.hovered);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(ResourceHelper.getButtonTexture());
|
||||
|
||||
if(ConfigSkin.getTextureType().equals("resourcepack"))
|
||||
{
|
||||
this.drawTexturedModalRect(this.x, this.y, 0, 46 + hovered * 20, this.width / 2, this.height);
|
||||
this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + hovered * 20, this.width / 2, this.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.drawTexturedModalRect(this.x, this.y, 0, hovered * 20, this.width / 2, this.height);
|
||||
this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, hovered * 20, this.width / 2, this.height);
|
||||
}
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
public void drawTooltip(int mouseX, int mouseY, int width, int height)
|
||||
{
|
||||
if(this.hovered && this.displayTooltip != null)
|
||||
{
|
||||
int tooltipWidth = Minecraft.getMinecraft().fontRenderer.getStringWidth(this.displayTooltip) + 9;
|
||||
int xOffset = 12;
|
||||
int yOffset = 12;
|
||||
boolean right = mouseX + xOffset + tooltipWidth > width;
|
||||
boolean left = mouseX > tooltipWidth + xOffset;
|
||||
|
||||
switch(this.tooltipType)
|
||||
{
|
||||
case TOP_RIGHT:
|
||||
this.renderTooltip(mouseX, mouseY, xOffset, -yOffset, right);
|
||||
break;
|
||||
case TOP_LEFT:
|
||||
this.renderTooltip(mouseX, mouseY, xOffset, -yOffset, left);
|
||||
break;
|
||||
case BOTTOM_RIGHT:
|
||||
this.renderTooltip(mouseX, mouseY, xOffset, yOffset, right);
|
||||
break;
|
||||
case BOTTOM_LEFT:
|
||||
this.renderTooltip(mouseX, mouseY, xOffset, yOffset, left);
|
||||
break;
|
||||
case RIGHT:
|
||||
this.renderTooltip(mouseX, mouseY, xOffset, 0, right);
|
||||
break;
|
||||
case LEFT:
|
||||
this.renderTooltip(mouseX, mouseY, xOffset, 0, left);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderTooltip(int mouseX, int mouseY, int xOffset, int yOffset, boolean left)
|
||||
{
|
||||
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
|
||||
GlStateManager.disableDepth();
|
||||
|
||||
String[] text = this.displayTooltip.split("\n");
|
||||
|
||||
int tooltipTextWidth = 0;
|
||||
int tooltipX = mouseX + xOffset;
|
||||
int tooltipY = mouseY + yOffset;
|
||||
|
||||
for(String line : text)
|
||||
{
|
||||
int length = fontRenderer.getStringWidth(line) + 1;
|
||||
|
||||
if(length > tooltipTextWidth)
|
||||
{
|
||||
tooltipTextWidth = length;
|
||||
}
|
||||
}
|
||||
|
||||
if(left)
|
||||
{
|
||||
tooltipX = mouseX - xOffset - tooltipTextWidth;
|
||||
}
|
||||
|
||||
int tooltipHeight = fontRenderer.FONT_HEIGHT * text.length;
|
||||
int backgroundColor = 0xF0100010;
|
||||
int borderColorStart = 0x505000FF;
|
||||
int borderColorEnd = (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000;
|
||||
|
||||
int zLevel = 300;
|
||||
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3, tooltipY - 3, backgroundColor, backgroundColor);
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY + tooltipHeight + 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, backgroundColor, backgroundColor);
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX - 4, tooltipY - 3, tooltipX - 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 3, tooltipY - 3, tooltipX + tooltipTextWidth + 4, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 2, tooltipY - 3 + 1, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY - 3 + 1, borderColorStart, borderColorStart);
|
||||
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY + tooltipHeight + 2, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, borderColorEnd, borderColorEnd);
|
||||
|
||||
for(int x = 0; x < text.length; x++)
|
||||
{
|
||||
fontRenderer.drawStringWithShadow(text[x], tooltipX + 1, tooltipY + 1 + fontRenderer.FONT_HEIGHT * x, -1);
|
||||
}
|
||||
|
||||
GlStateManager.enableDepth();
|
||||
}
|
||||
|
||||
protected void drawIcons()
|
||||
{
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(ResourceHelper.getIconTexture());
|
||||
|
||||
if(this.enabled == true)
|
||||
{
|
||||
if(this.hovered)
|
||||
{
|
||||
GlStateManager.color(1.0F, 1.0F, 0.6F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
GlStateManager.color(0.95F, 0.95F, 0.95F, 1.0F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GlStateManager.color(0.8F, 0.8F, 0.8F, 1.0F);
|
||||
}
|
||||
|
||||
this.drawTexturedModalRect(this.x + this.width / 2 - 4, this.y + 6, this.icon.getX() * 8, this.icon.getY() * 8, 8, 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY)
|
||||
{
|
||||
return super.mousePressed(mc, mouseX, mouseY) && this.isActive;
|
||||
}
|
||||
}
|
||||
189
src/main/java/exopandora/worldhandler/gui/button/GuiSlider.java
Normal file
189
src/main/java/exopandora/worldhandler/gui/button/GuiSlider.java
Normal file
@@ -0,0 +1,189 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import exopandora.worldhandler.config.ConfigSkin;
|
||||
import exopandora.worldhandler.gui.button.logic.ISliderResponder;
|
||||
import exopandora.worldhandler.gui.button.storage.ButtonStorage;
|
||||
import exopandora.worldhandler.gui.button.storage.SliderStorage;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiSlider<T> extends GuiButton
|
||||
{
|
||||
private boolean isMouseDown;
|
||||
private boolean isActive;
|
||||
|
||||
private final Object key;
|
||||
private final String name;
|
||||
private final ISliderResponder responder;
|
||||
private final Container frame;
|
||||
private final ButtonStorage<SliderStorage> storage;
|
||||
|
||||
public GuiSlider(Content container, Container frame, Object key, int x, int y, int width, int height, String name, float min, float max, float start, ISliderResponder responder)
|
||||
{
|
||||
super(Integer.MAX_VALUE, x, y, width, height, null);
|
||||
this.frame = frame;
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.responder = responder;
|
||||
this.storage = container.getStorage(key);
|
||||
|
||||
if(this.storage.getObject() == null || this.storage.getObject().getMin() != min || this.storage.getObject().getMax() != max)
|
||||
{
|
||||
this.storage.setObject(new SliderStorage(min, max, min == max ? 0 : ((start - min) / (max - min))));
|
||||
}
|
||||
|
||||
this.displayString = this.getDisplayString();
|
||||
}
|
||||
|
||||
private void setFloat(float value)
|
||||
{
|
||||
this.storage.getObject().setFloat(value);
|
||||
}
|
||||
|
||||
private float getFloat()
|
||||
{
|
||||
return this.storage.getObject().getFloat();
|
||||
}
|
||||
|
||||
private void setValue(int value)
|
||||
{
|
||||
SliderStorage slider = this.storage.getObject();
|
||||
this.storage.getObject().setFloat((value - slider.getMin()) / (slider.getMax() - slider.getMin()));
|
||||
}
|
||||
|
||||
private int getValue()
|
||||
{
|
||||
SliderStorage slider = this.storage.getObject();
|
||||
return (int) (slider.getMin() + (slider.getMax() - slider.getMin()) * this.getFloat());
|
||||
}
|
||||
|
||||
private String getDisplayString()
|
||||
{
|
||||
return this.responder.getText(this.key, I18n.format(this.name), this.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHoverState(boolean mouseOver)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.color((float) ConfigSkin.getButtonRed() / 255, (float) ConfigSkin.getButtonGreen() / 255, (float) ConfigSkin.getButtonBlue() / 255, (float) ConfigSkin.getButtonAlpha() / 255);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(ResourceHelper.getButtonTexture());
|
||||
|
||||
if(ConfigSkin.getTextureType().equals("resourcepack"))
|
||||
{
|
||||
this.drawTexturedModalRect(this.x, this.y, 0, 46, this.width / 2, this.height);
|
||||
this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46, this.width / 2, this.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.drawTexturedModalRect(this.x, this.y, 0, 0, this.width / 2, this.height);
|
||||
this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 0, this.width / 2, this.height);
|
||||
}
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
this.mouseDragged(minecraft, mouseX, mouseY);
|
||||
}
|
||||
|
||||
private void update(int mouseX, int mouseY)
|
||||
{
|
||||
float sliderValue = (float) (mouseX - (this.x + 4)) / (float) (this.width - 8);
|
||||
|
||||
if(sliderValue < 0.0F)
|
||||
{
|
||||
sliderValue = 0.0F;
|
||||
}
|
||||
|
||||
if(sliderValue > 1.0F)
|
||||
{
|
||||
sliderValue = 1.0F;
|
||||
}
|
||||
|
||||
this.setFloat(sliderValue);
|
||||
this.displayString = this.getDisplayString();
|
||||
this.responder.setValue(this.key, this.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(Minecraft mc, int mouseX, int mouseY)
|
||||
{
|
||||
if(this.visible)
|
||||
{
|
||||
if(this.isMouseDown)
|
||||
{
|
||||
this.update(mouseX, mouseY);
|
||||
}
|
||||
|
||||
int textureXOffset = ConfigSkin.getTextureType().equals("resourcepack") ? 0 : -46;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.color((float) ConfigSkin.getButtonRed() / 255, (float) ConfigSkin.getButtonGreen() / 255, (float) ConfigSkin.getButtonBlue() / 255, (float) ConfigSkin.getButtonAlpha() / 255);
|
||||
|
||||
this.drawTexturedModalRect(this.x + (int) (this.getFloat() * (float) (this.width - 8)), this.y, 0, 66 + textureXOffset, 4, 20);
|
||||
this.drawTexturedModalRect(this.x + (int) (this.getFloat() * (float) (this.width - 8)) + 4, this.y, 196, 66 + textureXOffset, 4, 20);
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
int color = 0xE0E0E0;
|
||||
|
||||
if(!this.enabled)
|
||||
{
|
||||
color = 0xA0A0A0;
|
||||
}
|
||||
else if(this.hovered)
|
||||
{
|
||||
color = 0xFFFFA0;
|
||||
}
|
||||
|
||||
this.drawCenteredString(mc.fontRenderer, this.displayString, this.x + this.width / 2, this.y + (this.height - 8) / 2, color);
|
||||
}
|
||||
|
||||
this.isActive = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY)
|
||||
{
|
||||
if(super.mousePressed(mc, mouseX, mouseY) && this.isActive)
|
||||
{
|
||||
this.update(mouseX, mouseY);
|
||||
this.isMouseDown = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY)
|
||||
{
|
||||
this.isMouseDown = false;
|
||||
|
||||
if(this.frame != null)
|
||||
{
|
||||
this.frame.initGui();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiPageButtonList;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiTextFieldTooltip
|
||||
{
|
||||
private GuiTextField textfield;
|
||||
private String display;
|
||||
|
||||
public GuiTextFieldTooltip(int x, int y, int width, int height, String display)
|
||||
{
|
||||
this.textfield = new GuiTextField(0, Minecraft.getMinecraft().fontRenderer, x, y, width, height);
|
||||
this.textfield.setMaxStringLength(Integer.MAX_VALUE);
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public GuiTextFieldTooltip(int x, int y, int width, int height)
|
||||
{
|
||||
this(x, y, width, height, null);
|
||||
}
|
||||
|
||||
public void setGuiResponder(GuiPageButtonList.GuiResponder responder)
|
||||
{
|
||||
this.textfield.setGuiResponder(responder);
|
||||
}
|
||||
|
||||
public void updateCursorCounter()
|
||||
{
|
||||
this.textfield.updateCursorCounter();
|
||||
}
|
||||
|
||||
public void setText(String text)
|
||||
{
|
||||
this.textfield.setText(text);
|
||||
}
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return this.textfield.getText();
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
if(this.textfield.getText() != null)
|
||||
{
|
||||
return this.textfield.getText().matches("(\u00A7[a-f0-9k-or])+");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canType(char charTyped)
|
||||
{
|
||||
return (!this.isEmpty() || charTyped != '\b') && this.textfield.isFocused();
|
||||
}
|
||||
|
||||
public String getSelectedText()
|
||||
{
|
||||
return this.textfield.getSelectedText();
|
||||
}
|
||||
|
||||
public void setValidator(Predicate<String> validator)
|
||||
{
|
||||
this.textfield.setValidator(validator);;
|
||||
}
|
||||
|
||||
public void writeText(String text)
|
||||
{
|
||||
this.textfield.writeText(text);
|
||||
}
|
||||
|
||||
public void deleteWords(int num)
|
||||
{
|
||||
this.textfield.deleteWords(num);
|
||||
}
|
||||
|
||||
public void deleteFromCursor(int num)
|
||||
{
|
||||
this.textfield.deleteFromCursor(num);
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return this.textfield.getId();
|
||||
}
|
||||
|
||||
public int getNthWordFromCursor(int numWords)
|
||||
{
|
||||
return this.textfield.getNthWordFromCursor(numWords);
|
||||
}
|
||||
|
||||
public int getNthWordFromPos(int n, int pos)
|
||||
{
|
||||
return this.textfield.getNthWordFromPos(n, pos);
|
||||
}
|
||||
|
||||
public int getNthWordFromPosWS(int n, int pos, boolean skipWs)
|
||||
{
|
||||
return this.textfield.getNthWordFromPosWS(n, pos, skipWs);
|
||||
}
|
||||
|
||||
public void moveCursorBy(int num)
|
||||
{
|
||||
this.textfield.moveCursorBy(num);
|
||||
}
|
||||
|
||||
public void setCursorPosition(int pos)
|
||||
{
|
||||
this.textfield.setCursorPosition(pos);
|
||||
}
|
||||
|
||||
public void setCursorPositionZero()
|
||||
{
|
||||
this.textfield.setCursorPositionZero();
|
||||
}
|
||||
|
||||
public void setCursorPositionEnd()
|
||||
{
|
||||
this.textfield.setCursorPositionEnd();
|
||||
}
|
||||
|
||||
public boolean textboxKeyTyped(char typedChar, int keyCode)
|
||||
{
|
||||
return this.textfield.textboxKeyTyped(typedChar, keyCode);
|
||||
}
|
||||
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
this.textfield.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
public void drawTextBox()
|
||||
{
|
||||
this.textfield.drawTextBox();
|
||||
|
||||
if(this.textfield.getVisible())
|
||||
{
|
||||
int x = this.textfield.getEnableBackgroundDrawing() ? this.textfield.x + 4 : this.textfield.x;
|
||||
int y = this.textfield.getEnableBackgroundDrawing() ? this.textfield.y + (this.textfield.height - 8) / 2 : this.textfield.y;
|
||||
|
||||
if(ChatFormatting.stripFormatting(this.textfield.getText()).isEmpty() && !this.textfield.isFocused() && this.display != null)
|
||||
{
|
||||
Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(this.display, (float) x, (float) y, 0x7F7F7F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxStringLength(int length)
|
||||
{
|
||||
this.textfield.setMaxStringLength(length);
|
||||
}
|
||||
|
||||
public int getMaxStringLength()
|
||||
{
|
||||
return this.textfield.getMaxStringLength();
|
||||
}
|
||||
|
||||
public int getCursorPosition()
|
||||
{
|
||||
return this.textfield.getCursorPosition();
|
||||
}
|
||||
|
||||
public boolean getEnableBackgroundDrawing()
|
||||
{
|
||||
return this.textfield.getEnableBackgroundDrawing();
|
||||
}
|
||||
|
||||
public void setEnableBackgroundDrawing(boolean enableBackgroundDrawing)
|
||||
{
|
||||
this.textfield.setEnableBackgroundDrawing(enableBackgroundDrawing);
|
||||
}
|
||||
|
||||
public void setTextColor(int color)
|
||||
{
|
||||
this.textfield.setTextColor(color);
|
||||
}
|
||||
|
||||
public void setDisabledTextColour(int color)
|
||||
{
|
||||
this.textfield.setDisabledTextColour(color);
|
||||
}
|
||||
|
||||
public void setFocused(boolean focused)
|
||||
{
|
||||
this.textfield.setFocused(focused);
|
||||
}
|
||||
|
||||
public boolean isFocused()
|
||||
{
|
||||
return this.textfield.isFocused();
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
this.textfield.setEnabled(enabled);
|
||||
}
|
||||
|
||||
public int getSelectionEnd()
|
||||
{
|
||||
return this.textfield.getSelectionEnd();
|
||||
}
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
return this.textfield.getWidth();
|
||||
}
|
||||
|
||||
public void setSelectionPos(int position)
|
||||
{
|
||||
this.textfield.setSelectionPos(position);
|
||||
}
|
||||
|
||||
public void setCanLoseFocus(boolean canLoseFocus)
|
||||
{
|
||||
this.textfield.setCanLoseFocus(canLoseFocus);
|
||||
}
|
||||
|
||||
public boolean getVisible()
|
||||
{
|
||||
return this.textfield.getVisible();
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible)
|
||||
{
|
||||
this.textfield.setVisible(visible);
|
||||
}
|
||||
|
||||
public void setDisplay(String display)
|
||||
{
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public String getDisplay()
|
||||
{
|
||||
return this.display;
|
||||
}
|
||||
|
||||
public void setPosition(int x, int y)
|
||||
{
|
||||
this.textfield.x = x;
|
||||
this.textfield.y = y;
|
||||
}
|
||||
|
||||
public void setWidth(int width)
|
||||
{
|
||||
this.textfield.width = width;
|
||||
}
|
||||
|
||||
public void setHeight(int height)
|
||||
{
|
||||
this.textfield.height = height;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package exopandora.worldhandler.gui.button.logic;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.format.EnumColor;
|
||||
import exopandora.worldhandler.gui.button.storage.ButtonStorage;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class ColorListButtonLogic implements IListButtonLogic<Integer>
|
||||
{
|
||||
@Override
|
||||
public final int getMax()
|
||||
{
|
||||
return (int) Arrays.stream(ChatFormatting.values()).filter(ChatFormatting::isColor).count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getObject(int index)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltipString(ButtonStorage<Integer> storage)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayString(ButtonStorage storage)
|
||||
{
|
||||
EnumColor color = EnumColor.getColorFromId(storage.getIndex());
|
||||
return color + I18n.format("gui.worldhandler.color") + ": " + I18n.format("gui.worldhandler.color." + color.getFormat());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return "color";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package exopandora.worldhandler.gui.button.logic;
|
||||
|
||||
import exopandora.worldhandler.gui.button.storage.ButtonStorage;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IListButtonLogic<T>
|
||||
{
|
||||
void actionPerformed(Container container, GuiButton button, ButtonStorage<T> storage);
|
||||
|
||||
int getMax();
|
||||
|
||||
T getObject(int index);
|
||||
|
||||
String getDisplayString(ButtonStorage<T> storage);
|
||||
|
||||
default String getTooltipString(ButtonStorage<T> storage)
|
||||
{
|
||||
if(storage != null && storage.getObject() != null)
|
||||
{
|
||||
return storage.getObject().toString() + " (" + (storage.getIndex() + 1) + "/" + this.getMax() + ")";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
String getId();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package exopandora.worldhandler.gui.button.logic;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ISliderResponder
|
||||
{
|
||||
void setValue(Object id, int value);
|
||||
String getText(Object id, String format, int value);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package exopandora.worldhandler.gui.button.responder;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import exopandora.worldhandler.format.TextFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class AttributeResponder extends SimpleResponder
|
||||
{
|
||||
public AttributeResponder(Consumer<Integer> valueConsumer)
|
||||
{
|
||||
super(valueConsumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Object id, String format, int value)
|
||||
{
|
||||
String suffix = ": " + value + " " + ((EnumAttributes) id).getOperation().getDeclaration();
|
||||
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
return TextFormatting.shortenString(format, 114 - fontRenderer.getStringWidth(suffix), fontRenderer) + suffix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package exopandora.worldhandler.gui.button.responder;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import exopandora.worldhandler.format.TextFormatting;
|
||||
import exopandora.worldhandler.gui.button.logic.ISliderResponder;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class SimpleResponder<T> implements ISliderResponder
|
||||
{
|
||||
private final Consumer<Integer> valueConsumer;
|
||||
|
||||
public SimpleResponder(Consumer<Integer> valueConsumer)
|
||||
{
|
||||
this.valueConsumer = valueConsumer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object id, int value)
|
||||
{
|
||||
this.valueConsumer.accept(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Object id, String format, int value)
|
||||
{
|
||||
String suffix = ": " + value;
|
||||
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
return TextFormatting.shortenString(format, 114 - fontRenderer.getStringWidth(suffix), fontRenderer) + suffix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package exopandora.worldhandler.gui.button.storage;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ButtonStorage<T>
|
||||
{
|
||||
private int index;
|
||||
private T object;
|
||||
|
||||
public void setIndex(int index)
|
||||
{
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public int getIndex()
|
||||
{
|
||||
return this.index;
|
||||
}
|
||||
|
||||
public void incrementIndex()
|
||||
{
|
||||
this.index++;
|
||||
}
|
||||
|
||||
public void decrementIndex()
|
||||
{
|
||||
this.index--;
|
||||
}
|
||||
|
||||
public T getObject()
|
||||
{
|
||||
return this.object;
|
||||
}
|
||||
|
||||
public void setObject(T object)
|
||||
{
|
||||
this.object = object;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package exopandora.worldhandler.gui.button.storage;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class SliderStorage
|
||||
{
|
||||
private final float min;
|
||||
private final float max;
|
||||
private float value;
|
||||
|
||||
public SliderStorage(float min, float max, float value)
|
||||
{
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public float getMin()
|
||||
{
|
||||
return this.min;
|
||||
}
|
||||
|
||||
public float getMax()
|
||||
{
|
||||
return this.max;
|
||||
}
|
||||
|
||||
public float getFloat()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setFloat(float value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package exopandora.worldhandler.gui.category;
|
||||
|
||||
import exopandora.worldhandler.main.Main;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.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");
|
||||
}
|
||||
|
||||
private static Category getRegisteredCategory(String name)
|
||||
{
|
||||
Category category = Category.REGISTRY.getObject(new ResourceLocation(Main.MODID, name));
|
||||
|
||||
if(category == null)
|
||||
{
|
||||
throw new IllegalStateException("Invalid Category requested: " + name);
|
||||
}
|
||||
|
||||
return category;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package exopandora.worldhandler.gui.category;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.main.Main;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.RegistryNamespaced;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class Category
|
||||
{
|
||||
public static final RegistryNamespaced<ResourceLocation, Category> REGISTRY = new RegistryNamespaced<ResourceLocation, Category>();
|
||||
|
||||
private final List<Content> contents;
|
||||
|
||||
public Category()
|
||||
{
|
||||
this.contents = new ArrayList<Content>();
|
||||
}
|
||||
|
||||
public Category(List<Content> contents)
|
||||
{
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
public Category(Content... contents)
|
||||
{
|
||||
this.contents = Arrays.asList(contents);
|
||||
}
|
||||
|
||||
public Category add(Content content)
|
||||
{
|
||||
this.contents.add(content);
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<Content> getContents()
|
||||
{
|
||||
return this.contents;
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
return this.contents.size();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Content getContent(int index)
|
||||
{
|
||||
return this.contents.get(index);
|
||||
}
|
||||
|
||||
public static void registerCategories()
|
||||
{
|
||||
registerCategory(0, "main", new Category(Contents.MAIN, Contents.CONTAINERS, Contents.MULTIPLAYER));
|
||||
registerCategory(1, "entities", new Category(Contents.SUMMON));
|
||||
registerCategory(2, "items", new Category(Contents.CUSTOM_ITEM, Contents.ENCHANTMENT));
|
||||
registerCategory(3, "blocks", new Category(Contents.EDIT_BLOCKS, Contents.SIGN_EDITOR, Contents.NOTE_EDITOR));
|
||||
registerCategory(4, "world", new Category(Contents.WORLD_INFO, Contents.GAMERULES));
|
||||
registerCategory(5, "player", new Category(Contents.PLAYER, Contents.EXPERIENCE, Contents.ADVANCEMENTS));
|
||||
registerCategory(6, "scoreboard", new Category(Contents.SCOREBOARD_OBJECTIVES, Contents.SCOREBOARD_TEAMS, Contents.SCOREBOARD_PLAYERS));
|
||||
}
|
||||
|
||||
private static void registerCategory(int id, String textualID, Category category)
|
||||
{
|
||||
registerCategory(id, new ResourceLocation(Main.MODID, textualID), category);
|
||||
}
|
||||
|
||||
private static void registerCategory(int id, ResourceLocation textualID, Category category)
|
||||
{
|
||||
REGISTRY.register(id, textualID, category);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package exopandora.worldhandler.gui.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import exopandora.worldhandler.config.ConfigButcher;
|
||||
import exopandora.worldhandler.config.ConfigSettings;
|
||||
import exopandora.worldhandler.config.ConfigSkin;
|
||||
import exopandora.worldhandler.main.Main;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
import net.minecraftforge.common.config.ConfigElement;
|
||||
import net.minecraftforge.fml.client.config.DummyConfigElement;
|
||||
import net.minecraftforge.fml.client.config.GuiConfig;
|
||||
import net.minecraftforge.fml.client.config.IConfigElement;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiConfigWorldHandler extends GuiConfig
|
||||
{
|
||||
public GuiConfigWorldHandler(GuiScreen parentScreen, List<IConfigElement> configElements)
|
||||
{
|
||||
super(parentScreen, configElements, Main.MODID, false, false, Main.NAME);
|
||||
}
|
||||
|
||||
public GuiConfigWorldHandler(GuiScreen parentScreen, ConfigCategory category)
|
||||
{
|
||||
this(parentScreen, new ConfigElement(category).getChildElements());
|
||||
}
|
||||
|
||||
public GuiConfigWorldHandler(GuiScreen parentScreen, String category)
|
||||
{
|
||||
this(parentScreen, WorldHandler.CONFIG.getCategory(category));
|
||||
}
|
||||
|
||||
public GuiConfigWorldHandler(GuiScreen parentScreen)
|
||||
{
|
||||
this(parentScreen, getConfigElements());
|
||||
}
|
||||
|
||||
private static List<IConfigElement> getConfigElements()
|
||||
{
|
||||
List<IConfigElement> list = new ArrayList();
|
||||
|
||||
list.add(new DummyConfigElement.DummyCategoryElement(I18n.format("gui.worldhandler.config.category.settings"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigSettings.CATEGORY)).getChildElements()));
|
||||
list.add(new DummyConfigElement.DummyCategoryElement(I18n.format("gui.worldhandler.config.category.skin"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigSkin.CATEGORY)).getChildElements()));
|
||||
list.add(new DummyConfigElement.DummyCategoryElement(I18n.format("gui.worldhandler.config.category.butcher"), "gui.worldhandler.config", new ConfigElement(WorldHandler.CONFIG.getCategory(ConfigButcher.CATEGORY)).getChildElements()));
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package exopandora.worldhandler.gui.config;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.client.IModGuiFactory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiFactoryWorldHandler implements IModGuiFactory
|
||||
{
|
||||
@Override
|
||||
public void initialize(Minecraft minecraft)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConfigGui()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiScreen createConfigGui(GuiScreen parentScreen)
|
||||
{
|
||||
return new GuiConfigWorldHandler(parentScreen);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package exopandora.worldhandler.gui.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import exopandora.worldhandler.gui.content.element.Element;
|
||||
import exopandora.worldhandler.gui.content.element.IElement;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class Container extends GuiScreen implements IContainer
|
||||
{
|
||||
protected final List<IElement> elements = new ArrayList<IElement>();
|
||||
|
||||
@Override
|
||||
public void add(GuiButton button)
|
||||
{
|
||||
this.buttonList.add(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(Element element)
|
||||
{
|
||||
this.elements.add(element);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package exopandora.worldhandler.gui.container;
|
||||
|
||||
import exopandora.worldhandler.gui.content.element.Element;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IContainer
|
||||
{
|
||||
void add(GuiButton button);
|
||||
void initButtons();
|
||||
void add(Element element);
|
||||
|
||||
String getPlayer();
|
||||
}
|
||||
@@ -0,0 +1,718 @@
|
||||
package exopandora.worldhandler.gui.container.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.builder.impl.BuilderDifficulty;
|
||||
import exopandora.worldhandler.builder.impl.BuilderDifficulty.EnumDifficulty;
|
||||
import exopandora.worldhandler.builder.impl.BuilderGamemode;
|
||||
import exopandora.worldhandler.builder.impl.BuilderGamemode.EnumGamemode;
|
||||
import exopandora.worldhandler.builder.impl.BuilderTime;
|
||||
import exopandora.worldhandler.builder.impl.BuilderTime.EnumMode;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWeather;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWeather.EnumWeather;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWorldHandler;
|
||||
import exopandora.worldhandler.config.ConfigSettings;
|
||||
import exopandora.worldhandler.config.ConfigSkin;
|
||||
import exopandora.worldhandler.format.TextFormatting;
|
||||
import exopandora.worldhandler.gui.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.button.EnumTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTab;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.IContent;
|
||||
import exopandora.worldhandler.gui.content.element.IElement;
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import exopandora.worldhandler.main.Main;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import exopandora.worldhandler.util.UtilRender;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiWorldHandlerContainer extends Container
|
||||
{
|
||||
private final Content content;
|
||||
private final int tabSize;
|
||||
private final int bgTextureWidth = 248;
|
||||
private final int bgTextureHeight = 166;
|
||||
private final int tabDistance = 2;
|
||||
private final int tabDistanceTotal;
|
||||
private final double tabWidth;
|
||||
private final double tabHalf;
|
||||
private final double tabEpsilon;
|
||||
private final String splash = this.getSplash();
|
||||
private final List<GuiButton> finalButtons = new ArrayList<GuiButton>();
|
||||
|
||||
private GuiTextFieldTooltip syntaxField;
|
||||
private GuiTextFieldTooltip nameField;
|
||||
|
||||
private static final BuilderWorldHandler BUILDER_WORLD_HANDLER = new BuilderWorldHandler();
|
||||
|
||||
public GuiWorldHandlerContainer(Content content)
|
||||
{
|
||||
this.content = content;
|
||||
this.tabSize = this.content.getCategory().getSize();
|
||||
this.tabDistanceTotal = Math.max(this.tabSize - 1, 1) * this.tabDistance;
|
||||
this.tabWidth = (this.bgTextureWidth - this.tabDistanceTotal) / Math.max(this.tabSize, 2);
|
||||
this.tabHalf = this.tabWidth / 2D;
|
||||
this.tabEpsilon = this.bgTextureWidth - (this.tabDistanceTotal + this.tabHalf * Math.max(this.tabSize, 2) * 2D);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
this.finalButtons.clear();
|
||||
this.elements.clear();
|
||||
|
||||
//INIT
|
||||
this.content.onPlayerNameChanged(this.getPlayer());
|
||||
this.content.initGui(this, this.getContentX(), this.getContentY());
|
||||
|
||||
//ELEMENTS
|
||||
|
||||
for(IElement element : this.elements)
|
||||
{
|
||||
element.initGui(this);
|
||||
}
|
||||
|
||||
//SHORTCUTS
|
||||
|
||||
final int x = this.width / 2 - 10;
|
||||
final int delta = 21;
|
||||
|
||||
if(ConfigSettings.areShortcutsEnabled())
|
||||
{
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-1, x - delta * 7, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.dawn", ConfigSettings.getDawn())), EnumTooltip.RIGHT, EnumIcon.TIME_DAWN));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-2, x - delta * 6, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.noon", ConfigSettings.getNoon())), EnumTooltip.RIGHT, EnumIcon.TIME_NOON));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-3, x - delta * 5, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.sunset", ConfigSettings.getSunset())), EnumTooltip.RIGHT, EnumIcon.TIME_SUNSET));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-4, x - delta * 4, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.midnight", ConfigSettings.getMidnight())), EnumTooltip.RIGHT, EnumIcon.TIME_MIDNIGHT));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-5, x - delta * 3, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.clear")), EnumTooltip.RIGHT, EnumIcon.WEATHER_SUN));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-6, x - delta * 2, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.rainy")), EnumTooltip.RIGHT, EnumIcon.WEATHER_RAIN));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-7, x - delta * 1, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.thunder")), EnumTooltip.RIGHT, EnumIcon.WEATHER_STORM));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-8, x - delta * 0, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.peaceful")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_PEACEFUL));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-9, x + delta * 1, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.easy")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_EASY));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-10, x + delta * 2, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.normal")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_NORMAL));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-11, x + delta * 3, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.hard")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_HARD));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-12, x + delta * 4, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.survival")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_SURVIVAL));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-13, x + delta * 5, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.creative")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_CREATIVE));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-14, x + delta * 6, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.adventure")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_ADVENTURE));
|
||||
this.finalButtons.add(new GuiButtonWorldHandler(-15, x + delta * 7, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.spectator")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_SPECTATOR));
|
||||
}
|
||||
|
||||
//SYNTAX
|
||||
|
||||
if(ConfigSettings.isCommandSyntaxEnabled())
|
||||
{
|
||||
this.syntaxField = new GuiTextFieldTooltip(x - delta * 7 + 1, this.height - 22, delta * 15 - 3, 20);
|
||||
this.updateSyntax();
|
||||
}
|
||||
|
||||
//NAME
|
||||
|
||||
this.nameField = new GuiTextFieldTooltip(0, 0, 0, 11);
|
||||
this.nameField.setMaxStringLength(16);
|
||||
this.nameField.setText(this.getPlayer());
|
||||
this.updateNameField();
|
||||
|
||||
final int backgroundX = this.getBackgroundX();
|
||||
final int backgroundY = this.getBackgroundY();
|
||||
|
||||
this.forEachTab((index, xOffset) ->
|
||||
{
|
||||
IContent tab = this.content.getCategory().getContent(index);
|
||||
|
||||
if(!this.content.getActiveContent().equals(tab))
|
||||
{
|
||||
this.finalButtons.add(new GuiButtonTab(-16, (int)(backgroundX + xOffset), backgroundY - 20, (int)this.tabWidth + (int)Math.ceil(this.tabEpsilon / this.tabSize), 21, index));
|
||||
}
|
||||
});
|
||||
|
||||
//BUTTONS
|
||||
|
||||
this.initButtons();
|
||||
}
|
||||
|
||||
public void initButtons()
|
||||
{
|
||||
this.buttonList.clear();
|
||||
|
||||
this.content.initButtons(this, this.getContentX(), this.getContentY());
|
||||
|
||||
if(this.finalButtons != null && !this.finalButtons.isEmpty())
|
||||
{
|
||||
this.buttonList.addAll(this.finalButtons);
|
||||
}
|
||||
|
||||
for(IElement element : this.elements)
|
||||
{
|
||||
element.initButtons(this);
|
||||
}
|
||||
}
|
||||
|
||||
private int getContentX()
|
||||
{
|
||||
return (this.width - this.bgTextureWidth) / 2 + 8 + this.getXOffset();
|
||||
}
|
||||
|
||||
private int getContentY()
|
||||
{
|
||||
return this.height / 2 - 50 + this.getYOffset();
|
||||
}
|
||||
|
||||
private int getXOffset()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int getYOffset()
|
||||
{
|
||||
return ConfigSettings.areShortcutsEnabled() ? 11 : 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen()
|
||||
{
|
||||
this.content.updateScreen(this);
|
||||
this.updateSyntax();
|
||||
}
|
||||
|
||||
private int getBackgroundX()
|
||||
{
|
||||
return (this.width - this.bgTextureWidth) / 2 + this.getXOffset();
|
||||
}
|
||||
|
||||
private int getBackgroundY()
|
||||
{
|
||||
return (this.height - this.bgTextureHeight) / 2 + this.getYOffset();
|
||||
}
|
||||
|
||||
private int getWatchOffset()
|
||||
{
|
||||
return ConfigSettings.isWatchEnabled() ? 9 : 0;
|
||||
}
|
||||
|
||||
private void forEachTab(BiConsumer<Integer, Double> consumer)
|
||||
{
|
||||
double xOffset = 0D;
|
||||
|
||||
for(int index = 0; index < this.tabSize; index++)
|
||||
{
|
||||
consumer.accept(index, xOffset);
|
||||
xOffset += this.tabWidth + this.tabDistance + this.tabEpsilon / this.tabSize;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSyntax()
|
||||
{
|
||||
if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
|
||||
{
|
||||
if(!this.syntaxField.isFocused())
|
||||
{
|
||||
this.syntaxField.setValidator(Predicates.alwaysTrue());
|
||||
|
||||
if(this.content.getCommandBuilder() != null)
|
||||
{
|
||||
this.syntaxField.setText(this.content.getCommandBuilder().toCommand());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.syntaxField.setText(BUILDER_WORLD_HANDLER.toCommand());
|
||||
}
|
||||
|
||||
this.syntaxField.setValidator(string -> string.equals(this.syntaxField.getText()));
|
||||
this.syntaxField.setCursorPositionZero();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateNameField()
|
||||
{
|
||||
final int backgroundX = this.getBackgroundX();
|
||||
final int backgroundY = this.getBackgroundY();
|
||||
|
||||
if(WorldHandler.USERNAME.isEmpty())
|
||||
{
|
||||
int width = this.fontRenderer.getStringWidth(I18n.format("gui.worldhandler.generic.edit_username")) + 2;
|
||||
|
||||
this.nameField.setWidth(width);
|
||||
this.nameField.setPosition(backgroundX + this.bgTextureWidth - this.getWatchOffset() - 7 - (this.fontRenderer.getStringWidth(this.content.getTitle()) + 2), backgroundY + 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
int width = this.fontRenderer.getStringWidth(WorldHandler.USERNAME) + 2;
|
||||
|
||||
this.nameField.setWidth(width);
|
||||
this.nameField.setPosition(backgroundX + this.bgTextureWidth - this.getWatchOffset() - 7 - width, backgroundY + 6);
|
||||
this.content.onPlayerNameChanged(WorldHandler.USERNAME);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException
|
||||
{
|
||||
switch(button.id)
|
||||
{
|
||||
case 1:
|
||||
Minecraft.getMinecraft().displayGuiScreen((GuiScreen) null);
|
||||
Minecraft.getMinecraft().setIngameFocus();
|
||||
break;
|
||||
case 0:
|
||||
if(this.content.getBackContent() != null)
|
||||
{
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(this.content.getBackContent()));
|
||||
}
|
||||
break;
|
||||
case -1:
|
||||
WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getDawn()));
|
||||
break;
|
||||
case -2:
|
||||
WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getNoon()));
|
||||
break;
|
||||
case -3:
|
||||
WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getSunset()));
|
||||
break;
|
||||
case -4:
|
||||
WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getMidnight()));
|
||||
break;
|
||||
case -5:
|
||||
WorldHandler.sendCommand(new BuilderWeather(EnumWeather.CLEAR));
|
||||
break;
|
||||
case -6:
|
||||
WorldHandler.sendCommand(new BuilderWeather(EnumWeather.RAIN));
|
||||
break;
|
||||
case -7:
|
||||
WorldHandler.sendCommand(new BuilderWeather(EnumWeather.THUNDER));
|
||||
break;
|
||||
case -8:
|
||||
WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.PEACEFUL));
|
||||
break;
|
||||
case -9:
|
||||
WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.EASY));
|
||||
break;
|
||||
case -10:
|
||||
WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.NORMAL));
|
||||
break;
|
||||
case -11:
|
||||
WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.HARD));
|
||||
break;
|
||||
case -12:
|
||||
WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.SURVIVAL));
|
||||
break;
|
||||
case -13:
|
||||
WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.CREATIVE));
|
||||
break;
|
||||
case -14:
|
||||
WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.ADVENTURE));
|
||||
break;
|
||||
case -15:
|
||||
WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.SPECTATOR));
|
||||
break;
|
||||
case -16:
|
||||
if(button instanceof GuiButtonTab)
|
||||
{
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(this.content.getCategory().getContent(((GuiButtonTab)button).getIndex())));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
elements:
|
||||
for(IElement element : this.elements)
|
||||
{
|
||||
if(element.actionPerformed(this, button))
|
||||
{
|
||||
break elements;
|
||||
}
|
||||
}
|
||||
|
||||
this.content.actionPerformed(this, button);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void defaultColor()
|
||||
{
|
||||
this.defaultColor(1);
|
||||
}
|
||||
|
||||
private void defaultColor(float alpha)
|
||||
{
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.color((float) ConfigSkin.getBackgroundRed() / 255, (float) ConfigSkin.getBackgroundGreen() / 255, (float) ConfigSkin.getBackgroundBlue() / 255, alpha * (float) ConfigSkin.getBackgroundAlpha() / 255);
|
||||
}
|
||||
|
||||
private void darkColor()
|
||||
{
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.color((float) ConfigSkin.getBackgroundRed() / 255 - 0.3F, (float) ConfigSkin.getBackgroundGreen() / 255 - 0.3F, (float) ConfigSkin.getBackgroundBlue() / 255 - 0.3F, (float) ConfigSkin.getBackgroundAlpha() / 255);
|
||||
}
|
||||
|
||||
private void bindBackground()
|
||||
{
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(ResourceHelper.getBackgroundTexture());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getSplash()
|
||||
{
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int day = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
int month = calendar.get(Calendar.MONTH) + 1;
|
||||
|
||||
if(day == 12 && month == 24)
|
||||
{
|
||||
return "Merry X-mas!";
|
||||
}
|
||||
else if(day == 1 && month == 1)
|
||||
{
|
||||
return "Happy new year!";
|
||||
}
|
||||
else if(day == 10 && month == 31)
|
||||
{
|
||||
return "OOoooOOOoooo! Spooky!";
|
||||
}
|
||||
else if(day == 3 && month == 28)
|
||||
{
|
||||
return (calendar.get(Calendar.YEAR) - 2013) + " Years of World Handler!";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
final int backgroundX = this.getBackgroundX();
|
||||
final int backgroundY = this.getBackgroundY();
|
||||
|
||||
//DEFAULT BACKGROUND
|
||||
|
||||
if(ConfigSkin.isBackgroundDrawingEnabled())
|
||||
{
|
||||
super.drawDefaultBackground();
|
||||
}
|
||||
|
||||
//COLOR
|
||||
|
||||
this.defaultColor();
|
||||
|
||||
//BACKGROUND
|
||||
|
||||
this.bindBackground();
|
||||
this.drawTexturedModalRect(backgroundX, backgroundY, 0, 0, this.bgTextureWidth, this.bgTextureHeight);
|
||||
|
||||
//TABS
|
||||
|
||||
this.forEachTab((index, xOffset) ->
|
||||
{
|
||||
IContent tab = this.content.getCategory().getContent(index);
|
||||
int yOffset;
|
||||
int fHeight;
|
||||
int color;
|
||||
|
||||
if(this.content.getActiveContent().equals(tab))
|
||||
{
|
||||
yOffset = -22;
|
||||
fHeight = 25;
|
||||
color = 0xFFFFFF;
|
||||
this.defaultColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
yOffset = -20;
|
||||
fHeight = 20;
|
||||
color = 0xE0E0E0;
|
||||
this.darkColor();
|
||||
}
|
||||
|
||||
this.bindBackground();
|
||||
this.drawTexturedModalRect((int)(backgroundX + xOffset), (int)(backgroundY + yOffset), 0, 0, (int) Math.ceil(this.tabHalf), fHeight);
|
||||
this.drawTexturedModalRect((int)(backgroundX + this.tabHalf + xOffset), (int)(backgroundY + yOffset), this.bgTextureWidth - (int) Math.ceil(this.tabHalf), 0, (int) Math.ceil(this.tabHalf), fHeight);
|
||||
|
||||
if(!ConfigSkin.areSharpEdgesEnabled())
|
||||
{
|
||||
if(this.content.getActiveContent().equals(tab))
|
||||
{
|
||||
//RIGHT TAB CURVATURE
|
||||
|
||||
if(index < this.tabSize - 1 || this.tabSize == 1)
|
||||
{
|
||||
int factor = 2;
|
||||
|
||||
for(int x = 0; x < factor; x++)
|
||||
{
|
||||
this.drawTexturedModalRect((int)(backgroundX + this.tabWidth + xOffset - x - 1), (int)(backgroundY + x + 1), (int)(this.tabWidth - x - 1), x + 1, x + 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//LEFT TAB CURVATURE
|
||||
|
||||
if(index > 0)
|
||||
{
|
||||
int factor = 2;
|
||||
|
||||
for(int x = 0; x < factor; x++)
|
||||
{
|
||||
this.drawTexturedModalRect((int)(backgroundX + xOffset), (int)(backgroundY + x + 1), xOffset.intValue(), x + 1, x + 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
int width = (int)(this.tabWidth - 3);
|
||||
int interval = 5;
|
||||
|
||||
//LEFT GRADIENT
|
||||
|
||||
if(index == 0)
|
||||
{
|
||||
for(int x = 0; x < width; x += interval)
|
||||
{
|
||||
this.defaultColor(1.0F - (x / (width + 5.0F * interval)));
|
||||
this.drawTexturedModalRect((int)(backgroundX + xOffset), (int)(backgroundY + yOffset + fHeight + x / interval), 0, fHeight, width - x, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//RIGHT GRADIENT
|
||||
|
||||
if(index == this.tabSize - 1 && this.tabSize > 1)
|
||||
{
|
||||
int offset = 3;
|
||||
|
||||
for(int x = 0; x < width; x += interval)
|
||||
{
|
||||
this.defaultColor(1.0F - (x / (width + 5.0F * interval)));
|
||||
this.drawTexturedModalRect((int)(backgroundX + Math.ceil(xOffset) + x + offset), (int)(backgroundY + yOffset + fHeight + x / interval), this.bgTextureWidth - width + x, fHeight, width - x, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//LEFT CORNER FILLER
|
||||
|
||||
if(index == 0)
|
||||
{
|
||||
int factor = 2;
|
||||
|
||||
for(int x = 0; x < factor; x++)
|
||||
{
|
||||
this.drawTexturedModalRect(backgroundX, backgroundY + x, 0, fHeight, factor - x, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//RIGHT CORNER FILLER
|
||||
|
||||
if(index == this.tabSize - 1)
|
||||
{
|
||||
int factor = 3;
|
||||
|
||||
for(int x = 0; x < factor + 1; x++)
|
||||
{
|
||||
this.drawTexturedModalRect(backgroundX + this.bgTextureWidth - x, backgroundY + factor - x, this.bgTextureWidth - x, fHeight, x, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.drawCenteredString(this.fontRenderer, ChatFormatting.UNDERLINE + tab.getTabTitle(), (int)(backgroundX + this.tabHalf + xOffset), (int)(backgroundY - 13), color);
|
||||
});
|
||||
|
||||
this.defaultColor();
|
||||
|
||||
//VERSION LABEL
|
||||
|
||||
final int hexAlpha = (int) (0xFF * 0.2) << 24;
|
||||
final int color = ConfigSkin.getLabelColor() + hexAlpha;
|
||||
|
||||
this.fontRenderer.drawString(Main.MC_VERSION + "-" + Main.VERSION, this.width - this.fontRenderer.getStringWidth(Main.MC_VERSION + "-" + Main.VERSION) - 2, this.height - 10, color);
|
||||
|
||||
//TITLE
|
||||
|
||||
final int maxWidth = this.bgTextureWidth - 7 - 2 - this.fontRenderer.getStringWidth(WorldHandler.USERNAME) - 2 - this.getWatchOffset() - 7;
|
||||
this.fontRenderer.drawString(TextFormatting.shortenString(this.content.getTitle(), maxWidth, this.fontRenderer), backgroundX + 7, backgroundY + 7, ConfigSkin.getLabelColor());
|
||||
|
||||
//HEADLINE
|
||||
|
||||
if(this.content.getHeadline() != null)
|
||||
{
|
||||
if(this.content.getHeadline().length > 0)
|
||||
{
|
||||
this.fontRenderer.drawString(this.content.getHeadline()[0], backgroundX + 8, backgroundY + 22, ConfigSkin.getHeadlineColor());
|
||||
}
|
||||
|
||||
if(this.content.getHeadline().length > 1)
|
||||
{
|
||||
this.fontRenderer.drawString(this.content.getHeadline()[1], backgroundX + 126, backgroundY + 22, ConfigSkin.getHeadlineColor());
|
||||
}
|
||||
}
|
||||
|
||||
//NAME FIELD
|
||||
|
||||
final String username = WorldHandler.USERNAME.isEmpty() && !this.nameField.isFocused() ? I18n.format("gui.worldhandler.generic.edit_username") : WorldHandler.USERNAME;
|
||||
this.fontRenderer.drawString(username, backgroundX + 232 - this.fontRenderer.getStringWidth(username), backgroundY + 7, ConfigSkin.getLabelColor());
|
||||
|
||||
//WATCH
|
||||
|
||||
if(ConfigSettings.isWatchEnabled())
|
||||
{
|
||||
final int watchX = backgroundX + 233;
|
||||
final int watchY = backgroundY + 5;
|
||||
|
||||
UtilRender.drawWatchIntoGui(this, watchX, watchY, Minecraft.getMinecraft().world.getWorldInfo().getWorldTime(), ConfigSettings.isSmoothWatchEnabled());
|
||||
|
||||
if(ConfigSettings.areTooltipsEnabled())
|
||||
{
|
||||
if(mouseX >= watchX && mouseX <= watchX + 9 && mouseY >= watchY && mouseY <= watchY + 9)
|
||||
{
|
||||
GuiUtils.drawHoveringText(Arrays.asList(TextFormatting.getWorldTime(Minecraft.getMinecraft().world.getWorldTime())), mouseX, mouseY + 9, this.width, this.height, this.width, this.fontRenderer);
|
||||
GlStateManager.disableLighting();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//BUTTONS
|
||||
|
||||
for(int x = 0; x < this.buttonList.size(); x++)
|
||||
{
|
||||
this.buttonList.get(x).drawButton(this.mc, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
for(int x = 0; x < this.labelList.size(); x++)
|
||||
{
|
||||
this.labelList.get(x).drawLabel(this.mc, mouseX, mouseY);
|
||||
}
|
||||
|
||||
//CONTAINER
|
||||
|
||||
this.content.drawScreen(this, this.getContentX(), this.getContentY(), mouseX, mouseY, partialTicks);
|
||||
|
||||
//CONTAINER ELEMENTS
|
||||
|
||||
for(IElement element : this.elements)
|
||||
{
|
||||
element.draw();
|
||||
}
|
||||
|
||||
//SYNTAX
|
||||
|
||||
if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
|
||||
{
|
||||
this.syntaxField.drawTextBox();
|
||||
}
|
||||
|
||||
//SPLASHTEXT
|
||||
|
||||
if(this.splash != null)
|
||||
{
|
||||
GlStateManager.pushMatrix();
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.translate((float) (backgroundX + 212), backgroundY + 15, 0.0F);
|
||||
GlStateManager.rotate(17.0F, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
float scale = 1.1F - MathHelper.abs(MathHelper.sin((float) (Minecraft.getSystemTime() % 1000L) / 1000.0F * (float) Math.PI * 2.0F) * 0.1F);
|
||||
scale = scale * 100.0F / this.fontRenderer.getStringWidth(this.splash);
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
|
||||
this.drawCenteredString(this.fontRenderer, this.splash, 0, (int) scale, 0xFFFF00);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
//TOOLTIPS
|
||||
|
||||
if(ConfigSettings.areTooltipsEnabled())
|
||||
{
|
||||
for(int x = 0; x < this.buttonList.size(); x++)
|
||||
{
|
||||
if(this.buttonList.get(x) instanceof GuiButtonWorldHandler)
|
||||
{
|
||||
((GuiButtonWorldHandler) this.buttonList.get(x)).drawTooltip(mouseX, mouseY, this.width, this.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char charTyped, int keyCode) throws IOException
|
||||
{
|
||||
super.keyTyped(charTyped, keyCode);
|
||||
|
||||
this.content.keyTyped(this, charTyped, keyCode);
|
||||
|
||||
if(this.nameField.isFocused())
|
||||
{
|
||||
this.nameField.textboxKeyTyped(charTyped, keyCode);
|
||||
WorldHandler.USERNAME = this.nameField.getText();
|
||||
this.updateNameField();
|
||||
}
|
||||
|
||||
if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
|
||||
{
|
||||
this.syntaxField.textboxKeyTyped(charTyped, keyCode);
|
||||
}
|
||||
|
||||
for(IElement element : this.elements)
|
||||
{
|
||||
element.keyTyped(this, charTyped, keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
|
||||
{
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
this.content.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.nameField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
if(this.nameField.isFocused())
|
||||
{
|
||||
this.nameField.setCursorPositionEnd();
|
||||
}
|
||||
|
||||
if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
|
||||
{
|
||||
this.syntaxField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
for(IElement element : this.elements)
|
||||
{
|
||||
element.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed()
|
||||
{
|
||||
this.content.onGuiClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame()
|
||||
{
|
||||
return ConfigSettings.isPauseEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayer()
|
||||
{
|
||||
return WorldHandler.USERNAME;
|
||||
}
|
||||
}
|
||||
111
src/main/java/exopandora/worldhandler/gui/content/Content.java
Normal file
111
src/main/java/exopandora/worldhandler/gui/content/Content.java
Normal file
@@ -0,0 +1,111 @@
|
||||
package exopandora.worldhandler.gui.content;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import exopandora.worldhandler.gui.button.storage.ButtonStorage;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentAdvancements;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentButcher;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentChangeWorld;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentContainers;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentContinue;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentCustomItem;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentEditBlocks;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentEnchantment;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentExperience;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentGamerules;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentMain;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentMultiplayer;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentNoteEditor;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentPlayer;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentPotions;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentScoreboardObjectives;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentScoreboardPlayers;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentScoreboardTeams;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentSignEditor;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentSummon;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentWorldInfo;
|
||||
import exopandora.worldhandler.main.Main;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.RegistryNamespaced;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class Content implements IContent
|
||||
{
|
||||
public static final RegistryNamespaced<ResourceLocation, Content> REGISTRY = new RegistryNamespaced<ResourceLocation, Content>();
|
||||
|
||||
public static void registerContents()
|
||||
{
|
||||
//MAIN
|
||||
registerContent(0, "main", new ContentMain());
|
||||
registerContent(1, "containers", new ContentContainers());
|
||||
registerContent(2, "multiplayer", new ContentMultiplayer());
|
||||
|
||||
//ENTITIES
|
||||
registerContent(3, "summon", new ContentSummon());
|
||||
|
||||
//ITEMS
|
||||
registerContent(5, "custom_item", new ContentCustomItem());
|
||||
registerContent(4, "enchantment", new ContentEnchantment());
|
||||
|
||||
//BLOCKS
|
||||
registerContent(6, "edit_blocks", new ContentEditBlocks());
|
||||
registerContent(7, "sign_editor", new ContentSignEditor());
|
||||
registerContent(8, "note_editor", new ContentNoteEditor());
|
||||
|
||||
//WORLD
|
||||
registerContent(9, "world", new ContentWorldInfo());
|
||||
registerContent(10, "gamerules", new ContentGamerules());
|
||||
|
||||
//PLAYER
|
||||
registerContent(11, "player", new ContentPlayer());
|
||||
registerContent(12, "experience", new ContentExperience());
|
||||
registerContent(13, "advancements", new ContentAdvancements());
|
||||
|
||||
//SCOREBOARD
|
||||
registerContent(14, "scoreboard_objectives", new ContentScoreboardObjectives());
|
||||
registerContent(15, "scoreboard_teams", new ContentScoreboardTeams());
|
||||
registerContent(16, "scoreboard_players", new ContentScoreboardPlayers());
|
||||
|
||||
//MISC
|
||||
registerContent(17, "change_world", new ContentChangeWorld());
|
||||
registerContent(18, "continue", new ContentContinue());
|
||||
|
||||
//NO CATEGORY
|
||||
registerContent(19, "potions", new ContentPotions());
|
||||
registerContent(20, "butcher", new ContentButcher());
|
||||
}
|
||||
|
||||
private static void registerContent(int id, String textualID, Content content)
|
||||
{
|
||||
registerContent(id, new ResourceLocation(Main.MODID, textualID), content);
|
||||
}
|
||||
|
||||
private static void registerContent(int id, ResourceLocation textualID, Content content)
|
||||
{
|
||||
REGISTRY.register(id, textualID, content);
|
||||
}
|
||||
|
||||
private Map<Object, ButtonStorage> storage;
|
||||
|
||||
public <T> ButtonStorage<T> getStorage(Object id)
|
||||
{
|
||||
if(this.storage == null)
|
||||
{
|
||||
this.storage = new HashMap<Object, ButtonStorage>();
|
||||
}
|
||||
|
||||
if(this.storage.containsKey(id))
|
||||
{
|
||||
return this.storage.get(id);
|
||||
}
|
||||
|
||||
ButtonStorage<T> storage = new ButtonStorage<T>();
|
||||
|
||||
this.storage.put(id, storage);
|
||||
|
||||
return storage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package exopandora.worldhandler.gui.content;
|
||||
|
||||
import exopandora.worldhandler.gui.content.impl.ContentContinue;
|
||||
import exopandora.worldhandler.gui.content.impl.abstr.ContentChild;
|
||||
import exopandora.worldhandler.main.Main;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class Contents
|
||||
{
|
||||
public static final Content MAIN;
|
||||
public static final Content CONTAINERS;
|
||||
public static final Content MULTIPLAYER;
|
||||
|
||||
public static final Content SUMMON;
|
||||
|
||||
public static final Content CUSTOM_ITEM;
|
||||
public static final Content ENCHANTMENT;
|
||||
|
||||
public static final Content EDIT_BLOCKS;
|
||||
public static final Content SIGN_EDITOR;
|
||||
public static final Content NOTE_EDITOR;
|
||||
|
||||
public static final Content WORLD_INFO;
|
||||
public static final Content GAMERULES;
|
||||
|
||||
public static final Content PLAYER;
|
||||
public static final Content EXPERIENCE;
|
||||
public static final Content ADVANCEMENTS;
|
||||
|
||||
public static final Content SCOREBOARD_OBJECTIVES;
|
||||
public static final Content SCOREBOARD_TEAMS;
|
||||
public static final Content SCOREBOARD_PLAYERS;
|
||||
|
||||
public static final ContentChild CHANGE_WORLD;
|
||||
public static final ContentContinue CONTINUE;
|
||||
|
||||
public static final ContentChild POTIONS;
|
||||
public static final ContentChild BUTCHER;
|
||||
|
||||
static
|
||||
{
|
||||
MAIN = Contents.getRegisteredContainer("main");
|
||||
CONTAINERS = Contents.getRegisteredContainer("containers");
|
||||
MULTIPLAYER = Contents.getRegisteredContainer("multiplayer");
|
||||
|
||||
SUMMON = Contents.getRegisteredContainer("summon");
|
||||
|
||||
CUSTOM_ITEM = Contents.getRegisteredContainer("custom_item");
|
||||
ENCHANTMENT = Contents.getRegisteredContainer("enchantment");
|
||||
|
||||
EDIT_BLOCKS = Contents.getRegisteredContainer("edit_blocks");
|
||||
SIGN_EDITOR = Contents.getRegisteredContainer("sign_editor");
|
||||
NOTE_EDITOR = Contents.getRegisteredContainer("note_editor");
|
||||
|
||||
WORLD_INFO = Contents.getRegisteredContainer("world");
|
||||
GAMERULES = Contents.getRegisteredContainer("gamerules");
|
||||
|
||||
PLAYER = Contents.getRegisteredContainer("player");
|
||||
EXPERIENCE = Contents.getRegisteredContainer("experience");
|
||||
ADVANCEMENTS = Contents.getRegisteredContainer("advancements");
|
||||
|
||||
SCOREBOARD_OBJECTIVES = Contents.getRegisteredContainer("scoreboard_objectives");
|
||||
SCOREBOARD_TEAMS = Contents.getRegisteredContainer("scoreboard_teams");
|
||||
SCOREBOARD_PLAYERS = Contents.getRegisteredContainer("scoreboard_players");
|
||||
|
||||
CHANGE_WORLD = Contents.getRegisteredContainer("change_world");
|
||||
CONTINUE = Contents.getRegisteredContainer("continue");
|
||||
|
||||
POTIONS = Contents.getRegisteredContainer("potions");
|
||||
BUTCHER = Contents.getRegisteredContainer("butcher");
|
||||
}
|
||||
|
||||
private static <T extends Content> T getRegisteredContainer(String name)
|
||||
{
|
||||
Content container = Content.REGISTRY.getObject(new ResourceLocation(Main.MODID, name));
|
||||
|
||||
if(container == null)
|
||||
{
|
||||
throw new IllegalStateException("Invalid Container requested: " + name);
|
||||
}
|
||||
|
||||
return (T) container;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package exopandora.worldhandler.gui.content;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IContent
|
||||
{
|
||||
default void initGui(Container container, int x, int y)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void initButtons(Container container, int x, int y);
|
||||
|
||||
default void updateScreen(Container container)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void keyTyped(Container container, char typedChar, int keyCode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void onPlayerNameChanged(String username)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Category getCategory();
|
||||
|
||||
String getTitle();
|
||||
String getTabTitle();
|
||||
|
||||
Content getActiveContent();
|
||||
|
||||
@Nullable
|
||||
default Content getBackContent()
|
||||
{
|
||||
return Contents.MAIN;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default ICommandBuilder getCommandBuilder()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default String[] getHeadline()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
default void onGuiClosed()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package exopandora.worldhandler.gui.content.element;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class Element implements IElement
|
||||
{
|
||||
protected int x;
|
||||
protected int y;
|
||||
|
||||
public Element(int x, int y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user