Bump Libzontreck

This commit is contained in:
zontreck 2024-04-30 04:26:42 -07:00
parent 4a7a8dd202
commit 2717c90cff
20 changed files with 19 additions and 926 deletions

View file

@ -2,8 +2,7 @@
# This is required to provide enough memory for the Minecraft decompilation process. # This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false org.gradle.daemon=false
libzontreck=1201.13.043024.0404
libzontreck=1201.11.040124.0231
## Environment Properties ## Environment Properties
@ -48,14 +47,14 @@ mod_name=Thresholds
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GPLv3 mod_license=GPLv3
# The mod version. See https://semver.org/ # The mod version. See https://semver.org/
mod_version=1201.4.040724.2332 mod_version=1201.4.043024.0426
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources. # This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html # See https://maven.apache.org/guides/mini/guide-naming-conventions.html
mod_group_id=dev.zontreck mod_group_id=dev.zontreck
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list. # The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
mod_authors=zontreck mod_authors=zontreck
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list. # The description of the mod. This is a simple multiline text string that is used for display purposes \in the mod list.
mod_description=Thresholds mod_description=Thresholds
# Pack version - this changes each minecraft release, in general. # Pack version - this changes each minecraft release, in general.

View file

@ -7,8 +7,6 @@ import dev.zontreck.libzontreck.edlibmc.Registries;
import dev.zontreck.libzontreck.profiles.Profile; import dev.zontreck.libzontreck.profiles.Profile;
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException; import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
import dev.zontreck.libzontreck.util.ChatHelpers; import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.libzontreck.vectors.Vector3;
import dev.zontreck.libzontreck.vectors.WorldPosition;
import dev.zontreck.otemod.blocks.DeprecatedModBlocks; import dev.zontreck.otemod.blocks.DeprecatedModBlocks;
import dev.zontreck.otemod.configs.snbt.ServerConfig; import dev.zontreck.otemod.configs.snbt.ServerConfig;
import dev.zontreck.otemod.effects.ModEffects; import dev.zontreck.otemod.effects.ModEffects;
@ -73,7 +71,6 @@ import dev.zontreck.otemod.networking.ModMessages;
@Mod(OTEMod.MOD_ID) @Mod(OTEMod.MOD_ID)
public class OTEMod public class OTEMod
{ {
public static final Vector3 ZERO_VECTOR = new Vector3(0,0,0);
// Directly reference a slf4j logger // Directly reference a slf4j logger
public static final Logger LOGGER = LogUtils.getLogger(); public static final Logger LOGGER = LogUtils.getLogger();
public static final String MOD_ID = "otemod"; public static final String MOD_ID = "otemod";
@ -116,7 +113,6 @@ public class OTEMod
MinecraftForge.EVENT_BUS.register(new ChatServerOverride()); MinecraftForge.EVENT_BUS.register(new ChatServerOverride());
MinecraftForge.EVENT_BUS.register(new CommandRegistry()); MinecraftForge.EVENT_BUS.register(new CommandRegistry());
MinecraftForge.EVENT_BUS.register(new VaultWatcher()); MinecraftForge.EVENT_BUS.register(new VaultWatcher());
MinecraftForge.EVENT_BUS.register(new dev.zontreck.otemod.zschem.EventHandler());
ModMenuTypes.CONTAINERS.register(bus); ModMenuTypes.CONTAINERS.register(bus);
MinecraftForge.EVENT_BUS.register(FlightEnchantment.class); MinecraftForge.EVENT_BUS.register(FlightEnchantment.class);
MinecraftForge.EVENT_BUS.register(NightVisionEnchantment.class); MinecraftForge.EVENT_BUS.register(NightVisionEnchantment.class);

View file

@ -1,8 +0,0 @@
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

@ -4,7 +4,7 @@ import com.mojang.brigadier.CommandDispatcher;
import dev.zontreck.libzontreck.events.TeleportEvent; import dev.zontreck.libzontreck.events.TeleportEvent;
import dev.zontreck.libzontreck.exceptions.InvalidDeserialization; import dev.zontreck.libzontreck.exceptions.InvalidDeserialization;
import dev.zontreck.libzontreck.util.ChatHelpers; import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.libzontreck.vectors.Vector3; import dev.zontreck.libzontreck.vectors.Vector3d;
import dev.zontreck.libzontreck.vectors.WorldPosition; import dev.zontreck.libzontreck.vectors.WorldPosition;
import dev.zontreck.otemod.configs.snbt.ServerConfig; import dev.zontreck.otemod.configs.snbt.ServerConfig;
import dev.zontreck.otemod.implementation.Messages; import dev.zontreck.otemod.implementation.Messages;
@ -45,7 +45,7 @@ public class BuildCommand
WorldPosition save = new WorldPosition(sp); WorldPosition save = new WorldPosition(sp);
PerPlayerDataRegistry.put(sp.getUUID(), "builder_entered_from", save.serialize()); PerPlayerDataRegistry.put(sp.getUUID(), "builder_entered_from", save.serialize());
WorldPosition pos = new WorldPosition(new Vector3(0, -55, 0), ModDimensions.BUILDER_DIM()); WorldPosition pos = new WorldPosition(new Vector3d(0, -55, 0), ModDimensions.BUILDER_DIM());
if(!MinecraftForge.EVENT_BUS.post(new TeleportEvent(pos, sp))) if(!MinecraftForge.EVENT_BUS.post(new TeleportEvent(pos, sp)))
stack.getPlayer().teleportTo(pos.getActualDimension(), pos.Position.x, pos.Position.y, pos.Position.z, 0, 0); stack.getPlayer().teleportTo(pos.getActualDimension(), pos.Position.x, pos.Position.y, pos.Position.z, 0, 0);

View file

@ -3,14 +3,9 @@ package dev.zontreck.otemod.commands.zschem;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.arguments.StringArgumentType;
import dev.zontreck.libzontreck.util.ChatHelpers; import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.libzontreck.vectors.Vector3;
import dev.zontreck.libzontreck.vectors.WorldPosition; import dev.zontreck.libzontreck.vectors.WorldPosition;
import dev.zontreck.otemod.OTEMod; import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.integrations.LuckPermsHelper; import dev.zontreck.otemod.integrations.LuckPermsHelper;
import dev.zontreck.otemod.permissions.Permissions;
import dev.zontreck.otemod.zschem.MemoryHolder;
import dev.zontreck.otemod.zschem.MemoryHolder.Container;
import dev.zontreck.otemod.zschem.StoredBlock;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands; import net.minecraft.commands.Commands;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
@ -46,6 +41,7 @@ public class LoadSchem {
// Perform sanity checks // Perform sanity checks
/*
ServerPlayer play = (ServerPlayer)source.getEntity(); ServerPlayer play = (ServerPlayer)source.getEntity();
if(play==null)return 1; if(play==null)return 1;
@ -125,6 +121,7 @@ public class LoadSchem {
} }
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro("!Dark_Red! You must set the first position"), ServerLifecycleHooks.getCurrentServer()); ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro("!Dark_Red! You must set the first position"), ServerLifecycleHooks.getCurrentServer());
return 0;*/
return 0; return 0;
} }

View file

@ -4,11 +4,6 @@ import com.mojang.brigadier.CommandDispatcher;
import dev.zontreck.libzontreck.util.ChatHelpers; import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.otemod.OTEMod; import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.integrations.LuckPermsHelper; import dev.zontreck.otemod.integrations.LuckPermsHelper;
import dev.zontreck.otemod.permissions.Permissions;
import dev.zontreck.otemod.zschem.MemoryHolder;
import dev.zontreck.otemod.zschem.MemoryHolder.Container;
import dev.zontreck.otemod.zschem.StoredBlock;
import dev.zontreck.otemod.zschem.WorldProp;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands; import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
@ -34,7 +29,7 @@ public class Place {
ServerPlayer play = (ServerPlayer)source.getEntity(); ServerPlayer play = (ServerPlayer)source.getEntity();
if(play==null)return 1; if(play==null)return 1;
/*
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_place)){ if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_place)){
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_place, Permissions.zschem); LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_place, Permissions.zschem);
return 1; return 1;
@ -70,7 +65,7 @@ public class Place {
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Green!Enqueued!"), ServerLifecycleHooks.getCurrentServer()); ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Green!Enqueued!"), ServerLifecycleHooks.getCurrentServer());
*/
return 0; return 0;
} }
} }

View file

@ -2,14 +2,8 @@ package dev.zontreck.otemod.commands.zschem;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import dev.zontreck.libzontreck.util.ChatHelpers; import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.libzontreck.vectors.Vector3;
import dev.zontreck.otemod.OTEMod; import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.integrations.LuckPermsHelper; import dev.zontreck.otemod.integrations.LuckPermsHelper;
import dev.zontreck.otemod.permissions.Permissions;
import dev.zontreck.otemod.zschem.MemoryHolder;
import dev.zontreck.otemod.zschem.MemoryHolder.Container;
import dev.zontreck.otemod.zschem.StoredBlock;
import dev.zontreck.otemod.zschem.WorldProp;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands; import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
@ -35,6 +29,7 @@ public class PlaceAsAir {
private static int place(CommandSourceStack source) { private static int place(CommandSourceStack source) {
/*
ServerPlayer play = (ServerPlayer)source.getEntity(); ServerPlayer play = (ServerPlayer)source.getEntity();
if(play==null)return 1; if(play==null)return 1;
@ -77,7 +72,7 @@ public class PlaceAsAir {
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Green!Enqueued!"), ServerLifecycleHooks.getCurrentServer()); ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro(OTEMod.OTEPrefix+" !Dark_Green!Enqueued!"), ServerLifecycleHooks.getCurrentServer());
*/
return 0; return 0;
} }
} }

View file

@ -3,13 +3,8 @@ package dev.zontreck.otemod.commands.zschem;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.arguments.StringArgumentType;
import dev.zontreck.libzontreck.util.ChatHelpers; import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.libzontreck.vectors.Vector3;
import dev.zontreck.otemod.OTEMod; import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.integrations.LuckPermsHelper; import dev.zontreck.otemod.integrations.LuckPermsHelper;
import dev.zontreck.otemod.permissions.Permissions;
import dev.zontreck.otemod.zschem.MemoryHolder;
import dev.zontreck.otemod.zschem.MemoryHolder.Container;
import dev.zontreck.otemod.zschem.StoredBlock;
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;
@ -44,7 +39,7 @@ public class SaveSchem {
ServerPlayer play = (ServerPlayer)source.getEntity(); ServerPlayer play = (ServerPlayer)source.getEntity();
if(play==null)return 1; if(play==null)return 1;
/*
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_save)){ if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_save)){
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_save, Permissions.zschem); LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_save, Permissions.zschem);
return 1; return 1;
@ -110,7 +105,7 @@ public class SaveSchem {
} }
} }
ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro("!Dark_Red! You must first set the positions"), ServerLifecycleHooks.getCurrentServer()); ChatHelpers.broadcastTo(play.getUUID(), ChatHelpers.macro("!Dark_Red! You must first set the positions"), ServerLifecycleHooks.getCurrentServer());
*/
return 0; return 0;
} }

View file

@ -3,11 +3,8 @@ package dev.zontreck.otemod.commands.zschem;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import dev.zontreck.libzontreck.chat.ChatColor; import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.libzontreck.util.ChatHelpers; import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.libzontreck.vectors.Vector3;
import dev.zontreck.otemod.OTEMod; import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.integrations.LuckPermsHelper; import dev.zontreck.otemod.integrations.LuckPermsHelper;
import dev.zontreck.otemod.permissions.Permissions;
import dev.zontreck.otemod.zschem.MemoryHolder;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands; import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -30,7 +27,7 @@ public class SetPos1 {
ServerPlayer play = (ServerPlayer)source.getEntity(); ServerPlayer play = (ServerPlayer)source.getEntity();
if(play==null)return 1; if(play==null)return 1;
/*
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_pos1)){ if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_pos1)){
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_pos1, Permissions.zschem); LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_pos1, Permissions.zschem);
return 1; return 1;
@ -39,7 +36,7 @@ public class SetPos1 {
MemoryHolder.setLevel(play, source.getLevel()); MemoryHolder.setLevel(play, source.getLevel());
ChatHelpers.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 1 set!")), ServerLifecycleHooks.getCurrentServer()); ChatHelpers.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 1 set!")), ServerLifecycleHooks.getCurrentServer());
*/
return 0; return 0;
} }
} }

View file

@ -3,11 +3,8 @@ package dev.zontreck.otemod.commands.zschem;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import dev.zontreck.libzontreck.chat.ChatColor; import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.libzontreck.util.ChatHelpers; import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.libzontreck.vectors.Vector3;
import dev.zontreck.otemod.OTEMod; import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.integrations.LuckPermsHelper; import dev.zontreck.otemod.integrations.LuckPermsHelper;
import dev.zontreck.otemod.permissions.Permissions;
import dev.zontreck.otemod.zschem.MemoryHolder;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands; import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -30,6 +27,7 @@ public class SetPos2 {
ServerPlayer play = (ServerPlayer)source.getEntity(); ServerPlayer play = (ServerPlayer)source.getEntity();
if(play==null)return 1; if(play==null)return 1;
/*
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_pos2)){ if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_pos2)){
LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_pos2, Permissions.zschem); LuckPermsHelper.sendNoPermissionsMessage(play, Permissions.zschem_pos2, Permissions.zschem);
return 1; return 1;
@ -39,7 +37,7 @@ public class SetPos2 {
MemoryHolder.setLevel(play, source.getLevel()); MemoryHolder.setLevel(play, source.getLevel());
ChatHelpers.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 2 set!")), ServerLifecycleHooks.getCurrentServer()); ChatHelpers.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 2 set!")), ServerLifecycleHooks.getCurrentServer());
*/
return 0; return 0;
} }
} }

View file

@ -1,7 +1,5 @@
package dev.zontreck.otemod.events; package dev.zontreck.otemod.events;
import dev.zontreck.libzontreck.vectors.Vector3;
import dev.zontreck.libzontreck.vectors.WorldPosition;
import dev.zontreck.otemod.OTEMod; import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.implementation.energy.IThresholdsEnergyContainer; import dev.zontreck.otemod.implementation.energy.IThresholdsEnergyContainer;
import dev.zontreck.otemod.integrations.KeyBindings; import dev.zontreck.otemod.integrations.KeyBindings;

View file

@ -8,7 +8,7 @@ import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
import dev.zontreck.libzontreck.util.ChatHelpers; import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.libzontreck.util.ItemUtils; import dev.zontreck.libzontreck.util.ItemUtils;
import dev.zontreck.libzontreck.util.heads.HeadUtilities; import dev.zontreck.libzontreck.util.heads.HeadUtilities;
import dev.zontreck.libzontreck.vectors.Vector3; import dev.zontreck.libzontreck.vectors.Vector3d;
import dev.zontreck.libzontreck.vectors.WorldPosition; import dev.zontreck.libzontreck.vectors.WorldPosition;
import dev.zontreck.otemod.OTEMod; import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.configs.snbt.ServerConfig; import dev.zontreck.otemod.configs.snbt.ServerConfig;
@ -123,7 +123,7 @@ public class EventHandler {
if(ev.getSource().is(DamageTypes.FELL_OUT_OF_WORLD) && (loc.getNamespace().equals(OTEMod.MOD_ID) || loc.getNamespace().equals("minecraft"))) if(ev.getSource().is(DamageTypes.FELL_OUT_OF_WORLD) && (loc.getNamespace().equals(OTEMod.MOD_ID) || loc.getNamespace().equals("minecraft")))
{ {
// Teleport the player to Thresholds // Teleport the player to Thresholds
WorldPosition pos = new WorldPosition(new Vector3(), ModDimensions.THRESHOLD_DIM()); WorldPosition pos = new WorldPosition(new Vector3d(), ModDimensions.THRESHOLD_DIM());
ServerPlayer sp = (ServerPlayer) ev.getEntity(); ServerPlayer sp = (ServerPlayer) ev.getEntity();
if(!MinecraftForge.EVENT_BUS.post(new TeleportEvent(pos, sp))) if(!MinecraftForge.EVENT_BUS.post(new TeleportEvent(pos, sp)))
sp.teleportTo(pos.getActualDimension(), 0, 365, 0, 0,0); sp.teleportTo(pos.getActualDimension(), 0, 365, 0, 0,0);

View file

@ -1,13 +0,0 @@
package dev.zontreck.otemod.permissions;
public class Permissions {
public static String zschem = "group.otemod.zschem";
public static String zschem_load = "otemod.commands.zschem.loadzschem";
public static String zschem_save = "otemod.commands.zschem.savezschem";
public static String zschem_place = "otemod.commands.zschem.placezschem";
public static String zschem_pos1 = "otemod.commands.zschem.pos1";
public static String zschem_pos2 = "otemod.commands.zschem.pos2";
public static String zschem_air = "otemod.commands.zschem.setair";
}

View file

@ -1,130 +0,0 @@
package dev.zontreck.otemod.zschem;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import dev.zontreck.libzontreck.vectors.WorldPosition;
import dev.zontreck.otemod.configs.snbt.ServerConfig;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.world.level.block.state.BlockState;
public class BlockContainerList {
private static final BlockContainerList INSTANCE =new BlockContainerList();
private final Lock lock;
private final List<StoredBlock> containers;
public BlockContainerList()
{
this.lock = new ReentrantLock();
this.containers = new ArrayList<>();
}
public static BlockContainerList getInstance()
{
return INSTANCE;
}
public int getNewLongestTick()
{
//Random rng = new Random();
int newLonger = ServerConfig.antigrief.timeBetween;
int cur = 0;
for (StoredBlock storedBlock : containers) {
if(cur < storedBlock.getTickValue()){
cur = storedBlock.getTickValue();
}
}
if(cur == 0)cur = ServerConfig.antigrief.healerTimer;
return cur + newLonger;
}
public void add(StoredBlock item)
{
lock.lock();
try{
for(StoredBlock sb : containers)
{
if(sb.getWorldPosition().same(item.getWorldPosition()))
{
return;
}
}
containers.add(item);
}finally{
lock.unlock();
}
}
public void tick()
{
lock.lock();
try{
Iterator<StoredBlock> isb = containers.iterator();
while(isb.hasNext())
{
StoredBlock storedBlock = isb.next();
storedBlock.tick();
if(storedBlock.isExpired()){
WorldPosition wp = storedBlock.getWorldPosition();
BlockState bs = wp.getActualDimension().getBlockState(wp.Position.asBlockPos());
if(bs.is(storedBlock.getState().getBlock()) || storedBlock.getTries() >= ServerConfig.antigrief.maxTries)
{
//HealRunner.scheduleHeal(storedBlock);
isb.remove();
//wp.getActualDimension().playSound(null, wp.Position.asBlockPos(), SoundEvents.ANVIL_USE, SoundSource.NEUTRAL, new Random().nextFloat(0.75f,1.0f), new Random().nextFloat(1));
}else {
HealRunner.scheduleHeal(storedBlock);
storedBlock.setTick(getNewLongestTick());
storedBlock.tickTries();
}
}
}
}finally{
lock.unlock();
}
}
public CompoundTag save(CompoundTag tag){
lock.lock();
try{
ListTag lst = new ListTag();
for (StoredBlock block : containers) {
lst.add(block.serialize());
}
tag.put("blocks", lst);
return tag;
}finally{
lock.unlock();
}
}
public static BlockContainerList load(CompoundTag tag){
BlockContainerList lst = new BlockContainerList();
ListTag xlst = tag.getList("blocks", CompoundTag.TAG_COMPOUND);
ListIterator<Tag> it = xlst.listIterator();
while(it.hasNext()){
Tag tg = it.next();
CompoundTag blk = (CompoundTag)tg;
StoredBlock sb = new StoredBlock(blk);
lst.add(sb);
}
return lst;
}
}

View file

@ -1,75 +0,0 @@
package dev.zontreck.otemod.zschem;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import dev.zontreck.libzontreck.util.SNbtIo;
import dev.zontreck.otemod.configs.snbt.ServerConfig;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo;
import net.minecraftforge.fml.loading.FMLConfig;
import net.minecraftforge.fml.loading.FMLPaths;
public class BlockSaver {
private static final int SAVE_INTERVAL = 1;
private final ScheduledExecutorService executor;
public BlockSaver(ScheduledExecutorService service)
{
executor=service;
}
public void start()
{
executor.scheduleAtFixedRate(()->{
CompoundTag primary = new CompoundTag();
primary=BlockContainerList.getInstance().save(primary);
File x = getPath().toFile();
if(ServerConfig.antigrief.debug)
{
// Save as sNBT
SNbtIo.writeSnbt(x.toPath(), primary);
}else{
try {
NbtIo.writeCompressed(primary, x);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}, SAVE_INTERVAL, SAVE_INTERVAL, TimeUnit.MINUTES);
}
// Healer Queue's data source is a NBT File in the config folder
public static final String HealerQueueFile = ".nbt";
public static final String HealerQueueDebugFile = ".dev.snbt";
public static Path getPath()
{
Path configDir = FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath());
//Path configFile = null;
return configDir.resolve("ote_queue");
}
public static String getExtension()
{
if(ServerConfig.antigrief.debug)
{
return BlockSaver.HealerQueueDebugFile;
}else {
return BlockSaver.HealerQueueFile;
}
}
}

View file

@ -1,82 +0,0 @@
package dev.zontreck.otemod.zschem;
import java.util.HashMap;
import java.util.Map;
import dev.zontreck.libzontreck.vectors.Vector3;
import dev.zontreck.libzontreck.vectors.WorldPosition;
import dev.zontreck.otemod.configs.snbt.ServerConfig;
import net.minecraft.server.level.ServerLevel;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.level.ExplosionEvent;
import net.minecraftforge.event.level.LevelEvent;
import net.minecraftforge.event.server.ServerStoppingEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
public class EventHandler {
@SubscribeEvent
public void onDetonate(ExplosionEvent ev)
{
if(ev.getLevel().isClientSide)return;
//Entity explodes = ev.getExplosion().getSourceMob();
// Register blocks to be healed
WorldPosition wpos = new WorldPosition(new Vector3(ev.getExplosion().getPosition()), (ServerLevel) ev.getLevel());
if(ServerConfig.antigrief.blacklistedDimensions.contains(wpos.Dimension)){
// Dimension is on the exclusion list. Do not process.
return;
}
WorldProp wp = WorldProp.acquire((ServerLevel)ev.getLevel());
if(wp!=null){
wp.onDetonate(ev);
}
}
private Map<ServerLevel, WorldProp> healers = new HashMap<ServerLevel, WorldProp>();
public Map<ServerLevel, WorldProp> getHealers()
{
return healers;
}
@SubscribeEvent
public void onUnload(LevelEvent.Unload ev)
{
if(!ev.getLevel().isClientSide())
{
healers.remove(ev.getLevel());
}
}
@SubscribeEvent
public void onShutdown(ServerStoppingEvent ev)
{
WorldProp.SaveAll();
}
@SubscribeEvent
public void onSaving(LevelEvent.Save ev)
{
WorldProp.SaveAll();
}
@SubscribeEvent
public void onLevelTick(TickEvent.LevelTickEvent ev)
{
if(!ev.level.isClientSide){
WorldProp wp = WorldProp.acquire((ServerLevel)ev.level);
if(wp!=null){
wp.onTick();
} else {
if(!healers.containsKey((ServerLevel) ev.level))
healers.put((ServerLevel) ev.level, wp);
}
MemoryHolder.tick();
}
}
}

View file

@ -1,78 +0,0 @@
package dev.zontreck.otemod.zschem;
import java.util.Random;
import dev.zontreck.libzontreck.exceptions.InvalidSideException;
import dev.zontreck.libzontreck.vectors.Vector3;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
public class HealRunner implements Runnable
{
public final StoredBlock BlockToSet;
// Play a popping sound at the block position
public final SoundEvent pop = SoundEvents.ITEM_PICKUP;
public HealRunner(StoredBlock sb)
{
BlockToSet = sb;
}
public static void scheduleHeal(StoredBlock sb){
sb.getWorldPosition().getActualDimension().getServer().execute(new HealRunner(sb));
}
@Override
public void run()
{
//BlockSnapshot bs = BlockSnapshot.create(level.dimension(), level, sb.getPos());
//BlockState current = level.getBlockState(sb.getPos());
ServerLevel level = (ServerLevel) BlockToSet.getWorldPosition().getActualDimension();
BlockState nState = Block.updateFromNeighbourShapes(BlockToSet.getState(), level, BlockToSet.getPos());
level.setBlock(BlockToSet.getPos(), nState, Block.UPDATE_CLIENTS); // no update?
//level.setBlocksDirty(sb.getPos(), sb.getState(), level.getBlockState(sb.getPos()));
//level.markAndNotifyBlock(sb.getPos(), level.getChunkAt(sb.getPos()), sb.getState(), level.getBlockState(sb.getPos()), 2, 0);
//level.getChunkAt(sb.getPos()).setBlockState(sb.getPos(), sb.getState(), false);
BlockEntity be = level.getBlockEntity(BlockToSet.getPos());
if(be!=null){
//be.deserializeNBT(sb.getBlockEntity());
if(BlockToSet.getBlockEntity()!=null){
be.load(BlockToSet.getBlockEntity());
be.setChanged();
}
}
// Everything is restored, play sound
SoundSource ss = SoundSource.NEUTRAL;
Vector3 v3 = BlockToSet.getWorldPosition().Position;
Random rng = new Random();
level.playSound(null, v3.asBlockPos(), pop, ss, rng.nextFloat(0.75f,1.0f), rng.nextFloat(1));
/*for(ServerPlayer player : level.players())
{
Vector3 playerPos = new Vector3(player.position());
if(sb.getWorldPosition().Position.distance(playerPos) < 15)
{
// have player's client play sound (Packet?)
}
}*/
}
}

View file

@ -1,178 +0,0 @@
package dev.zontreck.otemod.zschem;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.libzontreck.vectors.Vector3;
import dev.zontreck.otemod.OTEMod;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.player.Player;
public class MemoryHolder {
// This class holds the temporary memory related to zschem data
// We also store position information here.
private static final MemoryHolder INSTANCE = new MemoryHolder();
public static MemoryHolder get(){
return INSTANCE;
}
public class Container{
// Contains the position and block lists!
public Vector3 Pos1;
public Vector3 Pos2;
public List<StoredBlock> blocks;
public ServerLevel lvl;
private int tick = 0;
public void tick(){
this.tick--;
}
public boolean isExpired(){
if(tick <= 0){
return true;
}else return false;
}
public Container(){
tick = 15000;
Pos1 = OTEMod.ZERO_VECTOR;
Pos2 = OTEMod.ZERO_VECTOR;
}
public void reset(){
tick=15000;
}
}
private Map<UUID, Container> playerContainers = new HashMap<UUID,Container>();
private static final Lock lck = new ReentrantLock();
public static boolean hasPlayerCached(Player P)
{
lck.lock();
try{
UUID id = P.getUUID();
return get().playerContainers.containsKey(id);
}finally{
lck.unlock();
}
}
public static void tick()
{
lck.lock();
try{
Iterator<Map.Entry<UUID,Container>> imeuc = get().playerContainers.entrySet().iterator();
while(imeuc.hasNext())
{
Map.Entry<UUID,Container> entry = imeuc.next();
Container c = entry.getValue();
c.tick();
if(c.isExpired()){
imeuc.remove();
ChatHelpers.broadcastTo(entry.getKey(), ChatHelpers.macro(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!ZSchem Session expired")), c.lvl.getServer());
}
}
}finally{
lck.unlock();
}
}
private static void makeCachedPlayer(Player p){
if(!hasPlayerCached(p)){
Container c = INSTANCE.new Container();
get().playerContainers.put(p.getUUID(), c);
}
}
public static void setPos1(Player p, Vector3 pos)
{
makeCachedPlayer(p);
if(hasPlayerCached(p))
{
Container c = get().playerContainers.get(p.getUUID());
c.Pos1 = pos;
c.reset();
get().playerContainers.put(p.getUUID(), c);
}
}
public static void setLevel(Player p, ServerLevel lvl)
{
makeCachedPlayer(p);
if(hasPlayerCached(p))
{
Container c = get().playerContainers.get(p.getUUID());
c.lvl = lvl;
c.reset();
get().playerContainers.put(p.getUUID(), c);
}
}
public static void clear(Player p)
{
if(hasPlayerCached(p))
{
get().playerContainers.remove(p.getUUID());
}
}
public static void setPos2(Player p, Vector3 pos)
{
makeCachedPlayer(p);
if(hasPlayerCached(p))
{
Container c = get().playerContainers.get(p.getUUID());
c.Pos2 = pos;
c.reset();
get().playerContainers.put(p.getUUID(), c);
}
}
public static void setBlocks(Player p, List<StoredBlock> blk)
{
makeCachedPlayer(p);
if(hasPlayerCached(p))
{
Container c = get().playerContainers.get(p.getUUID());
c.blocks=blk;
c.reset();
get().playerContainers.put(p.getUUID(), c);
}
}
public static List<StoredBlock> getBlocks(Player p)
{
if(hasPlayerCached(p))
{
return get().playerContainers.get(p.getUUID()).blocks;
}else return new ArrayList<StoredBlock>();
}
public static Container getContainer(Player p)
{
if(hasPlayerCached(p)){
return get().playerContainers.get(p.getUUID());
}else return null;
}
}

View file

@ -1,167 +0,0 @@
package dev.zontreck.otemod.zschem;
import dev.zontreck.libzontreck.exceptions.InvalidDeserialization;
import dev.zontreck.libzontreck.vectors.Vector3;
import dev.zontreck.libzontreck.vectors.WorldPosition;
import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderGetter;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.nbt.Tag;
import net.minecraft.server.Bootstrap;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.generators.BlockStateProvider;
import net.minecraftforge.registries.RegistryManager;
public class StoredBlock
{
public CompoundTag blockData;
private WorldPosition position;
private BlockState state;
private CompoundTag blockEntity;
private int tick;
private int tries;
public void setPosition(Vector3 pos)
{
position.Position=pos;
}
public void updateWorld(ServerLevel lv)
{
position = new WorldPosition(position.Position, lv);
}
public void tick(){
this.tick--;
}
public void setTick(int tick){
this.tick=tick;
}
public boolean isExpired() {
return tick <= 0;
}
public void replaceBlockState(BlockState state)
{
this.state=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 position.Position.asBlockPos();
}
public final WorldPosition getWorldPosition()
{
return position;
}
public final BlockState getState()
{
return state;
}
public final long getChunkX()
{
Vector3 pos = position.Position;
return pos.rounded().x >> 4;
}
public final long getChunkZ()
{
Vector3 pos = position.Position;
return pos.rounded().z >> 4;
}
public void setBlockEntity(BlockEntity entity)
{
CompoundTag tag = entity.saveWithoutMetadata();
this.blockEntity=tag;
}
public final CompoundTag getBlockEntity(){
return blockEntity;
}
public static boolean hasBlockEntity(final CompoundTag tag){
return tag.contains("entity", Tag.TAG_COMPOUND);
}
public CompoundTag serialize()
{
final CompoundTag tag = new CompoundTag();
tag.put("pos", position.serialize());
tag.put("state", NbtUtils.writeBlockState(state));
tag.putInt("tick", tick);
tag.putInt("tries", tries);
if(blockEntity != null) tag.put("entity", blockEntity);
return tag;
}
public int getTries(){
return tries;
}
public int getTickValue()
{
return tick;
}
public void tickTries(){
tries++;
}
public void deserialize(final CompoundTag tag)
{
try {
position = new WorldPosition(tag.getCompound("pos"), false);
} catch (InvalidDeserialization e) {
e.printStackTrace();
}
HolderGetter<Block> hg = position.getActualDimension().holderLookup(Registries.BLOCK);
state = NbtUtils.readBlockState(hg, tag.getCompound("state"));
final CompoundTag tmp = tag.getCompound("entity");
blockEntity = tmp.isEmpty() ? null : tmp;
tick = tag.getInt("tick");
tries=tag.getInt("tries");
}
}

View file

@ -1,146 +0,0 @@
package dev.zontreck.otemod.zschem;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
import dev.zontreck.libzontreck.vectors.WorldPosition;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.event.level.ExplosionEvent;
public class WorldProp implements Supplier<Object>
{
public static Map<ServerLevel, WorldProp> props = new HashMap<ServerLevel,WorldProp>();
private Level world;
private BlockContainerList task;
public WorldProp(){
task = new BlockContainerList();
}
public void onTick()
{
task.tick();
}
public void onDetonate(ExplosionEvent ev)
{
Level w = ev.getLevel();
//int maxTicks = 0;
for(BlockPos p : ev.getExplosion().getToBlow())
{
BlockState bsExplode = w.getBlockState(p);
if(!isValid(bsExplode))continue;
if(!bsExplode.isAir() ){
//int ticks = OTEServerConfig.HEALER_TIMER.get() + maxTicks + OTEServerConfig.TIME_BETWEEN_BLOCKS.get();
//if(ticks<0) ticks = maxTicks + 10;
//maxTicks += 10;
int ticks = task.getNewLongestTick();
addHeal(p, bsExplode, world, ticks);
}
}
}
public void customEnqueue(StoredBlock sb)
{
int ticks = task.getNewLongestTick();
sb.setTick(ticks);
task.add(sb);
}
private void addHeal(BlockPos p, BlockState s, Level w, int tick)
{
StoredBlock sb = new StoredBlock(p, s, (ServerLevel)w);
sb.setTick(tick);
task.add(sb);
world.removeBlockEntity(p);
world.setBlock(p, Blocks.AIR.defaultBlockState(), 7);
}
private boolean isValid(BlockState bs)
{
if(bs.is(BlockTags.DOORS) || bs.is(BlockTags.BEDS) || bs.is(BlockTags.TALL_FLOWERS) || bs.is(Blocks.TNT)){
return false;
} else return true;
}
public static void SaveAll()
{
Path destBase = BlockSaver.getPath();
String ext = BlockSaver.getExtension();
for (Map.Entry<ServerLevel, WorldProp> entry : props.entrySet()) {
// Perform saving
String dimsafe = WorldPosition.getDimSafe(entry.getKey());
String pathTemp = destBase.toString()+"_"+dimsafe+ext;
Path finalPath = Path.of(pathTemp);
CompoundTag fnl = new CompoundTag();
fnl = entry.getValue().task.save(fnl);
try {
NbtIo.writeCompressed(fnl, finalPath.toFile());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public void load(CompoundTag tag)
{
task = BlockContainerList.load(tag);
}
public static WorldProp acquire(ServerLevel w)
{
if(props.containsKey(w))
{
return props.get(w);
}
Path destBase = BlockSaver.getPath();
String ext = BlockSaver.getExtension();
String dimsafe = WorldPosition.getDimSafe(w);
String pathTemp = destBase.toString()+"_"+dimsafe+ext;
Path finalPath = Path.of(pathTemp);
WorldProp nProp = new WorldProp();
nProp.world=w;
if(finalPath.toFile().exists())
{
try {
nProp.load(NbtIo.read(finalPath.toFile()));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
props.put(w,nProp);
return nProp;
}
@Override
public Object get()
{
return this;
}
}