Add a new block: Clear Glass

Finalizes changes to healing system
This commit is contained in:
Zontreck 2022-10-17 03:48:42 -07:00
parent 3b6caf1a03
commit 91eb2a2e43
10 changed files with 109 additions and 49 deletions

View file

@ -65,7 +65,7 @@ public class Handler
{
// Check an exclusions list
if(!OTEServerConfig.EXCLUDE_DIMENSIONS.get().contains(data.getWorldPosition().Dimension))
if(!data.getState().isAir() && !data.getState().is(tnt))
if(!data.getState().is(tnt))
toHeal.add(data);
}

View file

@ -58,6 +58,7 @@ public class HealerManager implements Runnable
}
HealerQueue.ToValidate.clear();
OTEMod.LOGGER.info("Validation of restore completed");
continue;
}
@ -70,7 +71,10 @@ public class HealerManager implements Runnable
// Remove the block from the queue now to prevent further issues
HealerQueue.ToHeal.remove(sb);
HealerQueue.ToValidate.add(sb);
if( !HealerQueue.ToValidate.add(sb) )
{
OTEMod.LOGGER.info("Failed to add Block to Validation queue!!! Verification of restore will not work");
}
// Healer object should have been added to the validation list
@ -108,14 +112,11 @@ public class HealerManager implements Runnable
if(OTEServerConfig.DEBUG_HEALER.get())
try {
HealerQueue.dump();
} catch (IOException e) {
e.printStackTrace();
}
HealerQueue.Shuffle();
try {
HealerQueue.dump();
} catch (IOException e) {
e.printStackTrace();
}
}
OTEMod.LOGGER.info("Tearing down healer jobs. Saving remaining queue, stand by...");

View file

@ -45,55 +45,60 @@ public class HealerQueue {
configFile = configDir.resolve(HealerQueue.HealerQueueFile);
}
OTEMod.LOGGER.info("OTE HEALER TEMPORARY FILE: "+configFile.toFile().getAbsolutePath());
//OTEMod.LOGGER.info("OTE HEALER TEMPORARY FILE: "+configFile.toFile().getAbsolutePath());
return configFile;
}
public static void Initialize()
{
if(OTEServerConfig.DEBUG_HEALER.get())
{
// Load the sNBT file
Path configFile = getPath();
File x = configFile.toFile();
String FinalStr = "";
try {
BufferedReader br = new BufferedReader(new FileReader(x));
while(br.ready())
Thread tx = new Thread(new Runnable(){
public void run(){
if(OTEServerConfig.DEBUG_HEALER.get())
{
FinalStr += br.readLine();
FinalStr += "\n";
// Load the sNBT file
Path configFile = getPath();
File x = configFile.toFile();
String FinalStr = "";
try {
BufferedReader br = new BufferedReader(new FileReader(x));
while(br.ready())
{
FinalStr += br.readLine();
}
br.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch(IOException e)
{
e.printStackTrace();
}
try {
HealerQueue.deserialize(NbtUtils.snbtToStructure(FinalStr));
} catch (CommandSyntaxException e) {
e.printStackTrace();
}
} else {
// Load from normal NBT
Path configFile = getPath();
File x = configFile.toFile();
// Load binary
try {
CompoundTag tag = NbtIo.readCompressed(x);
HealerQueue.deserialize(tag);
} catch (IOException e) {
e.printStackTrace();
}
}
br.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch(IOException e)
{
e.printStackTrace();
}
try {
HealerQueue.deserialize(NbtUtils.snbtToStructure(FinalStr));
} catch (CommandSyntaxException e) {
e.printStackTrace();
}
} else {
// Load from normal NBT
Path configFile = getPath();
File x = configFile.toFile();
// Load binary
try {
CompoundTag tag = NbtIo.readCompressed(x);
HealerQueue.deserialize(tag);
} catch (IOException e) {
e.printStackTrace();
}
}
});
tx.start();
// Set up the HealerManager / Runner
Thread tx = new Thread(new HealerManager());
tx.start();
Thread txx = new Thread(new HealerManager());
txx.start();
}
public static CompoundTag serialize()
@ -108,12 +113,14 @@ public class HealerQueue {
ListTag lst2 = new ListTag();
for(final StoredBlock block : HealerQueue.ToValidate)
{
lst.add(block.serialize());
lst2.add(block.serialize());
}
tag.put("queue", lst);
tag.put("validate", lst2);
//OTEMod.LOGGER.info("HEAL ["+HealerQueue.ToHeal.size()+"] / VALIDATE ["+HealerQueue.ToValidate.size()+"]");
// OK
return tag;
@ -135,7 +142,14 @@ public class HealerQueue {
StoredBlock sb = new StoredBlock(stored);
HealerQueue.ToHeal.add(sb);
}
}
OTEMod.LOGGER.info("Finished loading the queue");
if(tag.contains("validate"))
{
HealerQueue.ToValidate.clear();
ListTag items2 = tag.getList("validate", Tag.TAG_COMPOUND);
for(int i=0;i<items2.size();i++)
{
@ -144,6 +158,8 @@ public class HealerQueue {
HealerQueue.ToValidate.add(sb);
}
}
OTEMod.LOGGER.info("Finished loading validation queue for healer");
}
public static void dump() throws IOException
{

View file

@ -42,4 +42,9 @@ 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<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<Item> CLEAR_GLASS_BLOCK_I = ITEMS.register("clear_glass_block", () -> new BlockItem(CLEAR_GLASS_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
}