Push optimizations

* Attempt to fix vault screen text offsets
* Begin implementation of creeper heal
** Legacy implementation of ZSchem3 will be added, along with modded implementation
* Known: Will not build due to in-progress changes
This commit is contained in:
Zontreck 2022-10-16 06:04:21 -07:00
parent 04c558f2fc
commit 325a6ed11f
15 changed files with 261 additions and 68 deletions

View file

@ -3,7 +3,7 @@
org.gradle.jvmargs=-Xmx8G org.gradle.jvmargs=-Xmx8G
org.gradle.daemon=false org.gradle.daemon=false
my_version=1.3.4.1 my_version=1.3.4.2
mc_version=1.19.2 mc_version=1.19.2
forge_version=43.1.32 forge_version=43.1.32

View file

@ -0,0 +1,58 @@
package dev.zontreck.otemod.antigrief;
import java.util.Collection;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.event.level.ChunkDataEvent;
import net.minecraftforge.event.level.ExplosionEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
public class Handler
{
private static final String EXPLOSION_HEAL_TAG = "OTEEH";
@OnlyIn(Dist.DEDICATED_SERVER)
@SubscribeEvent
public void onChunkLoad(final ChunkDataEvent.Load event)
{
final CompoundTag EHTag = event.getData().getCompound(EXPLOSION_HEAL_TAG);
if(!EHTag.isEmpty())
{
final CompoundTag healer = EHTag.getCompound("healer");
if(!healer.isEmpty()){
// This would re-queue the healer
}
}
}
@OnlyIn(Dist.DEDICATED_SERVER)
@SubscribeEvent
public void onDetonation(ExplosionEvent.Detonate event)
{
ServerLevel level = (ServerLevel)event.getLevel();
Entity exploder = event.getExplosion().getExploder();
if(exploder==null)return ; // TODO: Make this check config
final Collection<BlockState> affectedBlocks = buildBlocks(level, event.getAffectedBlocks());
}
private Collection<BlockState> buildBlocks(ServerLevel level, Collection<BlockPos> positions)
{
for(final BlockPos pos : positions)
{
final BlockState state = level.getBlockState(pos);
}
}
}

View file

@ -0,0 +1,65 @@
package dev.zontreck.otemod.antigrief;
import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.commands.teleport.TeleportContainer;
import dev.zontreck.otemod.containers.Vector3;
import dev.zontreck.otemod.containers.WorldPosition;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.TagBuilder;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.storage.ChunkSerializer;
public class StoredBlock {
public CompoundTag blockData;
private WorldPosition position;
private BlockState state;
public StoredBlock(final BlockPos pos, final BlockState toSave, final ServerLevel lvl)
{
position = new WorldPosition(new Vector3(pos), lvl);
this.state=toSave;
}
public StoredBlock(final CompoundTag tag)
{
this.deserialize(tag);
}
public final BlockPos getPos()
{
return pos;
}
public final BlockState getState()
{
return state;
}
public final int getChunkX()
{
return pos.getX() >> 4;
}
public final int getChunkZ()
{
return pos.getZ() >> 4;
}
public CompoundTag serialize()
{
final CompoundTag tag = new CompoundTag();
tag.put("pos", )
}
}

View file

@ -0,0 +1,8 @@
package dev.zontreck.otemod.commands.antigrief;
// This will accelerate the healing queue, not do it instantly!
// The queue will get processed at a rate of 10* the configured rate.
public class HealNow
{
}

View file

@ -86,28 +86,7 @@ public class HomeCommand {
position = dest.Position.asMinecraftVector(); position = dest.Position.asMinecraftVector();
rot = dest.Rotation.asMinecraftVector(); rot = dest.Rotation.asMinecraftVector();
String dim = dest.Dimension; ServerLevel dimL = dest.getActualDimension();
String[] dims = dim.split(":");
ResourceLocation rl = new ResourceLocation(dims[0], dims[1]);
ServerLevel dimL = null;
for (ServerLevel lServerLevel : p.server.getAllLevels()) {
ResourceLocation XL = lServerLevel.dimension().location();
if(XL.getNamespace().equals(rl.getNamespace())){
if(XL.getPath().equals(rl.getPath())){
dimL = lServerLevel;
}
}
}
if(dimL == null)
{
SQL = "Failed to find the dimension";
ctx.sendFailure(Component.literal(ChatColor.DARK_RED+ChatColor.BOLD+"FAILED TO LOCATE THAT DIMENSION. CONTACT THE SERVER ADMIN"));
return 1;
}
TeleportActioner.ApplyTeleportEffect(p); TeleportActioner.ApplyTeleportEffect(p);
// Instantiate a Teleport Runner // Instantiate a Teleport Runner

View file

@ -52,7 +52,7 @@ public class SetHomeCommand {
Vec3 position = p.position(); Vec3 position = p.position();
Vec2 rot = p.getRotationVector(); Vec2 rot = p.getRotationVector();
TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.getLevel().dimension().location().getNamespace() + ":" + p.getLevel().dimension().location().getPath()); TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.getLevel());
String SQL = "REPLACE INTO `homes` (user, home_name, teleporter) VALUES (?, ?, ?);"; String SQL = "REPLACE INTO `homes` (user, home_name, teleporter) VALUES (?, ?, ?);";
PreparedStatement pstat = con.prepareStatement(SQL); PreparedStatement pstat = con.prepareStatement(SQL);

View file

@ -49,7 +49,7 @@ public class RTPWarpCommand {
Vec3 position = p.position(); Vec3 position = p.position();
Vec2 rot = p.getRotationVector(); Vec2 rot = p.getRotationVector();
TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.getLevel().dimension().location().getNamespace() + ":" + p.getLevel().dimension().location().getPath()); TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.getLevel());
String SQL = "REPLACE INTO `warps` (warpname, owner, warptype, teleporter) values (?, ?, ?, ?);"; String SQL = "REPLACE INTO `warps` (warpname, owner, warptype, teleporter) values (?, ?, ?, ?);";
pstat = con.prepareStatement(SQL); pstat = con.prepareStatement(SQL);

View file

@ -48,7 +48,7 @@ public class SetWarpCommand {
Vec3 position = p.position(); Vec3 position = p.position();
Vec2 rot = p.getRotationVector(); Vec2 rot = p.getRotationVector();
TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.getLevel().dimension().location().getNamespace() + ":" + p.getLevel().dimension().location().getPath()); TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.getLevel());
String SQL = "REPLACE INTO `warps` (warpname, owner, warptype, teleporter) values (?, ?, ?, ?);"; String SQL = "REPLACE INTO `warps` (warpname, owner, warptype, teleporter) values (?, ?, ?, ?);";
pstat = con.prepareStatement(SQL); pstat = con.prepareStatement(SQL);

View file

@ -59,27 +59,9 @@ public class WarpCommand {
{ {
TeleportDestination dest = new TeleportDestination(NbtUtils.snbtToStructure(rs.getString("teleporter"))); TeleportDestination dest = new TeleportDestination(NbtUtils.snbtToStructure(rs.getString("teleporter")));
String dim = dest.Dimension;
String[] dims = dim.split(":");
ResourceLocation rl = new ResourceLocation(dims[0], dims[1]); ServerLevel dimL = dest.getActualDimension();
ServerLevel dimL = null;
for (ServerLevel lServerLevel : p.server.getAllLevels()) {
ResourceLocation XL = lServerLevel.dimension().location();
if(XL.getNamespace().equals(rl.getNamespace())){
if(XL.getPath().equals(rl.getPath())){
dimL = lServerLevel;
}
}
}
if(dimL == null)
{
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), Component.literal(ChatColor.RED+"DIMENSION COULD NOT BE FOUND"), source.getServer());
return 1;
}
final int type = rs.getInt("warptype"); final int type = rs.getInt("warptype");
final ServerLevel f_dim = dimL; final ServerLevel f_dim = dimL;

View file

@ -1,6 +1,7 @@
package dev.zontreck.otemod.containers; package dev.zontreck.otemod.containers;
import dev.zontreck.otemod.exceptions.InvalidDeserialization; import dev.zontreck.otemod.exceptions.InvalidDeserialization;
import net.minecraft.core.BlockPos;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
public class Vector3 public class Vector3
@ -13,6 +14,11 @@ public class Vector3
return new Vec3(x, y, z); return new Vec3(x, y, z);
} }
public BlockPos asBlockPos()
{
return new BlockPos(asMinecraftVector());
}
public Vector3() public Vector3()
{ {
@ -32,6 +38,13 @@ public class Vector3
z=pos.z; z=pos.z;
} }
public Vector3(BlockPos pos)
{
x=pos.getX();
y=pos.getY();
z=pos.getZ();
}
public Vector3(String pos) throws InvalidDeserialization public Vector3(String pos) throws InvalidDeserialization
{ {
// This will be serialized most likely from the ToString method // This will be serialized most likely from the ToString method

View file

@ -0,0 +1,79 @@
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) throws InvalidDeserialization
{
Position = new Vector3(tag.getString("Position"));
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 serialize()
{
CompoundTag tag = new CompoundTag();
tag.putString("Position", Position.toString());
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;
}
}

View file

@ -2,41 +2,50 @@ package dev.zontreck.otemod.database;
import dev.zontreck.otemod.containers.Vector2; import dev.zontreck.otemod.containers.Vector2;
import dev.zontreck.otemod.containers.Vector3; import dev.zontreck.otemod.containers.Vector3;
import dev.zontreck.otemod.containers.WorldPosition;
import dev.zontreck.otemod.exceptions.InvalidDeserialization; import dev.zontreck.otemod.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;
/** /**
* This defines the data structure, and methods for deserializing and serializing teleport destinations, for easier storage in the database * This defines the data structure, and methods for deserializing and serializing teleport destinations, for easier storage in the database
**/ **/
public class TeleportDestination { public class TeleportDestination extends WorldPosition
public Vector3 Position; {
public Vector2 Rotation; public Vector2 Rotation;
public String Dimension;
public TeleportDestination(CompoundTag tag) throws InvalidDeserialization public TeleportDestination(CompoundTag tag) throws InvalidDeserialization
{ {
Position = new Vector3(tag.getString("Position")); super(tag);
Rotation = new Vector2(tag.getString("Rotation")); Rotation = new Vector2(tag.getString("Rotation"));
Dimension = tag.getString("Dimension");
} }
public TeleportDestination(Vector3 pos, Vector2 rot, String dim) public TeleportDestination(Vector3 pos, Vector2 rot, String dim)
{ {
Position = pos; super(pos, dim);
Rotation = rot; Rotation = rot;
Dimension = dim; }
public TeleportDestination(Vector3 pos, Vector2 rot, ServerLevel dim)
{
super(pos,dim);
Rotation=rot;
} }
@Override @Override
public String toString() public String toString()
{ {
CompoundTag tag = new CompoundTag();
tag.putString("Position", Position.toString()); return NbtUtils.structureToSnbt(serialize());
}
public CompoundTag serialize(){
CompoundTag tag = super.serialize();
tag.putString("Rotation", Rotation.toString()); tag.putString("Rotation", Rotation.toString());
tag.putString("Dimension", Dimension);
return NbtUtils.structureToSnbt(tag);
return tag;
} }
} }

View file

@ -37,16 +37,16 @@ public class VaultScreen extends AbstractContainerScreen <VaultMenu>
super.render(stack, mouseX, mouseY, partialTicks); super.render(stack, mouseX, mouseY, partialTicks);
this.renderTooltip(stack, mouseX, mouseY); this.renderTooltip(stack, mouseX, mouseY);
//this.font.draw(stack, this.title, this.leftPos + 17, this.topPos + 15, 0xFFFFFF); this.font.draw(stack, this.title, this.leftPos + 17, this.topPos + 15, 0xFFFFFF);
//this.font.draw(stack, this.playerInventoryTitle, this.leftPos + 17, this.topPos + 123, 0xFFFFFF); this.font.draw(stack, this.playerInventoryTitle, this.leftPos + 17, this.topPos + 123, 0xFFFFFF);
} }
@Override @Override
protected void renderLabels(PoseStack stack, int mouseX, int mouseY) protected void renderLabels(PoseStack stack, int mouseX, int mouseY)
{ {
this.font.draw(stack, this.title.getString(), this.leftPos + 17, this.topPos + 15, 0xFFFFFF); //this.font.draw(stack, this.title.getString(), this.leftPos + 17, this.topPos + 15, 0xFFFFFF);
this.font.draw(stack, this.playerInventoryTitle.getString(), this.leftPos + 17, this.topPos + 123, 0xFFFFFF); //this.font.draw(stack, this.playerInventoryTitle.getString(), this.leftPos + 17, this.topPos + 123, 0xFFFFFF);
} }
@Override @Override

View file

@ -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.1" #mandatory version="1.3.4.2" #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/

View file

@ -275,8 +275,8 @@
"when_in_range": { "when_in_range": {
"type": "minecraft:noise", "type": "minecraft:noise",
"noise": "minecraft:ore_veininess", "noise": "minecraft:ore_veininess",
"xz_scale": 5, "xz_scale": 10,
"y_scale": 5 "y_scale": 10
}, },
"when_out_of_range": 0 "when_out_of_range": 0
} }
@ -298,8 +298,8 @@
"when_in_range": { "when_in_range": {
"type": "minecraft:noise", "type": "minecraft:noise",
"noise": "minecraft:ore_vein_a", "noise": "minecraft:ore_vein_a",
"xz_scale": 8, "xz_scale": 16,
"y_scale": 8 "y_scale": 16
}, },
"when_out_of_range": 0 "when_out_of_range": 0
} }
@ -317,8 +317,8 @@
"when_in_range": { "when_in_range": {
"type": "minecraft:noise", "type": "minecraft:noise",
"noise": "minecraft:ore_vein_b", "noise": "minecraft:ore_vein_b",
"xz_scale": 8, "xz_scale": 16,
"y_scale": 8 "y_scale": 16
}, },
"when_out_of_range": 0 "when_out_of_range": 0
} }