Move code to libzontreck, test fixes to heal
This commit is contained in:
parent
91eb2a2e43
commit
6d3fa0375d
20 changed files with 35 additions and 357 deletions
|
@ -3,9 +3,9 @@
|
||||||
org.gradle.jvmargs=-Xmx8G
|
org.gradle.jvmargs=-Xmx8G
|
||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
|
|
||||||
my_version=1.3.4.2
|
my_version=1.3.4.3
|
||||||
|
|
||||||
mc_version=1.19.2
|
mc_version=1.19.2
|
||||||
forge_version=43.1.32
|
forge_version=43.1.32
|
||||||
jei_version=11.3.0.262
|
jei_version=11.3.0.262
|
||||||
libz_version=1.0.0.2
|
libz_version=1.0.1.0
|
|
@ -3,9 +3,9 @@ package dev.zontreck.otemod.antigrief;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||||
import dev.zontreck.otemod.OTEMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||||
import dev.zontreck.otemod.containers.Vector3;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
|
@ -20,12 +20,14 @@ public class HealerManager implements Runnable
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void run(){
|
public void run(){
|
||||||
|
boolean skipWait=false;
|
||||||
while(OTEMod.ALIVE)
|
while(OTEMod.ALIVE)
|
||||||
{
|
{
|
||||||
// Run the queue
|
// Run the queue
|
||||||
// We want to restore one block per run, then halt for number of seconds in config
|
// We want to restore one block per run, then halt for number of seconds in config
|
||||||
try {
|
try {
|
||||||
Thread.sleep(OTEServerConfig.HEALER_TIMER.get());
|
if(!skipWait)
|
||||||
|
Thread.sleep(OTEServerConfig.HEALER_TIMER.get());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -78,6 +80,13 @@ public class HealerManager implements Runnable
|
||||||
|
|
||||||
// Healer object should have been added to the validation list
|
// Healer object should have been added to the validation list
|
||||||
|
|
||||||
|
|
||||||
|
// Check if the block to restore, and the block at the location are identical
|
||||||
|
if(level.getBlockState(sb.getPos()).is(sb.getState().getBlock())){
|
||||||
|
skipWait=true;
|
||||||
|
continue; // Skip the wait, and this block
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
level.getServer().execute(new Runnable(){
|
level.getServer().execute(new Runnable(){
|
||||||
public void run()
|
public void run()
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package dev.zontreck.otemod.antigrief;
|
package dev.zontreck.otemod.antigrief;
|
||||||
|
|
||||||
import dev.zontreck.otemod.containers.Vector3;
|
import dev.zontreck.libzontreck.exceptions.InvalidDeserialization;
|
||||||
import dev.zontreck.otemod.containers.WorldPosition;
|
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||||
import dev.zontreck.otemod.exceptions.InvalidDeserialization;
|
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NbtUtils;
|
import net.minecraft.nbt.NbtUtils;
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class ModBlocks {
|
||||||
public static final RegistryObject<Item> AURORA_DOOR_I = ITEMS.register("aurora_door", () -> new BlockItem(AURORA_DOOR.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
|
public static final RegistryObject<Item> AURORA_DOOR_I = ITEMS.register("aurora_door", () -> new BlockItem(AURORA_DOOR.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
|
||||||
|
|
||||||
|
|
||||||
public static final RegistryObject<Block> CLEAR_GLASS_BLOCK = BLOCKS.register("clear_glass_block", () -> new Block(BlockBehaviour.Properties.copy(Blocks.GLASS).requiresCorrectToolForDrops().strength(1f).destroyTime(6)));
|
public static final RegistryObject<Block> CLEAR_GLASS_BLOCK = BLOCKS.register("clear_glass_block", () -> new Block(BlockBehaviour.Properties.copy(Blocks.GLASS).strength(1f).destroyTime(6)));
|
||||||
|
|
||||||
public static final RegistryObject<Item> CLEAR_GLASS_BLOCK_I = ITEMS.register("clear_glass_block", () -> new BlockItem(CLEAR_GLASS_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
|
public static final RegistryObject<Item> CLEAR_GLASS_BLOCK_I = ITEMS.register("clear_glass_block", () -> new BlockItem(CLEAR_GLASS_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,12 @@ import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
|
import dev.zontreck.libzontreck.exceptions.InvalidDeserialization;
|
||||||
import dev.zontreck.otemod.OTEMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||||
import dev.zontreck.otemod.commands.teleport.TeleportActioner;
|
import dev.zontreck.otemod.commands.teleport.TeleportActioner;
|
||||||
import dev.zontreck.otemod.commands.teleport.TeleportContainer;
|
import dev.zontreck.otemod.commands.teleport.TeleportContainer;
|
||||||
import dev.zontreck.otemod.database.TeleportDestination;
|
import dev.zontreck.otemod.database.TeleportDestination;
|
||||||
import dev.zontreck.otemod.exceptions.InvalidDeserialization;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.nbt.NbtUtils;
|
import net.minecraft.nbt.NbtUtils;
|
||||||
|
|
|
@ -8,10 +8,10 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
|
import dev.zontreck.libzontreck.vectors.Vector2;
|
||||||
|
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||||
import dev.zontreck.otemod.OTEMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||||
import dev.zontreck.otemod.containers.Vector2;
|
|
||||||
import dev.zontreck.otemod.containers.Vector3;
|
|
||||||
import dev.zontreck.otemod.database.TeleportDestination;
|
import dev.zontreck.otemod.database.TeleportDestination;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
|
|
|
@ -10,9 +10,9 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.arguments.BoolArgumentType;
|
import com.mojang.brigadier.arguments.BoolArgumentType;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
|
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||||
import dev.zontreck.otemod.OTEMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||||
import dev.zontreck.otemod.containers.Vector3;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
|
@ -32,5 +32,7 @@ public class TeleportRunnable implements Runnable
|
||||||
c.Assert(Action.PlayerInst);
|
c.Assert(Action.PlayerInst);
|
||||||
|
|
||||||
Action.PlayerInst.setPos(Action.Position);
|
Action.PlayerInst.setPos(Action.Position);
|
||||||
|
|
||||||
|
Action.PlayerInst.giveExperiencePoints(1); // Attempt to fix experience point bug
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
|
import dev.zontreck.libzontreck.vectors.Vector2;
|
||||||
|
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||||
import dev.zontreck.otemod.OTEMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||||
import dev.zontreck.otemod.containers.Vector2;
|
|
||||||
import dev.zontreck.otemod.containers.Vector3;
|
|
||||||
import dev.zontreck.otemod.database.TeleportDestination;
|
import dev.zontreck.otemod.database.TeleportDestination;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
|
|
|
@ -8,10 +8,10 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
|
import dev.zontreck.libzontreck.vectors.Vector2;
|
||||||
|
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||||
import dev.zontreck.otemod.OTEMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||||
import dev.zontreck.otemod.containers.Vector2;
|
|
||||||
import dev.zontreck.otemod.containers.Vector3;
|
|
||||||
import dev.zontreck.otemod.database.TeleportDestination;
|
import dev.zontreck.otemod.database.TeleportDestination;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
|
|
|
@ -8,10 +8,10 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
|
import dev.zontreck.libzontreck.vectors.Vector2;
|
||||||
|
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||||
import dev.zontreck.otemod.OTEMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||||
import dev.zontreck.otemod.containers.Vector2;
|
|
||||||
import dev.zontreck.otemod.containers.Vector3;
|
|
||||||
import dev.zontreck.otemod.database.TeleportDestination;
|
import dev.zontreck.otemod.database.TeleportDestination;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
|
|
|
@ -13,8 +13,6 @@ import dev.zontreck.libzontreck.chat.HoverTip;
|
||||||
import dev.zontreck.otemod.OTEMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||||
import dev.zontreck.otemod.configs.Profile;
|
import dev.zontreck.otemod.configs.Profile;
|
||||||
import dev.zontreck.otemod.containers.Vector2;
|
|
||||||
import dev.zontreck.otemod.containers.Vector3;
|
|
||||||
import dev.zontreck.otemod.database.TeleportDestination;
|
import dev.zontreck.otemod.database.TeleportDestination;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
package dev.zontreck.otemod.containers;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is a non-serializable instanced Vector that is meant to slam positions down as a integer
|
|
||||||
*/
|
|
||||||
public class NonAbsVector3
|
|
||||||
{
|
|
||||||
public long x;
|
|
||||||
public long y;
|
|
||||||
public long z;
|
|
||||||
|
|
||||||
public NonAbsVector3(Vector3 origin)
|
|
||||||
{
|
|
||||||
x = Math.round(origin.x);
|
|
||||||
y = Math.round(origin.y);
|
|
||||||
z = Math.round(origin.z);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,68 +0,0 @@
|
||||||
package dev.zontreck.otemod.containers;
|
|
||||||
|
|
||||||
import dev.zontreck.otemod.exceptions.InvalidDeserialization;
|
|
||||||
import net.minecraft.world.phys.Vec2;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
|
|
||||||
public class Vector2
|
|
||||||
{
|
|
||||||
public float x;
|
|
||||||
public float y;
|
|
||||||
|
|
||||||
public Vec2 asMinecraftVector(){
|
|
||||||
return new Vec2(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector2()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector2(float x, float y)
|
|
||||||
{
|
|
||||||
this.x=x;
|
|
||||||
this.y=y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector2(Vec2 pos)
|
|
||||||
{
|
|
||||||
x=pos.x;
|
|
||||||
y=pos.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector2(String pos) throws InvalidDeserialization
|
|
||||||
{
|
|
||||||
// This will be serialized most likely from the ToString method
|
|
||||||
// Parse
|
|
||||||
if(pos.startsWith("<"))
|
|
||||||
{
|
|
||||||
pos=pos.substring(1, pos.length()-1); // Rip off the ending bracket too
|
|
||||||
String[] positions = pos.split(", ");
|
|
||||||
if(positions.length!=2)
|
|
||||||
{
|
|
||||||
positions = pos.split(",");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(positions.length!=2)
|
|
||||||
{
|
|
||||||
throw new InvalidDeserialization("Positions must be in the same format provided by ToString() (ex. <1,1> or <1, 1>");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.x = Float.parseFloat(positions[0]);
|
|
||||||
this.y = Float.parseFloat(positions[1]);
|
|
||||||
// We are done now
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector2 Clone()
|
|
||||||
{
|
|
||||||
Vector2 n = new Vector2(x, y);
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "<"+String.valueOf(x)+", "+String.valueOf(y) + ">";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,140 +0,0 @@
|
||||||
package dev.zontreck.otemod.containers;
|
|
||||||
|
|
||||||
import dev.zontreck.otemod.exceptions.InvalidDeserialization;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
|
|
||||||
public class Vector3
|
|
||||||
{
|
|
||||||
public double x;
|
|
||||||
public double y;
|
|
||||||
public double z;
|
|
||||||
|
|
||||||
public Vec3 asMinecraftVector(){
|
|
||||||
return new Vec3(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockPos asBlockPos()
|
|
||||||
{
|
|
||||||
return new BlockPos(asMinecraftVector());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3(double x, double y, double z)
|
|
||||||
{
|
|
||||||
this.x=x;
|
|
||||||
this.y=y;
|
|
||||||
this.z=z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3(Vec3 pos)
|
|
||||||
{
|
|
||||||
x=pos.x;
|
|
||||||
y=pos.y;
|
|
||||||
z=pos.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3(BlockPos pos)
|
|
||||||
{
|
|
||||||
x=pos.getX();
|
|
||||||
y=pos.getY();
|
|
||||||
z=pos.getZ();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3(String pos) throws InvalidDeserialization
|
|
||||||
{
|
|
||||||
// This will be serialized most likely from the ToString method
|
|
||||||
// Parse
|
|
||||||
if(pos.startsWith("<"))
|
|
||||||
{
|
|
||||||
pos=pos.substring(1, pos.length()-1); // Rip off the ending bracket too
|
|
||||||
String[] positions = pos.split(", ");
|
|
||||||
if(positions.length!=3)
|
|
||||||
{
|
|
||||||
positions = pos.split(",");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(positions.length!=3)
|
|
||||||
{
|
|
||||||
throw new InvalidDeserialization("Positions must be in the same format provided by ToString() (ex. <1,1,1> or <1, 1, 1>");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.x = Double.parseDouble(positions[0]);
|
|
||||||
this.y = Double.parseDouble(positions[1]);
|
|
||||||
this.z = Double.parseDouble(positions[2]);
|
|
||||||
// We are done now
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3 subtract(Vector3 other)
|
|
||||||
{
|
|
||||||
return new Vector3(x-other.x, y-other.y, z-other.z);
|
|
||||||
}
|
|
||||||
public Vector3 add(Vector3 other)
|
|
||||||
{
|
|
||||||
return new Vector3(x+other.x, y+other.y, z +other.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double distance(Vector3 other)
|
|
||||||
{
|
|
||||||
Vector3 sub = subtract(other);
|
|
||||||
return Math.sqrt((sub.x * sub.x + sub.y * sub.y + sub.z * sub.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3 moveUp()
|
|
||||||
{
|
|
||||||
Vector3 up = Clone();
|
|
||||||
up.y+=1;
|
|
||||||
return up;
|
|
||||||
}
|
|
||||||
public Vector3 moveDown()
|
|
||||||
{
|
|
||||||
Vector3 up = Clone();
|
|
||||||
up.y-=1;
|
|
||||||
return up;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Vector3 Clone()
|
|
||||||
{
|
|
||||||
Vector3 n = new Vector3(x, y, z);
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "<"+String.valueOf(x)+", "+String.valueOf(y)+", "+String.valueOf(z)+">";
|
|
||||||
}
|
|
||||||
|
|
||||||
public NonAbsVector3 rounded()
|
|
||||||
{
|
|
||||||
NonAbsVector3 cl = new NonAbsVector3(this);
|
|
||||||
return cl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompoundTag serialize()
|
|
||||||
{
|
|
||||||
CompoundTag tag = new CompoundTag();
|
|
||||||
tag.putDouble("x", x);
|
|
||||||
tag.putDouble("y", y);
|
|
||||||
tag.putDouble("z", z);
|
|
||||||
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3(CompoundTag tag) {
|
|
||||||
this.deserialize(tag);
|
|
||||||
}
|
|
||||||
public void deserialize(CompoundTag tag)
|
|
||||||
{
|
|
||||||
x=tag.getDouble("x");
|
|
||||||
y=tag.getDouble("y");
|
|
||||||
z=tag.getDouble("z");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,94 +0,0 @@
|
||||||
package dev.zontreck.otemod.containers;
|
|
||||||
|
|
||||||
import dev.zontreck.otemod.OTEMod;
|
|
||||||
import dev.zontreck.otemod.exceptions.InvalidDeserialization;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.NbtUtils;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
|
|
||||||
public class WorldPosition
|
|
||||||
{
|
|
||||||
|
|
||||||
public Vector3 Position;
|
|
||||||
public String Dimension;
|
|
||||||
|
|
||||||
public WorldPosition(CompoundTag tag, boolean pretty) throws InvalidDeserialization
|
|
||||||
{
|
|
||||||
if(pretty){
|
|
||||||
|
|
||||||
Position = new Vector3(tag.getString("Position"));
|
|
||||||
Dimension = tag.getString("Dimension");
|
|
||||||
}else {
|
|
||||||
Position = new Vector3(tag.getCompound("pos"));
|
|
||||||
Dimension = tag.getString("Dimension");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorldPosition(Vector3 pos, String dim)
|
|
||||||
{
|
|
||||||
Position=pos;
|
|
||||||
Dimension=dim;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorldPosition(Vector3 pos, ServerLevel lvl)
|
|
||||||
{
|
|
||||||
Position=pos;
|
|
||||||
Dimension = lvl.dimension().location().getNamespace() + ":"+lvl.dimension().location().getPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return NbtUtils.structureToSnbt(serialize());
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompoundTag serializePretty()
|
|
||||||
{
|
|
||||||
CompoundTag tag = new CompoundTag();
|
|
||||||
|
|
||||||
tag.putString("Position", Position.toString());
|
|
||||||
tag.putString("Dimension", Dimension);
|
|
||||||
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompoundTag serialize()
|
|
||||||
{
|
|
||||||
CompoundTag tag = new CompoundTag();
|
|
||||||
tag.put("pos", Position.serialize());
|
|
||||||
tag.putString("Dimension", Dimension);
|
|
||||||
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ServerLevel getActualDimension()
|
|
||||||
{
|
|
||||||
|
|
||||||
String dim = Dimension;
|
|
||||||
String[] dims = dim.split(":");
|
|
||||||
|
|
||||||
ResourceLocation rl = new ResourceLocation(dims[0], dims[1]);
|
|
||||||
ServerLevel dimL = null;
|
|
||||||
for (ServerLevel lServerLevel : OTEMod.THE_SERVER.getAllLevels()) {
|
|
||||||
ResourceLocation XL = lServerLevel.dimension().location();
|
|
||||||
|
|
||||||
if(XL.getNamespace().equals(rl.getNamespace())){
|
|
||||||
if(XL.getPath().equals(rl.getPath())){
|
|
||||||
dimL = lServerLevel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(dimL == null)
|
|
||||||
{
|
|
||||||
OTEMod.LOGGER.error("DIMENSION COULD NOT BE FOUND : "+Dimension);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dimL;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +1,9 @@
|
||||||
package dev.zontreck.otemod.database;
|
package dev.zontreck.otemod.database;
|
||||||
|
|
||||||
import dev.zontreck.otemod.containers.Vector2;
|
import dev.zontreck.libzontreck.vectors.Vector2;
|
||||||
import dev.zontreck.otemod.containers.Vector3;
|
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||||
import dev.zontreck.otemod.containers.WorldPosition;
|
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||||
import dev.zontreck.otemod.exceptions.InvalidDeserialization;
|
import dev.zontreck.libzontreck.exceptions.InvalidDeserialization;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NbtUtils;
|
import net.minecraft.nbt.NbtUtils;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
package dev.zontreck.otemod.exceptions;
|
|
||||||
|
|
||||||
public class InvalidDeserialization extends Exception
|
|
||||||
{
|
|
||||||
public InvalidDeserialization(String error){
|
|
||||||
super(error);
|
|
||||||
}
|
|
||||||
public InvalidDeserialization(){
|
|
||||||
super("Incorrect information was provided to the deserializer");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,7 +19,7 @@ modId="otemod" #mandatory
|
||||||
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
||||||
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
|
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
|
||||||
# see the associated build.gradle script for how to populate this completely automatically during a build
|
# see the associated build.gradle script for how to populate this completely automatically during a build
|
||||||
version="1.3.4.2" #mandatory
|
version="1.3.4.3" #mandatory
|
||||||
# A display name for the mod
|
# A display name for the mod
|
||||||
displayName="OTEMod Resources" #mandatory
|
displayName="OTEMod Resources" #mandatory
|
||||||
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
|
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
{
|
{
|
||||||
"parent": "otemod:block/clear_glass_block"
|
"parent": "minecraft:block/glass"
|
||||||
}
|
}
|
Reference in a new issue