Demon Crucible implementation

Readded the Demon Crucible to test the World's Will Chunk saving/loading.
This commit is contained in:
WayofTime 2020-11-03 17:23:44 -05:00
parent bacd3d27f2
commit 5e8437fe58
19 changed files with 993 additions and 487 deletions

View file

@ -2,7 +2,7 @@ package wayoftime.bloodmagic.demonaura;
import java.lang.ref.WeakReference;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunk;
import wayoftime.bloodmagic.will.DemonWillHolder;
public class WillChunk
@ -10,14 +10,14 @@ public class WillChunk
PosXY loc;
private short base;
private DemonWillHolder currentWill = new DemonWillHolder();
private WeakReference<Chunk> chunkRef;
private WeakReference<IChunk> chunkRef;
public WillChunk(PosXY loc)
{
this.loc = loc;
}
public WillChunk(Chunk chunk, short base, DemonWillHolder currentWill)
public WillChunk(IChunk chunk, short base, DemonWillHolder currentWill)
{
this.loc = new PosXY(chunk.getPos().x, chunk.getPos().z);
this.chunkRef = new WeakReference(chunk);
@ -60,12 +60,12 @@ public class WillChunk
this.currentWill = currentWill;
}
public WeakReference<Chunk> getChunkRef()
public WeakReference<IChunk> getChunkRef()
{
return chunkRef;
}
public void setChunkRef(WeakReference<Chunk> chunkRef)
public void setChunkRef(WeakReference<IChunk> chunkRef)
{
this.chunkRef = chunkRef;
}

View file

@ -9,6 +9,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunk;
import wayoftime.bloodmagic.util.BMLog;
import wayoftime.bloodmagic.will.DemonWillHolder;
import wayoftime.bloodmagic.will.EnumDemonWillType;
@ -35,9 +36,9 @@ public class WorldDemonWillHandler
return getWillHolder(getDimensionResourceLocation(world), pos.getX() >> 4, pos.getZ() >> 4);
}
public static WillWorld getWillWorld(int dim)
public static WillWorld getWillWorld(ResourceLocation rl)
{
return containedWills.get(dim);
return containedWills.get(rl);
}
@Nullable
@ -60,13 +61,13 @@ public class WorldDemonWillHandler
}
}
public static void removeWillWorld(int dim)
public static void removeWillWorld(ResourceLocation rl)
{
containedWills.remove(dim);
BMLog.DEBUG.info("Removing demon will cache for world {}", dim);
containedWills.remove(rl);
BMLog.DEBUG.info("Removing demon will cache for world {}", rl);
}
public static void addWillChunk(ResourceLocation resourceLocation, Chunk chunk, short base, DemonWillHolder currentWill)
public static void addWillChunk(ResourceLocation resourceLocation, IChunk chunk, short base, DemonWillHolder currentWill)
{
WillWorld aw = containedWills.get(resourceLocation);
if (aw == null)
@ -167,7 +168,7 @@ public class WorldDemonWillHandler
if (willChunk == null)
{
Chunk chunk = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
generateWill(chunk);
generateWill(chunk, world);
willChunk = getWillChunk(getDimensionResourceLocation(world), pos.getX() >> 4, pos.getZ() >> 4);
}
@ -206,13 +207,14 @@ public class WorldDemonWillHandler
}
}
public static void generateWill(Chunk chunk)
public static void generateWill(IChunk chunk, World world)
{
addWillChunk(chunk.getWorld().getDimensionKey().getLocation(), chunk, (short) 1, new DemonWillHolder());
addWillChunk(getDimensionResourceLocation(world), chunk, (short) 1, new DemonWillHolder());
}
private static ResourceLocation getDimensionResourceLocation(World world)
public static ResourceLocation getDimensionResourceLocation(World world)
{
return world.getDimensionKey().getLocation();
}
}