Treat null as a default value

This commit is contained in:
Marcel Konrad
2020-05-24 20:03:36 +02:00
parent 1acdaa34b6
commit b2cbc6afb7
3 changed files with 4 additions and 28 deletions

View File

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

View File

@@ -70,7 +70,7 @@ public class BlockResourceLocation extends ItemResourceLocation
return this.state; return this.state;
} }
public <T extends Comparable<T>> void withState(IProperty<T> property, T value) public <T extends Comparable<T>> void setProperty(IProperty<T> property, T value)
{ {
if(this.state != null && this.state.has(property)) if(this.state != null && this.state.has(property))
{ {
@@ -105,12 +105,6 @@ public class BlockResourceLocation extends ItemResourceLocation
return null; return null;
} }
@Override
public BlockResourceLocation get()
{
return (BlockResourceLocation) super.get();
}
@Override @Override
public String toString() public String toString()
{ {

View File

@@ -52,16 +52,6 @@ public class ItemResourceLocation
this.nbt = nbt; this.nbt = nbt;
} }
public ItemResourceLocation get()
{
if(this.resource != null)
{
return this;
}
return null;
}
@Nullable @Nullable
public static ItemResourceLocation valueOf(String input) public static ItemResourceLocation valueOf(String input)
{ {