Readd NoneTarget
This commit is contained in:
parent
6ee9d025fb
commit
04d67ec4eb
5 changed files with 49 additions and 4 deletions
|
@ -10,6 +10,7 @@ import org.dimdev.dimdoors.item.ModItems;
|
|||
import org.dimdev.dimdoors.pockets.SchematicHandler;
|
||||
import org.dimdev.dimdoors.pockets.SchematicV2Handler;
|
||||
import org.dimdev.dimdoors.rift.targets.Targets;
|
||||
import org.dimdev.dimdoors.rift.targets.VirtualTarget;
|
||||
import org.dimdev.dimdoors.sound.ModSoundEvents;
|
||||
import org.dimdev.dimdoors.util.schematic.v2.SchematicTest;
|
||||
import org.dimdev.dimdoors.world.ModBiomes;
|
||||
|
@ -70,6 +71,7 @@ public class DimensionalDoorsInitializer implements ModInitializer {
|
|||
ModConfig.deserialize();
|
||||
|
||||
Targets.registerDefaultTargets();
|
||||
VirtualTarget.VirtualTargetType.register();
|
||||
|
||||
SchematicV2Handler.getInstance().load();
|
||||
SchematicHandler.INSTANCE.loadSchematics();
|
||||
|
|
|
@ -76,8 +76,8 @@ public class PocketEntranceMarker extends VirtualTarget implements EntityTarget
|
|||
|
||||
public static class PocketEntranceMarkerBuilder {
|
||||
private float weight;
|
||||
private VirtualTarget ifDestination;
|
||||
private VirtualTarget otherwiseDestination;
|
||||
private VirtualTarget ifDestination = NoneTarget.INSTANCE;
|
||||
private VirtualTarget otherwiseDestination = NoneTarget.INSTANCE;
|
||||
|
||||
PocketEntranceMarkerBuilder() {
|
||||
}
|
||||
|
|
|
@ -30,7 +30,8 @@ public abstract class VirtualTarget implements Target {
|
|||
}
|
||||
|
||||
public static CompoundTag toTag(VirtualTarget virtualTarget) {
|
||||
String type = REGISTRY.getId(virtualTarget.getType()).toString();
|
||||
Identifier id = REGISTRY.getId(virtualTarget.getType());
|
||||
String type = id.toString();
|
||||
|
||||
CompoundTag tag = virtualTarget.getType().toTag(virtualTarget);
|
||||
tag.putString("type", type);
|
||||
|
@ -87,6 +88,7 @@ public abstract class VirtualTarget implements Target {
|
|||
VirtualTargetType<PrivatePocketTarget> PRIVATE = register("dimdoors:private", a -> new PrivatePocketTarget(), a -> new CompoundTag(), PrivatePocketExitTarget.COLOR);
|
||||
VirtualTargetType<PrivatePocketExitTarget> PRIVATE_POCKET_EXIT = register("dimdoors:private_pocket_exit", a -> new PrivatePocketExitTarget(), a -> new CompoundTag(), PrivatePocketExitTarget.COLOR);
|
||||
VirtualTargetType<RelativeReference> RELATIVE = register("dimdoors:relative", RelativeReference::fromTag, RelativeReference::toTag, VirtualTarget.COLOR);
|
||||
VirtualTargetType<NoneTarget> NONE = register("dimdoors:none", tag -> NoneTarget.INSTANCE, i -> new CompoundTag(), COLOR);
|
||||
|
||||
T fromTag(CompoundTag tag);
|
||||
|
||||
|
@ -94,6 +96,9 @@ public abstract class VirtualTarget implements Target {
|
|||
|
||||
RGBA getColor();
|
||||
|
||||
static void register() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static <T extends VirtualTarget> VirtualTargetType<T> register(String id, Function<CompoundTag, T> fromTag, Function<T, CompoundTag> toTag, RGBA color) {
|
||||
return Registry.register(REGISTRY, (String) id, new VirtualTargetType<T>() {
|
||||
|
@ -115,4 +120,30 @@ public abstract class VirtualTarget implements Target {
|
|||
}
|
||||
}
|
||||
|
||||
public static class NoneTarget extends VirtualTarget {
|
||||
public static final NoneTarget INSTANCE = new NoneTarget();
|
||||
|
||||
private NoneTarget() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualTargetType<? extends VirtualTarget> getType() {
|
||||
return VirtualTargetType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o == INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return System.identityHashCode(INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[none]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,13 @@ import org.jetbrains.annotations.NotNull;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public final class RGBA implements Cloneable, Comparable<RGBA>, Iterable<Float> {
|
||||
public static Codec<RGBA> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||
public static final Codec<RGBA> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||
Codec.FLOAT.fieldOf("red").forGetter(RGBA::getRed),
|
||||
Codec.FLOAT.fieldOf("green").forGetter(RGBA::getGreen),
|
||||
Codec.FLOAT.fieldOf("blue").forGetter(RGBA::getBlue),
|
||||
Codec.FLOAT.fieldOf("alpha").forGetter(RGBA::getAlpha)
|
||||
).apply(instance, RGBA::new));
|
||||
public static final RGBA NONE = new RGBA(0, 0, 0, 0);
|
||||
|
||||
private final float red;
|
||||
private final float green;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.dimdev.dimdoors.world.pocket;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
||||
|
@ -108,4 +109,14 @@ public class VirtualLocation {
|
|||
public int getDepth() {
|
||||
return this.depth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("world", this.world)
|
||||
.add("x", this.x)
|
||||
.add("z", this.z)
|
||||
.add("depth", this.depth)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue