Replace deprecated ColoredString with MutableStringTextComponent
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import exopandora.worldhandler.format.text.ColoredString;
|
||||
import exopandora.worldhandler.text.MutableStringTextComponent;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
@@ -14,7 +14,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ComponentDisplay implements IBuilderComponent
|
||||
{
|
||||
private ColoredString name = new ColoredString();
|
||||
private MutableStringTextComponent name = new MutableStringTextComponent();
|
||||
private String[] lore = new String[2];
|
||||
|
||||
@Override
|
||||
@@ -22,9 +22,7 @@ public class ComponentDisplay implements IBuilderComponent
|
||||
{
|
||||
CompoundNBT display = new CompoundNBT();
|
||||
|
||||
String name = this.name.getText();
|
||||
|
||||
if(name != null && !name.isEmpty())
|
||||
if(this.name.getText() != null && !this.name.getText().isEmpty())
|
||||
{
|
||||
display.putString("Name", ITextComponent.Serializer.toJson(new StringTextComponent(this.name.toString())));
|
||||
}
|
||||
@@ -52,12 +50,12 @@ public class ComponentDisplay implements IBuilderComponent
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setName(ColoredString name)
|
||||
public void setName(MutableStringTextComponent name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ColoredString getName()
|
||||
public MutableStringTextComponent getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import exopandora.worldhandler.builder.component.impl.ComponentDisplay;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentEnchantment;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes.Applyable;
|
||||
import exopandora.worldhandler.format.text.ColoredString;
|
||||
import exopandora.worldhandler.text.MutableStringTextComponent;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -68,12 +68,12 @@ public class BuilderCustomItem extends BuilderGive
|
||||
return this.attribute.getAttributes();
|
||||
}
|
||||
|
||||
public void setName(ColoredString name)
|
||||
public void setName(MutableStringTextComponent name)
|
||||
{
|
||||
this.display.setName(name);
|
||||
}
|
||||
|
||||
public ColoredString getName()
|
||||
public MutableStringTextComponent getName()
|
||||
{
|
||||
return this.display.getName();
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package exopandora.worldhandler.builder.impl;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentTag;
|
||||
import exopandora.worldhandler.format.text.ColoredString;
|
||||
import exopandora.worldhandler.format.text.SignText;
|
||||
import exopandora.worldhandler.text.MutableStringTextComponent;
|
||||
import exopandora.worldhandler.text.SignText;
|
||||
import net.minecraft.nbt.StringNBT;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -40,16 +40,16 @@ public class BuilderSignEditor extends BuilderData
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ColoredString getColoredString(int line)
|
||||
public MutableStringTextComponent getColoredString(int line)
|
||||
{
|
||||
if(this.checkBounds(line))
|
||||
{
|
||||
return this.sign[line].getValue().getColoredString();
|
||||
return this.sign[line].getValue().getString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public String getCommand(int line)
|
||||
{
|
||||
@@ -60,7 +60,7 @@ public class BuilderSignEditor extends BuilderData
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public void setCommand(int line, String command)
|
||||
{
|
||||
|
||||
@@ -15,9 +15,9 @@ import exopandora.worldhandler.builder.component.impl.ComponentTag;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes.Applyable;
|
||||
import exopandora.worldhandler.builder.types.Coordinate.CoordinateType;
|
||||
import exopandora.worldhandler.text.MutableStringTextComponent;
|
||||
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.block.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -27,8 +27,6 @@ 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.StringTextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@@ -36,7 +34,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
public class BuilderSummon extends CommandBuilderNBT
|
||||
{
|
||||
private final ComponentAttributeMob attribute;
|
||||
private final ComponentTag<ColoredString> customName;
|
||||
private final ComponentTag<MutableStringTextComponent> customName;
|
||||
private final ComponentTag<ListNBT> passengers;
|
||||
private final ComponentTag<ListNBT> armorItems;
|
||||
private final ComponentTag<ListNBT> handItems;
|
||||
@@ -48,7 +46,7 @@ public class BuilderSummon extends CommandBuilderNBT
|
||||
public BuilderSummon()
|
||||
{
|
||||
this.attribute = this.registerNBTComponent(new ComponentAttributeMob(attribute -> attribute.getApplyable().equals(Applyable.BOTH) || attribute.getApplyable().equals(Applyable.MOB)));
|
||||
this.customName = this.registerNBTComponent(new ComponentTag<ColoredString>("CustomName", new ColoredString(), this::colorStringSerializer));
|
||||
this.customName = this.registerNBTComponent(new ComponentTag<MutableStringTextComponent>("CustomName", new MutableStringTextComponent(), this::textComponentSerializer));
|
||||
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));
|
||||
@@ -124,7 +122,7 @@ public class BuilderSummon extends CommandBuilderNBT
|
||||
return this.attribute.getAttributes();
|
||||
}
|
||||
|
||||
public void setCustomName(ColoredString name)
|
||||
public void setCustomName(MutableStringTextComponent name)
|
||||
{
|
||||
this.customName.setValue(name);
|
||||
}
|
||||
@@ -135,7 +133,7 @@ public class BuilderSummon extends CommandBuilderNBT
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ColoredString getCustomName()
|
||||
public MutableStringTextComponent getCustomName()
|
||||
{
|
||||
if(this.customName.getValue() != null)
|
||||
{
|
||||
@@ -348,11 +346,11 @@ public class BuilderSummon extends CommandBuilderNBT
|
||||
return null;
|
||||
}
|
||||
|
||||
private INBT colorStringSerializer(ColoredString string)
|
||||
private INBT textComponentSerializer(MutableStringTextComponent string)
|
||||
{
|
||||
if(string.getText() != null && !string.getText().isEmpty())
|
||||
if(string.getUnformattedComponentText() != null && !string.getUnformattedComponentText().isEmpty())
|
||||
{
|
||||
return new StringNBT(ITextComponent.Serializer.toJson(new StringTextComponent(string.toString())));
|
||||
return new StringNBT(string.serialize());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user