From eb7c01ad7b0681346660e6fd9009a0467636ca32 Mon Sep 17 00:00:00 2001 From: Timo Ley Date: Sat, 21 Jan 2023 22:58:54 +0100 Subject: [PATCH] feat: basic node synergy --- LICENSE | 7 ++ .../java/dev/tilera/auracore/AuraCore.java | 2 + src/main/java/dev/tilera/auracore/Config.java | 4 ++ .../auracore/client/AuraManagerClient.java | 2 + .../auracore/client/RenderEventHandler.java | 1 + .../tilera/auracore/mixins/MixinTileNode.java | 65 +++++++++++++++++++ .../tilera/auracore/network/AuraPacket.java | 4 ++ .../tilera/auracore/world/WorldGenerator.java | 24 ++++++- src/main/resources/auracore.mixins.json | 1 + 9 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 LICENSE create mode 100644 src/main/java/dev/tilera/auracore/mixins/MixinTileNode.java diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d6d4f45 --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright 2023 Timo Ley + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/src/main/java/dev/tilera/auracore/AuraCore.java b/src/main/java/dev/tilera/auracore/AuraCore.java index dc450d6..ce5fced 100644 --- a/src/main/java/dev/tilera/auracore/AuraCore.java +++ b/src/main/java/dev/tilera/auracore/AuraCore.java @@ -79,6 +79,8 @@ public class AuraCore { ConfigBlocks.blockCrystal.setTickRandomly(true); Recipes.initRecipes(); NetworkRegistry.INSTANCE.registerGuiHandler(this, proxy); + thaumcraft.common.config.Config.genStructure = false; + thaumcraft.common.config.Config.genAura = false; } @Mod.EventHandler diff --git a/src/main/java/dev/tilera/auracore/Config.java b/src/main/java/dev/tilera/auracore/Config.java index 5d9e935..2a103ad 100644 --- a/src/main/java/dev/tilera/auracore/Config.java +++ b/src/main/java/dev/tilera/auracore/Config.java @@ -10,10 +10,12 @@ public class Config { private static Configuration config = new Configuration(new File(Loader.instance().getConfigDir(), "AuraCore.cfg")); public static int nodeRarity = 23; public static int specialNodeRarity = 75; + public static int newNodeRarity = 20; public static boolean replaceSilverwood = true; public static boolean knowAllAspects = true; public static boolean replaceAspects = true; public static boolean legacyAspects = false; + public static boolean generateEldritchRing = true; public static boolean noScanning() { return knowAllAspects; @@ -23,10 +25,12 @@ public class Config { config.load(); nodeRarity = config.get("worldgen", "nodeRarity", nodeRarity).getInt(nodeRarity); specialNodeRarity = config.get("worldgen", "specialNodeRarity", specialNodeRarity).getInt(specialNodeRarity); + newNodeRarity = config.getInt("newNodeRarity", "worldgen", newNodeRarity, -1, Integer.MAX_VALUE, "Rarity of TC4 nodes generating instead of TC3 nodes (-1 to disable TC4 nodes)"); replaceSilverwood = config.getBoolean("replaceSilverwood", "worldgen", replaceSilverwood, "Replace Silverwood trees with TC3 Silverwood"); knowAllAspects = config.getBoolean("knowAllAspects", "research", knowAllAspects, "Know all Aspects from beginning"); replaceAspects = config.getBoolean("replaceAspects", "client", replaceAspects, "Replace some aspect textures"); legacyAspects = config.getBoolean("legacyAspects", "aspects", legacyAspects, "Use TC3 item aspects"); + generateEldritchRing = config.getBoolean("generateEldritchRing", "worldgen", generateEldritchRing, "Generate Eldritch Ring structures"); config.save(); } diff --git a/src/main/java/dev/tilera/auracore/client/AuraManagerClient.java b/src/main/java/dev/tilera/auracore/client/AuraManagerClient.java index 0e47535..cc12f2f 100644 --- a/src/main/java/dev/tilera/auracore/client/AuraManagerClient.java +++ b/src/main/java/dev/tilera/auracore/client/AuraManagerClient.java @@ -33,6 +33,7 @@ public class AuraManagerClient { public boolean lock; public byte type; public int dimension; + public boolean isVirtual; public NodeStats(AuraPacket packet, int dimension) { key = packet.key; @@ -46,6 +47,7 @@ public class AuraManagerClient { lock = packet.lock; type = packet.type; this.dimension = dimension; + this.isVirtual = packet.virtual; } } diff --git a/src/main/java/dev/tilera/auracore/client/RenderEventHandler.java b/src/main/java/dev/tilera/auracore/client/RenderEventHandler.java index 1771114..65ba02f 100644 --- a/src/main/java/dev/tilera/auracore/client/RenderEventHandler.java +++ b/src/main/java/dev/tilera/auracore/client/RenderEventHandler.java @@ -56,6 +56,7 @@ public class RenderEventHandler { int limit = 0; Collection col = AuraManagerClient.auraClientList.values(); for (NodeStats l : col) { + if (l.isVirtual) continue; float px = (float) l.x; float py = (float) l.y; float pz = (float) l.z; diff --git a/src/main/java/dev/tilera/auracore/mixins/MixinTileNode.java b/src/main/java/dev/tilera/auracore/mixins/MixinTileNode.java new file mode 100644 index 0000000..62eb8e5 --- /dev/null +++ b/src/main/java/dev/tilera/auracore/mixins/MixinTileNode.java @@ -0,0 +1,65 @@ +package dev.tilera.auracore.mixins; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import dev.tilera.auracore.api.EnumNodeType; +import dev.tilera.auracore.aura.AuraManager; +import net.minecraft.nbt.NBTTagCompound; +import thaumcraft.api.TileThaumcraft; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.api.nodes.NodeType; +import thaumcraft.common.tiles.TileNode; + +@Mixin(TileNode.class) +public abstract class MixinTileNode extends TileThaumcraft { + + @Shadow(remap = false) + private NodeType nodeType; + @Shadow(remap = false) + AspectList aspectsBase; + int virtualNodeID = -1; + + @Inject(method = "writeCustomNBT", at = @At("HEAD"), remap = false) + public void onNBTWrite(NBTTagCompound nbt, CallbackInfo ci) { + nbt.setInteger("virtualNodeID", this.virtualNodeID); + } + + @Inject(method = "readCustomNBT", at = @At("HEAD"), remap = false) + public void onNBTRead(NBTTagCompound nbt, CallbackInfo ci) { + if (nbt.hasKey("virtualNodeID")) { + this.virtualNodeID = nbt.getInteger("virtualNodeID"); + } + } + + @Inject(method = "updateEntity", at = @At("HEAD")) + public void onTick(CallbackInfo ci) { + if (virtualNodeID == -1) { + this.createVirtualNode(); + } + } + + private void createVirtualNode() { + EnumNodeType type = convertNodeType(nodeType); + virtualNodeID = AuraManager.registerAuraNode(this.worldObj, (short)aspectsBase.visSize(), type, this.worldObj.provider.dimensionId, this.xCoord, this.yCoord, this.zCoord, true); + } + + private static EnumNodeType convertNodeType(NodeType type) { + switch (type) { + case TAINTED: + case DARK: + return EnumNodeType.DARK; + case PURE: + return EnumNodeType.PURE; + case HUNGRY: + case UNSTABLE: + return EnumNodeType.UNSTABLE; + default: + return EnumNodeType.NORMAL; + } + } + +} diff --git a/src/main/java/dev/tilera/auracore/network/AuraPacket.java b/src/main/java/dev/tilera/auracore/network/AuraPacket.java index 8029bf2..860ad1e 100644 --- a/src/main/java/dev/tilera/auracore/network/AuraPacket.java +++ b/src/main/java/dev/tilera/auracore/network/AuraPacket.java @@ -16,6 +16,7 @@ public class AuraPacket implements IMessage { public int flux; public boolean lock; public byte type; + public boolean virtual; public AuraPacket() {} @@ -30,6 +31,7 @@ public class AuraPacket implements IMessage { this.flux = node.flux.visSize(); this.lock = node.locked; this.type = (byte) node.type.ordinal(); + this.virtual = node.isVirtual; } @Override @@ -44,6 +46,7 @@ public class AuraPacket implements IMessage { this.flux = buf.readInt(); this.lock = buf.readBoolean(); this.type = buf.readByte(); + this.virtual = buf.readBoolean(); } @Override @@ -58,6 +61,7 @@ public class AuraPacket implements IMessage { buf.writeInt(flux); buf.writeBoolean(lock); buf.writeByte(type); + buf.writeBoolean(virtual); } } diff --git a/src/main/java/dev/tilera/auracore/world/WorldGenerator.java b/src/main/java/dev/tilera/auracore/world/WorldGenerator.java index f207448..b458444 100644 --- a/src/main/java/dev/tilera/auracore/world/WorldGenerator.java +++ b/src/main/java/dev/tilera/auracore/world/WorldGenerator.java @@ -18,8 +18,11 @@ import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.structure.MapGenScatteredFeature; import thaumcraft.common.config.ConfigBlocks; +import thaumcraft.common.lib.world.ThaumcraftWorldGenerator; +import thaumcraft.common.lib.world.WorldGenEldritchRing; import thaumcraft.common.lib.world.WorldGenHilltopStones; import thaumcraft.common.lib.world.WorldGenMound; +import thaumcraft.common.lib.world.dim.MazeThread; public class WorldGenerator implements IWorldGenerator { @@ -65,6 +68,21 @@ public class WorldGenerator implements IWorldGenerator { int value = random.nextInt(200) + 400; AuraManager.registerAuraNode(world, (short)value, EnumNodeType.DARK, world.provider.dimensionId, randPosX2 + 9, randPosY + 8, randPosZ2 + 9); } + } else if (Config.generateEldritchRing && random.nextInt(66) == 0) { + WorldGenEldritchRing stonering = new WorldGenEldritchRing(); + randPosY += 8; + int w = 11 + random.nextInt(6) * 2; + int h = 11 + random.nextInt(6) * 2; + stonering.chunkX = chunkX; + stonering.chunkZ = chunkZ; + stonering.width = w; + stonering.height = h; + if (stonering.generate(world, random, randPosX2, randPosY, randPosZ2)) { + auraGen = true; + ThaumcraftWorldGenerator.createRandomNodeAt(world, randPosX2, randPosY + 2, randPosZ2, random, false, true, false); + Thread t = new Thread(new MazeThread(chunkX, chunkZ, w, h, random.nextLong())); + t.start(); + } } else { WorldGenHilltopStones hilltopStones = new WorldGenHilltopStones(); if (random.nextInt(3) == 0 && !AuraManager.specificAuraTypeNearby(world.provider.dimensionId, randPosX2, randPosY += 9, randPosZ2, EnumNodeType.UNSTABLE, 250) && hilltopStones.generate(world, random, randPosX2, randPosY, randPosZ2)) { @@ -162,7 +180,11 @@ public class WorldGenerator implements IWorldGenerator { } } } - AuraManager.registerAuraNode(world, (short)value, type, world.provider.dimensionId, x, y, z); + if (Config.newNodeRarity > 0 && random.nextInt(Config.newNodeRarity) == 0) { + ThaumcraftWorldGenerator.createRandomNodeAt(world, x, y, z, random, false, false, false); + } else { + AuraManager.registerAuraNode(world, (short)value, type, world.provider.dimensionId, x, y, z); + } return true; } return false; diff --git a/src/main/resources/auracore.mixins.json b/src/main/resources/auracore.mixins.json index 0f765ef..d8da816 100644 --- a/src/main/resources/auracore.mixins.json +++ b/src/main/resources/auracore.mixins.json @@ -13,6 +13,7 @@ "MixinTileJarFillable", "MixinTileAlembic", "MixinTileResearchTable", + "MixinTileNode", "MixinBlockCustomPlant", "MixinBlockCustomOre", "MixinBlockTable",