Update to 1.14.2

This commit is contained in:
Marcel Konrad
2019-06-18 17:37:55 +02:00
parent ae1bc97906
commit e5e6226fbf
90 changed files with 1310 additions and 1447 deletions

View File

@@ -12,8 +12,8 @@ public class Main
{
public static final String NAME = "World Handler";
public static final String MODID = "worldhandler";
public static final String MC_VERSION = "1.13.2";
public static final String MOD_VERSION = "2.4.1";
public static final String MC_VERSION = "1.14.2";
public static final String MOD_VERSION = "2.5";
public static final String URL = "https://minecraft.curseforge.com/projects/world-handler-command-gui";
public static void main(String[] args)

View File

@@ -75,7 +75,7 @@ public class WorldHandler
public void loadComplete(FMLLoadCompleteEvent event)
{
Content.registerContents();
Category.registerCategories();
Category.register();
InterModComms.getMessages(Main.MODID, Predicates.equalTo("register"))
.map(imc -> (Runnable) imc.getMessageSupplier().get())
.forEach(Runnable::run);

View File

@@ -16,7 +16,7 @@ import exopandora.worldhandler.builder.types.GreedyString;
import exopandora.worldhandler.builder.types.ItemResourceLocation;
import exopandora.worldhandler.builder.types.TargetSelector;
import exopandora.worldhandler.builder.types.Type;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -106,7 +106,7 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
this.set(index, resource != null ? resource.get() : null, Type.BLOCK_RESOURCE_LOCATION);
}
protected void setNode(int index, NBTTagCompound nbt)
protected void setNode(int index, CompoundNBT nbt)
{
this.set(index, nbt, Type.NBT);
}
@@ -220,7 +220,7 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
}
@Nullable
protected NBTTagCompound getNodeAsNBT(int index)
protected CompoundNBT getNodeAsNBT(int index)
{
return this.get(index, Type.NBT);
}

View File

@@ -4,8 +4,8 @@ import java.util.ArrayList;
import java.util.List;
import exopandora.worldhandler.builder.component.IBuilderComponent;
import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -46,19 +46,19 @@ public abstract class CommandBuilderNBT extends CommandBuilder implements IComma
return super.toActualCommand();
}
private NBTTagCompound buildNBT()
private CompoundNBT buildNBT()
{
NBTTagCompound nbt = new NBTTagCompound();
CompoundNBT nbt = new CompoundNBT();
for(IBuilderComponent component : this.TAG_TO_COMPONENT)
{
INBTBase serialized = component.serialize();
INBT serialized = component.serialize();
if(serialized != null)
{
if(!nbt.hasKey(component.getTag()))
if(!nbt.contains(component.getTag()))
{
nbt.setTag(component.getTag(), serialized);
nbt.put(component.getTag(), serialized);
}
}
}

View File

@@ -1,7 +1,6 @@
package exopandora.worldhandler.builder;
import com.mojang.realmsclient.gui.ChatFormatting;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -29,7 +28,7 @@ public class CommandString
}
else
{
this.command.append(" " + ChatFormatting.RED + "[error]" + ChatFormatting.RESET);
this.command.append(" " + TextFormatting.RED + "[error]" + TextFormatting.RESET);
}
}

View File

@@ -1,11 +1,11 @@
package exopandora.worldhandler.builder;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompoundNBT;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public interface ICommandBuilderNBT extends ICommandBuilder
{
void setNBT(NBTTagCompound nbt);
void setNBT(CompoundNBT nbt);
}

View File

@@ -2,7 +2,7 @@ package exopandora.worldhandler.builder.component;
import javax.annotation.Nullable;
import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.INBT;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -10,6 +10,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public interface IBuilderComponent
{
@Nullable
INBTBase serialize();
INBT serialize();
String getTag();
}

View File

@@ -8,37 +8,37 @@ import java.util.Set;
import javax.annotation.Nullable;
import exopandora.worldhandler.builder.component.IBuilderComponent;
import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.potion.Potion;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.potion.Effect;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public abstract class ComponentPotion implements IBuilderComponent
{
protected final Map<Potion, PotionMetadata> potions = new HashMap<Potion, PotionMetadata>();
protected final Map<Effect, EffectData> potions = new HashMap<Effect, EffectData>();
@Override
@Nullable
public INBTBase serialize()
public INBT serialize()
{
NBTTagList list = new NBTTagList();
ListNBT list = new ListNBT();
for(Entry<Potion, PotionMetadata> entry : this.potions.entrySet())
for(Entry<Effect, EffectData> entry : this.potions.entrySet())
{
PotionMetadata potion = entry.getValue();
EffectData potion = entry.getValue();
if(potion.getAmplifier() > 0)
{
NBTTagCompound compound = new NBTTagCompound();
CompoundNBT compound = new CompoundNBT();
compound.setByte("Id", (byte) Potion.getIdFromPotion(entry.getKey()));
compound.setByte("Amplifier", (byte) (potion.getAmplifier() - 1));
compound.setInt("Duration", Math.min(potion.toTicks(), 1000000));
compound.setBoolean("Ambient", potion.getAmbient());
compound.setBoolean("ShowParticles", potion.getShowParticles());
compound.putByte("Id", (byte) Effect.getIdFromPotion(entry.getKey()));
compound.putByte("Amplifier", (byte) (potion.getAmplifier() - 1));
compound.putInt("Duration", Math.min(potion.toTicks(), 1000000));
compound.putBoolean("Ambient", potion.getAmbient());
compound.putBoolean("ShowParticles", potion.getShowParticles());
list.add(compound);
}
@@ -52,87 +52,87 @@ public abstract class ComponentPotion implements IBuilderComponent
return list;
}
public void setAmplifier(Potion potion, byte amplifier)
public void setAmplifier(Effect potion, byte amplifier)
{
this.getMetadata(potion).setAmplifier(amplifier);
}
public byte getAmplifier(Potion potion)
public byte getAmplifier(Effect potion)
{
return this.getMetadata(potion).getAmplifier();
}
public void setSeconds(Potion potion, int seconds)
public void setSeconds(Effect potion, int seconds)
{
this.getMetadata(potion).setSeconds(seconds);
}
public int getSeconds(Potion potion)
public int getSeconds(Effect potion)
{
return this.getMetadata(potion).getSeconds();
}
public void setMinutes(Potion potion, int minutes)
public void setMinutes(Effect potion, int minutes)
{
this.getMetadata(potion).setMinutes(minutes);
}
public int getMinutes(Potion potion)
public int getMinutes(Effect potion)
{
return this.getMetadata(potion).getMinutes();
}
public void setHours(Potion potion, int hours)
public void setHours(Effect potion, int hours)
{
this.getMetadata(potion).setHours(hours);
}
public int getHours(Potion potion)
public int getHours(Effect potion)
{
return this.getMetadata(potion).getHours();
}
public void setShowParticles(Potion potion, boolean showParticles)
public void setShowParticles(Effect potion, boolean showParticles)
{
this.getMetadata(potion).setShowParticles(showParticles);
}
public boolean getShowParticles(Potion potion)
public boolean getShowParticles(Effect potion)
{
return this.getMetadata(potion).getShowParticles();
}
public void setAmbient(Potion potion, boolean ambient)
public void setAmbient(Effect potion, boolean ambient)
{
this.getMetadata(potion).setAmbient(ambient);
}
public boolean getAmbient(Potion potion)
public boolean getAmbient(Effect potion)
{
return this.getMetadata(potion).getAmbient();
}
private PotionMetadata getMetadata(Potion potion)
private EffectData getMetadata(Effect potion)
{
return this.potions.get(this.validate(potion));
}
private Potion validate(Potion potion)
private Effect validate(Effect potion)
{
if(!this.potions.containsKey(potion))
{
this.potions.put(potion, new PotionMetadata());
this.potions.put(potion, new EffectData());
}
return potion;
}
public Set<Potion> getPotions()
public Set<Effect> getEffects()
{
return this.potions.keySet();
}
public void remove(Potion potion)
public void remove(Effect potion)
{
this.potions.remove(potion);
}

View File

@@ -4,7 +4,7 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class PotionMetadata
public class EffectData
{
private byte amplifier;
private int seconds;
@@ -13,12 +13,12 @@ public class PotionMetadata
private boolean showParticles;
private boolean ambient;
public PotionMetadata()
public EffectData()
{
this((byte) 0, 0, 0, 0, true, false);
}
public PotionMetadata(byte amplifier, int seconds, int minutes, int hours, boolean showParticles, boolean ambient)
public EffectData(byte amplifier, int seconds, int minutes, int hours, boolean showParticles, boolean ambient)
{
this.amplifier = amplifier;
this.seconds = seconds;
@@ -90,12 +90,12 @@ public class PotionMetadata
public int toTicks()
{
return PotionMetadata.toTicks(this.seconds, this.minutes, this.hours);
return EffectData.toTicks(this.seconds, this.minutes, this.hours);
}
public int toSeconds()
{
return PotionMetadata.toSeconds(this.seconds, this.minutes, this.hours);
return EffectData.toSeconds(this.seconds, this.minutes, this.hours);
}
public static int toTicks(int seconds, int minutes, int hours)
@@ -108,37 +108,37 @@ public class PotionMetadata
return seconds + minutes * 60 + hours * 3600;
}
public PotionMetadata withAmplifier(byte amplifier)
public EffectData withAmplifier(byte amplifier)
{
this.amplifier = amplifier;
return this;
}
public PotionMetadata withShowParticles(boolean showParticles)
public EffectData withShowParticles(boolean showParticles)
{
this.showParticles = showParticles;
return this;
}
public PotionMetadata withSeconds(int seconds)
public EffectData withSeconds(int seconds)
{
this.seconds = seconds;
return this;
}
public PotionMetadata withMinutes(int minutes)
public EffectData withMinutes(int minutes)
{
this.minutes = minutes;
return this;
}
public PotionMetadata withHours(int hours)
public EffectData withHours(int hours)
{
this.hours = hours;
return this;
}
public PotionMetadata withAmbient(boolean ambient)
public EffectData withAmbient(boolean ambient)
{
this.ambient = ambient;
return this;

View File

@@ -8,9 +8,9 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.component.abstr.ComponentAttribute;
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -24,22 +24,22 @@ public class ComponentAttributeItem extends ComponentAttribute
@Override
@Nullable
public INBTBase serialize()
public INBT serialize()
{
NBTTagList attributes = new NBTTagList();
ListNBT attributes = new ListNBT();
for(Entry<EnumAttributes, Double> entry : this.attributes.entrySet())
{
if(this.applyable.apply(entry.getKey()) && entry.getValue() != 0)
{
NBTTagCompound attribute = new NBTTagCompound();
CompoundNBT attribute = new CompoundNBT();
attribute.setString("AttributeName", entry.getKey().getAttribute());
attribute.setString("Name", entry.getKey().getAttribute());
attribute.setDouble("Amount", entry.getKey().calculate(entry.getValue()));
attribute.setInt("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());
attribute.putString("AttributeName", entry.getKey().getAttribute());
attribute.putString("Name", entry.getKey().getAttribute());
attribute.putDouble("Amount", entry.getKey().calculate(entry.getValue()));
attribute.putInt("Operation", entry.getKey().getOperation().ordinal());
attribute.putLong("UUIDLeast", UUID.nameUUIDFromBytes(entry.getKey().getAttribute().getBytes()).getLeastSignificantBits());
attribute.putLong("UUIDMost", UUID.nameUUIDFromBytes(entry.getKey().getAttribute().getBytes()).getMostSignificantBits());
attributes.add(attribute);
}

View File

@@ -7,9 +7,9 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.component.abstr.ComponentAttribute;
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ListNBT;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -23,18 +23,18 @@ public class ComponentAttributeMob extends ComponentAttribute
@Override
@Nullable
public INBTBase serialize()
public INBT serialize()
{
NBTTagList attributes = new NBTTagList();
ListNBT attributes = new ListNBT();
for(Entry<EnumAttributes, Double> entry : this.attributes.entrySet())
{
if(this.applyable.apply(entry.getKey()) && entry.getValue() != 0)
{
NBTTagCompound attribute = new NBTTagCompound();
CompoundNBT attribute = new CompoundNBT();
attribute.setString("Name", entry.getKey().getAttribute());
attribute.setDouble("Base", entry.getKey().calculate(entry.getValue()));
attribute.putString("Name", entry.getKey().getAttribute());
attribute.putDouble("Base", entry.getKey().calculate(entry.getValue()));
attributes.add(attribute);
}

View File

@@ -2,12 +2,12 @@ package exopandora.worldhandler.builder.component.impl;
import exopandora.worldhandler.builder.component.IBuilderComponent;
import exopandora.worldhandler.format.text.ColoredString;
import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.StringNBT;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -18,30 +18,30 @@ public class ComponentDisplay implements IBuilderComponent
private String[] lore = new String[2];
@Override
public INBTBase serialize()
public INBT serialize()
{
NBTTagCompound display = new NBTTagCompound();
CompoundNBT display = new CompoundNBT();
String name = this.name.getText();
if(name != null && !name.isEmpty())
{
display.setString("Name", ITextComponent.Serializer.toJson(new TextComponentString(this.name.toString())));
display.putString("Name", ITextComponent.Serializer.toJson(new StringTextComponent(this.name.toString())));
}
NBTTagList lore = new NBTTagList();
ListNBT lore = new ListNBT();
for(int x = 0; x < this.lore.length; x++)
{
if(this.lore[x] != null && !this.lore[x].isEmpty())
{
lore.add(new NBTTagString(this.lore[x]));
lore.add(new StringNBT(this.lore[x]));
}
}
if(!lore.isEmpty())
{
display.setTag("Lore", lore);
display.put("Lore", lore);
}
if(!display.isEmpty())

View File

@@ -9,9 +9,9 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.component.IBuilderComponent;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ListNBT;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@@ -23,18 +23,18 @@ public class ComponentEnchantment implements IBuilderComponent
@Override
@Nullable
public INBTBase serialize()
public INBT serialize()
{
NBTTagList enchantments = new NBTTagList();
ListNBT enchantments = new ListNBT();
for(Entry<Enchantment, Short> entry : this.enchantments.entrySet())
{
if(entry.getValue() > 0)
{
NBTTagCompound enchantment = new NBTTagCompound();
CompoundNBT enchantment = new CompoundNBT();
enchantment.setString("id", ForgeRegistries.ENCHANTMENTS.getKey(entry.getKey()).toString());
enchantment.setShort("lvl", entry.getValue());
enchantment.putString("id", ForgeRegistries.ENCHANTMENTS.getKey(entry.getKey()).toString());
enchantment.putShort("lvl", entry.getValue());
enchantments.add(enchantment);
}

View File

@@ -10,11 +10,11 @@ import exopandora.worldhandler.builder.component.IBuilderComponent;
import exopandora.worldhandler.helper.ResourceHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.EntityType;
import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.ByteNBT;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.IntNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -61,44 +61,44 @@ public class ComponentSummon implements IBuilderComponent
}
@Override
public INBTBase serialize()
public INBT serialize()
{
if(this.name != null)
{
if(this.name.equalsIgnoreCase("Cat"))
{
this.tag = "CatType";
return new NBTTagInt(this.random.nextInt(3) + 1);
return new IntNBT(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);
return new IntNBT(0);
}
else if(this.name.equalsIgnoreCase("Librarian") || this.name.equalsIgnoreCase("Carthographer"))
{
this.tag = "Profession";
return new NBTTagInt(1);
return new IntNBT(1);
}
else if(this.name.equalsIgnoreCase("Cleric") || this.name.equalsIgnoreCase("Priest"))
{
this.tag = "Profession";
return new NBTTagInt(2);
return new IntNBT(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);
return new IntNBT(3);
}
else if(this.name.equalsIgnoreCase("Butcher") || this.name.equalsIgnoreCase("Leatherworker"))
{
this.tag = "Profession";
return new NBTTagInt(4);
return new IntNBT(4);
}
else if(this.name.equalsIgnoreCase("Nitwit"))
{
this.tag = "Profession";
return new NBTTagInt(5);
return new IntNBT(5);
}
if(this.entity != null)
@@ -108,18 +108,18 @@ public class ComponentSummon implements IBuilderComponent
if(StringUtils.containsIgnoreCase(this.name, "Baby"))
{
this.tag = "IsBaby";
return new NBTTagByte((byte) 1);
return new ByteNBT((byte) 1);
}
}
else if(this.entity.equals(EntityType.CHICKEN.getRegistryName()))
{
if(StringUtils.containsIgnoreCase(this.name, "Jockey") && !this.hasPassenger)
{
NBTTagCompound passenger = new NBTTagCompound();
NBTTagList list = new NBTTagList();
CompoundNBT passenger = new CompoundNBT();
ListNBT list = new ListNBT();
passenger.setString("id", EntityType.ZOMBIE.getRegistryName().toString());
passenger.setBoolean("IsBaby", true);
passenger.putString("id", EntityType.ZOMBIE.getRegistryName().toString());
passenger.putBoolean("IsBaby", true);
list.add(passenger);
this.tag = "Passengers";
@@ -130,10 +130,10 @@ public class ComponentSummon implements IBuilderComponent
{
if(StringUtils.containsIgnoreCase(this.name, "Jockey") && !this.hasPassenger)
{
NBTTagCompound passenger = new NBTTagCompound();
NBTTagList list = new NBTTagList();
CompoundNBT passenger = new CompoundNBT();
ListNBT list = new ListNBT();
passenger.setString("id", EntityType.SKELETON.getRegistryName().toString());
passenger.putString("id", EntityType.SKELETON.getRegistryName().toString());
list.add(passenger);
this.tag = "Passengers";

View File

@@ -7,35 +7,35 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.builder.component.IBuilderComponent;
import net.minecraft.nbt.INBTBase;
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.NBTTagShort;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.nbt.ByteArrayNBT;
import net.minecraft.nbt.ByteNBT;
import net.minecraft.nbt.DoubleNBT;
import net.minecraft.nbt.FloatNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.IntArrayNBT;
import net.minecraft.nbt.IntNBT;
import net.minecraft.nbt.LongArrayNBT;
import net.minecraft.nbt.LongNBT;
import net.minecraft.nbt.ShortNBT;
import net.minecraft.nbt.StringNBT;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class ComponentTag<T> implements IBuilderComponent
{
private final Function<T, INBTBase> serializer;
private final Function<T, INBT> serializer;
private final String tag;
private T value;
public ComponentTag(String tag, T value, Function<T, INBTBase> serializer)
public ComponentTag(String tag, T value, Function<T, INBT> serializer)
{
this.tag = tag;
this.value = value;
this.serializer = serializer;
}
public ComponentTag(String tag, Function<T, INBTBase> serializer)
public ComponentTag(String tag, Function<T, INBT> serializer)
{
this(tag, null, serializer);
}
@@ -63,7 +63,7 @@ public class ComponentTag<T> implements IBuilderComponent
@Override
@Nullable
public INBTBase serialize()
public INBT serialize()
{
if(this.value != null)
{
@@ -80,9 +80,9 @@ public class ComponentTag<T> implements IBuilderComponent
return null;
}
return new NBTTagString(string);
return new StringNBT(string);
}
else if(this.value instanceof INBTBase)
else if(this.value instanceof INBT)
{
if(this.value instanceof Collection<?>)
{
@@ -94,43 +94,43 @@ public class ComponentTag<T> implements IBuilderComponent
}
}
return (INBTBase) this.value;
return (INBT) this.value;
}
else if(this.value instanceof Integer)
{
return new NBTTagInt((Integer) this.value);
return new IntNBT((Integer) this.value);
}
else if(this.value instanceof Byte)
{
return new NBTTagByte((Byte) this.value);
return new ByteNBT((Byte) this.value);
}
else if(this.value instanceof Float)
{
return new NBTTagFloat((Float) this.value);
return new FloatNBT((Float) this.value);
}
else if(this.value instanceof Double)
{
return new NBTTagDouble((Double) this.value);
return new DoubleNBT((Double) this.value);
}
else if(this.value instanceof Long)
{
return new NBTTagLong((Long) this.value);
return new LongNBT((Long) this.value);
}
else if(this.value instanceof Short)
{
return new NBTTagShort((Short) this.value);
return new ShortNBT((Short) this.value);
}
else if(this.value instanceof Byte[])
{
return new NBTTagByteArray((byte[]) this.value);
return new ByteArrayNBT((byte[]) this.value);
}
else if(this.value instanceof Integer[])
{
return new NBTTagIntArray((int[]) this.value);
return new IntArrayNBT((int[]) this.value);
}
else if(this.value instanceof Long[])
{
return new NBTTagLongArray((long[]) this.value);
return new LongArrayNBT((long[]) this.value);
}
else
{

View File

@@ -9,7 +9,7 @@ import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.builder.types.TargetSelector;
import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.helper.EnumHelper;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.api.distmarker.Dist;
@@ -25,7 +25,7 @@ public class BuilderData extends BuilderBlockPos
super(2);
}
public BuilderData(EnumMode mode, ResourceLocation entity, NBTTagCompound nbt)
public BuilderData(EnumMode mode, ResourceLocation entity, CompoundNBT nbt)
{
this();
this.setMode(mode);
@@ -33,7 +33,7 @@ public class BuilderData extends BuilderBlockPos
this.setNBT(nbt);
}
public BuilderData(EnumMode mode, BlockPos pos, NBTTagCompound nbt)
public BuilderData(EnumMode mode, BlockPos pos, CompoundNBT nbt)
{
this();
this.setMode(mode);
@@ -129,7 +129,7 @@ public class BuilderData extends BuilderBlockPos
}
@Override
public void setNBT(NBTTagCompound nbt)
public void setNBT(CompoundNBT nbt)
{
if(this.getMode() == null || !this.getMode().equals(EnumMode.MERGE))
{
@@ -155,7 +155,7 @@ public class BuilderData extends BuilderBlockPos
}
@Nullable
public NBTTagCompound getNBT()
public CompoundNBT getNBT()
{
if(this.getMode() != null && this.getMode().equals(EnumMode.MERGE))
{

View File

@@ -7,7 +7,7 @@ import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.ItemResourceLocation;
import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.helper.ResourceHelper;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -68,13 +68,13 @@ public class BuilderGive extends CommandBuilderNBT
}
@Override
public void setNBT(NBTTagCompound nbt)
public void setNBT(CompoundNBT nbt)
{
this.itemResourceLocation.setNBT(nbt);
this.setNode(1, this.itemResourceLocation);
}
public NBTTagCompound getNBT()
public CompoundNBT getNBT()
{
return this.getNodeAsItemResourceLocation(1).getNBT();
}

View File

@@ -1,7 +1,7 @@
package exopandora.worldhandler.builder.impl;
import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.state.properties.NoteBlockInstrument;
import net.minecraft.util.math.BlockPos;

View File

@@ -4,9 +4,9 @@ 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.component.abstr.EffectData;
import exopandora.worldhandler.builder.types.Type;
import net.minecraft.potion.Potion;
import net.minecraft.potion.Effect;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -57,7 +57,7 @@ public class BuilderPotionEffect extends CommandBuilder
return this.getNodeAsString(1);
}
public void setEffect(Potion effect)
public void setEffect(Effect effect)
{
this.setEffect(effect.getRegistryName());
}
@@ -68,7 +68,7 @@ public class BuilderPotionEffect extends CommandBuilder
}
@Nullable
public Potion getEffectAsPotion()
public Effect getEffectAsPotion()
{
ResourceLocation location = this.getNodeAsResourceLocation(2);
@@ -123,7 +123,7 @@ public class BuilderPotionEffect extends CommandBuilder
public void setSeconds(int seconds)
{
this.seconds = seconds;
this.setDuration(PotionMetadata.toSeconds(this.seconds, this.minutes, this.hours));
this.setDuration(EffectData.toSeconds(this.seconds, this.minutes, this.hours));
}
public int getMinutes()
@@ -134,7 +134,7 @@ public class BuilderPotionEffect extends CommandBuilder
public void setMinutes(int minutes)
{
this.minutes = minutes;
this.setDuration(PotionMetadata.toSeconds(this.seconds, this.minutes, this.hours));
this.setDuration(EffectData.toSeconds(this.seconds, this.minutes, this.hours));
}
public int getHours()
@@ -145,7 +145,7 @@ public class BuilderPotionEffect extends CommandBuilder
public void setHours(int hours)
{
this.hours = hours;
this.setDuration(PotionMetadata.toSeconds(this.seconds, this.minutes, this.hours));
this.setDuration(EffectData.toSeconds(this.seconds, this.minutes, this.hours));
}
public BuilderGeneric getGiveCommand()

View File

@@ -4,7 +4,7 @@ import java.util.Set;
import exopandora.worldhandler.builder.component.impl.ComponentPotionItem;
import net.minecraft.item.Item;
import net.minecraft.potion.Potion;
import net.minecraft.potion.Effect;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -25,69 +25,69 @@ public class BuilderPotionItem extends BuilderGive
this.potion = this.registerNBTComponent(potion);
}
public void setAmplifier(Potion potion, byte amplifier)
public void setAmplifier(Effect potion, byte amplifier)
{
this.potion.setAmplifier(potion, amplifier);
}
public void setSeconds(Potion potion, int seconds)
public void setSeconds(Effect potion, int seconds)
{
this.potion.setSeconds(potion, seconds);
}
public void setMinutes(Potion potion, int minutes)
public void setMinutes(Effect potion, int minutes)
{
this.potion.setMinutes(potion, minutes);
}
public void setHours(Potion potion, int hours)
public void setHours(Effect potion, int hours)
{
this.potion.setHours(potion, hours);
}
public void setShowParticles(Potion potion, boolean showParticles)
public void setShowParticles(Effect potion, boolean showParticles)
{
this.potion.setShowParticles(potion, showParticles);
}
public void setAmbient(Potion potion, boolean ambient)
public void setAmbient(Effect potion, boolean ambient)
{
this.potion.setAmbient(potion, ambient);
}
public byte getAmplifier(Potion potion)
public byte getAmplifier(Effect potion)
{
return this.potion.getAmplifier(potion);
}
public int getSeconds(Potion potion)
public int getSeconds(Effect potion)
{
return this.potion.getSeconds(potion);
}
public int getMinutes(Potion potion)
public int getMinutes(Effect potion)
{
return this.potion.getMinutes(potion);
}
public int getHours(Potion potion)
public int getHours(Effect potion)
{
return this.potion.getHours(potion);
}
public boolean getShowParticles(Potion potion)
public boolean getShowParticles(Effect potion)
{
return this.potion.getShowParticles(potion);
}
public boolean getAmbient(Potion potion)
public boolean getAmbient(Effect potion)
{
return this.potion.getAmbient(potion);
}
public Set<Potion> getPotions()
public Set<Effect> getEffects()
{
return this.potion.getPotions();
return this.potion.getEffects();
}
public BuilderPotionItem getBuilderForPotion(Item item)

View File

@@ -48,7 +48,7 @@ public class BuilderRecipe extends CommandBuilder
return this.getNodeAsString(1);
}
public void setRecipe(IRecipe recipe)
public void setRecipe(IRecipe<?> recipe)
{
this.setRecipe(recipe.getId());
}

View File

@@ -5,7 +5,7 @@ import exopandora.worldhandler.builder.impl.abstr.BuilderBlockPos;
import exopandora.worldhandler.builder.types.BlockResourceLocation;
import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.builder.types.Type;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.IProperty;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
@@ -58,7 +58,7 @@ public class BuilderSetBlock extends BuilderBlockPos
}
@Override
public void setNBT(NBTTagCompound nbt)
public void setNBT(CompoundNBT nbt)
{
this.blockResourceLocation.setNBT(nbt);
this.setNode(3, this.blockResourceLocation);

View File

@@ -5,7 +5,7 @@ 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.minecraft.nbt.StringNBT;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -23,7 +23,7 @@ public class BuilderSignEditor extends BuilderData
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())));
this.sign[x] = this.registerNBTComponent(new ComponentTag<SignText>("Text" + (x + 1), new SignText(x), text -> new StringNBT(text.toString())));
}
}

View File

@@ -19,16 +19,16 @@ import exopandora.worldhandler.builder.types.CoordinateDouble;
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.block.Blocks;
import net.minecraft.item.Item;
import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.potion.Potion;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.StringNBT;
import net.minecraft.potion.Effect;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -37,9 +37,9 @@ 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 ComponentTag<ListNBT> passengers;
private final ComponentTag<ListNBT> armorItems;
private final ComponentTag<ListNBT> 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()};
@@ -49,9 +49,9 @@ public class BuilderSummon extends CommandBuilderNBT
{
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.passengers = this.registerNBTComponent(new ComponentTag<ListNBT>("Passengers"));
this.armorItems = this.registerNBTComponent(new ComponentTag<ListNBT>("ArmorItems", this::itemListSerializer));
this.handItems = this.registerNBTComponent(new ComponentTag<ListNBT>("HandItems", this::itemListSerializer));
this.summon = this.registerNBTComponent(new ComponentSummon(), "summon");
this.potion = this.registerNBTComponent(new ComponentPotionMob());
this.setX(new CoordinateDouble(0.0, CoordinateType.LOCAL));
@@ -154,10 +154,10 @@ public class BuilderSummon extends CommandBuilderNBT
{
if(entityName != null)
{
NBTTagCompound passenger = new NBTTagCompound();
passenger.setString("id", entityName.toString());
CompoundNBT passenger = new CompoundNBT();
passenger.putString("id", entityName.toString());
NBTTagList list = new NBTTagList();
ListNBT list = new ListNBT();
list.add(passenger);
this.passengers.setValue(list);
@@ -171,7 +171,7 @@ public class BuilderSummon extends CommandBuilderNBT
@Nullable
public ResourceLocation getPassenger()
{
NBTTagList list = this.passengers.getValue();
ListNBT list = this.passengers.getValue();
if(list != null && !list.isEmpty())
{
@@ -198,13 +198,13 @@ public class BuilderSummon extends CommandBuilderNBT
public void setArmorItems(ResourceLocation[] armor)
{
NBTTagList list = new NBTTagList();
ListNBT list = new ListNBT();
for(ResourceLocation item : armor)
{
NBTTagCompound compound = new NBTTagCompound();
compound.setString("id", item.toString());
compound.setInt("Count", 1);
CompoundNBT compound = new CompoundNBT();
compound.putString("id", item.toString());
compound.putInt("Count", 1);
list.add(compound);
}
@@ -247,13 +247,13 @@ public class BuilderSummon extends CommandBuilderNBT
public void setHandItems(ResourceLocation[] armor)
{
NBTTagList list = new NBTTagList();
ListNBT list = new ListNBT();
for(ResourceLocation item : armor)
{
NBTTagCompound compound = new NBTTagCompound();
compound.setString("id", item.toString());
compound.setInt("Count", 1);
CompoundNBT compound = new CompoundNBT();
compound.putString("id", item.toString());
compound.putInt("Count", 1);
list.add(compound);
}
@@ -270,72 +270,72 @@ public class BuilderSummon extends CommandBuilderNBT
return Blocks.AIR.getRegistryName();
}
public void setAmplifier(Potion potion, byte amplifier)
public void setAmplifier(Effect potion, byte amplifier)
{
this.potion.setAmplifier(potion, amplifier);
}
public void setSeconds(Potion potion, int seconds)
public void setSeconds(Effect potion, int seconds)
{
this.potion.setSeconds(potion, seconds);
}
public void setMinutes(Potion potion, int minutes)
public void setMinutes(Effect potion, int minutes)
{
this.potion.setMinutes(potion, minutes);
}
public void setHours(Potion potion, int hours)
public void setHours(Effect potion, int hours)
{
this.potion.setHours(potion, hours);
}
public void setShowParticles(Potion potion, boolean showParticles)
public void setShowParticles(Effect potion, boolean showParticles)
{
this.potion.setShowParticles(potion, showParticles);
}
public void setAmbient(Potion potion, boolean ambient)
public void setAmbient(Effect potion, boolean ambient)
{
this.potion.setAmbient(potion, ambient);
}
public byte getAmplifier(Potion potion)
public byte getAmplifier(Effect potion)
{
return this.potion.getAmplifier(potion);
}
public int getSeconds(Potion potion)
public int getSeconds(Effect potion)
{
return this.potion.getSeconds(potion);
}
public int getMinutes(Potion potion)
public int getMinutes(Effect potion)
{
return this.potion.getMinutes(potion);
}
public int getHours(Potion potion)
public int getHours(Effect potion)
{
return this.potion.getHours(potion);
}
public boolean getShowParticles(Potion potion)
public boolean getShowParticles(Effect potion)
{
return this.potion.getShowParticles(potion);
}
public boolean getAmbient(Potion potion)
public boolean getAmbient(Effect potion)
{
return this.potion.getAmbient(potion);
}
public Set<Potion> getPotions()
public Set<Effect> getEffects()
{
return this.potion.getPotions();
return this.potion.getEffects();
}
private INBTBase itemListSerializer(NBTTagList list)
private INBT itemListSerializer(ListNBT list)
{
for(int x = 0; x < list.size(); x++)
{
@@ -348,18 +348,18 @@ public class BuilderSummon extends CommandBuilderNBT
return null;
}
private INBTBase colorStringSerializer(ColoredString string)
private INBT colorStringSerializer(ColoredString string)
{
if(string.getText() != null && !string.getText().isEmpty())
{
return new NBTTagString(ITextComponent.Serializer.toJson(new TextComponentString(string.toString())));
return new StringNBT(ITextComponent.Serializer.toJson(new StringTextComponent(string.toString())));
}
return null;
}
@Override
public void setNBT(NBTTagCompound nbt)
public void setNBT(CompoundNBT nbt)
{
this.setNode(4, nbt);
}

View File

@@ -5,9 +5,9 @@ import javax.annotation.Nullable;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.BlockState;
import net.minecraft.command.arguments.BlockStateParser;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.IProperty;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
@@ -17,7 +17,7 @@ import net.minecraftforge.registries.ForgeRegistries;
@OnlyIn(Dist.CLIENT)
public class BlockResourceLocation extends ItemResourceLocation
{
private IBlockState state;
private BlockState state;
public BlockResourceLocation()
{
@@ -29,13 +29,13 @@ public class BlockResourceLocation extends ItemResourceLocation
this(resource, null, null);
}
public BlockResourceLocation(ResourceLocation resource, IBlockState state, NBTTagCompound nbt)
public BlockResourceLocation(ResourceLocation resource, BlockState state, CompoundNBT nbt)
{
super(resource, nbt);
this.state = this.findState(state, resource);
}
private IBlockState findState(IBlockState state, ResourceLocation resource)
private BlockState findState(BlockState state, ResourceLocation resource)
{
boolean matchOld = this.state != null && this.state.getBlock().getRegistryName().equals(resource);
boolean matchNew = state != null && state.getBlock().getRegistryName().equals(resource);
@@ -65,7 +65,7 @@ public class BlockResourceLocation extends ItemResourceLocation
this.state = this.findState(null, resource);
}
public IBlockState getState()
public BlockState getState()
{
return this.state;
}
@@ -94,7 +94,7 @@ public class BlockResourceLocation extends ItemResourceLocation
return null;
}
IBlockState state = parser.getState();
BlockState state = parser.getState();
if(state != null)
{

View File

@@ -4,8 +4,8 @@ import javax.annotation.Nullable;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -14,7 +14,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public class ItemResourceLocation
{
protected ResourceLocation resource;
protected NBTTagCompound nbt;
protected CompoundNBT nbt;
public ItemResourceLocation()
{
@@ -26,7 +26,7 @@ public class ItemResourceLocation
this(resource, null);
}
public ItemResourceLocation(ResourceLocation resource, NBTTagCompound nbt)
public ItemResourceLocation(ResourceLocation resource, CompoundNBT nbt)
{
this.resource = resource;
this.nbt = nbt;
@@ -42,12 +42,12 @@ public class ItemResourceLocation
this.resource = resource;
}
public NBTTagCompound getNBT()
public CompoundNBT getNBT()
{
return this.nbt;
}
public void setNBT(NBTTagCompound nbt)
public void setNBT(CompoundNBT nbt)
{
this.nbt = nbt;
}
@@ -67,7 +67,7 @@ public class ItemResourceLocation
{
int start = input.indexOf("{");
ResourceLocation resource = new ResourceLocation(input.substring(0, start));
NBTTagCompound nbt = null;
CompoundNBT nbt = null;
if(start > 0)
{

View File

@@ -7,7 +7,7 @@ import javax.annotation.Nullable;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -27,7 +27,7 @@ public enum Type
RESOURCE_LOCATION(Type::parseResourceLocation),
ITEM_RESOURCE_LOCATION(ItemResourceLocation::valueOf),
BLOCK_RESOURCE_LOCATION(BlockResourceLocation::valueOf),
NBT(Type::parseNBTTagCompound),
NBT(Type::parseCompoundNBT),
COORDINATE_INT(CoordinateInt::valueOf),
COORDINATE_DOUBLE(CoordinateDouble::valueOf),
TARGET_SELECTOR(TargetSelector::valueOf);
@@ -53,7 +53,7 @@ public enum Type
}
@Nullable
public static NBTTagCompound parseNBTTagCompound(String value)
public static CompoundNBT parseCompoundNBT(String value)
{
if(value != null)
{

View File

@@ -37,7 +37,7 @@ public class CommandWorldHandler
private static int display() throws CommandSyntaxException
{
Minecraft.getInstance().addScheduledTask(ActionHelper::displayGui);
Minecraft.getInstance().execute(ActionHelper::displayGui);
return 1;
}

View File

@@ -44,7 +44,7 @@ public class ConfigCategoryButcher
for(String entity : this.entities)
{
ResourceLocation resource = ResourceLocation.makeResourceLocation(entity);
ResourceLocation resource = ResourceLocation.tryCreate(entity);
if(resource != null)
{
@@ -85,7 +85,7 @@ public class ConfigCategoryButcher
{
if(string != null)
{
return ForgeRegistries.ENTITIES.containsKey(ResourceLocation.makeResourceLocation(string.toString()));
return ForgeRegistries.ENTITIES.containsKey(ResourceLocation.tryCreate(string.toString()));
}
return false;

View File

@@ -2,7 +2,6 @@ package exopandora.worldhandler.config;
import java.util.Arrays;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeConfigSpec;
@@ -50,66 +49,66 @@ public class ConfigCategorySettings
builder.push("settings");
this.valueCommandSyntax = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.command_syntax"))
.translation("gui.worldhandler.config.key.settings.command_syntax")
.translation("gui.worldhandler.config.settings.command_syntax")
.comment("Whether or not to display the current command at the bottom")
.define("command_syntax", false);
this.valueShortcuts = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.shortcuts"))
.translation("gui.worldhandler.config.key.settings.shortcuts")
.translation("gui.worldhandler.config.settings.shortcuts")
.comment("Whether or not to display a row of quick access buttons at the top")
.define("shortcuts", false);
this.valueShortcutKeys = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.key_shortcuts"))
.translation("gui.worldhandler.config.key.settings.key_shortcuts")
.translation("gui.worldhandler.config.settings.key_shortcuts")
.comment("Whether or not to enable button keys for pos1 and pos2")
.define("key_shortcuts", false);
this.valueTooltips = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.tooltips"))
.translation("gui.worldhandler.config.key.settings.tooltips")
.translation("gui.worldhandler.config.settings.tooltips")
.comment("Whether or not to display tooltips for buttons")
.define("tooltips", true);
this.valueWatch = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.watch"))
.translation("gui.worldhandler.config.key.settings.watch")
.translation("gui.worldhandler.config.settings.watch")
.comment("Whether or not to display a watch")
.define("watch", true);
this.valueSmoothWatch = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.smooth_watch"))
.translation("gui.worldhandler.config.key.settings.smooth_watch")
.translation("gui.worldhandler.config.settings.smooth_watch")
.comment("Whether or not the watch pointers move smoothly")
.define("smooth_watch", true);
this.valuePause = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.pause_game"))
.translation("gui.worldhandler.config.key.settings.pause_game")
.translation("gui.worldhandler.config.settings.pause_game")
.comment("Whether or not to pause the game when the gui is opened")
.define("pause_game", false);
this.valueCustomTimes = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.custom_times"))
.translation("gui.worldhandler.config.key.settings.custom_times")
.translation("gui.worldhandler.config.settings.custom_times")
.comment("Whether or not to use the custom times")
.define("custom_times", false);
this.valuePermissionQuery = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.permission_query"))
.translation("gui.worldhandler.config.key.settings.permission_query")
.translation("gui.worldhandler.config.settings.permission_query")
.comment("Whether or not the permission query is enabled")
.define("permission_query", true);
this.valueHighlightBlocks = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.highlight_blocks"))
.translation("gui.worldhandler.config.key.settings.highlight_blocks")
.translation("gui.worldhandler.config.settings.highlight_blocks")
.comment("Whether or not selected blocks will be highlighted")
.define("highlight_blocks", true);
this.valueDawn = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.custom_time_dawn"))
.translation("gui.worldhandler.config.key.settings.custom_time_dawn")
.translation("gui.worldhandler.config.settings.custom_time_dawn")
.comment("Ticks upon dawn")
.defineInRange("custom_time_dawn", 1000, 0, 24000);
this.valueNoon = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.custom_time_noon"))
.translation("gui.worldhandler.config.key.settings.custom_time_noon")
.translation("gui.worldhandler.config.settings.custom_time_noon")
.comment("Ticks upon noon")
.defineInRange("custom_time_noon", 6000, 0, 24000);
this.valueSunset = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.custom_time_sunset"))
.translation("gui.worldhandler.config.key.settings.custom_time_sunset")
.translation("gui.worldhandler.config.settings.custom_time_sunset")
.comment("Ticks upon sunset")
.defineInRange("custom_time_sunset", 12500, 0, 24000);
this.valueMidnight = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.custom_time_midnight"))
.translation("gui.worldhandler.config.key.settings.custom_time_midnight")
.translation("gui.worldhandler.config.settings.custom_time_midnight")
.comment("Ticks upon midnight")
.defineInRange("custom_time_midnight", 18000, 0, 24000);
this.valueBlockPlacingMode = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.block_placing_mode"))
.translation("gui.worldhandler.config.key.settings.block_placing_mode")
.translation("gui.worldhandler.config.settings.block_placing_mode")
.comment("Block placing mode (keep, replace, destroy)")
.defineInList("block_placing_mode", "keep", Arrays.asList("keep", "replace", "destroy"));
builder.pop();

View File

@@ -2,7 +2,6 @@ package exopandora.worldhandler.config;
import java.util.Arrays;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeConfigSpec;
@@ -48,64 +47,64 @@ public class ConfigCategorySkin
builder.push("skin");
this.valueIconSize = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.icon_size"))
.translation("gui.worldhandler.config.key.skin.icon_size")
.translation("gui.worldhandler.config.skin.icon_size")
.comment("Size of the icons")
.defineInList("icon_size", 16, Arrays.asList(16, 32, 64));
this.valueLabelColor = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.label_color"))
.translation("gui.worldhandler.config.key.skin.label_color")
.translation("gui.worldhandler.config.skin.label_color")
.comment("Label color")
.defineInRange("label_color", 0x1F1F1F, 0x80000000, 0x7FFFFFFF);
this.valueHeadlineColor = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.headline_color"))
.translation("gui.worldhandler.config.key.skin.headline_color")
.translation("gui.worldhandler.config.skin.headline_color")
.comment("Headline color")
.defineInRange("headline_color", 0x4F4F4F, 0x80000000, 0x7FFFFFFF);
this.valueBackgroundRed = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.background_red"))
.translation("gui.worldhandler.config.key.skin.background_red")
.translation("gui.worldhandler.config.skin.background_red")
.comment("Background red")
.defineInRange("background_red", 255, 0, 255);
this.valueBackgroundGreen = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.background_green"))
.translation("gui.worldhandler.config.key.skin.background_green")
.translation("gui.worldhandler.config.skin.background_green")
.comment("Background green")
.defineInRange("background_green", 255, 0, 255);
this.valueBackgroundBlue = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.background_blue"))
.translation("gui.worldhandler.config.key.skin.background_blue")
.translation("gui.worldhandler.config.skin.background_blue")
.comment("Background blue")
.defineInRange("background_blue", 255, 0, 255);
this.valueBackgroundAlpha = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.background_alpha"))
.translation("gui.worldhandler.config.key.skin.background_alpha")
.translation("gui.worldhandler.config.skin.background_alpha")
.comment("Background alpha")
.defineInRange("background_alpha", 255, 0, 255);
this.valueButtonRed = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.button_red"))
.translation("gui.worldhandler.config.key.skin.button_red")
.translation("gui.worldhandler.config.skin.button_red")
.comment("Button eed")
.defineInRange("button_red", 255, 0, 255);
this.valueButtonGreen = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.button_green"))
.translation("gui.worldhandler.config.key.skin.button_green")
.translation("gui.worldhandler.config.skin.button_green")
.comment("Button green")
.defineInRange("button_green", 255, 0, 255);
this.valueButtonBlue = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.button_blue"))
.translation("gui.worldhandler.config.key.skin.button_blue")
.translation("gui.worldhandler.config.skin.button_blue")
.comment("Button blue")
.defineInRange("button_blue", 255, 0, 255);
this.valueButtonAlpha = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.button_alpha"))
.translation("gui.worldhandler.config.key.skin.button_alpha")
.translation("gui.worldhandler.config.skin.button_alpha")
.comment("Button alpha")
.defineInRange("button_alpha", 255, 0, 255);
this.valueType = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.textures"))
.translation("gui.worldhandler.config.key.skin.textures")
.translation("gui.worldhandler.config.skin.textures")
.comment("Background texture (resourcepack, vanilla)")
.defineInList("textures", "resourcepack", Arrays.asList("resourcepack", "vanilla"));
this.valueSharpEdges = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.sharp_tab_edges"))
.translation("gui.worldhandler.config.key.settings.sharp_tab_edges")
.translation("gui.worldhandler.config.settings.sharp_tab_edges")
.comment("Whether or not the gui has sharp or smooth tab edges")
.define("sharp_tab_edges", false);
this.valueDrawBackground = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.draw_background"))
.translation("gui.worldhandler.config.key.settings.draw_background")
.translation("gui.worldhandler.config.settings.draw_background")
.comment("Whether or not to enable background drawing")
.define("draw_background", true);
builder.pop();

View File

@@ -1,6 +1,5 @@
package exopandora.worldhandler.config;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeConfigSpec;
@@ -34,43 +33,43 @@ public class ConfigCategorySliders
builder.push("sliders");
this.valueMaxPotionAmplifier = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_potion_amplifier"))
.translation("gui.worldhandler.config.key.sliders.max_potion_amplifier")
.translation("gui.worldhandler.config.sliders.max_potion_amplifier")
.comment("Maximum value for the potion amplifier")
.defineInRange("max_potion_amplifier", 100D, 0D, Byte.MAX_VALUE);
this.valueMaxItemEnchantment = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_item_enchantment"))
.translation("gui.worldhandler.config.key.sliders.max_item_enchantment")
.translation("gui.worldhandler.config.sliders.max_item_enchantment")
.comment("Maximum value for an item enchantment")
.defineInRange("max_item_enchantment", 100D, 0D, Integer.MAX_VALUE);
this.valueMaxItemAttributes = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_item_attributes"))
.translation("gui.worldhandler.config.key.sliders.max_item_attributes")
.translation("gui.worldhandler.config.sliders.max_item_attributes")
.comment("Maximum value for an item attribute")
.defineInRange("max_item_attributes", 100D, 0D, Double.MAX_VALUE);
this.valueMaxSummonPotionAmplifier = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_summon_potion_amplifier"))
.translation("gui.worldhandler.config.key.sliders.max_summon_potion_amplifier")
.translation("gui.worldhandler.config.sliders.max_summon_potion_amplifier")
.comment("Maximum value for the potion amplifier for summon")
.defineInRange("max_summon_potion_amplifier", 100D, 0D, Byte.MAX_VALUE);
this.valueMaxSummonPotionMinutes = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_summon_potion_minutes"))
.translation("gui.worldhandler.config.key.sliders.max_summon_potion_minutes")
.translation("gui.worldhandler.config.sliders.max_summon_potion_minutes")
.comment("Maximum value for the potion duration in minutes for summon")
.defineInRange("max_summon_potion_minutes", 100D, 0D, 16000);
this.valueMaxSummonAttributes = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_summon_attributes"))
.translation("gui.worldhandler.config.key.sliders.max_summon_attributes")
.translation("gui.worldhandler.config.sliders.max_summon_attributes")
.comment("Maximum value for attributes")
.defineInRange("max_summon_attributes", 100D, 0D, Double.MAX_VALUE);
this.valueMaxExperience = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_experience"))
.translation("gui.worldhandler.config.key.sliders.max_experience")
.translation("gui.worldhandler.config.sliders.max_experience")
.comment("Maximum value for experience")
.defineInRange("max_experience", 100D, 0D, 100000D);
this.valueMaxPlayerPoints = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_player_points"))
.translation("gui.worldhandler.config.key.sliders.max_player_points")
.translation("gui.worldhandler.config.sliders.max_player_points")
.comment("Maximum value for player points")
.defineInRange("max_player_points", 100D, 0D, 100000D);
this.valueMaxTriggerValue = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_trigger_value"))
.translation("gui.worldhandler.config.key.sliders.max_trigger_value")
.translation("gui.worldhandler.config.sliders.max_trigger_value")
.comment("Maximum value for triggers")
.defineInRange("max_trigger_value", 100D, 0D, 100000D);
builder.pop();

View File

@@ -1,5 +1,6 @@
package exopandora.worldhandler.event;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.ParseResults;
import com.mojang.brigadier.StringReader;
@@ -10,11 +11,10 @@ import exopandora.worldhandler.helper.BlockHelper;
import exopandora.worldhandler.helper.CommandHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.command.CommandSource;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.ClientChatEvent;
@@ -27,30 +27,26 @@ public class ClientEventHandler
@SubscribeEvent
public static void renderWorldLastEvent(RenderWorldLastEvent event)
{
if(Config.getSettings().highlightBlocks() && Minecraft.getInstance().world != null)
if(Config.getSettings().highlightBlocks() && Minecraft.getInstance().world != null && Minecraft.getInstance().getRenderManager().field_217783_c != null)
{
GlStateManager.pushMatrix();
GlStateManager.disableAlphaTest();
GlStateManager.enableBlend();
GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.lineWidth(2.0F);
GlStateManager.disableTexture2D();
GlStateManager.disableTexture();
GlStateManager.depthMask(false);
final double constant = 0.0020000000949949026D;
EntityPlayer player = Minecraft.getInstance().player;
Vec3d projected = Minecraft.getInstance().getRenderManager().field_217783_c.func_216785_c();
double playerX = player.lastTickPosX + (player.posX - player.lastTickPosX) * Minecraft.getInstance().getRenderPartialTicks();
double playerY = player.lastTickPosY + (player.posY - player.lastTickPosY) * Minecraft.getInstance().getRenderPartialTicks();
double playerZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * Minecraft.getInstance().getRenderPartialTicks();
double minX = Math.min(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) - constant - projected.x;
double minY = Math.min(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) - constant - projected.y;
double minZ = Math.min(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) - constant - projected.z;
double minX = Math.min(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) - constant - playerX;
double minY = Math.min(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) - constant - playerY;
double minZ = Math.min(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) - constant - playerZ;
double maxX = Math.max(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) + constant - playerX + 1;
double maxY = Math.max(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) + constant - playerY + 1;
double maxZ = Math.max(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) + constant - playerZ + 1;
double maxX = Math.max(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) + constant - projected.x + 1;
double maxY = Math.max(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) + constant - projected.y + 1;
double maxZ = Math.max(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) + constant - projected.z + 1;
Tessellator tesselator = Tessellator.getInstance();
BufferBuilder buffer = tesselator.getBuffer();
@@ -83,7 +79,7 @@ public class ClientEventHandler
GlStateManager.lineWidth(1.0F);
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.enableTexture();
GlStateManager.disableBlend();
GlStateManager.enableAlphaTest();
GlStateManager.popMatrix();

View File

@@ -16,7 +16,7 @@ public class KeyHandler
@SubscribeEvent
public static void keyInputEvent(KeyInputEvent event)
{
if(Minecraft.getInstance() != null && Minecraft.getInstance().currentScreen == null)
if(Minecraft.getInstance() != null && Minecraft.getInstance().field_71462_r == null)
{
if(WorldHandler.KEY_WORLD_HANDLER.isPressed())
{

View File

@@ -36,18 +36,18 @@ public enum EnumColor
UNDERLINE("underline", "n"),
ITALIC("italic", "o");
private String format;
private String name;
private String prefix;
private EnumColor(String format, String prefix)
private EnumColor(String name, String prefix)
{
this.format = format;
this.name = name;
this.prefix = prefix;
}
public String getFormat()
public String getName()
{
return this.format;
return this.name;
}
public String getPrefix()

View File

@@ -1,8 +1,7 @@
package exopandora.worldhandler.format.text;
import com.mojang.realmsclient.gui.ChatFormatting;
import exopandora.worldhandler.format.EnumColor;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -28,7 +27,7 @@ public class ColoredString extends FormattedString
public void setText(String string)
{
this.text = ChatFormatting.stripFormatting(string);
this.text = TextFormatting.getTextWithoutFormattingCodes(string);
}
public EnumColor getColor()
@@ -64,27 +63,27 @@ public class ColoredString extends FormattedString
{
if(this.italic)
{
result = ChatFormatting.ITALIC + result;
result = TextFormatting.ITALIC + result;
}
if(this.underlined)
{
result = ChatFormatting.UNDERLINE + result;
result = TextFormatting.UNDERLINE + result;
}
if(this.strikethrough)
{
result = ChatFormatting.STRIKETHROUGH + result;
result = TextFormatting.STRIKETHROUGH + result;
}
if(this.bold)
{
result = ChatFormatting.BOLD + result;
result = TextFormatting.BOLD + result;
}
if(this.obfuscated)
{
result = ChatFormatting.OBFUSCATED + result;
result = TextFormatting.OBFUSCATED + result;
}
if(this.color != null && !this.color.equals(EnumColor.DEFAULT))
@@ -110,7 +109,7 @@ public class ColoredString extends FormattedString
if(result.contains("\u00A7"))
{
result += ChatFormatting.RESET;
result += TextFormatting.RESET;
}
return result;

View File

@@ -17,7 +17,7 @@ public class JsonSignLine extends FormattedString
public JsonSignLine(ColoredString string)
{
this.text = super.getPreformattedString(string.getText());
this.color = string.getColor().getFormat();
this.color = string.getColor().getName();
this.bold = string.isBold();
this.strikethrough = string.isStriked();
this.underlined = string.isUnderlined();

View File

@@ -52,7 +52,7 @@ public class JsonSignLineSerializer implements JsonSerializer<JsonSignLine>
if(src.getColor() != null)
{
if(src.getColor().equals(EnumColor.DEFAULT.getFormat()))
if(src.getColor().equals(EnumColor.DEFAULT.getName()))
{
object.remove("color");
}

View File

@@ -1,91 +1,53 @@
package exopandora.worldhandler.gui.button;
import com.mojang.blaze3d.platform.GlStateManager;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.helper.ActionHelper;
import exopandora.worldhandler.helper.ResourceHelper;
import exopandora.worldhandler.util.ActionHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class GuiButtonBase extends GuiButton
public class GuiButtonBase extends Button
{
protected ActionHandler actionHandler;
public GuiButtonBase(int x, int y, int widthIn, int heightIn, String buttonText, ActionHandler actionHandler)
{
this(0, x, y, widthIn, heightIn, buttonText, actionHandler);
super(x, y, widthIn, heightIn, buttonText, button -> ActionHelper.tryRun(actionHandler));
}
public GuiButtonBase(int id, int x, int y, int widthIn, int heightIn, String buttonText, ActionHandler actionHandler)
@Override
public void renderButton(int mouseX, int mouseY, float partialTicks)
{
super(id, x, y, widthIn, heightIn, buttonText);
this.actionHandler = actionHandler;
this.renderBg(Minecraft.getInstance(), mouseX, mouseY);
this.drawCenteredString(Minecraft.getInstance().fontRenderer, this.getMessage(), this.x + this.width / 2, this.y + (this.height - 8) / 2, this.getFGColor());
}
protected void drawBackground(int mouseX, int mouseY)
@Override
protected void renderBg(Minecraft minecraft, int mouseX, int mouseY)
{
GlStateManager.enableBlend();
GlStateManager.color4f(Config.getSkin().getButtonRedF(), Config.getSkin().getButtonGreenF(), Config.getSkin().getButtonBlueF(), Config.getSkin().getButtonAlphaF());
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
int hovered = this.getHoverState(this.hovered);
int hovered = this.getYImage(this.isHovered());
Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.getButtonTexture());
if(Config.getSkin().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);
this.blit(this.x, this.y, 0, 46 + hovered * 20, this.width / 2, this.height);
this.blit(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);
this.blit(this.x, this.y, 0, hovered * 20, this.width / 2, this.height);
this.blit(this.x + this.width / 2, this.y, 200 - this.width / 2, hovered * 20, this.width / 2, this.height);
}
GlStateManager.disableBlend();
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
}
@Override
public void render(int mouseX, int mouseY, float partialTicks)
{
if(this.visible)
{
this.drawBackground(mouseX, mouseY);
this.renderBg(Minecraft.getInstance(), mouseX, mouseY);
this.drawCenteredString(Minecraft.getInstance().fontRenderer, this.displayString, this.x + this.width / 2, this.y + (this.height - 8) / 2, this.getTextColor());
}
}
@Override
public void onClick(double mouseX, double mouseY)
{
super.onClick(mouseX, mouseY);
if(this.actionHandler != null)
{
ActionHelper.tryRun(this.actionHandler);
}
}
protected int getTextColor()
{
int textColor = 0xE0E0E0;
if(!this.enabled)
{
textColor = 0xA0A0A0;
}
else if(this.hovered)
{
textColor = 0xFFFFA0;
}
return textColor;
}
}

View File

@@ -1,9 +1,10 @@
package exopandora.worldhandler.gui.button;
import com.mojang.blaze3d.platform.GlStateManager;
import exopandora.worldhandler.helper.ResourceHelper;
import exopandora.worldhandler.util.ActionHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -14,19 +15,14 @@ public class GuiButtonIcon extends GuiButtonTooltip
public GuiButtonIcon(int x, int y, int widthIn, int heightIn, EnumIcon icon, String tooltip, ActionHandler actionHandler)
{
this(0, x, y, widthIn, heightIn, icon, tooltip, actionHandler);
}
public GuiButtonIcon(int id, int x, int y, int widthIn, int heightIn, EnumIcon icon, String tooltip, ActionHandler actionHandler)
{
super(id, x, y, widthIn, heightIn, null, tooltip, actionHandler);
super(x, y, widthIn, heightIn, tooltip, tooltip, actionHandler);
this.icon = icon;
}
@Override
public void render(int mouseX, int mouseY, float partialTicks)
public void renderButton(int mouseX, int mouseY, float partialTicks)
{
super.render(mouseX, mouseY, partialTicks);
super.renderBg(Minecraft.getInstance(), mouseX, mouseY);
if(this.icon != null)
{
@@ -38,9 +34,9 @@ public class GuiButtonIcon extends GuiButtonTooltip
{
Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.getIconTexture());
if(this.enabled)
if(this.active)
{
if(this.hovered)
if(this.isHovered())
{
GlStateManager.color4f(1.0F, 1.0F, 0.6F, 1.0F);
}
@@ -54,6 +50,6 @@ public class GuiButtonIcon extends GuiButtonTooltip
GlStateManager.color4f(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);
this.blit(this.x + this.width / 2 - 4, this.y + 6, this.icon.getX() * 8, this.icon.getY() * 8, 8, 8);
}
}

View File

@@ -1,8 +1,9 @@
package exopandora.worldhandler.gui.button;
import com.mojang.blaze3d.platform.GlStateManager;
import exopandora.worldhandler.util.ActionHandler;
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;
@@ -16,40 +17,27 @@ public class GuiButtonItem extends GuiButtonBase
public GuiButtonItem(int x, int y, int width, int height, Item item, ActionHandler actionHandler)
{
this(0, x, y, width, height, item, actionHandler);
}
public GuiButtonItem(int id, int x, int y, int width, int height, Item item, ActionHandler actionHandler)
{
this(id, x, y, width, height, new ItemStack(item), actionHandler);
this(x, y, width, height, new ItemStack(item), actionHandler);
}
public GuiButtonItem(int x, int y, int width, int height, ItemStack stack, ActionHandler actionHandler)
{
this(0, x, y, width, height, stack, actionHandler);
}
public GuiButtonItem(int id, int x, int y, int width, int height, ItemStack stack, ActionHandler actionHandler)
{
super(id, x, y, width, height, null, actionHandler);
super(x, y, width, height, stack.getTextComponent().getString(), actionHandler);
this.stack = stack;
}
@Override
public void render(int mouseX, int mouseY, float partialTicks)
public void renderButton(int mouseX, int mouseY, float partialTicks)
{
if(this.visible)
{
super.drawBackground(mouseX, mouseY);
GlStateManager.enableRescaleNormal();
RenderHelper.enableGUIStandardItemLighting();
Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(this.stack, this.x + this.width / 2 - 8, this.y + 2);
RenderHelper.disableStandardItemLighting();
GlStateManager.disableRescaleNormal();
GlStateManager.disableBlend();
}
super.renderBg(Minecraft.getInstance(), mouseX, mouseY);
GlStateManager.enableRescaleNormal();
RenderHelper.enableGUIStandardItemLighting();
Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(this.stack, this.x + this.width / 2 - 8, this.y + 2);
RenderHelper.disableStandardItemLighting();
GlStateManager.disableRescaleNormal();
GlStateManager.enableAlphaTest();
}
}

View File

@@ -2,14 +2,12 @@ package exopandora.worldhandler.gui.button;
import java.util.List;
import com.mojang.realmsclient.gui.ChatFormatting;
import exopandora.worldhandler.format.TextFormatting;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.logic.ILogicMapped;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -22,42 +20,35 @@ public class GuiButtonList<T> extends GuiButtonTooltip
public GuiButtonList(int x, int y, List<T> items, int widthIn, int heightIn, Container container, ILogicMapped<T> logic)
{
this(0, x, y, items, widthIn, heightIn, container, logic);
}
public GuiButtonList(int id, int x, int y, List<T> items, int widthIn, int heightIn, Container container, ILogicMapped<T> logic)
{
super(id, x, y, widthIn, heightIn, null, null, null);
super(x, y, widthIn, heightIn, null, null, null);
this.items = items;
this.logic = logic;
this.persistence = container.getContent().getPersistence(this.logic.getId(), Persistence::new);
this.updateMessage();
}
@Override
public void render(int mouseX, int mouseY, float partialTicks)
public void renderButton(int mouseX, int mouseY, float partialTicks)
{
if(this.visible)
super.renderBg(Minecraft.getInstance(), mouseX, mouseY);
this.updateMessage();
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
if(this.getMessage() != null && !this.getMessage().isEmpty())
{
this.drawBackground(mouseX, mouseY);
String leftArrow = this.isHoveringLeft(mouseX, mouseY) ? TextFormatting.BOLD + "<" + TextFormatting.RESET : "<";
String rightArrow = this.isHoveringRight(mouseX, mouseY) ? TextFormatting.BOLD + ">" + TextFormatting.RESET : ">";
String displayString = this.logic.translate(this.items.get(this.persistence.getIndex()));
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
if(displayString != null && !displayString.isEmpty())
{
String leftArrow = this.isHoveringLeft(mouseX, mouseY) ? ChatFormatting.BOLD + "<" + ChatFormatting.RESET : "<";
String rightArrow = this.isHoveringRight(mouseX, mouseY) ? ChatFormatting.BOLD + ">" + ChatFormatting.RESET : ">";
int maxWidth = Math.max(0, this.width - fontRenderer.getStringWidth("< >"));
int spaceWidth = fontRenderer.getStringWidth(" ");
String display = TextFormatting.shortenString(displayString, maxWidth, fontRenderer);
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());
}
int maxWidth = Math.max(0, this.width - fontRenderer.getStringWidth("< >"));
int spaceWidth = fontRenderer.getStringWidth(" ");
String display = exopandora.worldhandler.format.TextFormatting.shortenString(this.getMessage(), maxWidth, fontRenderer);
int yPos = this.y + (this.height - 8) / 2;
this.drawCenteredString(fontRenderer, display, this.x + this.width / 2, yPos, this.getFGColor());
this.drawCenteredString(fontRenderer, leftArrow, this.x + this.width / 2 - maxWidth / 2 - spaceWidth, yPos, this.getFGColor());
this.drawCenteredString(fontRenderer, rightArrow, this.x + this.width / 2 + maxWidth / 2 + spaceWidth, yPos, this.getFGColor());
}
}
@@ -76,7 +67,7 @@ public class GuiButtonList<T> extends GuiButtonTooltip
if(this.isHoveringLeft(mouseX, mouseY))
{
if(GuiScreen.isShiftKeyDown())
if(Screen.hasShiftDown())
{
if(index < 10)
{
@@ -101,7 +92,7 @@ public class GuiButtonList<T> extends GuiButtonTooltip
}
else if(this.isHoveringRight(mouseX, mouseY))
{
if(GuiScreen.isShiftKeyDown())
if(Screen.hasShiftDown())
{
if(index > max - 10)
{
@@ -128,6 +119,11 @@ public class GuiButtonList<T> extends GuiButtonTooltip
this.logic.onClick(this.items.get(this.persistence.getIndex()));
}
private void updateMessage()
{
this.setMessage(this.logic.translate(this.items.get(this.persistence.getIndex())));
}
private boolean isHoveringLeft(double mouseX, double mouseY)
{
return this.isHoveringVertical(mouseY) && mouseX >= this.x && mouseX < this.x + Math.ceil(this.width / 2);

View File

@@ -1,5 +1,7 @@
package exopandora.worldhandler.gui.button;
import com.mojang.blaze3d.platform.GlStateManager;
import exopandora.worldhandler.Main;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.util.ActionHandler;
@@ -7,7 +9,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.SimpleSound;
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.minecraftforge.api.distmarker.Dist;
@@ -23,94 +24,92 @@ public class GuiButtonPiano extends GuiButtonBase
public GuiButtonPiano(int x, int y, int widthIn, int heightIn, String buttonText, SoundEvent sound, float pitch, Type type, ActionHandler actionHandler)
{
this(0, x, y, widthIn, heightIn, buttonText, sound, pitch, type, actionHandler);
}
public GuiButtonPiano(int buttonId, int x, int y, int widthIn, int heightIn, String buttonText, SoundEvent sound, float pitch, Type type, ActionHandler actionHandler)
{
super(buttonId, x, y, widthIn, heightIn, buttonText, actionHandler);
super(x, y, widthIn, heightIn, buttonText, actionHandler);
this.sound = sound;
this.pitch = pitch;
this.type = type;
}
@Override
public void render(int mouseX, int mouseY, float partialTicks)
public void renderButton(int mouseX, int mouseY, float partialTicks)
{
if(this.visible)
switch(this.type)
{
switch(this.type)
{
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);
GlStateManager.color4f(1.0F, 1.0F, 1.0F, Config.getSkin().getButtonAlphaF());
Minecraft.getInstance().getTextureManager().bindTexture(NOTE);
switch(this.type)
{
case LEFT:
case NORMAL:
case RIGHT:
this.drawWhiteKey(hoverstate);
break;
case BLACK:
this.drawBlackKey(hoverstate);
break;
default:
break;
}
case LEFT:
this.isHovered = this.isHoveringLeft(mouseX, mouseY);
break;
case NORMAL:
this.isHovered = this.isHoveringNormal(mouseX, mouseY);
break;
case RIGHT:
this.isHovered = this.isHoveringRight(mouseX, mouseY);
break;
case BLACK:
this.isHovered = this.isHoveringBlack(mouseX, mouseY);
break;
default:
break;
}
int hoverstate = this.getYImage(this.isHovered);
GlStateManager.color4f(1.0F, 1.0F, 1.0F, Config.getSkin().getButtonAlphaF());
Minecraft.getInstance().getTextureManager().bindTexture(NOTE);
switch(this.type)
{
case LEFT:
case NORMAL:
case RIGHT:
this.drawWhiteKey(hoverstate);
break;
case BLACK:
this.drawBlackKey(hoverstate);
break;
default:
break;
}
}
protected void drawWhiteKey(int hoverstate)
{
int textColor = this.getTextColor();
int textColor = this.getFGColor();
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
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);
this.blit(this.x, this.y, 25 + hoverstate * 15 - 15, 0, 15, 92);
fontRenderer.drawString(this.getMessage(), this.x + this.width / 2 - fontRenderer.getStringWidth(this.getMessage()) / 2, this.y + (this.height - 8) / 2 + 36, textColor);
}
protected void drawBlackKey(int hoverstate)
{
this.drawTexturedModalRect(this.x, this.y, 55 + hoverstate * -9 + 18, 0, 9, 58);
}
protected int getTextColor()
{
int textColor = 0x000000;
if(!this.enabled)
{
textColor = 0xA0A0A0;
}
else if(this.hovered)
{
textColor = 0x8B8B8B;
}
return textColor;
this.blit(this.x, this.y, 55 + hoverstate * -9 + 18, 0, 9, 58);
}
@Override
public void playPressSound(SoundHandler soundHandler)
public int getFGColor()
{
soundHandler.play(SimpleSound.getMasterRecord(this.sound, this.pitch));
if(this.packedFGColor != 0)
{
return this.packedFGColor;
}
int textColor = 0x000000;
if(!this.active)
{
textColor = 0xA0A0A0;
}
else if (this.isHovered())
{
textColor = 0x8B8B8B;
}
return textColor;
}
@Override
public void playDownSound(SoundHandler soundHandler)
{
soundHandler.play(SimpleSound.master(this.sound, this.pitch));
}
private boolean isHoveringBlack(double mouseX, double mouseY)
@@ -134,23 +133,29 @@ public class GuiButtonPiano extends GuiButtonBase
}
@Override
protected boolean isPressable(double mouseX, double mouseY)
public boolean isMouseOver(double mouseX, double mouseY)
{
switch(this.type)
{
case LEFT:
return this.enabled && this.visible && this.isHoveringLeft(mouseX, mouseY);
return this.active && this.visible && this.isHoveringLeft(mouseX, mouseY);
case NORMAL:
return this.enabled && this.visible && this.isHoveringNormal(mouseX, mouseY);
return this.active && this.visible && this.isHoveringNormal(mouseX, mouseY);
case RIGHT:
return this.enabled && this.visible && this.isHoveringRight(mouseX, mouseY);
return this.active && this.visible && this.isHoveringRight(mouseX, mouseY);
case BLACK:
return this.enabled && this.visible && this.isHoveringBlack(mouseX, mouseY);
return this.active && this.visible && this.isHoveringBlack(mouseX, mouseY);
default:
return false;
}
}
@Override
protected boolean clicked(double mouseX, double mouseY)
{
return this.isMouseOver(mouseX, mouseY);
}
@OnlyIn(Dist.CLIENT)
public static enum Type
{

View File

@@ -1,16 +1,16 @@
package exopandora.worldhandler.gui.button;
import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.widget.button.AbstractButton;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class GuiButtonTab extends GuiButton
public abstract class GuiButtonTab extends AbstractButton
{
public GuiButtonTab(int x, int y, int widthIn, int heightIn)
public GuiButtonTab(int x, int y, int widthIn, int heightIn, String narration)
{
super(0, x, y, widthIn, heightIn, null);
super(x, y, widthIn, heightIn, narration);
}
@Override
@@ -20,7 +20,7 @@ public class GuiButtonTab extends GuiButton
}
@Override
public void playPressSound(SoundHandler soundHandlerIn)
public void playDownSound(SoundHandler soundHandlerIn)
{
}

View File

@@ -16,26 +16,21 @@ public class GuiButtonTooltip extends GuiButtonBase
public GuiButtonTooltip(int x, int y, int widthIn, int heightIn, String buttonText, String tooltip, ActionHandler actionHandler)
{
this(0, x, y, widthIn, heightIn, buttonText, tooltip, actionHandler);
}
public GuiButtonTooltip(int id, int x, int y, int widthIn, int heightIn, String buttonText, String tooltip, ActionHandler actionHandler)
{
super(id, x, y, widthIn, heightIn, buttonText, actionHandler);
super(x, y, widthIn, heightIn, buttonText, actionHandler);
this.tooltip = tooltip;
}
public void renderTooltip(int mouseX, int mouseY)
{
if(this.hovered && this.tooltip != null)
if(this.isHovered() && this.tooltip != null)
{
List<String> list = Arrays.asList(this.tooltip.split("\n"));
if(!list.isEmpty())
{
int tooltipWidth = Minecraft.getInstance().fontRenderer.getStringWidth(this.tooltip) + 9;
int width = Minecraft.getInstance().currentScreen.width;
int height = Minecraft.getInstance().currentScreen.height;
int width = Minecraft.getInstance().field_71462_r.width;
int height = Minecraft.getInstance().field_71462_r.height;
GuiUtils.drawHoveringText(list, mouseX, mouseY, width, height, tooltipWidth, Minecraft.getInstance().fontRenderer);
}

View File

@@ -2,13 +2,14 @@ package exopandora.worldhandler.gui.button;
import java.util.Objects;
import com.mojang.blaze3d.platform.GlStateManager;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.format.TextFormatting;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.logic.ILogic;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -19,16 +20,9 @@ public class GuiSlider extends GuiButtonBase
private final ILogicSlider logic;
private final Container container;
private boolean dragging;
public GuiSlider(int x, int y, int widthIn, int heightIn, double min, double max, double start, Container container, ILogicSlider logic)
{
this(0, x, y, widthIn, heightIn, min, max, start, container, logic);
}
public GuiSlider(int id, int x, int y, int widthIn, int heightIn, double min, double max, double start, Container container, ILogicSlider logic)
{
super(id, x, y, widthIn, heightIn, null, null);
super(x, y, widthIn, heightIn, null, null);
this.logic = Objects.requireNonNull(logic);
this.container = Objects.requireNonNull(container);
this.persistence = this.container.getContent().getPersistence(this.logic.getId(), () -> new Persistence(min, max, min == max ? 0.0 : ((start - min) / (max - min))));
@@ -40,51 +34,38 @@ public class GuiSlider extends GuiButtonBase
@Override
protected void renderBg(Minecraft minecraft, int mouseX, int mouseY)
{
if(this.visible)
{
if(this.dragging)
{
this.persistence.setValue((mouseX - (this.x + 4)) / (float) (this.width - 8));
this.updateSlider();
}
int xOffset = Config.getSkin().getTextureType().equals("resourcepack") ? 0 : -46;
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.color4f(Config.getSkin().getButtonRedF(), Config.getSkin().getButtonGreenF(), Config.getSkin().getButtonBlueF(), Config.getSkin().getButtonAlphaF());
this.drawTexturedModalRect(this.x + (int) (this.persistence.getValue() * (float) (this.width - 8)), this.y, 0, 66 + xOffset, 4, 20);
this.drawTexturedModalRect(this.x + (int) (this.persistence.getValue() * (float) (this.width - 8)) + 4, this.y, 196, 66 + xOffset, 4, 20);
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
super.renderBg(minecraft, mouseX, mouseY);
int xOffset = Config.getSkin().getTextureType().equals("resourcepack") ? 0 : -46;
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.color4f(Config.getSkin().getButtonRedF(), Config.getSkin().getButtonGreenF(), Config.getSkin().getButtonBlueF(), Config.getSkin().getButtonAlphaF());
this.blit(this.x + (int) (this.persistence.getValue() * (float) (this.width - 8)), this.y, 0, 66 + xOffset, 4, 20);
this.blit(this.x + (int) (this.persistence.getValue() * (float) (this.width - 8)) + 4, this.y, 196, 66 + xOffset, 4, 20);
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
@Override
public void onClick(double mouseX, double mouseY)
{
this.persistence.setValue((mouseX - (this.x + 4)) / (this.width - 8));
this.updateSlider();
this.dragging = true;
this.updateSlider(mouseX);
}
@Override
public void onRelease(double mouseX, double mouseY)
protected void onDrag(double mouseX, double mouseY, double deltaX, double deltaY)
{
super.onRelease(mouseX, mouseY);
this.dragging = false;
this.updateSlider(mouseX);
super.onDrag(mouseX, mouseY, deltaX, deltaY);
}
@Override
protected int getHoverState(boolean mouseOver)
{
return 0;
}
private void updateSlider()
protected void updateSlider(double mouseX)
{
this.persistence.setValue((mouseX - (this.x + 4)) / (float) (this.width - 8));
if(this.persistence.getValue() < 0.0F)
{
this.persistence.setValue(0.0F);
@@ -99,13 +80,18 @@ public class GuiSlider extends GuiButtonBase
this.logic.onChangeSliderValue(this.persistence.getValueInt());
}
@Override
protected int getYImage(boolean mouseOver)
{
return 0;
}
private void updateDisplayString()
{
int value = this.persistence.getValueInt();
String suffix = this.logic.formatValue(value) + this.logic.formatSuffix(value);
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
this.displayString = TextFormatting.shortenString(this.logic.formatPrefix(value), this.width - fontRenderer.getStringWidth(suffix), fontRenderer) + suffix;
this.setMessage(TextFormatting.shortenString(this.logic.formatPrefix(value), this.width - fontRenderer.getStringWidth(suffix), fontRenderer) + suffix);
}
@OnlyIn(Dist.CLIENT)

View File

@@ -1,48 +1,38 @@
package exopandora.worldhandler.gui.button;
import com.mojang.realmsclient.gui.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class GuiTextFieldTooltip extends GuiTextField
public class GuiTextFieldTooltip extends TextFieldWidget
{
private String tooltip;
public GuiTextFieldTooltip(int x, int y, int width, int height)
{
this(0, x, y, width, height, null);
}
public GuiTextFieldTooltip(int id, int x, int y, int width, int height)
{
this(id, x, y, width, height, null);
this(x, y, width, height, null);
}
public GuiTextFieldTooltip(int x, int y, int width, int height, String tooltip)
{
this(0, x, y, width, height, tooltip);
}
public GuiTextFieldTooltip(int id, int x, int y, int width, int height, String tooltip)
{
super(id, Minecraft.getInstance().fontRenderer, x, y, width, height);
super(Minecraft.getInstance().fontRenderer, x, y, width, height, null);
this.setMaxStringLength(Integer.MAX_VALUE);
this.tooltip = tooltip;
}
@Override
public void drawTextField(int x, int y, float partialTicks)
public void renderButton(int x, int y, float partialTicks)
{
super.drawTextField(x, y, partialTicks);
super.renderButton(x, y, partialTicks);
if(this.getVisible() && !this.isFocused() && this.tooltip != null && ChatFormatting.stripFormatting(this.getText()).isEmpty())
if(this.getVisible() && !this.isFocused() && this.tooltip != null && TextFormatting.getTextWithoutFormattingCodes(this.getText()).isEmpty())
{
int tx = this.getEnableBackgroundDrawing() ? this.x + 4 : this.x;
int ty = this.getEnableBackgroundDrawing() ? this.y + (this.height - 8) / 2 : this.y;
boolean enableBackgroundDrawing = this.getAdjustedWidth() != this.width;
int tx = enableBackgroundDrawing ? this.x + 4 : this.x;
int ty = enableBackgroundDrawing ? this.y + (this.height - 8) / 2 : this.y;
Minecraft.getInstance().fontRenderer.drawStringWithShadow(this.tooltip, (float) tx, (float) ty, 0x7F7F7F);
}

View File

@@ -29,7 +29,7 @@ public class Categories
private static Category getRegisteredCategory(String name)
{
Category category = Category.REGISTRY.get(new ResourceLocation(Main.MODID, name));
Category category = Category.REGISTRY.getValue(new ResourceLocation(Main.MODID, name));
if(category == null)
{

View File

@@ -11,17 +11,21 @@ import exopandora.worldhandler.Main;
import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.gui.content.Contents;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.IRegistry;
import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistryEntry;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.RegistryBuilder;
@OnlyIn(Dist.CLIENT)
public class Category extends ForgeRegistryEntry<Category>
{
public static final String NAMESPACE = String.join("_", new String[] {Main.MODID, "category"});
public static final IRegistry<Category> REGISTRY = IRegistry.func_212610_a(NAMESPACE, new RegistryNamespacedDefaultedByKey<Category>(new ResourceLocation(NAMESPACE, "main")));
public static final IForgeRegistry<Category> REGISTRY = new RegistryBuilder<Category>()
.setType(Category.class)
.setName(new ResourceLocation(String.join("_", new String[] {Main.MODID, "category"})))
.disableSync()
.disableSaving()
.create();
private final List<Content> contents;
@@ -62,24 +66,25 @@ public class Category extends ForgeRegistryEntry<Category>
return this.contents.get(index);
}
public static void registerCategories()
public static void register()
{
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, Contents.RECIPES));
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));
Category.register("main", new Category(Contents.MAIN, Contents.CONTAINERS, Contents.MULTIPLAYER));
Category.register("entities", new Category(Contents.SUMMON));
Category.register("items", new Category(Contents.CUSTOM_ITEM, Contents.ENCHANTMENT, Contents.RECIPES));
Category.register("blocks", new Category(Contents.EDIT_BLOCKS, Contents.SIGN_EDITOR, Contents.NOTE_EDITOR));
Category.register("world", new Category(Contents.WORLD_INFO, Contents.GAMERULES));
Category.register("player", new Category(Contents.PLAYER, Contents.EXPERIENCE, Contents.ADVANCEMENTS));
Category.register("scoreboard", new Category(Contents.SCOREBOARD_OBJECTIVES, Contents.SCOREBOARD_TEAMS, Contents.SCOREBOARD_PLAYERS));
}
private static void registerCategory(int id, String textualID, Category category)
private static void register(String name, Category category)
{
registerCategory(id, new ResourceLocation(Main.MODID, textualID), category);
Category.register(new ResourceLocation(Main.MODID, name), category);
}
private static void registerCategory(int id, ResourceLocation textualID, Category category)
private static void register(ResourceLocation name, Category category)
{
REGISTRY.register(id, textualID, category);
category.setRegistryName(name);
REGISTRY.register(category);
}
}

View File

@@ -5,33 +5,39 @@ 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.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public abstract class Container extends GuiScreen implements IContainer
public abstract class Container extends Screen implements IContainer
{
protected Container(ITextComponent title)
{
super(title);
}
protected final List<IElement> elements = new ArrayList<IElement>();
@Override
public <T extends GuiButton> T add(T button)
public <T extends Widget> T add(T button)
{
return super.addButton(button);
}
public <T extends GuiTextField> T add(T textfield)
public <T extends TextFieldWidget> T add(T textfield)
{
this.children.add(textfield);
return textfield;
}
@Override
public void initGui()
public void init()
{
super.initGui();
super.init();
}
@Override

View File

@@ -2,14 +2,14 @@ package exopandora.worldhandler.gui.container;
import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.gui.content.element.Element;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.widget.Widget;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public interface IContainer
{
<T extends GuiButton> T add(T button);
<T extends Widget> T add(T button);
void initButtons();
void add(Element element);

View File

@@ -9,7 +9,7 @@ import java.util.function.BiConsumer;
import javax.annotation.Nullable;
import com.google.common.base.Predicates;
import com.mojang.realmsclient.gui.ChatFormatting;
import com.mojang.blaze3d.platform.GlStateManager;
import exopandora.worldhandler.Main;
import exopandora.worldhandler.WorldHandler;
@@ -29,11 +29,11 @@ import exopandora.worldhandler.helper.ActionHelper;
import exopandora.worldhandler.helper.ResourceHelper;
import exopandora.worldhandler.util.UtilRender;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.config.GuiUtils;
@@ -51,7 +51,7 @@ public class GuiWorldHandler extends Container
private final double tabHalf;
private final double tabEpsilon;
private final String splash = this.getSplash();
private final List<GuiButton> finalButtons = new ArrayList<GuiButton>();
private final List<Widget> finalButtons = new ArrayList<Widget>();
private GuiTextFieldTooltip syntaxField;
private GuiTextFieldTooltip nameField;
@@ -60,6 +60,7 @@ public class GuiWorldHandler extends Container
public GuiWorldHandler(Content content) throws Exception
{
super(new StringTextComponent(content.getTitle()));
this.content = content;
this.tabSize = this.content.getCategory().getSize();
this.tabDistanceTotal = Math.max(this.tabSize - 1, 1) * this.tabDistance;
@@ -70,9 +71,9 @@ public class GuiWorldHandler extends Container
}
@Override
public void initGui()
public void init()
{
super.initGui();
super.init();
ActionHelper.tryRun(() ->
{
@@ -129,7 +130,7 @@ public class GuiWorldHandler extends Container
this.nameField = new GuiTextFieldTooltip(0, 0, 0, 11);
this.nameField.setMaxStringLength(16);
this.nameField.setText(this.getPlayer());
this.nameField.setTextAcceptHandler((id, text) ->
this.nameField.func_212954_a(text ->
{
WorldHandler.USERNAME = text;
this.updateNameField();
@@ -145,10 +146,10 @@ public class GuiWorldHandler extends Container
if(!this.content.getActiveContent().equals(tab))
{
this.finalButtons.add(new GuiButtonTab((int) (backgroundX + xOffset), backgroundY - 20, (int) this.tabWidth + (int) Math.ceil(this.tabEpsilon / this.tabSize), 21)
this.finalButtons.add(new GuiButtonTab((int) (backgroundX + xOffset), backgroundY - 20, (int) this.tabWidth + (int) Math.ceil(this.tabEpsilon / this.tabSize), 21, tab.getTabTitle())
{
@Override
public void onClick(double mouseX, double mouseY)
public void onPress()
{
ActionHelper.changeTab(GuiWorldHandler.this.content, index);
}
@@ -282,13 +283,13 @@ public class GuiWorldHandler extends Container
if(WorldHandler.USERNAME.isEmpty())
{
int width = this.fontRenderer.getStringWidth(I18n.format("gui.worldhandler.generic.edit_username")) + 2;
int width = this.font.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);
this.nameField.setPosition(backgroundX + this.bgTextureWidth - this.getWatchOffset() - 7 - (this.font.getStringWidth(this.content.getTitle()) + 2), backgroundY + 6);
}
else
{
int width = this.fontRenderer.getStringWidth(WorldHandler.USERNAME) + 2;
int width = this.font.getStringWidth(WorldHandler.USERNAME) + 2;
this.nameField.setWidth(width);
this.nameField.setPosition(backgroundX + this.bgTextureWidth - this.getWatchOffset() - 7 - width, backgroundY + 6);
}
@@ -357,7 +358,7 @@ public class GuiWorldHandler extends Container
if(Config.getSkin().drawBackground())
{
super.drawDefaultBackground();
super.renderBackground();
}
//COLOR
@@ -367,7 +368,7 @@ public class GuiWorldHandler extends Container
//BACKGROUND
this.bindBackground();
this.drawTexturedModalRect(backgroundX, backgroundY, 0, 0, this.bgTextureWidth, this.bgTextureHeight);
this.blit(backgroundX, backgroundY, 0, 0, this.bgTextureWidth, this.bgTextureHeight);
//TABS
@@ -394,8 +395,8 @@ public class GuiWorldHandler extends Container
}
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);
this.blit((int) (backgroundX + xOffset), (int) (backgroundY + yOffset), 0, 0, (int) Math.ceil(this.tabHalf), fHeight);
this.blit((int) (backgroundX + this.tabHalf + xOffset), (int) (backgroundY + yOffset), this.bgTextureWidth - (int) Math.ceil(this.tabHalf), 0, (int) Math.ceil(this.tabHalf), fHeight);
if(!Config.getSkin().sharpEdges())
{
@@ -409,7 +410,7 @@ public class GuiWorldHandler extends Container
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);
this.blit((int) (backgroundX + this.tabWidth + xOffset - x - 1), (int) (backgroundY + x + 1), (int) (this.tabWidth - x - 1), x + 1, x + 1, 1);
}
}
@@ -421,7 +422,7 @@ public class GuiWorldHandler extends Container
for(int x = 0; x < factor; x++)
{
this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + x + 1), xOffset.intValue(), x + 1, x + 1, 1);
this.blit((int) (backgroundX + xOffset), (int) (backgroundY + x + 1), xOffset.intValue(), x + 1, x + 1, 1);
}
}
@@ -435,7 +436,7 @@ public class GuiWorldHandler extends Container
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);
this.blit((int) (backgroundX + xOffset), (int) (backgroundY + yOffset + fHeight + x / interval), 0, fHeight, width - x, 1);
}
}
@@ -448,7 +449,7 @@ public class GuiWorldHandler extends Container
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);
this.blit((int) (backgroundX + Math.ceil(xOffset) + x + offset), (int) (backgroundY + yOffset + fHeight + x / interval), this.bgTextureWidth - width + x, fHeight, width - x, 1);
}
}
}
@@ -462,7 +463,7 @@ public class GuiWorldHandler extends Container
for(int x = 0; x < factor; x++)
{
this.drawTexturedModalRect(backgroundX, backgroundY + x, 0, fHeight, factor - x, 1);
this.blit(backgroundX, backgroundY + x, 0, fHeight, factor - x, 1);
}
}
@@ -474,13 +475,13 @@ public class GuiWorldHandler extends Container
for(int x = 0; x < factor + 1; x++)
{
this.drawTexturedModalRect(backgroundX + this.bgTextureWidth - x, backgroundY + factor - x, this.bgTextureWidth - x, fHeight, x, 1);
this.blit(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.drawCenteredString(this.font, net.minecraft.util.text.TextFormatting.UNDERLINE + tab.getTabTitle(), (int) (backgroundX + this.tabHalf + xOffset), (int) (backgroundY - 13), color);
});
this.defaultColor();
@@ -490,15 +491,15 @@ public class GuiWorldHandler extends Container
final String label = Main.MC_VERSION + "-" + Main.MOD_VERSION;
final int hexAlpha = (int) (0xFF * 0.2) << 24;
final int color = Config.getSkin().getLabelColor() + hexAlpha;
final int versionWidth = this.width - this.fontRenderer.getStringWidth(label) - 2;
final int versionWidth = this.width - this.font.getStringWidth(label) - 2;
final int versionHeight = this.height - 10;
this.fontRenderer.drawString(label, versionWidth, versionHeight, color);
this.font.drawString(label, versionWidth, versionHeight, 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, Config.getSkin().getLabelColor());
final int maxWidth = this.bgTextureWidth - 7 - 2 - this.font.getStringWidth(WorldHandler.USERNAME) - 2 - this.getWatchOffset() - 7;
this.font.drawString(TextFormatting.shortenString(this.content.getTitle(), maxWidth, this.font), backgroundX + 7, backgroundY + 7, Config.getSkin().getLabelColor());
//HEADLINE
@@ -506,19 +507,19 @@ public class GuiWorldHandler extends Container
{
if(this.content.getHeadline().length > 0)
{
this.fontRenderer.drawString(this.content.getHeadline()[0], backgroundX + 8, backgroundY + 22, Config.getSkin().getHeadlineColor());
this.font.drawString(this.content.getHeadline()[0], backgroundX + 8, backgroundY + 22, Config.getSkin().getHeadlineColor());
}
if(this.content.getHeadline().length > 1)
{
this.fontRenderer.drawString(this.content.getHeadline()[1], backgroundX + 126, backgroundY + 22, Config.getSkin().getHeadlineColor());
this.font.drawString(this.content.getHeadline()[1], backgroundX + 126, backgroundY + 22, Config.getSkin().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, Config.getSkin().getLabelColor());
this.font.drawString(username, backgroundX + 232 - this.font.getStringWidth(username), backgroundY + 7, Config.getSkin().getLabelColor());
//WATCH
@@ -533,7 +534,7 @@ public class GuiWorldHandler extends Container
{
if(mouseX >= watchX && mouseX <= watchX + 9 && mouseY >= watchY && mouseY <= watchY + 9)
{
GuiUtils.drawHoveringText(Arrays.asList(TextFormatting.formatWorldTime(Minecraft.getInstance().world.getDayTime())), mouseX, mouseY + 9, this.width, this.height, this.width, this.fontRenderer);
GuiUtils.drawHoveringText(Arrays.asList(TextFormatting.formatWorldTime(Minecraft.getInstance().world.getDayTime())), mouseX, mouseY + 9, this.width, this.height, this.width, this.font);
GlStateManager.disableLighting();
}
}
@@ -546,11 +547,6 @@ public class GuiWorldHandler extends Container
this.buttons.get(x).render(mouseX, mouseY, partialTicks);
}
for(int x = 0; x < this.labels.size(); x++)
{
this.labels.get(x).render(mouseX, mouseY, partialTicks);
}
//CONTAINER
this.content.drawScreen(this, this.getContentX(), this.getContentY(), mouseX, mouseY, partialTicks);
@@ -566,7 +562,7 @@ public class GuiWorldHandler extends Container
if(Config.getSettings().commandSyntax() && this.syntaxField != null)
{
this.syntaxField.drawTextField(mouseX, mouseY, partialTicks);
this.syntaxField.renderButton(mouseX, mouseY, partialTicks);
}
//SPLASHTEXT
@@ -580,10 +576,10 @@ public class GuiWorldHandler extends Container
GlStateManager.rotatef(17.0F, 0.0F, 0.0F, 1.0F);
float scale = 1.1F - MathHelper.abs(MathHelper.sin((float) (System.currentTimeMillis() % 1000L) / 1000.0F * (float) Math.PI * 2.0F) * 0.1F);
scale = scale * 100.0F / this.fontRenderer.getStringWidth(this.splash);
scale = scale * 100.0F / this.font.getStringWidth(this.splash);
GlStateManager.scalef(scale, scale, scale);
this.drawCenteredString(this.fontRenderer, this.splash, 0, (int) scale, 0xFFFF00);
this.drawCenteredString(this.font, this.splash, 0, (int) scale, 0xFFFF00);
GlStateManager.popMatrix();
}
@@ -592,7 +588,7 @@ public class GuiWorldHandler extends Container
if(Config.getSettings().tooltips())
{
for(GuiButton button : this.buttons)
for(Widget button : this.buttons)
{
if(button instanceof GuiButtonTooltip)
{
@@ -605,7 +601,7 @@ public class GuiWorldHandler extends Container
if(mouseX >= versionWidth && mouseY >= versionHeight)
{
GuiUtils.drawHoveringText(Arrays.asList(label), versionWidth - 12, versionHeight + 12, this.width + this.fontRenderer.getStringWidth(label), this.height + 10, this.width, this.fontRenderer);
GuiUtils.drawHoveringText(Arrays.asList(label), versionWidth - 12, versionHeight + 12, this.width + this.font.getStringWidth(label), this.height + 10, this.width, this.font);
}
});
}
@@ -633,13 +629,14 @@ public class GuiWorldHandler extends Container
}
@Override
public void onGuiClosed()
public void onClose()
{
ActionHelper.tryRun(this.content::onGuiClosed);
super.onClose();
}
@Override
public boolean doesGuiPauseGame()
public boolean isPauseScreen()
{
return Config.getSettings().pause();
}
@@ -655,4 +652,10 @@ public class GuiWorldHandler extends Container
{
return this.content;
}
@Override
public boolean shouldCloseOnEsc()
{
return true;
}
}

View File

@@ -19,82 +19,87 @@ 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.ContentScoreboardObjectives;
import exopandora.worldhandler.gui.content.impl.ContentPlayer;
import exopandora.worldhandler.gui.content.impl.ContentScoreboardPlayers;
import exopandora.worldhandler.gui.content.impl.ContentPotions;
import exopandora.worldhandler.gui.content.impl.ContentRecipes;
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.ContentSettings;
import exopandora.worldhandler.gui.content.impl.ContentSignEditor;
import exopandora.worldhandler.gui.content.impl.ContentSummon;
import exopandora.worldhandler.gui.content.impl.ContentScoreboardTeams;
import exopandora.worldhandler.gui.content.impl.ContentWorldInfo;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.IRegistry;
import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistryEntry;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.RegistryBuilder;
@OnlyIn(Dist.CLIENT)
public abstract class Content extends ForgeRegistryEntry<Content> implements IContent
{
public static final String NAMESPACE = String.join("_", new String[] {Main.MODID, "content"});
public static final IRegistry<Content> REGISTRY = IRegistry.func_212610_a(NAMESPACE, new RegistryNamespacedDefaultedByKey<Content>(new ResourceLocation(NAMESPACE, "main")));
public static final IForgeRegistry<Content> REGISTRY = new RegistryBuilder<Content>()
.setType(Content.class)
.setName(new ResourceLocation(String.join("_", new String[] {Main.MODID, "content"})))
.disableSync()
.disableSaving()
.create();
public static void registerContents()
{
//MAIN
registerContent(0, "main", new ContentMain());
registerContent(1, "containers", new ContentContainers());
registerContent(2, "multiplayer", new ContentMultiplayer());
Content.register("main", new ContentMain());
Content.register("containers", new ContentContainers());
Content.register("multiplayer", new ContentMultiplayer());
//ENTITIES
registerContent(3, "summon", new ContentSummon());
Content.register("summon", new ContentSummon());
//ITEMS
registerContent(5, "custom_item", new ContentCustomItem());
registerContent(4, "enchantment", new ContentEnchantment());
Content.register("custom_item", new ContentCustomItem());
Content.register("enchantment", new ContentEnchantment());
//BLOCKS
registerContent(6, "edit_blocks", new ContentEditBlocks());
registerContent(7, "sign_editor", new ContentSignEditor());
registerContent(8, "note_editor", new ContentNoteEditor());
Content.register("edit_blocks", new ContentEditBlocks());
Content.register("sign_editor", new ContentSignEditor());
Content.register("note_editor", new ContentNoteEditor());
//WORLD
registerContent(9, "world", new ContentWorldInfo());
registerContent(10, "gamerules", new ContentGamerules());
registerContent(11, "recipes", new ContentRecipes());
Content.register("world", new ContentWorldInfo());
Content.register("gamerules", new ContentGamerules());
Content.register("recipes", new ContentRecipes());
//PLAYER
registerContent(12, "player", new ContentPlayer());
registerContent(13, "experience", new ContentExperience());
registerContent(14, "advancements", new ContentAdvancements());
Content.register("player", new ContentPlayer());
Content.register("experience", new ContentExperience());
Content.register("advancements", new ContentAdvancements());
//SCOREBOARD
registerContent(15, "scoreboard_objectives", new ContentScoreboardObjectives());
registerContent(16, "scoreboard_teams", new ContentScoreboardTeams());
registerContent(17, "scoreboard_players", new ContentScoreboardPlayers());
Content.register("scoreboard_objectives", new ContentScoreboardObjectives());
Content.register("scoreboard_teams", new ContentScoreboardTeams());
Content.register("scoreboard_players", new ContentScoreboardPlayers());
//MISC
registerContent(18, "change_world", new ContentChangeWorld());
registerContent(19, "continue", new ContentContinue());
Content.register("change_world", new ContentChangeWorld());
Content.register("continue", new ContentContinue());
//NO CATEGORY
registerContent(20, "potions", new ContentPotions());
registerContent(21, "butcher", new ContentButcher());
registerContent(22, "butcher_settings", new ContentButcherSettings());
registerContent(23, "settings", new ContentSettings());
Content.register("potions", new ContentPotions());
Content.register("butcher", new ContentButcher());
Content.register("butcher_settings", new ContentButcherSettings());
Content.register("settings", new ContentSettings());
}
private static void registerContent(int id, String textualID, Content content)
private static void register(String name, Content content)
{
registerContent(id, new ResourceLocation(Main.MODID, textualID), content);
Content.registerContent(new ResourceLocation(Main.MODID, name), content);
}
private static void registerContent(int id, ResourceLocation textualID, Content content)
private static void registerContent(ResourceLocation name, Content content)
{
REGISTRY.register(id, textualID, content);
content.setRegistryName(name);
REGISTRY.register(content);
}
private Map<String, Object> persistence;

View File

@@ -81,7 +81,7 @@ public class Contents
private static Content getRegisteredContent(String name)
{
Content content = Content.REGISTRY.get(new ResourceLocation(Main.MODID, name));
Content content = Content.REGISTRY.getValue(new ResourceLocation(Main.MODID, name));
if(content == null)
{

View File

@@ -3,8 +3,6 @@ package exopandora.worldhandler.gui.content.element.impl;
import java.util.ArrayList;
import java.util.List;
import com.mojang.realmsclient.gui.ChatFormatting;
import exopandora.worldhandler.format.EnumColor;
import exopandora.worldhandler.format.text.ColoredString;
import exopandora.worldhandler.gui.button.GuiButtonBase;
@@ -15,6 +13,7 @@ import exopandora.worldhandler.gui.content.element.Element;
import exopandora.worldhandler.gui.logic.ILogicColorMenu;
import exopandora.worldhandler.gui.logic.ILogicMapped;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -69,7 +68,7 @@ public class ElementColorMenu extends Element
this.textField.setValidator(this.logic::validate);
this.textField.setTextFormatter(this.string::textFormatter);
this.textField.setText(this.string.getText());
this.textField.setTextAcceptHandler((id, text) ->
this.textField.func_212954_a(text ->
{
this.string.setText(text);
});
@@ -87,7 +86,7 @@ public class ElementColorMenu extends Element
@Override
public String translate(EnumColor item)
{
return item + I18n.format("gui.worldhandler.color") + ": " + I18n.format("gui.worldhandler.color." + item.getFormat());
return item + I18n.format("gui.worldhandler.color") + ": " + I18n.format("gui.worldhandler.color." + item.getName());
}
@Override
@@ -115,30 +114,30 @@ public class ElementColorMenu extends Element
}
}));
container.add(new GuiButtonBase(this.x + 118, this.y + 48, 20, 20, (this.string.isItalic() ? ChatFormatting.ITALIC : ChatFormatting.RESET) + "I", () ->
container.add(new GuiButtonBase(this.x + 118, this.y + 48, 20, 20, (this.string.isItalic() ? TextFormatting.ITALIC : TextFormatting.RESET) + "I", () ->
{
this.string.setItalic(!this.string.isItalic());
container.initGui();
container.init();
}));
container.add(new GuiButtonBase(this.x + 118 + 24 - 1, this.y + 48, 20, 20, (this.string.isBold() ? ChatFormatting.BOLD : ChatFormatting.RESET) + "B", () ->
container.add(new GuiButtonBase(this.x + 118 + 24 - 1, this.y + 48, 20, 20, (this.string.isBold() ? TextFormatting.BOLD : TextFormatting.RESET) + "B", () ->
{
this.string.setBold(!this.string.isBold());
container.initGui();
container.init();
}));
container.add(new GuiButtonBase(this.x + 118 + 24 * 2 - 1, this.y + 48, 20, 20, (this.string.isUnderlined() ? ChatFormatting.UNDERLINE : ChatFormatting.RESET) + "U", () ->
container.add(new GuiButtonBase(this.x + 118 + 24 * 2 - 1, this.y + 48, 20, 20, (this.string.isUnderlined() ? TextFormatting.UNDERLINE : TextFormatting.RESET) + "U", () ->
{
this.string.setUnderlined(!this.string.isUnderlined());
container.initGui();
container.init();
}));
container.add(new GuiButtonBase(this.x + 118 + 24 * 3 - 1, this.y + 48, 20, 20, (this.string.isStriked() ? ChatFormatting.STRIKETHROUGH : ChatFormatting.RESET) + "S", () ->
container.add(new GuiButtonBase(this.x + 118 + 24 * 3 - 1, this.y + 48, 20, 20, (this.string.isStriked() ? TextFormatting.STRIKETHROUGH : TextFormatting.RESET) + "S", () ->
{
this.string.setStriked(!this.string.isStriked());
container.initGui();
container.init();
}));
container.add(new GuiButtonBase(this.x + 118 + 24 * 4 - 2, this.y + 48, 20, 20, (this.string.isObfuscated() ? ChatFormatting.OBFUSCATED : ChatFormatting.RESET) + "O", () ->
container.add(new GuiButtonBase(this.x + 118 + 24 * 4 - 2, this.y + 48, 20, 20, (this.string.isObfuscated() ? TextFormatting.OBFUSCATED : TextFormatting.RESET) + "O", () ->
{
this.string.setObfuscated(!this.string.isObfuscated());
container.initGui();
container.init();
}));
}
}
@@ -152,6 +151,6 @@ public class ElementColorMenu extends Element
@Override
public void draw(int mouseX, int mouseY, float partialTicks)
{
this.textField.drawTextField(mouseX, mouseY, partialTicks);
this.textField.renderButton(mouseX, mouseY, partialTicks);
}
}

View File

@@ -98,7 +98,7 @@ public class ElementMultiButtonList extends Element
for(int x = this.getDepth() + 1; x < this.maxDepth; x++)
{
GuiButtonBase button = new GuiButtonBase(this.x, this.y + 24 * x, 114, 20, null, null);
button.enabled = false;
button.active = false;
container.add(button);
}
}

View File

@@ -10,7 +10,7 @@ import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.content.element.Element;
import exopandora.worldhandler.gui.logic.ILogicPageList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -57,11 +57,11 @@ public class ElementPageList<T> extends Element
int buttonWidth = (this.width - 4) / 2;
GuiButtonBase left = new GuiButtonBase(this.x, this.y + (this.height + 4) * this.length, buttonWidth + 1, this.height, "<", () -> this.goLeft(container));
left.enabled = this.persistence.getPage() > 0;
left.active = this.persistence.getPage() > 0;
container.add(left);
GuiButtonBase right = new GuiButtonBase(this.x + 5 + buttonWidth, this.y + (this.height + 4) * this.length, buttonWidth, this.height, ">", () -> this.goRight(container));
right.enabled = this.persistence.getPage() < this.getTotalPages() - 1;
right.active = this.persistence.getPage() < this.getTotalPages() - 1;
container.add(right);
}
@@ -84,13 +84,13 @@ public class ElementPageList<T> extends Element
if(this.logic.doDisable())
{
button.enabled = this.persistence.getSelectedIndex() != index;
button.active = this.persistence.getSelectedIndex() != index;
}
}
else
{
button = new GuiButtonBase(this.x, this.y + (this.height + 4) * x, this.width, this.height, null, null);
button.enabled = false;
button.active = false;
}
container.add(button);
@@ -113,7 +113,7 @@ public class ElementPageList<T> extends Element
{
int page = this.persistence.getPage();
if(GuiScreen.isShiftKeyDown())
if(Screen.hasShiftDown())
{
this.persistence.setPage(page - Math.min(10, page));
}
@@ -129,7 +129,7 @@ public class ElementPageList<T> extends Element
{
int page = this.persistence.getPage();
if(GuiScreen.isShiftKeyDown())
if(Screen.hasShiftDown())
{
this.persistence.setPage(page + Math.min(10, this.getTotalPages() - 1 - page));
}

View File

@@ -4,8 +4,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import com.mojang.realmsclient.gui.ChatFormatting;
import exopandora.worldhandler.builder.ICommandBuilder;
import exopandora.worldhandler.builder.impl.BuilderAdvancement;
import exopandora.worldhandler.builder.impl.BuilderAdvancement.EnumActionType;
@@ -29,6 +27,7 @@ import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -129,7 +128,7 @@ public class ContentAdvancements extends Content
{
CommandHelper.sendCommand(this.builderAdvancement.getBuilderForAction(EnumActionType.REVOKE));
}));
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.actions.reset"), () ->
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, TextFormatting.RED + I18n.format("gui.worldhandler.actions.reset"), () ->
{
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.CONTINUE.withBuilder(this.builderAdvancement.getBuilder(EnumActionType.REVOKE, EnumMode.EVERYTHING)).withParent(Contents.ADVANCEMENTS)));
}));

View File

@@ -56,7 +56,7 @@ public class ContentButcher extends ContentChild
return true;
});
this.radiusField.setText(this.radius);
this.radiusField.setTextAcceptHandler((id, text) ->
this.radiusField.func_212954_a(text ->
{
this.radius = text;
@@ -87,7 +87,7 @@ public class ContentButcher extends ContentChild
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.BUTCHER_SETTINGS.withParent(Contents.BUTCHER)));
}));
container.add(slaughter = new GuiButtonBase(2, x + 116 / 2, y + 60, 232 / 2, 20, I18n.format("gui.worldhandler.butcher.slaughter"), () ->
container.add(slaughter = new GuiButtonBase(x + 116 / 2, y + 60, 232 / 2, 20, I18n.format("gui.worldhandler.butcher.slaughter"), () ->
{
for(ResourceLocation entry : Config.getButcher().getEntities())
{
@@ -95,7 +95,7 @@ public class ContentButcher extends ContentChild
}
}));
slaughter.enabled = this.radius != null && !this.radius.isEmpty() && !Config.CLIENT.getButcher().getEntities().isEmpty();
slaughter.active = this.radius != null && !this.radius.isEmpty() && !Config.CLIENT.getButcher().getEntities().isEmpty();
}
@Override
@@ -107,7 +107,7 @@ public class ContentButcher extends ContentChild
@Override
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
{
this.radiusField.drawTextField(mouseX, mouseY, partialTicks);
this.radiusField.renderButton(mouseX, mouseY, partialTicks);
}
@Override

View File

@@ -35,14 +35,7 @@ public class ContentButcherSettings extends ContentChild
@Override
public String translate(EntityType<?> item)
{
TextFormatting color = TextFormatting.RED;
if(Config.CLIENT.getButcher().containsEntity(item.getRegistryName()))
{
color = TextFormatting.GREEN;
}
return color + I18n.format(item.getTranslationKey());
return I18n.format(item.getTranslationKey());
}
@Override
@@ -96,8 +89,8 @@ public class ContentButcherSettings extends ContentChild
boolean contains = Config.CLIENT.getButcher().containsEntity(this.entity);
button1.enabled = !contains;
button2.enabled = contains;
button1.active = !contains;
button2.active = contains;
}
@Override

View File

@@ -5,14 +5,14 @@ import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.content.impl.abstr.ContentChild;
import exopandora.worldhandler.helper.ActionHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiConnecting;
import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.gui.GuiMultiplayer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiWorldSelection;
import net.minecraft.client.gui.screen.ConnectingScreen;
import net.minecraft.client.gui.screen.MainMenuScreen;
import net.minecraft.client.gui.screen.MultiplayerScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.WorldSelectionScreen;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -27,7 +27,7 @@ public class ContentChangeWorld extends ContentChild
container.add(new GuiButtonBase(x + 116 / 2, y + 24, 232 / 2, 20, I18n.format("gui.worldhandler.change_world.singleplayer"), () ->
{
Minecraft.getInstance().displayGuiScreen(new GuiWorldSelection(container));
Minecraft.getInstance().displayGuiScreen(new WorldSelectionScreen(container));
}));
container.add(new GuiButtonBase(x + 116 / 2, y + 48, 232 / 2, 20, I18n.format("gui.worldhandler.change_world.multiplayer"), () ->
{
@@ -36,14 +36,14 @@ public class ContentChangeWorld extends ContentChild
if(server != null)
{
Minecraft.getInstance().world.sendQuittingDisconnectingPacket();
Minecraft.getInstance().loadWorld((WorldClient)null);
Minecraft.getInstance().loadWorld(null);
Minecraft.getInstance().displayGuiScreen(new GuiMultiplayer(new GuiScreen()
Minecraft.getInstance().displayGuiScreen(new MultiplayerScreen(new Screen(new StringTextComponent(""))
{
@Override
public void initGui()
public void init()
{
Minecraft.getInstance().displayGuiScreen(new GuiConnecting(new GuiMainMenu(), Minecraft.getInstance(), server));
Minecraft.getInstance().displayGuiScreen(new ConnectingScreen(new MainMenuScreen(), Minecraft.getInstance(), server));
Minecraft.getInstance().mouseHelper.grabMouse();
}
}));
@@ -56,10 +56,10 @@ public class ContentChangeWorld extends ContentChild
Minecraft.getInstance().world.sendQuittingDisconnectingPacket();
Minecraft.getInstance().loadWorld(null);
Minecraft.getInstance().displayGuiScreen(new GuiMultiplayer(new GuiScreen()
Minecraft.getInstance().displayGuiScreen(new MultiplayerScreen(new Screen(new StringTextComponent(""))
{
@Override
public void initGui()
public void init()
{
Minecraft.getInstance().launchIntegratedServer(folderName, worldName, null);
Minecraft.getInstance().displayGuiScreen(null);

View File

@@ -16,9 +16,9 @@ import exopandora.worldhandler.helper.ActionHelper;
import exopandora.worldhandler.helper.BlockHelper;
import exopandora.worldhandler.helper.CommandHelper;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

View File

@@ -1,7 +1,5 @@
package exopandora.worldhandler.gui.content.impl;
import com.mojang.realmsclient.gui.ChatFormatting;
import exopandora.worldhandler.builder.ICommandBuilder;
import exopandora.worldhandler.builder.ICommandBuilderSyntax;
import exopandora.worldhandler.gui.button.GuiButtonBase;
@@ -13,6 +11,7 @@ import exopandora.worldhandler.helper.ActionHelper;
import exopandora.worldhandler.helper.CommandHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -45,7 +44,7 @@ public class ContentContinue extends ContentChild
public void initGui(Container container, int x, int y)
{
this.commandField = new GuiTextFieldTooltip(x + 116 / 2, y + 12, 116, 20);
this.commandField.setFocused(false);
this.commandField.setFocused2(false);
if(this.builder instanceof ICommandBuilderSyntax)
{
@@ -67,7 +66,7 @@ public class ContentContinue extends ContentChild
container.add(new GuiButtonBase(x + 118, y + 96, 114, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
container.add(this.commandField);
container.add(new GuiButtonBase(x + 116 / 2, y + 36, 116, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.generic.yes"), () ->
container.add(new GuiButtonBase(x + 116 / 2, y + 36, 116, 20, TextFormatting.RED + I18n.format("gui.worldhandler.generic.yes"), () ->
{
CommandHelper.sendCommand(this.builder, this.special);
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(this.parent));
@@ -78,7 +77,7 @@ public class ContentContinue extends ContentChild
@Override
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
{
this.commandField.drawTextField(mouseX, mouseY, partialTicks);
this.commandField.renderButton(mouseX, mouseY, partialTicks);
}
@Override

View File

@@ -87,7 +87,7 @@ public class ContentCustomItem extends Content
this.itemField = new GuiTextFieldTooltip(x + 118, y, 114, 20, I18n.format("gui.worldhandler.items.custom_item.start.item_id"));
this.itemField.setValidator(Predicates.<String>notNull());
this.itemField.setText(this.item);
this.itemField.setTextAcceptHandler((id, text) ->
this.itemField.func_212954_a(text ->
{
this.item = text;
this.builderCutomItem.setItem(this.item);
@@ -97,7 +97,7 @@ public class ContentCustomItem extends Content
this.itemLore1Field = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.items.custom_item.start.lore_1"));
this.itemLore1Field.setValidator(Predicates.<String>notNull());
this.itemLore1Field.setText(this.builderCutomItem.getLore1());
this.itemLore1Field.setTextAcceptHandler((id, text) ->
this.itemLore1Field.func_212954_a(text ->
{
this.builderCutomItem.setLore1(text);
container.initButtons();
@@ -106,7 +106,7 @@ public class ContentCustomItem extends Content
this.itemLore2Field = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.items.custom_item.start.lore_2"));
this.itemLore2Field.setValidator(Predicates.<String>notNull());
this.itemLore2Field.setText(this.builderCutomItem.getLore2());
this.itemLore2Field.setTextAcceptHandler((id, text) ->
this.itemLore2Field.func_212954_a(text ->
{
this.builderCutomItem.setLore2(text);
container.initButtons();
@@ -228,53 +228,53 @@ public class ContentCustomItem extends Content
container.add(button1 = new GuiButtonBase(x, y, 114, 20, I18n.format("gui.worldhandler.items.custom_item.start"), () ->
{
this.selectedPage = "start";
container.initGui();
container.init();
}));
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, I18n.format("gui.worldhandler.items.custom_item.enchantment"), () ->
{
this.selectedPage = "enchant";
container.initGui();
container.init();
}));
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, I18n.format("gui.worldhandler.items.custom_item.attributes"), () ->
{
this.selectedPage = "attributes";
container.initGui();
container.init();
}));
if(this.selectedPage.equals("start"))
{
button1.enabled = false;
button1.active = false;
container.add(button5 = new GuiButtonBase(x + 118, y + 72, 56, 20, "<", () ->
{
this.startPage--;
container.initGui();
container.init();
}));
container.add(button6 = new GuiButtonBase(x + 118 + 60, y + 72, 55, 20, ">", () ->
{
this.startPage++;
container.initGui();
container.init();
}));
if(this.startPage == 0)
{
button5.enabled = false;
button5.active = false;
container.add(this.itemField);
container.add(this.itemLore1Field);
container.add(this.itemLore2Field);
}
else if(this.startPage == 1)
{
button6.enabled = false;
button6.active = false;
}
}
else if(this.selectedPage.equals("enchant"))
{
button2.enabled = false;
button2.active = false;
}
else if(this.selectedPage.equals("attributes"))
{
button3.enabled = false;
button3.active = false;
}
if(!this.builderCutomItem.needsCommandBlock() && !this.builderCutomItem.getName().isSpecial())
@@ -286,7 +286,7 @@ public class ContentCustomItem extends Content
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.place_command_block"), this::send));
}
button4.enabled = ResourceHelper.isRegistered(ResourceHelper.stringToResourceLocation(this.item), ForgeRegistries.ITEMS);
button4.active = ResourceHelper.isRegistered(ResourceHelper.stringToResourceLocation(this.item), ForgeRegistries.ITEMS);
}
private void send()
@@ -310,9 +310,9 @@ public class ContentCustomItem extends Content
{
if(this.selectedPage.equals("start") && this.startPage == 0)
{
this.itemField.drawTextField(mouseX, mouseY, partialTicks);
this.itemLore1Field.drawTextField(mouseX, mouseY, partialTicks);
this.itemLore2Field.drawTextField(mouseX, mouseY, partialTicks);
this.itemField.renderButton(mouseX, mouseY, partialTicks);
this.itemLore1Field.renderButton(mouseX, mouseY, partialTicks);
this.itemLore2Field.renderButton(mouseX, mouseY, partialTicks);
}
}

View File

@@ -76,7 +76,7 @@ public class ContentEditBlocks extends Content
this.x1Field = new GuiTextFieldTooltip(x + 118, y, 55, 20);
this.x1Field.setValidator(this.getCoordinatePredicate("X1"));
this.x1Field.setText("X1: " + BlockHelper.getPos1().getX());
this.x1Field.setTextAcceptHandler((id, text) ->
this.x1Field.func_212954_a(text ->
{
BlockHelper.setPos1(BlockHelper.setX(BlockHelper.getPos1(), this.parseCoordinate(text)));
});
@@ -84,7 +84,7 @@ public class ContentEditBlocks extends Content
this.y1Field = new GuiTextFieldTooltip(x + 118, y + 24, 55, 20);
this.y1Field.setValidator(this.getCoordinatePredicate("Y1"));
this.y1Field.setText("Y1: " + BlockHelper.getPos1().getY());
this.y1Field.setTextAcceptHandler((id, text) ->
this.y1Field.func_212954_a(text ->
{
BlockHelper.setPos1(BlockHelper.setY(BlockHelper.getPos1(), this.parseCoordinate(text)));
});
@@ -92,7 +92,7 @@ public class ContentEditBlocks extends Content
this.z1Field = new GuiTextFieldTooltip(x + 118, y + 48, 55, 20);
this.z1Field.setValidator(this.getCoordinatePredicate("Z1"));
this.z1Field.setText("Z1: " + BlockHelper.getPos1().getZ());
this.z1Field.setTextAcceptHandler((id, text) ->
this.z1Field.func_212954_a(text ->
{
BlockHelper.setPos1(BlockHelper.setZ(BlockHelper.getPos1(), this.parseCoordinate(text)));
});
@@ -100,7 +100,7 @@ public class ContentEditBlocks extends Content
this.x2Field = new GuiTextFieldTooltip(x + 118 + 59, y, 55, 20);
this.x2Field.setValidator(this.getCoordinatePredicate("X2"));
this.x2Field.setText("X2: " + BlockHelper.getPos2().getX());
this.x2Field.setTextAcceptHandler((id, text) ->
this.x2Field.func_212954_a(text ->
{
BlockHelper.setPos2(BlockHelper.setX(BlockHelper.getPos2(), this.parseCoordinate(text)));
});
@@ -108,7 +108,7 @@ public class ContentEditBlocks extends Content
this.y2Field = new GuiTextFieldTooltip(x + 118 + 59, y + 24, 55, 20);
this.y2Field.setValidator(this.getCoordinatePredicate("Y2"));
this.y2Field.setText("Y2: " + BlockHelper.getPos2().getY());
this.y2Field.setTextAcceptHandler((id, text) ->
this.y2Field.func_212954_a(text ->
{
BlockHelper.setPos2(BlockHelper.setY(BlockHelper.getPos2(), this.parseCoordinate(text)));
});
@@ -116,7 +116,7 @@ public class ContentEditBlocks extends Content
this.z2Field = new GuiTextFieldTooltip(x + 118 + 59, y + 48, 55, 20);
this.z2Field.setValidator(this.getCoordinatePredicate("Z2"));
this.z2Field.setText("Z2: " + BlockHelper.getPos2().getZ());
this.z2Field.setTextAcceptHandler((id, text) ->
this.z2Field.func_212954_a(text ->
{
BlockHelper.setPos2(BlockHelper.setZ(BlockHelper.getPos2(), this.parseCoordinate(text)));
});
@@ -124,7 +124,7 @@ public class ContentEditBlocks extends Content
this.block1Field = new GuiTextFieldTooltip(x + 118, y, 114, 20, this.selectedPage.equals("fill") ? I18n.format("gui.worldhandler.edit_blocks.fill.block_id_to_fill") : I18n.format("gui.worldhandler.edit_blocks.replace.block_id_replace"));
this.block1Field.setValidator(Predicates.notNull());
this.block1Field.setText(this.block1);
this.block1Field.setTextAcceptHandler((id, text) ->
this.block1Field.func_212954_a(text ->
{
this.block1 = text;
this.builderFill.setBlock1(this.block1);
@@ -134,7 +134,7 @@ public class ContentEditBlocks extends Content
this.block2Field = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.edit_blocks.replace.block_id_place"));
this.block2Field.setValidator(Predicates.notNull());
this.block2Field.setText(this.block2);
this.block2Field.setTextAcceptHandler((id, text) ->
this.block2Field.func_212954_a(text ->
{
this.block2 = text;
this.builderFill.setBlock2(this.block2);
@@ -156,22 +156,22 @@ public class ContentEditBlocks extends Content
container.add(button1 = new GuiButtonBase(x, y, 114, 20, I18n.format("gui.worldhandler.edit_blocks.coordinates"), () ->
{
this.selectedPage = "coordinates";
container.initGui();
container.init();
}));
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, I18n.format("gui.worldhandler.edit_blocks.fill"), () ->
{
this.selectedPage = "fill";
container.initGui();
container.init();
}));
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, I18n.format("gui.worldhandler.edit_blocks.replace"), () ->
{
this.selectedPage = "replace";
container.initGui();
container.init();
}));
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.edit_blocks.clone"), () ->
{
this.selectedPage = "clone";
container.initGui();
container.init();
}));
int yOffset1 = 0;
@@ -182,7 +182,7 @@ public class ContentEditBlocks extends Content
if(this.selectedPage.equals("coordinates"))
{
button1.enabled = false;
button1.active = false;
yOffset1 = 72;
yOffset2 = 72;
@@ -199,7 +199,7 @@ public class ContentEditBlocks extends Content
}
else if(this.selectedPage.equals("fill"))
{
button2.enabled = false;
button2.active = false;
yOffset1 = 24;
yOffset2 = 48;
@@ -212,11 +212,11 @@ public class ContentEditBlocks extends Content
{
CommandHelper.sendCommand(this.builderFill.getBuilderForFill());
}));
button1.enabled = ResourceHelper.isRegistered(this.builderFill.getBlock1(), ForgeRegistries.BLOCKS);
button1.active = ResourceHelper.isRegistered(this.builderFill.getBlock1(), ForgeRegistries.BLOCKS);
}
else if(this.selectedPage.equals("replace"))
{
button3.enabled = false;
button3.active = false;
yOffset1 = 48;
yOffset2 = 48;
@@ -226,15 +226,15 @@ public class ContentEditBlocks extends Content
container.add(this.block1Field);
container.add(this.block2Field);
container.add(button1 = new GuiButtonBase(8, x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.edit_blocks.replace"), () ->
container.add(button1 = new GuiButtonBase(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.edit_blocks.replace"), () ->
{
CommandHelper.sendCommand(this.builderFill.getBuilderForReplace());
}));
button1.enabled = ResourceHelper.isRegistered(this.builderFill.getBlock1(), ForgeRegistries.BLOCKS) && ResourceHelper.isRegistered(this.builderFill.getBlock2(), ForgeRegistries.BLOCKS);
button1.active = ResourceHelper.isRegistered(this.builderFill.getBlock1(), ForgeRegistries.BLOCKS) && ResourceHelper.isRegistered(this.builderFill.getBlock2(), ForgeRegistries.BLOCKS);
}
else if(this.selectedPage.equals("clone"))
{
button4.enabled = false;
button4.active = false;
yOffset1 = 24;
yOffset2 = 48;
@@ -278,12 +278,12 @@ public class ContentEditBlocks extends Content
container.add(new GuiButtonBase(x + 118, y + yOffset1, width1, 20, I18n.format("gui.worldhandler.edit_blocks.pos.set_pos_1"), () ->
{
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
container.initGui();
container.init();
}));
container.add(new GuiButtonBase(x + 118 + xOffset2, y + yOffset2, width2, 20, I18n.format("gui.worldhandler.edit_blocks.pos.set_pos_2"), () ->
{
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
container.initGui();
container.init();
}));
}
@@ -316,22 +316,22 @@ public class ContentEditBlocks extends Content
{
if(this.selectedPage.equals("coordinates"))
{
this.x1Field.drawTextField(mouseX, mouseY, partialTicks);
this.y1Field.drawTextField(mouseX, mouseY, partialTicks);
this.z1Field.drawTextField(mouseX, mouseY, partialTicks);
this.x1Field.renderButton(mouseX, mouseY, partialTicks);
this.y1Field.renderButton(mouseX, mouseY, partialTicks);
this.z1Field.renderButton(mouseX, mouseY, partialTicks);
this.x2Field.drawTextField(mouseX, mouseY, partialTicks);
this.y2Field.drawTextField(mouseX, mouseY, partialTicks);
this.z2Field.drawTextField(mouseX, mouseY, partialTicks);
this.x2Field.renderButton(mouseX, mouseY, partialTicks);
this.y2Field.renderButton(mouseX, mouseY, partialTicks);
this.z2Field.renderButton(mouseX, mouseY, partialTicks);
}
else if(this.selectedPage.equals("fill"))
{
this.block1Field.drawTextField(mouseX, mouseY, partialTicks);
this.block1Field.renderButton(mouseX, mouseY, partialTicks);
}
else if(this.selectedPage.equals("replace"))
{
this.block1Field.drawTextField(mouseX, mouseY, partialTicks);
this.block2Field.drawTextField(mouseX, mouseY, partialTicks);
this.block1Field.renderButton(mouseX, mouseY, partialTicks);
this.block2Field.renderButton(mouseX, mouseY, partialTicks);
}
}

View File

@@ -55,7 +55,7 @@ public class ContentExperience extends Content
container.add(this.buttonAdd = new GuiButtonBase(x + 116 / 2, y + 24, 114, 20, I18n.format("gui.worldhandler.actions.add"), () ->
{
CommandHelper.sendCommand(this.builderExperience.getBuilderForAddLevels());
container.initGui();
container.init();
}));
container.add(this.buttonRemove = new GuiButtonBase(x + 116 / 2, y + 48, 114, 20, I18n.format("gui.worldhandler.actions.remove"), () ->
{
@@ -64,13 +64,13 @@ public class ContentExperience extends Content
container.add(new GuiButtonTooltip(x + 116 / 2, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.reset"), I18n.format("gui.worldhandler.actions.set_to_0"), () ->
{
CommandHelper.sendCommand(this.builderExperience.getBuilderForResetLevels());
container.initGui();
container.init();
}));
boolean enabled = this.builderExperience.getLevel() > 0;
this.buttonAdd.enabled = enabled;
this.buttonRemove.enabled = enabled;
this.buttonAdd.active = enabled;
this.buttonRemove.active = enabled;
}
@Override
@@ -78,8 +78,8 @@ public class ContentExperience extends Content
{
boolean enabled = this.builderExperience.getLevel() > 0;
this.buttonAdd.enabled = enabled;
this.buttonRemove.enabled = enabled;
this.buttonAdd.active = enabled;
this.buttonRemove.active = enabled;
}
@Override

View File

@@ -48,7 +48,7 @@ public class ContentGamerules extends Content
this.valueField.setValidator(Predicates.notNull());
this.valueField.setText(this.value);
this.valueField.setCursorPositionEnd();
this.valueField.setTextAcceptHandler((id, text) ->
this.valueField.func_212954_a(text ->
{
this.value = text;
this.builderGamerule.setValue(this.value);
@@ -143,7 +143,7 @@ public class ContentGamerules extends Content
{
if(!this.booleanValue)
{
this.valueField.drawTextField(mouseX, mouseY, partialTicks);
this.valueField.renderButton(mouseX, mouseY, partialTicks);
}
}

View File

@@ -13,7 +13,7 @@ import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.gui.content.Contents;
import exopandora.worldhandler.helper.ActionHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreenResourcePacks;
import net.minecraft.client.gui.screen.ResourcePacksScreen;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -86,7 +86,7 @@ public class ContentMain extends Content
container.add(new GuiButtonBase(x + 78, y + 96, 76, 20, I18n.format("gui.worldhandler.resourcepack"), () ->
{
Minecraft.getInstance().gameSettings.saveOptions();
Minecraft.getInstance().displayGuiScreen(new GuiScreenResourcePacks(container));
Minecraft.getInstance().displayGuiScreen(new ResourcePacksScreen(container));
}));
container.add(new GuiButtonBase(x + 158, y + 96, 74, 20, I18n.format("gui.worldhandler.generic.backToGame"), ActionHelper::backToGame));
}

View File

@@ -85,10 +85,10 @@ public class ContentMultiplayer extends Content
{
this.playerField = new GuiTextFieldTooltip(x + 118, y + this.shiftDown, 114, 20, I18n.format("gui.worldhandler.multiplayer.username"));
this.playerField.setValidator(Predicates.notNull());
this.playerField.setFocused(false);
this.playerField.setFocused2(false);
this.playerField.setText(this.builderKick.getPlayer());
this.playerField.setMaxStringLength(16);
this.playerField.setTextAcceptHandler((id, text) ->
this.playerField.func_212954_a(text ->
{
this.setPlayer(this.playerField.getText());
container.initButtons();
@@ -96,9 +96,9 @@ public class ContentMultiplayer extends Content
this.reasonField = new GuiTextFieldTooltip(x + 118, y + 24 + this.shiftDown, 114, 20, I18n.format("gui.worldhandler.multiplayer.kick_ban.reason"));
this.reasonField.setValidator(Predicates.notNull());
this.reasonField.setFocused(false);
this.reasonField.setFocused2(false);
this.reasonField.setText(this.builderKick.getReason());
this.reasonField.setTextAcceptHandler((id, text) ->
this.reasonField.func_212954_a(text ->
{
this.setReason(this.reasonField.getText());
container.initButtons();
@@ -122,31 +122,31 @@ public class ContentMultiplayer extends Content
{
this.selected = "kickBan";
this.shiftDown = 0;
container.initGui();
container.init();
}));
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, I18n.format("gui.worldhandler.multiplayer.pardon"), () ->
{
this.selected = "pardon";
this.shiftDown = 24;
container.initGui();
container.init();
}));
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, I18n.format("gui.worldhandler.multiplayer.permissions"), () ->
{
this.selected = "permissions";
this.shiftDown = 12;
container.initGui();
container.init();
}));
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.multiplayer.runtime"), () ->
{
this.selected = "runtime";
this.shiftDown = 0;
container.initGui();
container.init();
}));
container.add(button5 = new GuiButtonBase(x, y + 96, 114, 20, I18n.format("gui.worldhandler.multiplayer.whitelist"), () ->
{
this.selected = "whitelist";
this.shiftDown = 0;
container.initGui();
container.init();
}));
if(this.selected.equals("kickBan"))
@@ -164,11 +164,11 @@ public class ContentMultiplayer extends Content
if(this.playerField.getText().isEmpty())
{
button6.enabled = false;
button7.enabled = false;
button6.active = false;
button7.active = false;
}
button1.enabled = false;
button1.active = false;
}
else if(this.selected.equals("pardon"))
{
@@ -180,10 +180,10 @@ public class ContentMultiplayer extends Content
if(this.playerField.getText().isEmpty())
{
button6.enabled = false;
button6.active = false;
}
button2.enabled = false;
button2.active = false;
}
else if(this.selected.equals("permissions"))
{
@@ -199,11 +199,11 @@ public class ContentMultiplayer extends Content
if(this.playerField.getText().isEmpty())
{
button6.enabled = false;
button7.enabled = false;
button6.active = false;
button7.active = false;
}
button3.enabled = false;
button3.active = false;
}
else if(this.selected.equals("runtime"))
{
@@ -224,7 +224,7 @@ public class ContentMultiplayer extends Content
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.CONTINUE.withBuilder(this.builderStop).withParent(Contents.MULTIPLAYER)));
}));
button4.enabled = false;
button4.active = false;
}
else if(this.selected.equals("whitelist"))
{
@@ -254,11 +254,11 @@ public class ContentMultiplayer extends Content
if(this.playerField.getText().isEmpty())
{
button6.enabled = false;
button7.enabled = false;
button6.active = false;
button7.active = false;
}
button5.enabled = false;
button5.active = false;
}
}
@@ -281,12 +281,12 @@ public class ContentMultiplayer extends Content
{
if(this.selected.equals("kickBan"))
{
this.reasonField.drawTextField(mouseX, mouseY, partialTicks);
this.reasonField.renderButton(mouseX, mouseY, partialTicks);
}
if(!this.selected.equals("runtime"))
{
this.playerField.drawTextField(mouseX, mouseY, partialTicks);
this.playerField.renderButton(mouseX, mouseY, partialTicks);
}
}

View File

@@ -1,5 +1,7 @@
package exopandora.worldhandler.gui.content.impl;
import com.mojang.blaze3d.platform.GlStateManager;
import exopandora.worldhandler.Main;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.builder.ICommandBuilder;
@@ -16,12 +18,12 @@ import exopandora.worldhandler.gui.content.Contents;
import exopandora.worldhandler.helper.ActionHelper;
import exopandora.worldhandler.helper.BlockHelper;
import exopandora.worldhandler.helper.CommandHelper;
import net.minecraft.block.Blocks;
import net.minecraft.block.NoteBlock;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.state.properties.NoteBlockInstrument;
import net.minecraft.util.ResourceLocation;
@@ -47,7 +49,7 @@ public class ContentNoteEditor extends Content
@Override
public void init(Container container)
{
this.isActive = BlockHelper.isFocusedBlockEqualTo(Blocks.NOTE_BLOCK);
this.isActive = BlockHelper.getFocusedBlock() instanceof NoteBlock;
this.builderNoteEditor.setPosition(BlockHelper.getFocusedBlockPos());
}
@@ -179,14 +181,14 @@ public class ContentNoteEditor extends Content
GlStateManager.color3f(1.0F, 1.0F, 1.0F);
Minecraft.getInstance().getTextureManager().bindTexture(NOTE);
container.drawTexturedModalRect(x - 1, y - 1, 0, 0, 8, 59);
container.drawTexturedModalRect(x - 1, y - 1 + 59, 0, 59, 13, 35);
container.blit(x - 1, y - 1, 0, 0, 8, 59);
container.blit(x - 1, y - 1 + 59, 0, 59, 13, 35);
container.drawTexturedModalRect(x - 1 + 232 - 5, y - 1, 18, 0, 7, 59);
container.drawTexturedModalRect(x - 1 + 232 - 10, y - 1 + 59, 13, 59, 12, 35);
container.blit(x - 1 + 232 - 5, y - 1, 18, 0, 7, 59);
container.blit(x - 1 + 232 - 10, y - 1 + 59, 13, 59, 12, 35);
container.drawTexturedModalRect(x - 1 + 8, y - 1, 0, 94, 219, 1);
container.drawTexturedModalRect(x - 1 + 13, y - 1 + 93, 0, 94, 209, 1);
container.blit(x - 1 + 8, y - 1, 0, 94, 219, 1);
container.blit(x - 1 + 13, y - 1 + 93, 0, 94, 209, 1);
}
else
{
@@ -203,7 +205,7 @@ public class ContentNoteEditor extends Content
RenderHelper.disableStandardItemLighting();
GlStateManager.popMatrix();
String displayString = I18n.format("gui.worldhandler.blocks.note_block_editor.look_at_note_block", WorldHandler.KEY_WORLD_HANDLER.getKey().getName());
String displayString = I18n.format("gui.worldhandler.blocks.note_block_editor.look_at_note_block", WorldHandler.KEY_WORLD_HANDLER.getLocalizedName());
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
fontRenderer.drawString(displayString, x + 116 - fontRenderer.getStringWidth(displayString) / 2, y + 70, Config.getSkin().getLabelColor());
}

View File

@@ -1,6 +1,6 @@
package exopandora.worldhandler.gui.content.impl;
import com.mojang.realmsclient.gui.ChatFormatting;
import com.mojang.blaze3d.platform.GlStateManager;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.builder.ICommandBuilder;
@@ -18,11 +18,11 @@ import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.gui.content.Contents;
import exopandora.worldhandler.helper.ActionHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.inventory.InventoryScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -84,35 +84,35 @@ public class ContentPlayer extends Content
container.add(button1 = new GuiButtonBase(x, y, 114, 20, I18n.format("gui.worldhandler.entities.player.start"), () ->
{
this.selectedMain = "start";
container.initGui();
container.init();
}));
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, I18n.format("gui.worldhandler.entities.player.score"), () ->
{
this.selectedMain = "score";
container.initGui();
container.init();
}));
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, I18n.format("gui.worldhandler.entities.player.position"), () ->
{
this.selectedMain = "position";
container.initGui();
container.init();
}));
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.entities.player.miscellaneous"), () ->
{
this.selectedMain = "miscellaneous";
container.initGui();
container.init();
}));
if(this.selectedMain.equals("start"))
{
button1.enabled = false;
button1.active = false;
}
else if(this.selectedMain.equals("score"))
{
button2.enabled = false;
button2.active = false;
}
else if(this.selectedMain.equals("position"))
{
button3.enabled = false;
button3.active = false;
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.entities.player.position.copy_position"), () ->
{
@@ -125,21 +125,21 @@ public class ContentPlayer extends Content
}
else if(this.selectedMain.equals("miscellaneous"))
{
button4.enabled = false;
button4.active = false;
container.add(new GuiButtonBase(x + 118, y, 114, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.entities.player.miscellaneous.set_spawn"), () ->
container.add(new GuiButtonBase(x + 118, y, 114, 20, TextFormatting.RED + I18n.format("gui.worldhandler.entities.player.miscellaneous.set_spawn"), () ->
{
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.CONTINUE.withBuilder(this.builderSpawnpoint).withParent(Contents.PLAYER)));
}));
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.entities.player.miscellaneous.set_global_spawn"), () ->
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, TextFormatting.RED + I18n.format("gui.worldhandler.entities.player.miscellaneous.set_global_spawn"), () ->
{
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.CONTINUE.withBuilder(this.builderSetworldspawn).withParent(Contents.PLAYER)));
}));
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.entities.player.miscellaneous.kill"), () ->
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, TextFormatting.RED + I18n.format("gui.worldhandler.entities.player.miscellaneous.kill"), () ->
{
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.CONTINUE.withBuilder(this.builderKill).withParent(Contents.PLAYER)));
}));
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, ChatFormatting.RED + I18n.format("gui.worldhandler.entities.player.miscellaneous.clear_inventory"), () ->
container.add(new GuiButtonBase(x + 118, y + 72, 114, 20, TextFormatting.RED + I18n.format("gui.worldhandler.entities.player.miscellaneous.clear_inventory"), () ->
{
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.CONTINUE.withBuilder(this.builderClear).withParent(Contents.PLAYER)));
}));
@@ -166,24 +166,24 @@ public class ContentPlayer extends Content
int yPos = y + 82;
int playerNameWidth = Minecraft.getInstance().fontRenderer.getStringWidth(Minecraft.getInstance().player.getName().getFormattedText()) / 2;
Gui.drawRect(container.width / 2 - playerNameWidth - 1 + 59, yPos - 74, container.width / 2 + playerNameWidth + 1 + 59, yPos - 65, 0x3F000000);
Screen.fill(container.width / 2 - playerNameWidth - 1 + 59, yPos - 74, container.width / 2 + playerNameWidth + 1 + 59, yPos - 65, 0x3F000000);
Minecraft.getInstance().fontRenderer.drawString(Minecraft.getInstance().player.getName().getFormattedText(), container.width / 2 - playerNameWidth + 59, yPos - 73, 0xE0E0E0);
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiInventory.drawEntityOnScreen(xPos, yPos, 30, xPos - mouseX, yPos - mouseY - 44, Minecraft.getInstance().player);
InventoryScreen.drawEntityOnScreen(xPos, yPos, 30, xPos - mouseX, yPos - mouseY - 44, Minecraft.getInstance().player);
GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
}
else if(this.selectedMain.equals("score"))
{
this.scoreField.drawTextField(mouseX, mouseY, partialTicks);
this.xpField.drawTextField(mouseX, mouseY, partialTicks);
this.coinsField.drawTextField(mouseX, mouseY, partialTicks);
this.scoreField.renderButton(mouseX, mouseY, partialTicks);
this.xpField.renderButton(mouseX, mouseY, partialTicks);
this.coinsField.renderButton(mouseX, mouseY, partialTicks);
}
else if(this.selectedMain.equals("position"))
{
this.posXField.drawTextField(mouseX, mouseY, partialTicks);
this.posYField.drawTextField(mouseX, mouseY, partialTicks);
this.posZField.drawTextField(mouseX, mouseY, partialTicks);
this.posXField.renderButton(mouseX, mouseY, partialTicks);
this.posYField.renderButton(mouseX, mouseY, partialTicks);
this.posZField.renderButton(mouseX, mouseY, partialTicks);
}
}

View File

@@ -19,8 +19,8 @@ import exopandora.worldhandler.helper.ActionHelper;
import exopandora.worldhandler.helper.CommandHelper;
import exopandora.worldhandler.util.ActionHandler;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.Items;
import net.minecraft.potion.Potion;
import net.minecraft.item.Items;
import net.minecraft.potion.Effect;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@@ -47,7 +47,7 @@ public class ContentPotions extends ContentChild
this.builderPotion.setAmplifier((byte) Config.getSliders().getMaxPotionAmplifier());
}
for(Potion potion : this.builderPotionItem.getPotions())
for(Effect potion : this.builderPotionItem.getEffects())
{
byte amplifier = this.builderPotionItem.getAmplifier(potion);
@@ -61,29 +61,29 @@ public class ContentPotions extends ContentChild
@Override
public void initGui(Container container, int x, int y)
{
ElementPageList<Potion> potions = new ElementPageList<Potion>(x, y, new ArrayList<Potion>(ForgeRegistries.POTIONS.getValues()), 114, 20, 3, container, new ILogicPageList<Potion>()
ElementPageList<Effect> potions = new ElementPageList<Effect>(x, y, new ArrayList<Effect>(ForgeRegistries.POTIONS.getValues()), 114, 20, 3, container, new ILogicPageList<Effect>()
{
@Override
public String translate(Potion item)
public String translate(Effect item)
{
return I18n.format(item.getName());
}
@Override
public String toTooltip(Potion item)
public String toTooltip(Effect item)
{
return item.getRegistryName().toString();
}
@Override
public void onClick(Potion item)
public void onClick(Effect item)
{
ContentPotions.this.builderPotion.setEffect(item);
container.initButtons();
}
@Override
public GuiButtonBase onRegister(int x, int y, int width, int height, String text, Potion item, ActionHandler actionHandler)
public GuiButtonBase onRegister(int x, int y, int width, int height, String text, Effect item, ActionHandler actionHandler)
{
return new GuiButtonTooltip(x, y, width, height, text, this.toTooltip(item), actionHandler);
}
@@ -119,28 +119,28 @@ public class ContentPotions extends ContentChild
container.add(new GuiButtonBase(x + 118, y + 36, 114, 20, I18n.format("gui.worldhandler.potions.effect.remove"), () ->
{
CommandHelper.sendCommand(this.builderPotion.getRemoveCommand());
container.initGui();
container.init();
}));
container.add(new GuiButtonBase(x + 118, y + 60, 114, 20, I18n.format("gui.worldhandler.potions.effect.remove_all"), () ->
{
CommandHelper.sendCommand(this.builderPotion.getClearCommand());
container.initGui();
container.init();
}));
}
else if(this.potionPage == 1)
{
Potion potion = this.builderPotion.getEffectAsPotion();
Effect potion = this.builderPotion.getEffectAsPotion();
container.add(new GuiButtonBase(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.potions.effect.ambient", this.builderPotionItem.getAmbient(potion) ? I18n.format("gui.worldhandler.generic.on") : I18n.format("gui.worldhandler.generic.off")), () ->
{
this.builderPotionItem.setAmbient(potion, !this.builderPotionItem.getAmbient(potion));
container.initGui();
container.init();
}));
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.potions.effect.particles", this.builderPotion.getHideParticles() ? I18n.format("gui.worldhandler.generic.off") : I18n.format("gui.worldhandler.generic.on")), () ->
{
this.builderPotion.setHideParticles(!this.builderPotion.getHideParticles());
this.builderPotionItem.setShowParticles(potion, !this.builderPotionItem.getShowParticles(potion));
container.initGui();
container.init();
}));
container.add(new GuiSlider(x + 118, y, 114, 20, 0, Config.getSliders().getMaxPotionAmplifier(), 0, container, new LogicSliderSimple("amplifier" + potion.getRegistryName(), I18n.format("gui.worldhandler.potions.effect.amplifier"), value ->
{
@@ -150,7 +150,7 @@ public class ContentPotions extends ContentChild
}
else if(this.potionPage == 2)
{
Potion potion = this.builderPotion.getEffectAsPotion();
Effect potion = this.builderPotion.getEffectAsPotion();
container.add(new GuiSlider(x + 118, y, 114, 20, 0, 59, 0, container, new LogicSliderSimple("s" + potion.getRegistryName(), I18n.format("gui.worldhandler.potion.time.seconds"), value ->
{
@@ -174,62 +174,62 @@ public class ContentPotions extends ContentChild
{
CommandHelper.sendCommand(this.builderPotion.getGiveCommand());
this.potionPage = 0;
container.initGui();
container.init();
}));
container.add(button2 = new GuiButtonBase(x + 118, y + 24, 56, 20, I18n.format("gui.worldhandler.potions.effect.tipped_arrow"), () ->
{
CommandHelper.sendCommand(this.builderPotionItem.getBuilderForPotion(Items.TIPPED_ARROW));
this.potionPage = 0;
container.initGui();
container.init();
}));
container.add(button3 = new GuiButtonTooltip(x + 178, y + 24, 55, 20, I18n.format("gui.worldhandler.potions.effect.bottle"), I18n.format("gui.worldhandler.actions.place_command_block"), () ->
{
CommandHelper.sendCommand(this.builderPotionItem.getBuilderForPotion(Items.POTION));
this.potionPage = 0;
container.initGui();
container.init();
}));
container.add(button4 = new GuiButtonTooltip(x + 118, y + 48, 56, 20, I18n.format("gui.worldhandler.potions.effect.splash"), I18n.format("gui.worldhandler.actions.place_command_block"), () ->
{
CommandHelper.sendCommand(this.builderPotionItem.getBuilderForPotion(Items.SPLASH_POTION));
this.potionPage = 0;
container.initGui();
container.init();
}));
container.add(button5 = new GuiButtonTooltip(x + 178, y + 48, 55, 20, I18n.format("gui.worldhandler.potions.effect.lingering"), I18n.format("gui.worldhandler.actions.place_command_block"), () ->
{
CommandHelper.sendCommand(this.builderPotionItem.getBuilderForPotion(Items.LINGERING_POTION));
this.potionPage = 0;
container.initGui();
container.init();
}));
boolean enabled = this.builderPotion.getAmplifier() >= 0;
button1.enabled = enabled;
button2.enabled = enabled;
button3.enabled = enabled;
button4.enabled = enabled;
button5.enabled = enabled;
button1.active = enabled;
button2.active = enabled;
button3.active = enabled;
button4.active = enabled;
button5.active = enabled;
}
if(this.potionPage > 0)
{
container.add(new GuiButtonBase(4, x + 118, y + 72, 56, 20, "<", () ->
container.add(new GuiButtonBase(x + 118, y + 72, 56, 20, "<", () ->
{
this.potionPage--;
container.initGui();
container.init();
}));
container.add(button1 = new GuiButtonBase(5, x + 118 + 60, y + 72, 55, 20, ">", () ->
container.add(button1 = new GuiButtonBase(x + 118 + 60, y + 72, 55, 20, ">", () ->
{
this.next(container);
}));
button1.enabled = this.potionPage < 3;
button1.active = this.potionPage < 3;
}
}
private void next(Container container)
{
this.potionPage++;
container.initGui();
container.init();
}
@Override

View File

@@ -23,10 +23,9 @@ import exopandora.worldhandler.helper.ActionHelper;
import exopandora.worldhandler.helper.CommandHelper;
import exopandora.worldhandler.helper.RegistryTranslator;
import net.minecraft.client.resources.I18n;
import net.minecraft.stats.StatList;
import net.minecraft.stats.StatType;
import net.minecraft.stats.Stats;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.IRegistry;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@@ -52,7 +51,7 @@ public class ContentScoreboardObjectives extends ContentScoreboard
this.objectField = new GuiTextFieldTooltip(x + 118, y + (this.selectedObjective.equals("remove") ? 24 : 0), 114, 20, I18n.format("gui.worldhandler.scoreboard.objectives.objective"));
this.objectField.setValidator(Predicates.notNull());
this.objectField.setText(ContentScoreboard.getObjective());
this.objectField.setTextAcceptHandler((id, text) ->
this.objectField.func_212954_a(text ->
{
ContentScoreboard.setObjective(text);
this.builderObjectives.setObjective(ContentScoreboard.getObjective());
@@ -70,19 +69,19 @@ public class ContentScoreboardObjectives extends ContentScoreboard
if(resource != null)
{
StatType<?> type = IRegistry.field_212634_w.func_212608_b(resource);
StatType<?> type = ForgeRegistries.STAT_TYPES.getValue(resource);
if(type != null)
{
if(type.equals(StatList.CUSTOM))
if(type.equals(Stats.CUSTOM))
{
return I18n.format("gui.worldhandler.scoreboard.objectives.stat.custom");
}
else if(type.equals(StatList.ENTITY_KILLED))
else if(type.equals(Stats.ENTITY_KILLED))
{
return I18n.format("gui.worldhandler.scoreboard.objectives.stat.killed");
}
else if(type.equals(StatList.ENTITY_KILLED_BY))
else if(type.equals(Stats.ENTITY_KILLED_BY))
{
return I18n.format("gui.worldhandler.scoreboard.objectives.stat.killed_by");
}
@@ -98,7 +97,7 @@ public class ContentScoreboardObjectives extends ContentScoreboard
}
}
if(Arrays.stream(EnumColor.values()).map(EnumColor::getFormat).anyMatch(Predicates.equalTo(key)))
if(Arrays.stream(EnumColor.values()).map(EnumColor::getName).anyMatch(Predicates.equalTo(key)))
{
return I18n.format("gui.worldhandler.color." + key);
}
@@ -132,7 +131,7 @@ public class ContentScoreboardObjectives extends ContentScoreboard
@Nullable
private ResourceLocation makeResourceLocation(String key)
{
return ResourceLocation.makeResourceLocation(key.replace(".", ":"));
return ResourceLocation.tryCreate(key.replace(".", ":"));
}
@Nullable
@@ -154,12 +153,7 @@ public class ContentScoreboardObjectives extends ContentScoreboard
}
}
if(IRegistry.field_212623_l.func_212607_c(resource))
{
return true;
}
return false;
return ForgeRegistries.STAT_TYPES.containsKey(resource);
}
});
@@ -215,28 +209,28 @@ public class ContentScoreboardObjectives extends ContentScoreboard
container.add(button1 = new GuiButtonBase(x, y, 114, 20, I18n.format("gui.worldhandler.scoreboard.objectives.create"), () ->
{
this.selectedObjective = "create";
container.initGui();
container.init();
}));
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, I18n.format("gui.worldhandler.scoreboard.objectives.display"), () ->
{
this.selectedObjective = "display";
container.initGui();
container.init();
}));
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, I18n.format("gui.worldhandler.scoreboard.objectives.undisplay"), () ->
{
this.selectedObjective = "undisplay";
container.initGui();
container.init();
}));
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.scoreboard.objectives.remove"), () ->
{
this.selectedObjective = "remove";
container.initGui();
container.init();
}));
button1.enabled = !this.selectedObjective.equals("create");
button2.enabled = !this.selectedObjective.equals("display");
button3.enabled = !this.selectedObjective.equals("undisplay");
button4.enabled = !this.selectedObjective.equals("remove");
button1.active = !this.selectedObjective.equals("create");
button2.active = !this.selectedObjective.equals("display");
button3.active = !this.selectedObjective.equals("undisplay");
button4.active = !this.selectedObjective.equals("remove");
int yOffset = this.selectedObjective.equals("undisplay") ? -12 : (this.selectedObjective.equals("remove") ? -24 : 0);
@@ -258,9 +252,9 @@ public class ContentScoreboardObjectives extends ContentScoreboard
container.add(button1 = new GuiButtonBase(x + 118, y + 72 + yOffset, 114, 20, I18n.format("gui.worldhandler.actions.perform"), () ->
{
CommandHelper.sendCommand(this.builderObjectives);
container.initGui();
container.init();
}));
button1.enabled = this.selectedObjective.equals("undisplay") || ContentScoreboard.isObjectiveValid();
button1.active = this.selectedObjective.equals("undisplay") || ContentScoreboard.isObjectiveValid();
}
@Override
@@ -277,7 +271,7 @@ public class ContentScoreboardObjectives extends ContentScoreboard
{
if(!this.selectedObjective.equals("undisplay"))
{
this.objectField.drawTextField(mouseX, mouseY, partialTicks);
this.objectField.renderButton(mouseX, mouseY, partialTicks);
}
}

View File

@@ -80,7 +80,7 @@ public class ContentScoreboardPlayers extends ContentScoreboard
this.objectField = new GuiTextFieldTooltip(x + 118, y, 114, 20, I18n.format("gui.worldhandler.scoreboard.objectives.objective"));
this.objectField.setValidator(Predicates.notNull());
this.objectField.setText(ContentScoreboard.getObjective());
this.objectField.setTextAcceptHandler((id, text) ->
this.objectField.func_212954_a(text ->
{
ContentScoreboard.setObjective(text);
this.builderPlayers.setObjective(ContentScoreboard.getObjective());
@@ -91,7 +91,7 @@ public class ContentScoreboardPlayers extends ContentScoreboard
this.tagField = new GuiTextFieldTooltip(x + 118, y + 12, 114, 20, I18n.format("gui.worldhandler.scoreboard.players.tag"));
this.tagField.setValidator(string -> string != null && !string.contains(" "));
this.tagField.setText(this.tag);
this.tagField.setTextAcceptHandler((id, text) ->
this.tagField.func_212954_a(text ->
{
this.tag = text;
this.builderTag.setName(this.tag);
@@ -112,22 +112,22 @@ public class ContentScoreboardPlayers extends ContentScoreboard
container.add(button1 = new GuiButtonBase(x, y + 12, 114, 20, I18n.format("gui.worldhandler.scoreboard.players.points"), () ->
{
this.selectedPlayer = "add|set|remove";
container.initGui();
container.init();
}));
container.add(button2 = new GuiButtonBase(x, y + 36, 114, 20, I18n.format("gui.worldhandler.scoreboard.players.tag"), () ->
{
this.selectedPlayer = "tag";
container.initGui();
container.init();
}));
container.add(button3 = new GuiButtonBase(x, y + 60, 114, 20, I18n.format("gui.worldhandler.scoreboard.players.trigger"), () ->
{
this.selectedPlayer = "enable";
container.initGui();
container.init();
}));
button1.enabled = !this.selectedPlayer.equals("add|set|remove");
button2.enabled = !this.selectedPlayer.equals("tag");
button3.enabled = !this.selectedPlayer.equals("enable");
button1.active = !this.selectedPlayer.equals("add|set|remove");
button2.active = !this.selectedPlayer.equals("tag");
button3.active = !this.selectedPlayer.equals("enable");
boolean enabled = ContentScoreboard.isObjectiveValid();
this.builderPlayers.setMode(this.selectedPlayer);
@@ -141,42 +141,42 @@ public class ContentScoreboardPlayers extends ContentScoreboard
container.add(this.addButton = new GuiButtonBase(x + 118, y + 48, 56, 20, I18n.format("gui.worldhandler.actions.add"), () ->
{
CommandHelper.sendCommand(this.builderPlayers.getBuilderForPoints(EnumMode.ADD));
container.initGui();
container.init();
}));
container.add(this.removeButton = new GuiButtonBase(x + 118 + 114 / 2 + 1, y + 48, 56, 20, I18n.format("gui.worldhandler.actions.remove"), () ->
{
CommandHelper.sendCommand(this.builderPlayers.getBuilderForPoints(EnumMode.REMOVE));
container.initGui();
container.init();
}));
container.add(button1 = new GuiButtonTooltip(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.reset"), I18n.format("gui.worldhandler.actions.set_to_0"), () ->
{
CommandHelper.sendCommand(this.builderPlayers.getBuilderForPoints(EnumMode.SET, 0));
container.initGui();
container.init();
}));
boolean points = enabled && this.builderPlayers.getPoints() > 0;
this.addButton.enabled = points;
this.removeButton.enabled = points;
button1.enabled = enabled;
this.addButton.active = points;
this.removeButton.active = points;
button1.active = enabled;
}
else if(this.selectedPlayer.equals("tag"))
{
container.add(button1 = new GuiButtonBase(x + 118, y + 36, 114, 20, I18n.format("gui.worldhandler.actions.add"), () ->
{
CommandHelper.sendCommand(this.builderTag.getBuilderForMode(BuilderTag.EnumMode.ADD));
container.initGui();
container.init();
}));
container.add(button2 = new GuiButtonBase(x + 118, y + 60, 114, 20, I18n.format("gui.worldhandler.actions.remove"), () ->
{
CommandHelper.sendCommand(this.builderTag.getBuilderForMode(BuilderTag.EnumMode.REMOVE));
container.initGui();
container.init();
}));
boolean tag = this.tag != null && !this.tag.isEmpty();
button1.enabled = tag;
button2.enabled = tag;
button1.active = tag;
button2.active = tag;
}
else if(this.selectedPlayer.equals("enable"))
{
@@ -187,22 +187,22 @@ public class ContentScoreboardPlayers extends ContentScoreboard
container.add(this.addButton = new GuiButtonBase(x + 118, y + 48, 56, 20, I18n.format("gui.worldhandler.actions.add"), () ->
{
CommandHelper.sendCommand(this.builderTrigger.getBuilderForMode(BuilderTrigger.EnumMode.ADD));
container.initGui();
container.init();
}));
container.add(this.removeButton = new GuiButtonBase(x + 118 + 114 / 2 + 1, y + 48, 56, 20, I18n.format("gui.worldhandler.actions.set"), () ->
{
CommandHelper.sendCommand(this.builderTrigger.getBuilderForMode(BuilderTrigger.EnumMode.SET));
container.initGui();
container.init();
}));
container.add(button1 = new GuiButtonBase(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.generic.enable"), () ->
{
CommandHelper.sendCommand(this.builderPlayers.getBuilderForEnable());
container.initGui();
container.init();
}));
this.addButton.enabled = enabled && this.builderTrigger.getValue() > 0;
this.removeButton.enabled = enabled;
button1.enabled = enabled;
this.addButton.active = enabled && this.builderTrigger.getValue() > 0;
this.removeButton.active = enabled;
button1.active = enabled;
}
if(this.selectedPlayer.equals("tag"))
@@ -232,13 +232,13 @@ public class ContentScoreboardPlayers extends ContentScoreboard
{
boolean points = enabled && this.builderPlayers.getPoints() > 0;
this.addButton.enabled = points;
this.removeButton.enabled = points;
this.addButton.active = points;
this.removeButton.active = points;
}
else if(this.selectedPlayer.equals("enable"))
{
this.addButton.enabled = enabled && this.builderTrigger.getValue() > 0;
this.removeButton.enabled = enabled;
this.addButton.active = enabled && this.builderTrigger.getValue() > 0;
this.removeButton.active = enabled;
}
this.objectField.tick();
@@ -250,11 +250,11 @@ public class ContentScoreboardPlayers extends ContentScoreboard
{
if(this.selectedPlayer.equals("tag"))
{
this.tagField.drawTextField(mouseX, mouseY, partialTicks);
this.tagField.renderButton(mouseX, mouseY, partialTicks);
}
else
{
this.objectField.drawTextField(mouseX, mouseY, partialTicks);
this.objectField.renderButton(mouseX, mouseY, partialTicks);
}
}

View File

@@ -45,7 +45,7 @@ public class ContentScoreboardTeams extends ContentScoreboard
this.teamField = new GuiTextFieldTooltip(x + 118, y + (this.selectedTeam.equals("option") ? 0 : (this.selectedTeam.equals("add") ? 24 : 12)), 114, 20, I18n.format("gui.worldhandler.scoreboard.team.team"));
this.teamField.setValidator(Predicates.notNull());
this.teamField.setText(this.team);
this.teamField.setTextAcceptHandler((id, text) ->
this.teamField.func_212954_a(text ->
{
this.team = text;
this.builderTeams.setTeam(this.team);
@@ -65,7 +65,7 @@ public class ContentScoreboardTeams extends ContentScoreboard
}
else if(depth == 1)
{
if(Arrays.stream(EnumColor.values()).map(EnumColor::getFormat).anyMatch(Predicates.equalTo(key)))
if(Arrays.stream(EnumColor.values()).map(EnumColor::getName).anyMatch(Predicates.equalTo(key)))
{
return I18n.format("gui.worldhandler.color." + key);
}
@@ -120,28 +120,28 @@ public class ContentScoreboardTeams extends ContentScoreboard
container.add(button1 = new GuiButtonBase(x, y, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.create"), () ->
{
this.selectedTeam = "add";
container.initGui();
container.init();
}));
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.join") + " / " + I18n.format("gui.worldhandler.scoreboard.team.leave"), () ->
{
this.selectedTeam = "join|leave";
container.initGui();
container.init();
}));
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.remove") + " / " + I18n.format("gui.worldhandler.scoreboard.team.empty"), () ->
{
this.selectedTeam = "remove|empty";
container.initGui();
container.init();
}));
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.scoreboard.team.options"), () ->
{
this.selectedTeam = "option";
container.initGui();
container.init();
}));
button1.enabled = !this.selectedTeam.equals("add");
button2.enabled = !this.selectedTeam.equals("join|leave");
button3.enabled = !this.selectedTeam.equals("remove|empty");
button4.enabled = !this.selectedTeam.equals("option");
button1.active = !this.selectedTeam.equals("add");
button2.active = !this.selectedTeam.equals("join|leave");
button3.active = !this.selectedTeam.equals("remove|empty");
button4.active = !this.selectedTeam.equals("option");
this.builderTeams.setMode(this.selectedTeam);
@@ -166,7 +166,7 @@ public class ContentScoreboardTeams extends ContentScoreboard
container.initButtons();
}));
button1.enabled = enabled;
button1.active = enabled;
}
else if(this.selectedTeam.equals("remove|empty"))
{
@@ -181,8 +181,8 @@ public class ContentScoreboardTeams extends ContentScoreboard
container.initButtons();
}));
button1.enabled = enabled;
button2.enabled = enabled;
button1.active = enabled;
button2.active = enabled;
}
if(!this.selectedTeam.equals("join|leave") && !this.selectedTeam.equals("remove|empty"))
@@ -194,7 +194,7 @@ public class ContentScoreboardTeams extends ContentScoreboard
CommandHelper.sendCommand(this.builderTeams);
container.initButtons();
}));
button1.enabled = enabled;
button1.active = enabled;
}
container.add(this.teamField);
@@ -209,7 +209,7 @@ public class ContentScoreboardTeams extends ContentScoreboard
@Override
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
{
this.teamField.drawTextField(mouseX, mouseY, partialTicks);
this.teamField.renderButton(mouseX, mouseY, partialTicks);
}
@Override

View File

@@ -55,13 +55,13 @@ public class ContentSettings extends ContentChild
@Override
public String translate(Setting<?> item)
{
return I18n.format("gui.worldhandler.config.key.settings." + item.getKey());
return I18n.format("gui.worldhandler.config.settings." + item.getKey());
}
@Override
public String toTooltip(Setting<?> item)
{
return I18n.format("gui.worldhandler.config.comment.settings." + item.getKey());
return null;
}
@Override
@@ -126,18 +126,18 @@ public class ContentSettings extends ContentChild
container.add(button1 = new GuiButtonBase(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.generic.enable"), () ->
{
setting.set(true);
container.initButtons();
container.init();
}));
container.add(button2 = new GuiButtonBase(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.generic.disable"), () ->
{
setting.set(false);
container.initButtons();
container.init();
}));
boolean enabled = setting.get();
button1.enabled = !enabled;
button2.enabled = enabled;
button1.active = !enabled;
button2.active = enabled;
}
else if(this.setting instanceof IntegerSetting)
{
@@ -158,7 +158,7 @@ public class ContentSettings extends ContentChild
setting.set(Integer.parseInt(text));
}
container.initButtons();
container.init();
}));
}
}
@@ -177,7 +177,7 @@ public class ContentSettings extends ContentChild
{
if(this.setting instanceof IntegerSetting)
{
this.valueField.drawTextField(mouseX, mouseY, partialTicks);
this.valueField.renderButton(mouseX, mouseY, partialTicks);
}
}

View File

@@ -2,6 +2,7 @@ package exopandora.worldhandler.gui.content.impl;
import com.google.common.base.Predicates;
import com.mojang.blaze3d.platform.GlStateManager;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.builder.ICommandBuilder;
@@ -19,14 +20,13 @@ import exopandora.worldhandler.gui.logic.ILogicColorMenu;
import exopandora.worldhandler.helper.ActionHelper;
import exopandora.worldhandler.helper.BlockHelper;
import exopandora.worldhandler.helper.CommandHelper;
import net.minecraft.block.AbstractSignBlock;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -51,7 +51,7 @@ public class ContentSignEditor extends Content
@Override
public void init(Container container)
{
this.isActive = BlockHelper.isFocusedBlockEqualTo(Blocks.SIGN) || BlockHelper.isFocusedBlockEqualTo(Blocks.WALL_SIGN);
this.isActive = BlockHelper.getFocusedBlock() instanceof AbstractSignBlock;
this.builderSignEditor.setPosition(BlockHelper.getFocusedBlockPos());
}
@@ -64,7 +64,7 @@ public class ContentSignEditor extends Content
this.commandField.setValidator(Predicates.notNull());
this.commandField.setText(this.builderSignEditor.getCommand(this.selectedLine));
this.commandField.setCursorPositionEnd();
this.commandField.setTextAcceptHandler((id, text) ->
this.commandField.func_212954_a(text ->
{
this.builderSignEditor.setCommand(this.selectedLine, text);
container.initButtons();
@@ -111,22 +111,22 @@ public class ContentSignEditor extends Content
container.add(button1 = new GuiButtonBase(x, y, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.text_line_1"), () ->
{
this.selectedLine = 0;
container.initGui();
container.init();
}));
container.add(button2 = new GuiButtonBase(x, y + 24, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.text_line_2"), () ->
{
this.selectedLine = 1;
container.initGui();
container.init();
}));
container.add(button3 = new GuiButtonBase(x, y + 48, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.text_line_3"), () ->
{
this.selectedLine = 2;
container.initGui();
container.init();
}));
container.add(button4 = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.blocks.sign_editor.text_line_4"), () ->
{
this.selectedLine = 3;
container.initGui();
container.init();
}));
if(this.editColor)
@@ -143,18 +143,28 @@ public class ContentSignEditor extends Content
}));
}
button1.enabled = this.selectedLine != 0;
button2.enabled = this.selectedLine != 1;
button3.enabled = this.selectedLine != 2;
button4.enabled = this.selectedLine != 3;
button1.active = this.selectedLine != 0;
button2.active = this.selectedLine != 1;
button3.active = this.selectedLine != 2;
button4.active = this.selectedLine != 3;
}
}
@Override
public void tick(Container container)
{
if(this.editColor)
{
}
}
private void toggleEditColor(Container container)
{
this.editColor = !this.editColor;
container.initGui();
container.init();
}
@Override
public void drawScreen(Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
{
@@ -162,7 +172,7 @@ public class ContentSignEditor extends Content
{
if(!this.editColor)
{
this.commandField.drawTextField(mouseX, mouseY, partialTicks);
this.commandField.renderButton(mouseX, mouseY, partialTicks);
}
}
else
@@ -175,12 +185,12 @@ public class ContentSignEditor extends Content
GlStateManager.translatef(container.width / 2 - 8.5F * scale, container.height / 2 - 15 - 8.5F * scale, 0);
GlStateManager.scalef(scale, scale, scale);
Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(new ItemStack(Items.SIGN), 0, 0);
Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(new ItemStack(Items.field_222071_kr), 0, 0);
RenderHelper.disableStandardItemLighting();
GlStateManager.popMatrix();
String displayString = I18n.format("gui.worldhandler.blocks.sign_editor.look_at_sign", WorldHandler.KEY_WORLD_HANDLER.func_197978_k());
String displayString = I18n.format("gui.worldhandler.blocks.sign_editor.look_at_sign", WorldHandler.KEY_WORLD_HANDLER.getLocalizedName());
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
fontRenderer.drawString(displayString, x + 116 - fontRenderer.getStringWidth(displayString) / 2, y + 70, Config.getSkin().getLabelColor());
}

View File

@@ -30,12 +30,12 @@ import exopandora.worldhandler.gui.logic.LogicSliderSimple;
import exopandora.worldhandler.helper.ActionHelper;
import exopandora.worldhandler.helper.CommandHelper;
import exopandora.worldhandler.util.ActionHandler;
import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
import net.minecraft.potion.Potion;
import net.minecraft.item.Items;
import net.minecraft.potion.Effect;
import net.minecraft.potion.Effects;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -79,7 +79,7 @@ public class ContentSummon extends Content
}
}
for(Potion potion : this.builderSummon.getPotions())
for(Effect potion : this.builderSummon.getEffects())
{
byte amplifier = this.builderSummon.getAmplifier(potion);
@@ -103,7 +103,7 @@ public class ContentSummon extends Content
this.mobField = new GuiTextFieldTooltip(x + 118, y, 114, 20, I18n.format("gui.worldhandler.entities.summon.start.mob_id") + " (" + I18n.format("gui.worldhandler.generic.name") + ")");
this.mobField.setValidator(Predicates.notNull());
this.mobField.setText(this.mob);
this.mobField.setTextAcceptHandler((id, text) ->
this.mobField.func_212954_a(text ->
{
this.mob = text;
this.builderSummon.setEntity(this.mob);
@@ -113,7 +113,7 @@ public class ContentSummon extends Content
this.customNameField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, I18n.format("gui.worldhandler.entities.summon.start.custom_name"));
this.customNameField.setValidator(Predicates.notNull());
this.customNameField.setText(this.name);
this.customNameField.setTextAcceptHandler((id, text) ->
this.customNameField.func_212954_a(text ->
{
this.name = text;
this.builderSummon.setCustomName(this.name);
@@ -123,7 +123,7 @@ public class ContentSummon extends Content
this.passengerField = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.entities.summon.start.passenger_mob_id"));
this.passengerField.setValidator(Predicates.notNull());
this.passengerField.setText(this.passenger);
this.passengerField.setTextAcceptHandler((id, text) ->
this.passengerField.func_212954_a(text ->
{
this.passenger = this.passengerField.getText();
this.builderSummon.setPassenger(this.passenger);
@@ -213,27 +213,27 @@ public class ContentSummon extends Content
container.add(button4 = new GuiButtonBase(x, y, 114, 20, I18n.format("gui.worldhandler.entities.summon.start"), () ->
{
this.page = "main";
container.initGui();
container.init();
}));
container.add(button5 = new GuiButtonBase(x, y + 24, 114, 20, I18n.format("gui.worldhandler.entities.summon.potion_effects"), () ->
{
this.page = "potionEffects";
container.initGui();
container.init();
}));
container.add(button6 = new GuiButtonBase(x, y + 48, 114, 20, I18n.format("gui.worldhandler.entities.summon.attributes"), () ->
{
this.page = "attributes";
container.initGui();
container.init();
}));
container.add(button7 = new GuiButtonBase(x, y + 72, 114, 20, I18n.format("gui.worldhandler.entities.summon.equipment"), () ->
{
this.page = "equipment";
container.initGui();
container.init();
}));
if(this.page.equals("main"))
{
button4.enabled = false;
button4.active = false;
container.add(this.mobField);
container.add(this.customNameField);
@@ -248,39 +248,39 @@ public class ContentSummon extends Content
container.add(button3 = new GuiButtonBase(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.actions.place_command_block"), this::send));
}
button3.enabled = ForgeRegistries.ENTITIES.containsKey(this.builderSummon.getEntity());
button3.active = ForgeRegistries.ENTITIES.containsKey(this.builderSummon.getEntity());
}
else if(this.page.equals("potionEffects"))
{
button5.enabled = false;
button5.active = false;
container.add(button1 = new GuiButtonBase(x + 118, y + 72, 56, 20, "<", () ->
{
this.potionPage--;
container.initGui();
container.init();
}));
container.add(button2 = new GuiButtonBase(x + 118 + 60, y + 72, 55, 20, ">", () ->
{
this.potionPage++;
container.initGui();
container.init();
}));
int count = 0;
for(ResourceLocation location : this.getSortedPotionList())
{
Potion potion = ForgeRegistries.POTIONS.getValue(location);
Effect potion = ForgeRegistries.POTIONS.getValue(location);
if(!potion.equals(MobEffects.INSTANT_DAMAGE) && !potion.equals(MobEffects.INSTANT_HEALTH))
if(!potion.equals(Effects.field_76432_h) && !potion.equals(Effects.field_76433_i))
{
if(this.potionPage == 0)
{
button1.enabled = false;
button1.active = false;
}
if(this.potionPage == ForgeRegistries.POTIONS.getKeys().size() - 3)
{
button2.enabled = false;
button2.active = false;
}
if(count == this.potionPage)
@@ -296,7 +296,7 @@ public class ContentSummon extends Content
container.add(new GuiButtonBase(x + 118, y + 48, 114, 20, I18n.format("gui.worldhandler.potions.effect.particles", this.builderSummon.getShowParticles(potion) ? I18n.format("gui.worldhandler.generic.on") : I18n.format("gui.worldhandler.generic.off")), () ->
{
this.builderSummon.setShowParticles(potion, !this.builderSummon.getShowParticles(potion));
container.initGui();
container.init();
}));
break;
}
@@ -307,259 +307,259 @@ public class ContentSummon extends Content
}
else if(this.page.equals("attributes"))
{
button6.enabled = false;
button6.active = false;
}
else if(this.page.equals("equipment"))
{
container.add(button1 = new GuiButtonBase(x + 118, y + 72, 56, 20, "<", () ->
{
this.equipmentPage--;
container.initGui();
container.init();
}));
container.add(button2 = new GuiButtonBase(x + 118 + 60, y + 72, 54, 20, ">", () ->
{
this.equipmentPage++;
container.initGui();
container.init();
}));
if(this.equipmentPage == 0)
{
button1.enabled = false;
button1.active = false;
container.add(button8 = new GuiButtonItem(x + 118, y, 18, 20, Items.LEATHER_HELMET, () ->
{
this.builderSummon.setArmorItem(3, Items.LEATHER_HELMET);
container.initGui();
container.init();
}));
container.add(button9 = new GuiButtonItem(x + 118 + 20 - 1, y, 18, 20, Items.IRON_HELMET, () ->
{
this.builderSummon.setArmorItem(3, Items.IRON_HELMET);
container.initGui();
container.init();
}));
container.add(button10 = new GuiButtonItem(x + 118 + 20 * 2 - 2, y, 18, 20, Items.CHAINMAIL_HELMET, () ->
{
this.builderSummon.setArmorItem(3, Items.CHAINMAIL_HELMET);
container.initGui();
container.init();
}));
container.add(button11 = new GuiButtonItem(x + 118 + 20 * 3 - 3, y, 18, 20, Items.GOLDEN_HELMET, () ->
{
this.builderSummon.setArmorItem(3, Items.GOLDEN_HELMET);
container.initGui();
container.init();
}));
container.add(button12 = new GuiButtonItem(x + 118 + 20 * 4 - 4, y, 18, 20, Items.DIAMOND_HELMET, () ->
{
this.builderSummon.setArmorItem(3, Items.DIAMOND_HELMET);
container.initGui();
container.init();
}));
container.add(button13 = new GuiButtonBase(x + 118 + 20 * 5 - 5, y, 20, 20, null, () ->
{
this.builderSummon.setArmorItem(3, Blocks.AIR);
container.initGui();
container.init();
}));
container.add(button14 = new GuiButtonItem(x + 118, y + 24, 18, 20, Items.LEATHER_CHESTPLATE, () ->
{
this.builderSummon.setArmorItem(2, Items.LEATHER_CHESTPLATE);
container.initGui();
container.init();
}));
container.add(button15 = new GuiButtonItem(x + 118 + 20 - 1, y + 24, 18, 20, Items.IRON_CHESTPLATE, () ->
{
this.builderSummon.setArmorItem(2, Items.IRON_CHESTPLATE);
container.initGui();
container.init();
}));
container.add(button16 = new GuiButtonItem(x + 118 + 20 * 2 - 2, y + 24, 18, 20, Items.CHAINMAIL_CHESTPLATE, () ->
{
this.builderSummon.setArmorItem(2, Items.CHAINMAIL_CHESTPLATE);
container.initGui();
container.init();
}));
container.add(button17 = new GuiButtonItem(x + 118 + 20 * 3 - 3, y + 24, 18, 20, Items.GOLDEN_CHESTPLATE, () ->
{
this.builderSummon.setArmorItem(2, Items.GOLDEN_CHESTPLATE);
container.initGui();
container.init();
}));
container.add(button18 = new GuiButtonItem(x + 118 + 20 * 4 - 4, y + 24, 18, 20, Items.DIAMOND_CHESTPLATE, () ->
{
this.builderSummon.setArmorItem(2, Items.DIAMOND_CHESTPLATE);
container.initGui();
container.init();
}));
container.add(button19 = new GuiButtonBase(x + 118 + 20 * 5 - 5, y + 24, 20, 20, null, () ->
{
this.builderSummon.setArmorItem(2, Blocks.AIR);
container.initGui();
container.init();
}));
container.add(button20 = new GuiButtonItem(x + 118, y + 48, 18, 20, Items.LEATHER_LEGGINGS, () ->
{
this.builderSummon.setArmorItem(1, Items.LEATHER_LEGGINGS);
container.initGui();
container.init();
}));
container.add(button21 = new GuiButtonItem(x + 118 + 20 - 1, y + 48, 18, 20, Items.IRON_LEGGINGS, () ->
{
this.builderSummon.setArmorItem(1, Items.IRON_LEGGINGS);
container.initGui();
container.init();
}));
container.add(button22 = new GuiButtonItem(x + 118 + 20 * 2 - 2, y + 48, 18, 20, Items.CHAINMAIL_LEGGINGS, () ->
{
this.builderSummon.setArmorItem(1, Items.CHAINMAIL_LEGGINGS);
container.initGui();
container.init();
}));
container.add(button23 = new GuiButtonItem(x + 118 + 20 * 3 - 3, y + 48, 18, 20, Items.GOLDEN_LEGGINGS, () ->
{
this.builderSummon.setArmorItem(1, Items.GOLDEN_LEGGINGS);
container.initGui();
container.init();
}));
container.add(button24 = new GuiButtonItem(x + 118 + 20 * 4 - 4, y + 48, 18, 20, Items.DIAMOND_LEGGINGS, () ->
{
this.builderSummon.setArmorItem(1, Items.DIAMOND_LEGGINGS);
container.initGui();
container.init();
}));
container.add(button25 = new GuiButtonBase(x + 118 + 20 * 5 - 5, y + 48, 20, 20, null, () ->
{
this.builderSummon.setArmorItem(1, Blocks.AIR);
container.initGui();
container.init();
}));
button8.enabled = !this.builderSummon.getArmorItem(3).equals(Items.LEATHER_HELMET.getRegistryName());
button9.enabled = !this.builderSummon.getArmorItem(3).equals(Items.IRON_HELMET.getRegistryName());
button10.enabled = !this.builderSummon.getArmorItem(3).equals(Items.CHAINMAIL_HELMET.getRegistryName());
button11.enabled = !this.builderSummon.getArmorItem(3).equals(Items.GOLDEN_HELMET.getRegistryName());
button12.enabled = !this.builderSummon.getArmorItem(3).equals(Items.DIAMOND_HELMET.getRegistryName());
button13.enabled = !this.builderSummon.getArmorItem(3).equals(Blocks.AIR.getRegistryName());
button8.active = !this.builderSummon.getArmorItem(3).equals(Items.LEATHER_HELMET.getRegistryName());
button9.active = !this.builderSummon.getArmorItem(3).equals(Items.IRON_HELMET.getRegistryName());
button10.active = !this.builderSummon.getArmorItem(3).equals(Items.CHAINMAIL_HELMET.getRegistryName());
button11.active = !this.builderSummon.getArmorItem(3).equals(Items.GOLDEN_HELMET.getRegistryName());
button12.active = !this.builderSummon.getArmorItem(3).equals(Items.DIAMOND_HELMET.getRegistryName());
button13.active = !this.builderSummon.getArmorItem(3).equals(Blocks.AIR.getRegistryName());
button14.enabled = !this.builderSummon.getArmorItem(2).equals(Items.LEATHER_CHESTPLATE.getRegistryName());
button15.enabled = !this.builderSummon.getArmorItem(2).equals(Items.IRON_CHESTPLATE.getRegistryName());
button16.enabled = !this.builderSummon.getArmorItem(2).equals(Items.CHAINMAIL_CHESTPLATE.getRegistryName());
button17.enabled = !this.builderSummon.getArmorItem(2).equals(Items.GOLDEN_CHESTPLATE.getRegistryName());
button18.enabled = !this.builderSummon.getArmorItem(2).equals(Items.DIAMOND_CHESTPLATE.getRegistryName());
button19.enabled = !this.builderSummon.getArmorItem(2).equals(Blocks.AIR.getRegistryName());
button14.active = !this.builderSummon.getArmorItem(2).equals(Items.LEATHER_CHESTPLATE.getRegistryName());
button15.active = !this.builderSummon.getArmorItem(2).equals(Items.IRON_CHESTPLATE.getRegistryName());
button16.active = !this.builderSummon.getArmorItem(2).equals(Items.CHAINMAIL_CHESTPLATE.getRegistryName());
button17.active = !this.builderSummon.getArmorItem(2).equals(Items.GOLDEN_CHESTPLATE.getRegistryName());
button18.active = !this.builderSummon.getArmorItem(2).equals(Items.DIAMOND_CHESTPLATE.getRegistryName());
button19.active = !this.builderSummon.getArmorItem(2).equals(Blocks.AIR.getRegistryName());
button20.enabled = !this.builderSummon.getArmorItem(1).equals(Items.LEATHER_LEGGINGS.getRegistryName());
button21.enabled = !this.builderSummon.getArmorItem(1).equals(Items.IRON_LEGGINGS.getRegistryName());
button22.enabled = !this.builderSummon.getArmorItem(1).equals(Items.CHAINMAIL_LEGGINGS.getRegistryName());
button23.enabled = !this.builderSummon.getArmorItem(1).equals(Items.GOLDEN_LEGGINGS.getRegistryName());
button24.enabled = !this.builderSummon.getArmorItem(1).equals(Items.DIAMOND_LEGGINGS.getRegistryName());
button25.enabled = !this.builderSummon.getArmorItem(1).equals(Blocks.AIR.getRegistryName());
button20.active = !this.builderSummon.getArmorItem(1).equals(Items.LEATHER_LEGGINGS.getRegistryName());
button21.active = !this.builderSummon.getArmorItem(1).equals(Items.IRON_LEGGINGS.getRegistryName());
button22.active = !this.builderSummon.getArmorItem(1).equals(Items.CHAINMAIL_LEGGINGS.getRegistryName());
button23.active = !this.builderSummon.getArmorItem(1).equals(Items.GOLDEN_LEGGINGS.getRegistryName());
button24.active = !this.builderSummon.getArmorItem(1).equals(Items.DIAMOND_LEGGINGS.getRegistryName());
button25.active = !this.builderSummon.getArmorItem(1).equals(Blocks.AIR.getRegistryName());
}
else if(this.equipmentPage == 1)
{
button2.enabled = false;
button2.active = false;
container.add(button8 = new GuiButtonItem(x + 118, y, 18, 20, Items.LEATHER_BOOTS, () ->
{
this.builderSummon.setArmorItem(0, Items.LEATHER_BOOTS);
container.initGui();
container.init();
}));
container.add(button9 = new GuiButtonItem(x + 118 + 20 - 1, y, 18, 20, Items.IRON_BOOTS, () ->
{
this.builderSummon.setArmorItem(0, Items.IRON_BOOTS);
container.initGui();
container.init();
}));
container.add(button10 = new GuiButtonItem(x + 118 + 20 * 2 - 2, y, 18, 20, Items.CHAINMAIL_BOOTS, () ->
{
this.builderSummon.setArmorItem(0, Items.CHAINMAIL_BOOTS);
container.initGui();
container.init();
}));
container.add(button11 = new GuiButtonItem(x + 118 + 20 * 3 - 3, y, 18, 20, Items.GOLDEN_BOOTS, () ->
{
this.builderSummon.setArmorItem(0, Items.GOLDEN_BOOTS);
container.initGui();
container.init();
}));
container.add(button12 = new GuiButtonItem(x + 118 + 20 * 4 - 4, y, 18, 20, Items.DIAMOND_BOOTS, () ->
{
this.builderSummon.setArmorItem(0, Items.DIAMOND_BOOTS);
container.initGui();
container.init();
}));
container.add(button13 = new GuiButtonBase(x + 118 + 20 * 5 - 5, y, 20, 20, null, () ->
{
this.builderSummon.setArmorItem(0, Blocks.AIR);
container.initGui();
container.init();
}));
container.add(button14 = new GuiButtonItem(x + 118, y + 24, 18, 20, Items.WOODEN_SWORD, () ->
{
this.builderSummon.setHandItem(0, Items.WOODEN_SWORD);
container.initGui();
container.init();
}));
container.add(button15 = new GuiButtonItem(x + 118 + 20 - 1, y + 24, 18, 20, Items.STONE_SWORD, () ->
{
this.builderSummon.setHandItem(0, Items.STONE_SWORD);
container.initGui();
container.init();
}));
container.add(button16 = new GuiButtonItem(x + 118 + 20 * 2 - 2, y + 24, 18, 20, Items.IRON_SWORD, () ->
{
this.builderSummon.setHandItem(0, Items.IRON_SWORD);
container.initGui();
container.init();
}));
container.add(button17 = new GuiButtonItem(x + 118 + 20 * 3 - 3, y + 24, 18, 20, Items.GOLDEN_SWORD, () ->
{
this.builderSummon.setHandItem(0, Items.GOLDEN_SWORD);
container.initGui();
container.init();
}));
container.add(button18 = new GuiButtonItem(x + 118 + 20 * 4 - 4, y + 24, 18, 20, Items.DIAMOND_SWORD, () ->
{
this.builderSummon.setHandItem(0, Items.DIAMOND_SWORD);
container.initGui();
container.init();
}));
container.add(button19 = new GuiButtonBase(x + 118 + 20 * 5 - 5, y + 24, 20, 20, null, () ->
{
this.builderSummon.setHandItem(0, Blocks.AIR);
container.initGui();
container.init();
}));
container.add(button20 = new GuiButtonItem(x + 118, y + 48, 18, 20, Items.WOODEN_SWORD, () ->
{
this.builderSummon.setHandItem(1, Items.WOODEN_SWORD);
container.initGui();
container.init();
}));
container.add(button21 = new GuiButtonItem(x + 118 + 20 - 1, y + 48, 18, 20, Items.STONE_SWORD, () ->
{
this.builderSummon.setHandItem(1, Items.STONE_SWORD);
container.initGui();
container.init();
}));
container.add(button22 = new GuiButtonItem(x + 118 + 20 * 2 - 2, y + 48, 18, 20, Items.IRON_SWORD, () ->
{
this.builderSummon.setHandItem(1, Items.IRON_SWORD);
container.initGui();
container.init();
}));
container.add(button23 = new GuiButtonItem(x + 118 + 20 * 3 - 3, y + 48, 18, 20, Items.GOLDEN_SWORD, () ->
{
this.builderSummon.setHandItem(1, Items.GOLDEN_SWORD);
container.initGui();
container.init();
}));
container.add(button24 = new GuiButtonItem(x + 118 + 20 * 4 - 4, y + 48, 18, 20, Items.DIAMOND_SWORD, () ->
{
this.builderSummon.setHandItem(1, Items.DIAMOND_SWORD);
container.initGui();
container.init();
}));
container.add(button25 = new GuiButtonBase(x + 118 + 20 * 5 - 5, y + 48, 20, 20, null, () ->
{
this.builderSummon.setHandItem(1, Blocks.AIR);
container.initGui();
container.init();
}));
button8.enabled = !this.builderSummon.getArmorItem(0).equals(Items.LEATHER_BOOTS.getRegistryName());
button9.enabled = !this.builderSummon.getArmorItem(0).equals(Items.IRON_BOOTS.getRegistryName());
button10.enabled = !this.builderSummon.getArmorItem(0).equals(Items.CHAINMAIL_BOOTS.getRegistryName());
button11.enabled = !this.builderSummon.getArmorItem(0).equals(Items.GOLDEN_BOOTS.getRegistryName());
button12.enabled = !this.builderSummon.getArmorItem(0).equals(Items.DIAMOND_BOOTS.getRegistryName());
button13.enabled = !this.builderSummon.getArmorItem(0).equals(Blocks.AIR.getRegistryName());
button8.active = !this.builderSummon.getArmorItem(0).equals(Items.LEATHER_BOOTS.getRegistryName());
button9.active = !this.builderSummon.getArmorItem(0).equals(Items.IRON_BOOTS.getRegistryName());
button10.active = !this.builderSummon.getArmorItem(0).equals(Items.CHAINMAIL_BOOTS.getRegistryName());
button11.active = !this.builderSummon.getArmorItem(0).equals(Items.GOLDEN_BOOTS.getRegistryName());
button12.active = !this.builderSummon.getArmorItem(0).equals(Items.DIAMOND_BOOTS.getRegistryName());
button13.active = !this.builderSummon.getArmorItem(0).equals(Blocks.AIR.getRegistryName());
button14.enabled = !this.builderSummon.getHandItem(0).equals(Items.WOODEN_SWORD.getRegistryName());
button15.enabled = !this.builderSummon.getHandItem(0).equals(Items.STONE_SWORD.getRegistryName());
button16.enabled = !this.builderSummon.getHandItem(0).equals(Items.IRON_SWORD.getRegistryName());
button17.enabled = !this.builderSummon.getHandItem(0).equals(Items.GOLDEN_SWORD.getRegistryName());
button18.enabled = !this.builderSummon.getHandItem(0).equals(Items.DIAMOND_SWORD.getRegistryName());
button19.enabled = !this.builderSummon.getHandItem(0).equals(Blocks.AIR.getRegistryName());
button14.active = !this.builderSummon.getHandItem(0).equals(Items.WOODEN_SWORD.getRegistryName());
button15.active = !this.builderSummon.getHandItem(0).equals(Items.STONE_SWORD.getRegistryName());
button16.active = !this.builderSummon.getHandItem(0).equals(Items.IRON_SWORD.getRegistryName());
button17.active = !this.builderSummon.getHandItem(0).equals(Items.GOLDEN_SWORD.getRegistryName());
button18.active = !this.builderSummon.getHandItem(0).equals(Items.DIAMOND_SWORD.getRegistryName());
button19.active = !this.builderSummon.getHandItem(0).equals(Blocks.AIR.getRegistryName());
button20.enabled = !this.builderSummon.getHandItem(1).equals(Items.WOODEN_SWORD.getRegistryName());
button21.enabled = !this.builderSummon.getHandItem(1).equals(Items.STONE_SWORD.getRegistryName());
button22.enabled = !this.builderSummon.getHandItem(1).equals(Items.IRON_SWORD.getRegistryName());
button23.enabled = !this.builderSummon.getHandItem(1).equals(Items.GOLDEN_SWORD.getRegistryName());
button24.enabled = !this.builderSummon.getHandItem(1).equals(Items.DIAMOND_SWORD.getRegistryName());
button25.enabled = !this.builderSummon.getHandItem(1).equals(Blocks.AIR.getRegistryName());
button20.active = !this.builderSummon.getHandItem(1).equals(Items.WOODEN_SWORD.getRegistryName());
button21.active = !this.builderSummon.getHandItem(1).equals(Items.STONE_SWORD.getRegistryName());
button22.active = !this.builderSummon.getHandItem(1).equals(Items.IRON_SWORD.getRegistryName());
button23.active = !this.builderSummon.getHandItem(1).equals(Items.GOLDEN_SWORD.getRegistryName());
button24.active = !this.builderSummon.getHandItem(1).equals(Items.DIAMOND_SWORD.getRegistryName());
button25.active = !this.builderSummon.getHandItem(1).equals(Blocks.AIR.getRegistryName());
}
button7.enabled = false;
button7.active = false;
}
}
@@ -584,9 +584,9 @@ public class ContentSummon extends Content
{
if(this.page.equals("main"))
{
this.mobField.drawTextField(mouseX, mouseY, partialTicks);
this.customNameField.drawTextField(mouseX, mouseY, partialTicks);
this.passengerField.drawTextField(mouseX, mouseY, partialTicks);
this.mobField.renderButton(mouseX, mouseY, partialTicks);
this.customNameField.renderButton(mouseX, mouseY, partialTicks);
this.passengerField.renderButton(mouseX, mouseY, partialTicks);
}
else if(this.page.equals("equipment"))
{
@@ -595,7 +595,7 @@ public class ContentSummon extends Content
for(int row = 0; row < 3; row++)
{
container.drawTexturedModalRect(x + 116 + 99, y + 2 + 24 * row, 112, 221, 16, 16);
container.blit(x + 116 + 99, y + 2 + 24 * row, 112, 221, 16, 16);
}
}
}

View File

@@ -53,7 +53,7 @@ public class ContentWorldInfo extends Content
this.worldField.setText(I18n.format("gui.worldhandler.world_info.world.name") + ": " + this.getWorldInfo(WorldInfo::getWorldName, world));
this.terrainField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20);
this.terrainField.setText(I18n.format("gui.worldhandler.world_info.world.world_type") + ": " + this.getWorldInfo(info -> I18n.format(info.getTerrainType().getTranslationKey()), world));
this.terrainField.setText(I18n.format("gui.worldhandler.world_info.world.world_type") + ": " + this.getWorldInfo(info -> I18n.format(info.getGenerator().getTranslationKey()), world));
this.seedField = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20);
this.seedField.setText(I18n.format("gui.worldhandler.world_info.world.seed") + ": " + this.getSeed(world));
@@ -80,38 +80,38 @@ public class ContentWorldInfo extends Content
container.add(start = new GuiButtonBase(x, y + 12, 114, 20, I18n.format("gui.worldhandler.world_info.start"), () ->
{
this.selectedMain = "start";
container.initGui();
container.init();
}));
container.add(world = new GuiButtonBase(x, y + 36, 114, 20, I18n.format("gui.worldhandler.world_info.world"), () ->
{
this.selectedMain = "world";
container.initGui();
container.init();
}));
container.add(stats = new GuiButtonBase(x, y + 60, 114, 20, I18n.format("gui.worldhandler.world_info.statistics"), () ->
{
this.selectedMain = "stats";
container.initGui();
container.init();
}));
if(this.selectedMain.equals("start"))
{
start.enabled = false;
start.active = false;
}
else if(this.selectedMain.equals("world"))
{
GuiButtonBase seed;
world.enabled = false;
world.active = false;
container.add(seed = new GuiButtonBase(x + 118, y + 72, 114, 20, I18n.format("gui.worldhandler.world_info.world.copy_seed"), () ->
{
Minecraft.getInstance().keyboardListener.setClipboardString(this.getSeed(this.getWorld()));
}));
seed.enabled = Minecraft.getInstance().getIntegratedServer() != null;
seed.active = Minecraft.getInstance().getIntegratedServer() != null;
}
else if(this.selectedMain.equals("stats"))
{
stats.enabled = false;
stats.active = false;
}
}
@@ -128,20 +128,20 @@ public class ContentWorldInfo extends Content
{
if(this.selectedMain.equals("start"))
{
this.posXField.drawTextField(mouseX, mouseY, partialTicks);
this.posYField.drawTextField(mouseX, mouseY, partialTicks);
this.posZField.drawTextField(mouseX, mouseY, partialTicks);
this.posXField.renderButton(mouseX, mouseY, partialTicks);
this.posYField.renderButton(mouseX, mouseY, partialTicks);
this.posZField.renderButton(mouseX, mouseY, partialTicks);
}
else if(this.selectedMain.equals("world"))
{
this.worldField.drawTextField(mouseX, mouseY, partialTicks);
this.terrainField.drawTextField(mouseX, mouseY, partialTicks);
this.seedField.drawTextField(mouseX, mouseY, partialTicks);
this.worldField.renderButton(mouseX, mouseY, partialTicks);
this.terrainField.renderButton(mouseX, mouseY, partialTicks);
this.seedField.renderButton(mouseX, mouseY, partialTicks);
}
else if(this.selectedMain.equals("stats"))
{
this.totalTimeField.drawTextField(mouseX, mouseY, partialTicks);
this.currentTimeField.drawTextField(mouseX, mouseY, partialTicks);
this.totalTimeField.renderButton(mouseX, mouseY, partialTicks);
this.currentTimeField.renderButton(mouseX, mouseY, partialTicks);
}
}

View File

@@ -1,7 +1,5 @@
package exopandora.worldhandler.helper;
import com.mojang.realmsclient.gui.ChatFormatting;
import exopandora.worldhandler.Main;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.builder.impl.BuilderDifficulty;
@@ -17,13 +15,15 @@ import exopandora.worldhandler.gui.container.impl.GuiWorldHandler;
import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.gui.content.Contents;
import exopandora.worldhandler.util.ActionHandler;
import net.minecraft.block.AbstractSignBlock;
import net.minecraft.block.NoteBlock;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.Blocks;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.util.text.event.ClickEvent.Action;
import net.minecraftforge.api.distmarker.Dist;
@@ -130,23 +130,23 @@ public class ActionHelper
{
try
{
action.run();
if(action != null)
{
action.run();
}
}
catch(Exception e)
{
if(!Minecraft.getInstance().isGameFocused())
{
Minecraft.getInstance().displayGuiScreen(null);
Minecraft.getInstance().mouseHelper.grabMouse();
}
Minecraft.getInstance().displayGuiScreen(null);
Minecraft.getInstance().mouseHelper.grabMouse();
TextComponentString name = new TextComponentString(Main.NAME);
StringTextComponent name = new StringTextComponent(Main.NAME);
name.setStyle(new Style().setUnderlined(true).setClickEvent(new ClickEvent(Action.OPEN_URL, Main.URL)));
TextComponentTranslation message = new TextComponentTranslation("worldhandler.error.gui", name);
TranslationTextComponent message = new TranslationTextComponent("worldhandler.error.gui", name);
message.setStyle(new Style().setColor(net.minecraft.util.text.TextFormatting.RED));
Minecraft.getInstance().ingameGUI.addChatMessage(ChatType.SYSTEM, message);
Minecraft.getInstance().field_71456_v.addChatMessage(ChatType.SYSTEM, message);
WorldHandler.LOGGER.throwing(e);
}
}
@@ -155,18 +155,18 @@ public class ActionHelper
{
if(!CommandHelper.canPlayerIssueCommand() && Config.getSettings().permissionQuery())
{
Minecraft.getInstance().ingameGUI.addChatMessage(ChatType.SYSTEM, new TextComponentString(ChatFormatting.RED + I18n.format("worldhandler.permission.refused")));
Minecraft.getInstance().ingameGUI.addChatMessage(ChatType.SYSTEM, new TextComponentString(ChatFormatting.RED + I18n.format("worldhandler.permission.refused.change", I18n.format("gui.worldhandler.config.key.settings.permission_query"))));
Minecraft.getInstance().field_71456_v.addChatMessage(ChatType.SYSTEM, new StringTextComponent(TextFormatting.RED + I18n.format("worldhandler.permission.refused")));
Minecraft.getInstance().field_71456_v.addChatMessage(ChatType.SYSTEM, new StringTextComponent(TextFormatting.RED + I18n.format("worldhandler.permission.refused.change", I18n.format("gui.worldhandler.config.key.settings.permission_query"))));
}
else
{
ActionHelper.tryRun(() ->
{
if(BlockHelper.isFocusedBlockEqualTo(Blocks.SIGN) || BlockHelper.isFocusedBlockEqualTo(Blocks.WALL_SIGN))
if(BlockHelper.getFocusedBlock() instanceof AbstractSignBlock)
{
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.SIGN_EDITOR));
}
else if(BlockHelper.isFocusedBlockEqualTo(Blocks.NOTE_BLOCK))
else if(BlockHelper.getFocusedBlock() instanceof NoteBlock)
{
Minecraft.getInstance().displayGuiScreen(new GuiWorldHandler(Contents.NOTE_EDITOR));
}

View File

@@ -18,49 +18,52 @@ import exopandora.worldhandler.builder.types.CoordinateDouble;
import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.config.Config;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityType;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.play.client.CPacketUpdateCommandBlock;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.DoubleNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.network.play.client.CUpdateCommandBlockPacket;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntityCommandBlock;
import net.minecraft.util.EnumFacing;
import net.minecraft.tileentity.CommandBlockTileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.RayTraceResult.Type;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BlockHelper
{
private static BlockPos POS_1 = BlockPos.ORIGIN;
private static BlockPos POS_2 = BlockPos.ORIGIN;
private static BlockPos POS_1 = BlockPos.ZERO;
private static BlockPos POS_2 = BlockPos.ZERO;
private static final List<Consumer<BlockPos>> POS_1_OBSERVERS = new ArrayList<Consumer<BlockPos>>();
private static final List<Consumer<BlockPos>> POS_2_OBSERVERS = new ArrayList<Consumer<BlockPos>>();
private static final Block[] BLACKLIST = new Block[] {Blocks.AIR, Blocks.WATER, Blocks.LAVA};
public static BlockPos getFocusedBlockPos()
{
RayTraceResult rayTrace = Minecraft.getInstance().objectMouseOver;
RayTraceResult result = Minecraft.getInstance().objectMouseOver;
if(rayTrace != null && rayTrace.type.equals(RayTraceResult.Type.BLOCK))
if(result != null && result.getType().equals(Type.BLOCK))
{
BlockPos position = rayTrace.getBlockPos();
BlockRayTraceResult blockResult = (BlockRayTraceResult) result;
if(!ArrayUtils.contains(BLACKLIST, Minecraft.getInstance().world.getBlockState(position).getBlock()))
if(!ArrayUtils.contains(BLACKLIST, Minecraft.getInstance().world.getBlockState(blockResult.getPos()).getBlock()))
{
return position;
return blockResult.getPos();
}
}
return Minecraft.getInstance().player.getPosition();
}
public static boolean isFocusedBlockEqualTo(Block block)
public static Block getFocusedBlock()
{
return getBlock(getFocusedBlockPos()) == block;
return Minecraft.getInstance().world.getBlockState(getFocusedBlockPos()).getBlock();
}
public static Block getBlock(BlockPos pos)
@@ -148,19 +151,19 @@ public class BlockHelper
POS_2_OBSERVERS.add(observer);
}
private static NBTTagCompound newCommandBlock(String command)
private static CompoundNBT newCommandBlock(String command)
{
NBTTagCompound blockState = new NBTTagCompound();
blockState.setString("Name", Blocks.COMMAND_BLOCK.getRegistryName().toString());
CompoundNBT blockState = new CompoundNBT();
blockState.putString("Name", Blocks.COMMAND_BLOCK.getRegistryName().toString());
NBTTagCompound tileEntityData = new NBTTagCompound();
tileEntityData.setString("Command", command);
tileEntityData.setBoolean("auto", true);
CompoundNBT tileEntityData = new CompoundNBT();
tileEntityData.putString("Command", command);
tileEntityData.putBoolean("auto", true);
NBTTagCompound commandBlock = new NBTTagCompound();
commandBlock.setInt("Time", 1);
commandBlock.setTag("BlockState", blockState);
commandBlock.setTag("TileEntityData", tileEntityData);
CompoundNBT commandBlock = new CompoundNBT();
commandBlock.putInt("Time", 1);
commandBlock.put("BlockState", blockState);
commandBlock.put("TileEntityData", tileEntityData);
return commandBlock;
}
@@ -178,28 +181,34 @@ public class BlockHelper
fill.setZ2(new CoordinateInt(0, CoordinateType.GLOBAL));
fill.setBlock1(new BlockResourceLocation(Blocks.AIR.getRegistryName()));
NBTTagCompound block = newCommandBlock(fill.toActualCommand());
block.setString("id", "falling_block");
CompoundNBT executer = newCommandBlock(command);
executer.putString("id", "falling_block");
NBTTagList passengers = new NBTTagList();
passengers.add(block);
ListNBT passengers = new ListNBT();
passengers.add(executer);
NBTTagCompound nbt = newCommandBlock(command);
nbt.setTag("Passengers", passengers);
CompoundNBT remover = newCommandBlock(fill.toActualCommand());
remover.put("Passengers", passengers);
ListNBT motion = new ListNBT();
motion.add(new DoubleNBT(0.0D));
motion.add(new DoubleNBT(0.315D));
motion.add(new DoubleNBT(0.0D));
remover.put("Motion", motion);
Minecraft.getInstance().displayGuiScreen(null);
Minecraft.getInstance().mouseHelper.grabMouse();
BuilderSummon summon = new BuilderSummon();
summon.setEntity(EntityType.FALLING_BLOCK.getRegistryName().toString());
summon.setX(new CoordinateDouble(0.0, CoordinateType.LOCAL));
summon.setY(new CoordinateDouble(0.54, CoordinateType.LOCAL));
summon.setZ(new CoordinateDouble(0.0, CoordinateType.LOCAL));
summon.setNBT(nbt);
summon.setX(new CoordinateDouble(0.0, CoordinateType.GLOBAL));
summon.setY(new CoordinateDouble(0.5, CoordinateType.GLOBAL));
summon.setZ(new CoordinateDouble(0.0, CoordinateType.GLOBAL));
summon.setNBT(remover);
BlockPos pos = Minecraft.getInstance().player.getPosition().add(0, 3, 0);
Minecraft.getInstance().player.sendChatMessage(new BuilderSetBlock(pos, Blocks.COMMAND_BLOCK.getRegistryName(), Config.CLIENT.getSettings().getBlockPlacingMode()).toActualCommand());
Minecraft.getInstance().getConnection().sendPacket(new CPacketUpdateCommandBlock(pos, summon.toActualCommand(false), TileEntityCommandBlock.Mode.REDSTONE, true, false, true));
Minecraft.getInstance().getConnection().sendPacket(new CUpdateCommandBlockPacket(pos, summon.toActualCommand(false), CommandBlockTileEntity.Mode.REDSTONE, true, false, true));
return true;
}
@@ -212,16 +221,16 @@ public class BlockHelper
switch(Minecraft.getInstance().player.getHorizontalFacing())
{
case NORTH:
CommandHelper.sendCommand(new BuilderSetBlock(new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(2, CoordinateType.LOCAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()).withState(BlockStateProperties.HORIZONTAL_FACING, EnumFacing.SOUTH));
CommandHelper.sendCommand(new BuilderSetBlock(new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(2, CoordinateType.LOCAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()).withState(BlockStateProperties.HORIZONTAL_FACING, Direction.SOUTH));
break;
case EAST:
CommandHelper.sendCommand(new BuilderSetBlock(new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(2, CoordinateType.LOCAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()).withState(BlockStateProperties.HORIZONTAL_FACING, EnumFacing.WEST));
CommandHelper.sendCommand(new BuilderSetBlock(new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(2, CoordinateType.LOCAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()).withState(BlockStateProperties.HORIZONTAL_FACING, Direction.WEST));
break;
case SOUTH:
CommandHelper.sendCommand(new BuilderSetBlock(new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(2, CoordinateType.LOCAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()).withState(BlockStateProperties.HORIZONTAL_FACING, EnumFacing.NORTH));
CommandHelper.sendCommand(new BuilderSetBlock(new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(2, CoordinateType.LOCAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()).withState(BlockStateProperties.HORIZONTAL_FACING, Direction.NORTH));
break;
case WEST:
CommandHelper.sendCommand(new BuilderSetBlock(new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(2, CoordinateType.LOCAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()).withState(BlockStateProperties.HORIZONTAL_FACING, EnumFacing.EAST));
CommandHelper.sendCommand(new BuilderSetBlock(new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(CoordinateType.LOCAL), new CoordinateInt(2, CoordinateType.LOCAL), block.getRegistryName(), Config.getSettings().getBlockPlacingMode()).withState(BlockStateProperties.HORIZONTAL_FACING, Direction.EAST));
break;
default:
break;

View File

@@ -9,7 +9,7 @@ import exopandora.worldhandler.command.CommandWH;
import exopandora.worldhandler.command.CommandWorldHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandSource;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -18,7 +18,7 @@ public class CommandHelper
{
public static void sendFeedback(CommandSource source, String message)
{
source.sendFeedback(new TextComponentString(message), false);
source.sendFeedback(new StringTextComponent(message), false);
}
public static boolean canPlayerIssueCommand()

View File

@@ -10,9 +10,9 @@ import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.potion.Potion;
import net.minecraft.potion.Effect;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.IRegistry;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -24,17 +24,17 @@ import net.minecraftforge.registries.IForgeRegistry;
public class RegistryTranslator
{
private static final Map<IForgeRegistry<?>, Function<?, String>> FORGE = new HashMap<IForgeRegistry<?>, Function<?, String>>();
private static final Map<IRegistry<?>, Function<?, String>> VANILLA = new HashMap<IRegistry<?>, Function<?, String>>();
private static final Map<Registry<?>, Function<?, String>> VANILLA = new HashMap<Registry<?>, Function<?, String>>();
static
{
register(ForgeRegistries.BLOCKS, Block::getTranslationKey);
register(ForgeRegistries.ITEMS, Item::getTranslationKey);
register(ForgeRegistries.POTIONS, Potion::getName);
register(ForgeRegistries.POTIONS, Effect::getName);
register(ForgeRegistries.BIOMES, Biome::getTranslationKey);
register(ForgeRegistries.ENCHANTMENTS, Enchantment::getName);
register(ForgeRegistries.ENTITIES, EntityType::getTranslationKey);
register(IRegistry.field_212623_l, stat -> "stat." + stat.toString().replace(':', '.'));
register(Registry.field_212623_l, stat -> "stat." + stat.toString().replace(':', '.'));
}
private static <T extends ForgeRegistryEntry<T>> void register(IForgeRegistry<T> registry, Function<T, String> mapper)
@@ -42,7 +42,7 @@ public class RegistryTranslator
FORGE.put(registry, mapper);
}
private static <T> void register(IRegistry<T> registry, Function<T, String> mapper)
private static <T> void register(Registry<T> registry, Function<T, String> mapper)
{
VANILLA.put(registry, mapper);
}
@@ -59,11 +59,11 @@ public class RegistryTranslator
}
}
for(IRegistry<?> registry : VANILLA.keySet())
for(Registry<?> registry : VANILLA.keySet())
{
if(registry.func_212607_c(resource))
if(registry.containsKey(resource))
{
return ((Function<T, String>) VANILLA.get(registry)).apply((T) registry.func_212608_b(resource));
return ((Function<T, String>) VANILLA.get(registry)).apply((T) registry.getOrDefault(resource));
}
}

View File

@@ -6,17 +6,17 @@ import java.util.function.Function;
import java.util.function.Predicate;
import com.google.common.base.Predicates;
import com.mojang.realmsclient.gui.ChatFormatting;
import net.minecraft.scoreboard.ScoreCriteria;
import net.minecraft.scoreboard.Team.CollisionRule;
import net.minecraft.scoreboard.Team.EnumVisible;
import net.minecraft.stats.StatList;
import net.minecraft.scoreboard.Team.Visible;
import net.minecraft.stats.StatType;
import net.minecraft.stats.Stats;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.IRegistry;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@OnlyIn(Dist.CLIENT)
public class ScoreboardHelper
@@ -33,9 +33,8 @@ public class ScoreboardHelper
private void init()
{
//Lists
final List<Node> colors = this.createList(ChatFormatting.values(), ChatFormatting::getName, ChatFormatting::isColor);
final List<Node> visibility = this.createList(EnumVisible.values(), value -> value.internalName);
final List<Node> colors = this.createList(TextFormatting.values(), TextFormatting::getFriendlyName, TextFormatting::isColor);
final List<Node> visibility = this.createList(Visible.values(), value -> value.internalName);
final List<Node> collision = this.createList(CollisionRule.values(), value -> value.name);
final List<Node> bool = this.createList(new Boolean[] {true, false}, String::valueOf);
@@ -48,18 +47,18 @@ public class ScoreboardHelper
this.objectives.merge("minecraft", (parent, child) -> parent + "." + child);
for(StatType<?> type : IRegistry.field_212634_w)
for(StatType<?> type : ForgeRegistries.STAT_TYPES)
{
if(!type.equals(StatList.CUSTOM))
if(!type.equals(Stats.CUSTOM))
{
List<Node> entries = new ArrayList<Node>();
for(ResourceLocation key : type.getRegistry().getKeys())
for(ResourceLocation key : type.getRegistry().keySet())
{
entries.add(new Node(this.buildKey(key)));
}
this.objectives.addNode(this.buildKey(IRegistry.field_212634_w.getKey(type)), entries);
this.objectives.addNode(this.buildKey(ForgeRegistries.STAT_TYPES.getKey(type)), entries);
}
}

View File

@@ -1,18 +1,19 @@
package exopandora.worldhandler.util;
import com.mojang.blaze3d.platform.GlStateManager;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.format.TextFormatting;
import exopandora.worldhandler.helper.ResourceHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.gui.screen.Screen;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class UtilRender
{
public static void drawWatchIntoGui(Gui gui, int width, int height, long worldTicks, boolean smooth)
public static void drawWatchIntoGui(Screen gui, int width, int height, long worldTicks, boolean smooth)
{
float hour = TextFormatting.getHour(worldTicks);
float minute = TextFormatting.getMinute(worldTicks);
@@ -31,11 +32,11 @@ public class UtilRender
GlStateManager.scalef(0.25F, 0.25F, 0.25F);
GlStateManager.rotatef(rotationHour, 0F, 0F, 1F);
Gui.drawRect(-1, -1, 1, 11, 0xFF383838);
Screen.fill(-1, -1, 1, 11, 0xFF383838);
GlStateManager.rotatef(-rotationHour, 0F, 0F, 1F);
GlStateManager.rotatef(rotationMinute, 0F, 0F, 1F);
Gui.drawRect(-1, -1, 1, 15, 0xFF6F6F6F);
Screen.fill(-1, -1, 1, 15, 0xFF6F6F6F);
GlStateManager.rotatef(-rotationMinute, 0F, 0F, 1F);
GlStateManager.color3f(1.0F, 1.0F, 1.0F);
@@ -44,11 +45,11 @@ public class UtilRender
GlStateManager.color3f(Config.getSkin().getButtonRedF(), Config.getSkin().getButtonGreenF(), Config.getSkin().getButtonBlueF());
Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.getIconTexture());
gui.drawTexturedModalRect(width + 0, height, 48, 0, 10, 10);
gui.blit(width + 0, height, 48, 0, 10, 10);
GlStateManager.pushMatrix();
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
Gui.drawRect((width + 5) * 2 - 1, (height + 4) * 2 + 1, (width + 6) * 2 - 1, (height + 5) * 2 + 1, 0xFF000000);
Screen.fill((width + 5) * 2 - 1, (height + 4) * 2 + 1, (width + 6) * 2 - 1, (height + 5) * 2 + 1, 0xFF000000);
GlStateManager.popMatrix();
}
}