custom events backend, and entity attribute query.
This commit is contained in:
1 parent
40869ef9bf
commit
f2721ab87a
4 files changed
+78
No files matched your search
@@ -34,6 +34,7 @@ import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ColumnPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
@@ -396,4 +397,26 @@ public class ValueConversions
|
||||
predicateData.getCMDataTag() == null?Value.NULL:new NBTSerializableValue(predicateData.getCMDataTag())
|
||||
);
|
||||
}
|
||||
|
||||
public static Value guess(ServerWorld serverWorld, Object o) {
|
||||
if (o instanceof List)
|
||||
return ListValue.wrap(((List<?>) o).stream().map(oo -> guess(serverWorld, oo)).collect(Collectors.toList()));
|
||||
if (o instanceof BlockPos)
|
||||
return new BlockValue(null, serverWorld, (BlockPos)o);
|
||||
if (o instanceof Entity)
|
||||
return EntityValue.of((Entity) o);
|
||||
if (o instanceof Vec3d)
|
||||
return of((Vec3d)o);
|
||||
if (o instanceof Vec3i)
|
||||
return of(new BlockPos((Vec3i)o));
|
||||
if (o instanceof ItemStack)
|
||||
return of((ItemStack)o);
|
||||
if (o instanceof Boolean)
|
||||
return BooleanValue.of((Boolean) o);
|
||||
if (o instanceof Number)
|
||||
return NumericValue.of((Number) o);
|
||||
if (o instanceof Identifier)
|
||||
return of((Identifier)o);
|
||||
return StringValue.of(o.toString());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user