Blood Magic

Blood Magic

94M Downloads

TileSpectral

Reaviik opened this issue ยท 8 comments

commented

Issue Description:

Note: If this bug occurs in a modpack, please report this to the modpack author. Otherwise, delete this line and add your description here. If this is a feature request, this template does not apply to you. Just delete everything.

What happens: An error in the TileSpectral block prohibits sending and rendering the chunk where it is to the client

What you expected to happen:

Steps to reproduce:

  1. It happens occasionally, as I own a server and several players reported this error to me, I bring it here. Not even WorldEdit can replace the block. however, this block appears in places where players had not yet started playing blood magic

  2. This server is running Arclight version arclight-1.20.1-1.0.4-fd335c1 (MC: 1.20.1) (Implementing API version 1.20.1-R0.1-SNAPSHOT)
    ...


Affected Versions (Do not use "latest"):

  • BloodMagic: 1.20.1-3.3.2-44
  • Minecraft: 1.20.1
  • Forge: 47.0.20
commented

Sorry about my English. Is there any way to remove this block through the mod? or get his coordinates

commented

I got a command from ATM's redit to remove the blocks, from the sigil of suppression
/fill ~-10 ~-10 ~-10 ~25 ~14 ~25 minecraft:air replace bloodmagic:spectral
apparently happens when there are more than 1000 blocks

commented

We are having similar issue with this block on our server. It corrupted earlier and was restricting players from logging on. Please could this be fixed? Also that block has missing texture fyi.

commented

Running into the same problem. Anyone have any solutions?

commented

I'm also experiencing this issue while using 1.20.1-3.3.3.45 in ATM9 (also Forge 47.2.20). I've been successful in using Reaviik's command to remove some of the offending blocks from around the server, but the warnings have completely eclipsed my console and the corrupted areas are causing players to fail to render nearby chunks or be disconnected outright.

commented

I'm unable to upload a patch file. But for those who know how to make a build and apply a git patch.

It's not a good way to resolve it. But it does the trick on my server .. Not sure if it is breaking any logic.
Only required on the server.

diff --git a/src/main/java/wayoftime/bloodmagic/common/tile/TileSpectral.java b/src/main/java/wayoftime/bloodmagic/common/tile/TileSpectral.java
index e78e24861..1579f5767 100644
--- a/src/main/java/wayoftime/bloodmagic/common/tile/TileSpectral.java
+++ b/src/main/java/wayoftime/bloodmagic/common/tile/TileSpectral.java
@@ -6,6 +6,7 @@ import net.minecraft.nbt.CompoundTag;
 import net.minecraft.nbt.NbtUtils;
 import net.minecraft.world.level.Level;
 import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.Blocks;
 import net.minecraft.world.level.block.LiquidBlock;
 import net.minecraft.world.level.block.entity.BlockEntity;
 import net.minecraft.world.level.block.entity.BlockEntityType;
@@ -55,7 +56,12 @@ public class TileSpectral extends TileBase
 
 	public void revertToFluid()
 	{
-		level.setBlock(worldPosition, storedBlock, 3);
+		if (storedBlock != null) {
+			level.setBlock(worldPosition, storedBlock, 3);
+		} else {
+			com.mojang.logging.LogUtils.getLogger().error("Removing spectral with air at {}", worldPosition.toString());
+			level.setBlock(worldPosition, Blocks.AIR.defaultBlockState(), 20);
+		}
 //		BlockState fluidState = Block.getStateById(meta);
 	}
 
@@ -67,19 +73,24 @@ public class TileSpectral extends TileBase
 	public void setContainedBlockInfo(BlockState state)
 	{
 		storedBlock = state;
-
 	}
 
 	@Override
 	public void deserialize(CompoundTag tag)
 	{
-		storedBlock = NbtUtils.readBlockState(this.level.holderLookup(Registries.BLOCK), tag.getCompound("BlockState"));
+		try {
+			storedBlock = NbtUtils.readBlockState(this.level.holderLookup(Registries.BLOCK), tag.getCompound("BlockState"));
+		} catch (Exception ignored) {
+		}
 	}
 
 	@Override
 	public CompoundTag serialize(CompoundTag tag)
 	{
-		tag.put("BlockState", NbtUtils.writeBlockState(storedBlock));
+		try {
+			tag.put("BlockState", NbtUtils.writeBlockState(storedBlock));
+		} catch (Exception ignored) {
+		}
 		return tag;
 	}
 }
commented

I'm unable to upload a patch file. But for those who know how to make a build and apply a git patch.

It's not a good way to resolve it. But it does the trick on my server .. Not sure if it is breaking any logic. Only required on the server.

diff --git a/src/main/java/wayoftime/bloodmagic/common/tile/TileSpectral.java b/src/main/java/wayoftime/bloodmagic/common/tile/TileSpectral.java
index e78e24861..1579f5767 100644
--- a/src/main/java/wayoftime/bloodmagic/common/tile/TileSpectral.java
+++ b/src/main/java/wayoftime/bloodmagic/common/tile/TileSpectral.java
@@ -6,6 +6,7 @@ import net.minecraft.nbt.CompoundTag;
 import net.minecraft.nbt.NbtUtils;
 import net.minecraft.world.level.Level;
 import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.Blocks;
 import net.minecraft.world.level.block.LiquidBlock;
 import net.minecraft.world.level.block.entity.BlockEntity;
 import net.minecraft.world.level.block.entity.BlockEntityType;
@@ -55,7 +56,12 @@ public class TileSpectral extends TileBase
 
 	public void revertToFluid()
 	{
-		level.setBlock(worldPosition, storedBlock, 3);
+		if (storedBlock != null) {
+			level.setBlock(worldPosition, storedBlock, 3);
+		} else {
+			com.mojang.logging.LogUtils.getLogger().error("Removing spectral with air at {}", worldPosition.toString());
+			level.setBlock(worldPosition, Blocks.AIR.defaultBlockState(), 20);
+		}
 //		BlockState fluidState = Block.getStateById(meta);
 	}
 
@@ -67,19 +73,24 @@ public class TileSpectral extends TileBase
 	public void setContainedBlockInfo(BlockState state)
 	{
 		storedBlock = state;
-
 	}
 
 	@Override
 	public void deserialize(CompoundTag tag)
 	{
-		storedBlock = NbtUtils.readBlockState(this.level.holderLookup(Registries.BLOCK), tag.getCompound("BlockState"));
+		try {
+			storedBlock = NbtUtils.readBlockState(this.level.holderLookup(Registries.BLOCK), tag.getCompound("BlockState"));
+		} catch (Exception ignored) {
+		}
 	}
 
 	@Override
 	public CompoundTag serialize(CompoundTag tag)
 	{
-		tag.put("BlockState", NbtUtils.writeBlockState(storedBlock));
+		try {
+			tag.put("BlockState", NbtUtils.writeBlockState(storedBlock));
+		} catch (Exception ignored) {
+		}
 		return tag;
 	}
 }

Patch threw an error when trying to apply. Here is my manual application of this patch for anyone else who is going down this blood magic rabbit hole:

package wayoftime.bloodmagic.common.tile;

import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import wayoftime.bloodmagic.common.block.BlockSpectral;
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
import wayoftime.bloodmagic.common.block.type.SpectralBlockType;
import wayoftime.bloodmagic.common.tile.base.TileBase;

public class TileSpectral extends TileBase
{
	public BlockState storedBlock;

	public TileSpectral(BlockEntityType<?> type, BlockPos pos, BlockState state)
	{
		super(type, pos, state);
	}

	public TileSpectral(BlockPos pos, BlockState state)
	{
		this(BloodMagicTileEntities.SPECTRAL_TYPE.get(), pos, state);
	}

	public static void createOrRefreshSpectralBlock(Level world, BlockPos pos)
	{
		if (world.isEmptyBlock(pos))
		{
			return;
		}

		BlockState potentialFluidBlockState = world.getBlockState(pos);

		if (isFluidBlock(potentialFluidBlockState.getBlock()))
		{
			world.setBlock(pos, BloodMagicBlocks.SPECTRAL.get().defaultBlockState(), 3);
			BlockEntity spectralTile = world.getBlockEntity(pos);
			if (spectralTile instanceof TileSpectral)
			{
				((TileSpectral) spectralTile).setContainedBlockInfo(potentialFluidBlockState);
				world.scheduleTick(pos, spectralTile.getBlockState().getBlock(), BlockSpectral.DECAY_RATE);
			}
		} else if (potentialFluidBlockState.getBlock() == BloodMagicBlocks.SPECTRAL.get() && potentialFluidBlockState.getValue(BlockSpectral.SPECTRAL_STATE) == SpectralBlockType.LEAKING)
		{
			world.setBlock(pos, BloodMagicBlocks.SPECTRAL.get().defaultBlockState(), 0);
		}
	}

	public void revertToFluid()
	{
		if (storedBlock != null) {
			level.setBlock(worldPosition, storedBlock, 3);
		} else {
			com.mojang.logging.LogUtils.getLogger().error("Removing spectral with air at {}", worldPosition.toString());
			level.setBlock(worldPosition, Blocks.AIR.defaultBlockState(), 20);
		}
//		BlockState fluidState = Block.getStateById(meta);
	}

	public static boolean isFluidBlock(Block block)
	{
		return block instanceof LiquidBlock;
	}

	public void setContainedBlockInfo(BlockState state)
	{
		storedBlock = state;
	}

	@Override
	public void deserialize(CompoundTag tag)
	{
		try {
			storedBlock = NbtUtils.readBlockState(this.level.holderLookup(Registries.BLOCK), tag.getCompound("BlockState"));
		} catch (Exception ignored) {
		}
	}

	@Override
	public CompoundTag serialize(CompoundTag tag)
	{
		try {
			tag.put("BlockState", NbtUtils.writeBlockState(storedBlock));
		} catch (Exception ignored) {
		}
		return tag;
	}
}

commented

I'm unable to upload a patch file. But for those who know how to make a build and apply a git patch.
It's not a good way to resolve it. But it does the trick on my server .. Not sure if it is breaking any logic. Only required on the server.

diff --git a/src/main/java/wayoftime/bloodmagic/common/tile/TileSpectral.java b/src/main/java/wayoftime/bloodmagic/common/tile/TileSpectral.java
index e78e24861..1579f5767 100644
--- a/src/main/java/wayoftime/bloodmagic/common/tile/TileSpectral.java
+++ b/src/main/java/wayoftime/bloodmagic/common/tile/TileSpectral.java
@@ -6,6 +6,7 @@ import net.minecraft.nbt.CompoundTag;
 import net.minecraft.nbt.NbtUtils;
 import net.minecraft.world.level.Level;
 import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.Blocks;
 import net.minecraft.world.level.block.LiquidBlock;
 import net.minecraft.world.level.block.entity.BlockEntity;
 import net.minecraft.world.level.block.entity.BlockEntityType;
@@ -55,7 +56,12 @@ public class TileSpectral extends TileBase
 
 	public void revertToFluid()
 	{
-		level.setBlock(worldPosition, storedBlock, 3);
+		if (storedBlock != null) {
+			level.setBlock(worldPosition, storedBlock, 3);
+		} else {
+			com.mojang.logging.LogUtils.getLogger().error("Removing spectral with air at {}", worldPosition.toString());
+			level.setBlock(worldPosition, Blocks.AIR.defaultBlockState(), 20);
+		}
 //		BlockState fluidState = Block.getStateById(meta);
 	}
 
@@ -67,19 +73,24 @@ public class TileSpectral extends TileBase
 	public void setContainedBlockInfo(BlockState state)
 	{
 		storedBlock = state;
-
 	}
 
 	@Override
 	public void deserialize(CompoundTag tag)
 	{
-		storedBlock = NbtUtils.readBlockState(this.level.holderLookup(Registries.BLOCK), tag.getCompound("BlockState"));
+		try {
+			storedBlock = NbtUtils.readBlockState(this.level.holderLookup(Registries.BLOCK), tag.getCompound("BlockState"));
+		} catch (Exception ignored) {
+		}
 	}
 
 	@Override
 	public CompoundTag serialize(CompoundTag tag)
 	{
-		tag.put("BlockState", NbtUtils.writeBlockState(storedBlock));
+		try {
+			tag.put("BlockState", NbtUtils.writeBlockState(storedBlock));
+		} catch (Exception ignored) {
+		}
 		return tag;
 	}
 }

Patch threw an error when trying to apply. Here is my manual application of this patch for anyone else who is going down this blood magic rabbit hole:

package wayoftime.bloodmagic.common.tile;

import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import wayoftime.bloodmagic.common.block.BlockSpectral;
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
import wayoftime.bloodmagic.common.block.type.SpectralBlockType;
import wayoftime.bloodmagic.common.tile.base.TileBase;

public class TileSpectral extends TileBase
{
	public BlockState storedBlock;

	public TileSpectral(BlockEntityType<?> type, BlockPos pos, BlockState state)
	{
		super(type, pos, state);
	}

	public TileSpectral(BlockPos pos, BlockState state)
	{
		this(BloodMagicTileEntities.SPECTRAL_TYPE.get(), pos, state);
	}

	public static void createOrRefreshSpectralBlock(Level world, BlockPos pos)
	{
		if (world.isEmptyBlock(pos))
		{
			return;
		}

		BlockState potentialFluidBlockState = world.getBlockState(pos);

		if (isFluidBlock(potentialFluidBlockState.getBlock()))
		{
			world.setBlock(pos, BloodMagicBlocks.SPECTRAL.get().defaultBlockState(), 3);
			BlockEntity spectralTile = world.getBlockEntity(pos);
			if (spectralTile instanceof TileSpectral)
			{
				((TileSpectral) spectralTile).setContainedBlockInfo(potentialFluidBlockState);
				world.scheduleTick(pos, spectralTile.getBlockState().getBlock(), BlockSpectral.DECAY_RATE);
			}
		} else if (potentialFluidBlockState.getBlock() == BloodMagicBlocks.SPECTRAL.get() && potentialFluidBlockState.getValue(BlockSpectral.SPECTRAL_STATE) == SpectralBlockType.LEAKING)
		{
			world.setBlock(pos, BloodMagicBlocks.SPECTRAL.get().defaultBlockState(), 0);
		}
	}

	public void revertToFluid()
	{
		if (storedBlock != null) {
			level.setBlock(worldPosition, storedBlock, 3);
		} else {
			com.mojang.logging.LogUtils.getLogger().error("Removing spectral with air at {}", worldPosition.toString());
			level.setBlock(worldPosition, Blocks.AIR.defaultBlockState(), 20);
		}
//		BlockState fluidState = Block.getStateById(meta);
	}

	public static boolean isFluidBlock(Block block)
	{
		return block instanceof LiquidBlock;
	}

	public void setContainedBlockInfo(BlockState state)
	{
		storedBlock = state;
	}

	@Override
	public void deserialize(CompoundTag tag)
	{
		try {
			storedBlock = NbtUtils.readBlockState(this.level.holderLookup(Registries.BLOCK), tag.getCompound("BlockState"));
		} catch (Exception ignored) {
		}
	}

	@Override
	public CompoundTag serialize(CompoundTag tag)
	{
		try {
			tag.put("BlockState", NbtUtils.writeBlockState(storedBlock));
		} catch (Exception ignored) {
		}
		return tag;
	}
}

How i can apply this patch? What file i need and where do i put it?