Update libzontreck version, fix bugs in StoredBlocks
This commit is contained in:
parent
d65bbe2f06
commit
b4c73493d4
8 changed files with 37 additions and 38 deletions
|
@ -3,9 +3,9 @@
|
|||
org.gradle.jvmargs=-Xmx8G
|
||||
org.gradle.daemon=false
|
||||
|
||||
my_version=1.3.5.1
|
||||
my_version=1.3.5.3
|
||||
|
||||
mc_version=1.19.2
|
||||
forge_version=43.2.3
|
||||
libz_version=1.0.2.1
|
||||
libz_version=1.0.2.3
|
||||
luckperms_version=5.4
|
|
@ -49,9 +49,9 @@ public class OTEServerConfig {
|
|||
|
||||
BUILDER.pop();
|
||||
BUILDER.push("ANTIGRIEF").comment("AntiGrief Explosion Healing Events");
|
||||
HEALER_TIMER = BUILDER.comment("Time between healing events (In Milliseconds)").define("timer", 1000); // Should this be lower?
|
||||
HEALER_TIMER = BUILDER.comment("Time between healing events (In Milliseconds)").define("timer", 250); // Should this be lower?
|
||||
DEBUG_HEALER = BUILDER.comment("Whether or not to debug the healer engine. (Saves as SNBT instead of NBT)").define("debug", false);
|
||||
TIME_BETWEEN_BLOCKS = BUILDER.comment("The amount of time between restoring blocks (Maximum). This is in ticks").define("time_between", 250);
|
||||
TIME_BETWEEN_BLOCKS = BUILDER.comment("The amount of time between restoring blocks (Maximum). This is in ticks").define("time_between", 25);
|
||||
|
||||
MAX_TRIES_HEAL = BUILDER.comment("Maximum amount of retries to restore a block").define("max_tries", 6);
|
||||
|
||||
|
|
|
@ -30,6 +30,22 @@ public class BlockContainerList {
|
|||
return INSTANCE;
|
||||
}
|
||||
|
||||
public int getNewLongestTick()
|
||||
{
|
||||
//Random rng = new Random();
|
||||
int newLonger = OTEServerConfig.TIME_BETWEEN_BLOCKS.get();
|
||||
int cur = 0;
|
||||
|
||||
for (StoredBlock storedBlock : containers) {
|
||||
if(cur < storedBlock.getTickValue()){
|
||||
cur = storedBlock.getTickValue();
|
||||
}
|
||||
}
|
||||
if(cur == 0)cur = OTEServerConfig.HEALER_TIMER.get();
|
||||
|
||||
return cur + newLonger;
|
||||
}
|
||||
|
||||
public void add(StoredBlock item)
|
||||
{
|
||||
lock.lock();
|
||||
|
@ -67,7 +83,7 @@ public class BlockContainerList {
|
|||
isb.remove();
|
||||
}else {
|
||||
HealRunner.scheduleHeal(storedBlock);
|
||||
storedBlock.setTick(OTEServerConfig.HEALER_TIMER.get());
|
||||
storedBlock.setTick(getNewLongestTick());
|
||||
storedBlock.tickTries();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class BlockSaver {
|
|||
{
|
||||
|
||||
Path configDir = FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath());
|
||||
Path configFile = null;
|
||||
//Path configFile = null;
|
||||
return configDir.resolve("ote_queue");
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.level.ExplosionEvent;
|
||||
import net.minecraftforge.event.level.LevelEvent;
|
||||
|
@ -18,7 +17,7 @@ public class EventHandler {
|
|||
{
|
||||
if(ev.getLevel().isClientSide)return;
|
||||
|
||||
Entity explodes = ev.getExplosion().getSourceMob();
|
||||
//Entity explodes = ev.getExplosion().getSourceMob();
|
||||
// Register blocks to be healed
|
||||
WorldProp wp = WorldProp.acquire((ServerLevel)ev.getLevel());
|
||||
if(wp!=null){
|
||||
|
|
|
@ -110,6 +110,10 @@ public class StoredBlock
|
|||
public int getTries(){
|
||||
return tries;
|
||||
}
|
||||
public int getTickValue()
|
||||
{
|
||||
return tick;
|
||||
}
|
||||
|
||||
public void tickTries(){
|
||||
tries++;
|
||||
|
|
|
@ -1,33 +1,22 @@
|
|||
package dev.zontreck.otemod.zschem;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Dictionary;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
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.minecraft.world.level.saveddata.SavedData;
|
||||
import net.minecraft.world.level.storage.DimensionDataStorage;
|
||||
import net.minecraftforge.event.level.ExplosionEvent;
|
||||
|
||||
public class WorldProp implements Supplier<Object>
|
||||
|
@ -35,7 +24,6 @@ public class WorldProp implements Supplier<Object>
|
|||
public static Map<ServerLevel, WorldProp> props = new HashMap<ServerLevel,WorldProp>();
|
||||
private Level world;
|
||||
private BlockContainerList task;
|
||||
static final String KEY = OTEMod.MOD_ID + ":" + WorldProp.class.getSimpleName();
|
||||
|
||||
public WorldProp(){
|
||||
task = new BlockContainerList();
|
||||
|
@ -49,7 +37,7 @@ public class WorldProp implements Supplier<Object>
|
|||
public void onDetonate(ExplosionEvent.Detonate ev)
|
||||
{
|
||||
Level w = ev.getLevel();
|
||||
int maxTicks = 0;
|
||||
//int maxTicks = 0;
|
||||
|
||||
for(BlockPos p : ev.getAffectedBlocks())
|
||||
{
|
||||
|
@ -57,9 +45,10 @@ public class WorldProp implements Supplier<Object>
|
|||
if(!isValid(bsExplode))continue;
|
||||
|
||||
if(!bsExplode.isAir() ){
|
||||
int ticks = OTEServerConfig.HEALER_TIMER.get() + maxTicks + OTEServerConfig.TIME_BETWEEN_BLOCKS.get();
|
||||
if(ticks<0) ticks = maxTicks + OTEServerConfig.TIME_BETWEEN_BLOCKS.get();
|
||||
maxTicks += OTEServerConfig.TIME_BETWEEN_BLOCKS.get();
|
||||
//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);
|
||||
|
@ -91,7 +80,8 @@ public class WorldProp implements Supplier<Object>
|
|||
|
||||
for (Map.Entry<ServerLevel, WorldProp> entry : props.entrySet()) {
|
||||
// Perform saving
|
||||
String dimsafe = entry.getKey().dimension().location().getNamespace() +"-"+entry.getKey().dimension().location().getPath();
|
||||
WorldPosition wp = new WorldPosition(new Vector3(), entry.getKey());
|
||||
String dimsafe = wp.DimSafe;
|
||||
String pathTemp = destBase.toString()+"_"+dimsafe+ext;
|
||||
|
||||
Path finalPath = Path.of(pathTemp);
|
||||
|
@ -120,7 +110,8 @@ public class WorldProp implements Supplier<Object>
|
|||
}
|
||||
Path destBase = BlockSaver.getPath();
|
||||
String ext = BlockSaver.getExtension();
|
||||
String dimsafe = w.dimension().location().getNamespace() +"-"+w.dimension().location().getPath();
|
||||
WorldPosition wp = new WorldPosition(new Vector3(), w);
|
||||
String dimsafe = wp.DimSafe;
|
||||
String pathTemp = destBase.toString()+"_"+dimsafe+ext;
|
||||
|
||||
Path finalPath = Path.of(pathTemp);
|
||||
|
@ -141,17 +132,6 @@ public class WorldProp implements Supplier<Object>
|
|||
|
||||
props.put(w,nProp);
|
||||
return nProp;
|
||||
/*DimensionDataStorage dds = w.getDataStorage();
|
||||
WorldProp wp = dds.computeIfAbsent(p->{
|
||||
WorldProp swp = new WorldProp();
|
||||
swp.load(p);
|
||||
return swp;
|
||||
}, ()->{
|
||||
return new WorldProp();
|
||||
}, KEY);
|
||||
wp.world = w;
|
||||
return wp;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
# ${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
|
||||
version="1.3.5.1" #mandatory
|
||||
version="1.3.5.3" #mandatory
|
||||
# A display name for the mod
|
||||
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/
|
||||
|
|
Reference in a new issue