From 80dd20bf30f95a6c6b473894d07bf14a67941e4a Mon Sep 17 00:00:00 2001
From: HellFirePvP <01ecs01m>
Date: Sun, 25 Oct 2015 01:20:48 +0200
Subject: [PATCH] - Unregistered Node-Jar handling from Automagy and native TC
- Rerouted Node-Jar-ing to Gadomancy - Preparation for Growing Node Jar-ing
mechanics
---
.../makeo/gadomancy/client/ClientProxy.java | 1 +
.../client/events/RenderEventHandler.java | 13 +-
.../renderers/item/ItemExNodeRenderer.java | 8 +-
.../renderers/item/tc/ItemNodeRenderer.java | 172 +++++++++++++++
.../tile/RenderTileExtendedNode.java | 6 +-
.../tile/tc/RenderTileNodeBasic.java | 15 +-
.../makeo/gadomancy/common/CommonProxy.java | 31 ++-
.../makeo/gadomancy/common/Gadomancy.java | 2 +-
.../blocks/tiles/GrowingNodeBehavior.java | 203 ++++++++++++++++++
.../common/blocks/tiles/TileExtendedNode.java | 62 +++---
.../common/events/EventHandlerWorld.java | 159 ++++++++++++--
.../integration/IntegrationAutomagy.java | 19 ++
.../common/registration/ModSubstitutions.java | 60 ++++++
.../common/registration/RegisteredItems.java | 1 +
.../common/utils/JarMultiblockHandler.java | 146 +++++++++++++
15 files changed, 833 insertions(+), 65 deletions(-)
create mode 100644 src/main/java/makeo/gadomancy/client/renderers/item/tc/ItemNodeRenderer.java
create mode 100644 src/main/java/makeo/gadomancy/common/blocks/tiles/GrowingNodeBehavior.java
create mode 100644 src/main/java/makeo/gadomancy/common/registration/ModSubstitutions.java
create mode 100644 src/main/java/makeo/gadomancy/common/utils/JarMultiblockHandler.java
diff --git a/src/main/java/makeo/gadomancy/client/ClientProxy.java b/src/main/java/makeo/gadomancy/client/ClientProxy.java
index 0ede834..ac3b512 100644
--- a/src/main/java/makeo/gadomancy/client/ClientProxy.java
+++ b/src/main/java/makeo/gadomancy/client/ClientProxy.java
@@ -29,6 +29,7 @@ import makeo.gadomancy.common.registration.RegisteredItems;
import makeo.gadomancy.common.utils.Injector;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.Render;
+import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.SimpleReloadableResourceManager;
import net.minecraft.entity.Entity;
diff --git a/src/main/java/makeo/gadomancy/client/events/RenderEventHandler.java b/src/main/java/makeo/gadomancy/client/events/RenderEventHandler.java
index cef50fb..df9113c 100644
--- a/src/main/java/makeo/gadomancy/client/events/RenderEventHandler.java
+++ b/src/main/java/makeo/gadomancy/client/events/RenderEventHandler.java
@@ -19,6 +19,7 @@ import thaumcraft.api.wands.ItemFocusBasic;
import thaumcraft.client.lib.REHWandHandler;
import thaumcraft.common.items.relics.ItemThaumometer;
import thaumcraft.common.items.wands.ItemWandCasting;
+import thaumcraft.common.tiles.TileJarNode;
import java.util.ArrayList;
@@ -68,10 +69,14 @@ public class RenderEventHandler {
int blockZ = e.target.blockZ;
if(Minecraft.getMinecraft().gameSettings.thirdPersonView == 0) {
TileEntity tile = e.player.worldObj.getTileEntity(blockX, blockY, blockZ);
- if(!(tile instanceof TileExtendedNode)) return;
- TileExtendedNode node = (TileExtendedNode) tile;
- if(!node.growing) return;
- GrowingDisplayManager.notifyDisplayTick(node.getId(), node.getNodeType());
+ if(tile instanceof TileExtendedNode) {
+ TileExtendedNode node = (TileExtendedNode) tile;
+ if(!node.growing) return;
+ GrowingDisplayManager.notifyDisplayTick(node.getId(), node.getNodeType());
+ } else if(tile instanceof TileJarNode) {
+ TileJarNode nodeJar = (TileJarNode) tile;
+
+ }
}
}
}
diff --git a/src/main/java/makeo/gadomancy/client/renderers/item/ItemExNodeRenderer.java b/src/main/java/makeo/gadomancy/client/renderers/item/ItemExNodeRenderer.java
index d9e2093..c8e4a4d 100644
--- a/src/main/java/makeo/gadomancy/client/renderers/item/ItemExNodeRenderer.java
+++ b/src/main/java/makeo/gadomancy/client/renderers/item/ItemExNodeRenderer.java
@@ -4,6 +4,7 @@ import makeo.gadomancy.common.registration.RegisteredBlocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import thaumcraft.client.renderers.tile.ItemNodeRenderer;
+
/**
* This class is part of the Gadomancy Mod
* Gadomancy is Open Source and distributed under the
@@ -16,11 +17,16 @@ public class ItemExNodeRenderer extends ItemNodeRenderer {
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
- return (item != null) && (item.getItem() == Item.getItemFromBlock(RegisteredBlocks.blockNode)) && (item.getItemDamage() == 0);
+ return (item != null) && (item.getItem() == Item.getItemFromBlock(RegisteredBlocks.blockNode)) && ((item.getItemDamage() == 0) || item.getItemDamage() == 5);
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return helper != ItemRendererHelper.EQUIPPED_BLOCK;
}
+
+ @Override
+ public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
+ makeo.gadomancy.client.renderers.item.tc.ItemNodeRenderer.renderNodeItem(type, item, data);
+ }
}
diff --git a/src/main/java/makeo/gadomancy/client/renderers/item/tc/ItemNodeRenderer.java b/src/main/java/makeo/gadomancy/client/renderers/item/tc/ItemNodeRenderer.java
new file mode 100644
index 0000000..1c75e7e
--- /dev/null
+++ b/src/main/java/makeo/gadomancy/client/renderers/item/tc/ItemNodeRenderer.java
@@ -0,0 +1,172 @@
+package makeo.gadomancy.client.renderers.item.tc;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.MathHelper;
+import net.minecraftforge.client.IItemRenderer;
+import org.lwjgl.opengl.GL11;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.api.nodes.INode;
+import thaumcraft.api.nodes.NodeType;
+import thaumcraft.client.lib.UtilsFX;
+import thaumcraft.client.renderers.tile.TileNodeRenderer;
+import thaumcraft.common.config.ConfigBlocks;
+import thaumcraft.common.tiles.TileNode;
+
+/**
+ * This class is NOT part of the Gadomancy Mod
+ * This file is copied from Azanors thaumcraft.client.renderers.tile.ItemNodeRenderer.java and contains small modifications
+ * Thaumcraft: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1292130
+ *
+ * Created by Azanor
+ * Modified by HellFirePvP @ 24.10.2015 17:19
+ */
+public class ItemNodeRenderer implements IItemRenderer {
+
+ public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) {
+ return (item != null) && (item.getItem() == Item.getItemFromBlock(ConfigBlocks.blockAiry)) && ((item.getItemDamage() == 0) || (item.getItemDamage() == 5));
+ }
+
+ public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) {
+ if (helper == IItemRenderer.ItemRendererHelper.EQUIPPED_BLOCK) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
+ //Gadomancy: Redirect.
+ renderNodeItem(type, item, data);
+ }
+
+ //Gadomancy: Renamed to access it static from another class
+ public static void renderNodeItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) {
+ if (type == IItemRenderer.ItemRenderType.ENTITY) {
+ GL11.glTranslatef(-0.5F, -0.25F, -0.5F);
+ } else if ((type == IItemRenderer.ItemRenderType.EQUIPPED) && ((data[1] instanceof EntityPlayer))) {
+ GL11.glTranslatef(0.0F, 0.0F, -0.5F);
+ }
+ TileNode tjf = new TileNode();
+ tjf.setAspects(aspects);
+ tjf.setNodeType(NodeType.NORMAL);
+ tjf.blockType = ConfigBlocks.blockAiry;
+ tjf.blockMetadata = 0;
+ GL11.glPushMatrix();
+ GL11.glTranslated(0.5D, 0.5D, 0.5D);
+ GL11.glScaled(2.0D, 2.0D, 2.0D);
+ renderItemNode(tjf);
+ GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
+ renderItemNode(tjf);
+ GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
+ renderItemNode(tjf);
+ GL11.glPopMatrix();
+ GL11.glEnable(32826);
+ }
+
+ private static AspectList aspects = new AspectList().add(Aspect.AIR, 40).add(Aspect.FIRE, 40).add(Aspect.EARTH, 40).add(Aspect.WATER, 40);
+
+ public static void renderItemNode(INode node) {
+ if (node.getAspects().size() > 0) {
+ EntityLivingBase viewer = Minecraft.getMinecraft().renderViewEntity;
+ float alpha = 0.5F;
+ if (node.getNodeModifier() != null) {
+ switch (node.getNodeModifier()) {
+ case BRIGHT:
+ alpha *= 1.5F;
+ break;
+ case PALE:
+ alpha *= 0.66F;
+ break;
+ case FADING:
+ alpha *= (MathHelper.sin(viewer.ticksExisted / 3.0F) * 0.25F + 0.33F);
+ }
+ }
+ GL11.glPushMatrix();
+ GL11.glAlphaFunc(516, 0.003921569F);
+ GL11.glDepthMask(false);
+ GL11.glDisable(2884);
+ long nt = System.nanoTime();
+ long time = nt / 5000000L;
+ float bscale = 0.25F;
+
+ GL11.glPushMatrix();
+ float rad = 6.283186F;
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha);
+
+ UtilsFX.bindTexture(TileNodeRenderer.nodetex);
+ int frames = 32;
+ int i = (int) ((nt / 40000000L + 1L) % frames);
+
+ int count = 0;
+ float scale = 0.0F;
+ float average = 0.0F;
+ for (Aspect aspect : node.getAspects().getAspects()) {
+ if (aspect.getBlend() == 771) {
+ alpha = (float) (alpha * 1.5D);
+ }
+ average += node.getAspects().getAmount(aspect);
+ GL11.glPushMatrix();
+ GL11.glEnable(3042);
+ GL11.glBlendFunc(770, aspect.getBlend());
+ scale = MathHelper.sin(viewer.ticksExisted / (14.0F - count)) * bscale + bscale * 2.0F;
+ scale = 0.2F + scale * (node.getAspects().getAmount(aspect) / 50.0F);
+ UtilsFX.renderAnimatedQuadStrip(scale, alpha / node.getAspects().size(), frames, 0, i, 0.0F, aspect.getColor());
+ GL11.glDisable(3042);
+ GL11.glPopMatrix();
+ count++;
+ if (aspect.getBlend() == 771) {
+ alpha = (float) (alpha / 1.5D);
+ }
+ }
+ average /= node.getAspects().size();
+ GL11.glPushMatrix();
+ GL11.glEnable(3042);
+ i = (int) ((nt / 40000000L + 1L) % frames);
+ scale = 0.1F + average / 150.0F;
+ int strip = 1;
+ switch (node.getNodeType()) {
+ case NORMAL:
+ GL11.glBlendFunc(770, 1);
+ break;
+ case UNSTABLE:
+ GL11.glBlendFunc(770, 1);
+ strip = 6;
+ break;
+ case DARK:
+ GL11.glBlendFunc(770, 771);
+ strip = 2;
+ break;
+ case TAINTED:
+ GL11.glBlendFunc(770, 771);
+ strip = 5;
+ break;
+ case PURE:
+ GL11.glBlendFunc(770, 1);
+ strip = 4;
+ break;
+ case HUNGRY:
+ scale *= 0.75F;
+ GL11.glBlendFunc(770, 1);
+ strip = 3;
+ }
+ GL11.glColor4f(1.0F, 0.0F, 1.0F, alpha);
+ UtilsFX.renderAnimatedQuadStrip(scale, alpha, frames, strip, i, 0.0F, 16777215);
+
+ GL11.glDisable(3042);
+ GL11.glPopMatrix();
+
+ GL11.glPopMatrix();
+
+ GL11.glEnable(2884);
+ GL11.glDepthMask(true);
+ GL11.glAlphaFunc(516, 0.1F);
+ GL11.glPopMatrix();
+ }
+ }
+
+}
diff --git a/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileExtendedNode.java b/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileExtendedNode.java
index 83c9423..70deb4f 100644
--- a/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileExtendedNode.java
+++ b/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileExtendedNode.java
@@ -22,6 +22,10 @@ public class RenderTileExtendedNode extends TileEntitySpecialRenderer {
double rX = node.xCoord + 0.5;
double rY = node.yCoord + 0.5;
double rZ = node.zCoord + 0.5;
- RenderTileNodeBasic.renderTileEntityAt(tile, rX, rY, rZ, partialTicks);
+ float size = 1.0F;
+ if(node.growing) {
+ size *= 1.5F;
+ }
+ RenderTileNodeBasic.renderTileEntityAt(tile, rX, rY, rZ, partialTicks, size);
}
}
diff --git a/src/main/java/makeo/gadomancy/client/renderers/tile/tc/RenderTileNodeBasic.java b/src/main/java/makeo/gadomancy/client/renderers/tile/tc/RenderTileNodeBasic.java
index f84c68a..5f722b1 100644
--- a/src/main/java/makeo/gadomancy/client/renderers/tile/tc/RenderTileNodeBasic.java
+++ b/src/main/java/makeo/gadomancy/client/renderers/tile/tc/RenderTileNodeBasic.java
@@ -23,9 +23,9 @@ import thaumcraft.common.tiles.TileNode;
/**
* This class is NOT part of the Gadomancy Mod
- * This file is copied from Azanors thaumcraft.client.renderers.models.gear.ModelWand.java and contains small modifications
+ * This file is copied from Azanors thaumcraft.client.renderers.tile.TileNodeRenderer.java and contains small modifications
* Thaumcraft: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1292130
- *
+ *
* Created by Azanor
* Modified by HellFirePvP @ 23.10.2015 20:04
*/
@@ -37,6 +37,7 @@ public class RenderTileNodeBasic {
- Where a node is rendered is now defined of the parameters of renderTileEntityAt() and no longer of the node-tile itself
- Node rendering takes doubles as params and no longer int values.
+ - Redirected renderTileEntityAt to a renderTileEntityAt where a size of the node can be specified
Changes made by HellFirePvP
*/
@@ -177,11 +178,17 @@ public class RenderTileNodeBasic {
}
}
+ //Gadomancy START
public static void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) {
+ renderTileEntityAt(tile, x, y, z, partialTicks, 1.0F);
+ }
+ //Gadomancy END
+
+ //Gadomancy: Added dynamic size
+ public static void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks, float size) {
if (!(tile instanceof INode)) {
return;
}
- float size = 1.0F;
INode node = (INode) tile;
double viewDistance = 64.0D;
EntityLivingBase viewer = Minecraft.getMinecraft().renderViewEntity;
@@ -190,7 +197,7 @@ public class RenderTileNodeBasic {
if ((viewer instanceof EntityPlayer)) {
if ((tile != null) && ((tile instanceof TileJarNode))) {
condition = true;
- size = 0.7F;
+ size = (float) ((size * 7D) / 10D); //Gadomancy: Node size is 70% of the default size in standart TC. calculating the same here.
} else if ((((EntityPlayer) viewer).inventory.armorItemInSlot(3) != null) && ((((EntityPlayer) viewer).inventory.armorItemInSlot(3).getItem() instanceof IRevealer)) && (((IRevealer) ((EntityPlayer) viewer).inventory.armorItemInSlot(3).getItem()).showNodes(((EntityPlayer) viewer).inventory.armorItemInSlot(3), viewer))) {
condition = true;
depthIgnore = true;
diff --git a/src/main/java/makeo/gadomancy/common/CommonProxy.java b/src/main/java/makeo/gadomancy/common/CommonProxy.java
index 9e824a9..18fcbe0 100644
--- a/src/main/java/makeo/gadomancy/common/CommonProxy.java
+++ b/src/main/java/makeo/gadomancy/common/CommonProxy.java
@@ -12,16 +12,24 @@ import makeo.gadomancy.common.events.EventHandlerWorld;
import makeo.gadomancy.common.network.PacketHandler;
import makeo.gadomancy.common.registration.*;
import makeo.gadomancy.client.ClientProxy;
+import makeo.gadomancy.common.utils.Injector;
+import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
+import thaumcraft.api.wands.WandTriggerRegistry;
import thaumcraft.common.blocks.BlockAiryItem;
import thaumcraft.common.config.ConfigBlocks;
import thaumcraft.common.entities.golems.ContainerGolem;
import thaumcraft.common.entities.golems.EntityGolemBase;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
/**
* This class is part of the Gadomancy Mod
* Gadomancy is Open Source and distributed under the
@@ -43,17 +51,11 @@ public class CommonProxy implements IGuiHandler {
RegisteredBlocks.init();
RegisteredItems.init();
RegisteredGolemStuff.init();
+
+ ModSubstitutions.preInit();
}
public void initalize() {
- try {
- RegisteredItems.itemBlockAiryCopy = new BlockAiryItem(RegisteredBlocks.blockNode);
- GameRegistry.addSubstitutionAlias("Thaumcraft:blockAiry", GameRegistry.Type.BLOCK, RegisteredBlocks.blockNode);
- GameRegistry.addSubstitutionAlias("Thaumcraft:blockAiry", GameRegistry.Type.ITEM, RegisteredItems.itemBlockAiryCopy);
- ConfigBlocks.blockAiry = RegisteredBlocks.blockNode;
- } catch (Exception e) {
- e.printStackTrace();
- }
NetworkRegistry.INSTANCE.registerGuiHandler(Gadomancy.instance, this);
@@ -62,6 +64,8 @@ public class CommonProxy implements IGuiHandler {
MinecraftForge.EVENT_BUS.register(new EventHandlerWorld());
RegisteredRecipes.init();
+
+ ModSubstitutions.init();
}
public void postInitalize() {
@@ -69,6 +73,17 @@ public class CommonProxy implements IGuiHandler {
RegisteredIntegrations.init();
RegisteredResearches.postInit();
+
+ ModSubstitutions.postInit();
+ }
+
+ public static void unregisterWandHandler(String modid, Block block, int metadata) {
+ HashMap> triggers = new Injector(WandTriggerRegistry.class).getField("triggers");
+ HashMap modTriggers = triggers.get(modid);
+ if(modTriggers == null) return;
+ List arrKey = Arrays.asList(block, metadata);
+ modTriggers.remove(arrKey);
+ triggers.put(modid, modTriggers);
}
@Override
diff --git a/src/main/java/makeo/gadomancy/common/Gadomancy.java b/src/main/java/makeo/gadomancy/common/Gadomancy.java
index 058f706..b980f2f 100644
--- a/src/main/java/makeo/gadomancy/common/Gadomancy.java
+++ b/src/main/java/makeo/gadomancy/common/Gadomancy.java
@@ -19,7 +19,7 @@ import makeo.gadomancy.common.data.ModData;
*
* Created by makeo @ 29.11.2014 14:07
*/
-@Mod(modid = Gadomancy.MODID, name = Gadomancy.NAME, version = Gadomancy.VERSION, dependencies="required-after:Thaumcraft@[4.1.1.11,);after:Waila")
+@Mod(modid = Gadomancy.MODID, name = Gadomancy.NAME, version = Gadomancy.VERSION, dependencies="required-after:Thaumcraft@[4.1.1.11,);after:Waila;after:Automagy")
public class Gadomancy
{
public static final String MODID = "gadomancy";
diff --git a/src/main/java/makeo/gadomancy/common/blocks/tiles/GrowingNodeBehavior.java b/src/main/java/makeo/gadomancy/common/blocks/tiles/GrowingNodeBehavior.java
new file mode 100644
index 0000000..b67b217
--- /dev/null
+++ b/src/main/java/makeo/gadomancy/common/blocks/tiles/GrowingNodeBehavior.java
@@ -0,0 +1,203 @@
+package makeo.gadomancy.common.blocks.tiles;
+
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Random;
+
+/**
+ * This class is part of the Gadomancy Mod
+ * Gadomancy is Open Source and distributed under the
+ * GNU LESSER GENERAL PUBLIC LICENSE
+ * for more read the LICENSE file
+ *
+ * Created by HellFirePvP @ 24.10.2015 10:50
+ */
+public class GrowingNodeBehavior {
+
+ public static final double SATURATION_DIFFICULTY = 10D;
+ public static final double SATURATION_CAP = 100D;
+ private static final Random rand = new Random();
+
+ //The lower the 'happier'
+ private double overallHappiness = 0.0D;
+
+ //Maps saturation to aspects. higher saturation may stop the node from accepting an aspect.
+ //Primal aspects increase saturation even more for those aspects than compound ones.
+ //At a defined point the node will stop accepting new aspects overall and chances are it will collapse into
+ //a even more deadly hungry node..
+ private Map aspectSaturation = new LinkedHashMap();
+
+ //Ensures that the node gets fed up faster if you feed it the same aspect over and over again.
+ private Aspect lastFedAspect = null;
+ private int lastFedRow = 0;
+
+ //If this is true, the node stops growing.
+ private boolean isSaturated = false;
+
+ public void addAspect(AspectType type, AspectList nodeAspects, Aspect aspect, int value) {
+ if(isSaturated) return;
+
+ double increasedSaturation = getSaturation(type, aspect);
+ addSaturation(aspect, increasedSaturation);
+ nodeAspects.add(aspect, value);
+
+ computeOverallSaturation();
+ }
+
+ //Computes the saturation of all current aspects and calculates the overall happiness as well as if the
+ //Node will stop growing.
+ private void computeOverallSaturation() {
+ if(isSaturated) return;
+
+ double completeSaturation = 0D;
+ int aspects = aspectSaturation.keySet().size();
+ for(Aspect a : aspectSaturation.keySet()) {
+ completeSaturation += aspectSaturation.get(a);
+ }
+
+ //Not just 0.0-1.0!
+ //Values vary from 0.0 to SATURATION_CAP (or a bit higher)
+ double percentSaturation = completeSaturation / ((double) aspects);
+
+ double satCmp = SATURATION_CAP;
+
+ satCmp *= 8.5;
+ satCmp /= 10;
+
+ //If the saturation is in the upper 85%
+ System.out.println(percentSaturation + " - " + overallHappiness);
+ if(percentSaturation > satCmp) {
+ this.isSaturated = true;
+ }
+ }
+
+ private void addSaturation(Aspect aspect, double increasedSaturation) {
+ double overallReduction = 1D / SATURATION_DIFFICULTY;
+ if(aspectSaturation.containsKey(aspect)) {
+ aspectSaturation.put(aspect, aspectSaturation.get(aspect) + increasedSaturation);
+ } else {
+ aspectSaturation.put(aspect, increasedSaturation);
+ }
+ for(Aspect a : aspectSaturation.keySet()) {
+ if(a.equals(aspect)) continue;
+ double newSaturation = aspectSaturation.get(a) - overallReduction;
+ newSaturation = newSaturation < 0 ? 0 : newSaturation;
+ aspectSaturation.put(a, newSaturation);
+ }
+ }
+
+ private double getSaturation(AspectType type, Aspect aspect) {
+ double mult = 1D;
+ switch (type) {
+ case WISP:
+ mult -= 0.2D; //Growing node doesn't get saturated by wisps that fast.
+ break;
+ case WISP_ESSENCE:
+ mult += 0.2D; //Growing node doesn't like essences all the time..
+ break;
+ case ASPECT_ORB:
+ mult -= 0.3D; //Growing node prefers aspects in their most natural form.
+ break;
+ }
+ if(lastFedAspect != null) {
+ if(lastFedAspect.equals(aspect)) {
+ mult += 0.4D;
+ lastFedRow++;
+ }
+ }
+ lastFedAspect = aspect;
+ double sat = aspect.isPrimal() ? 1.4D : 1D;
+ return sat * mult;
+ }
+
+ public boolean doesAccept(Aspect aspect) {
+ if(isSaturated) {
+ handleOverfeed();
+ return false;
+ }
+
+ if(aspectSaturation.containsKey(aspect)) {
+ double percentageToSaturation = aspectSaturation.get(aspect) / SATURATION_CAP; // 0.0 - 1.0
+ boolean mayAdd = rand.nextFloat() > percentageToSaturation;
+ if(mayAdd) {
+ double inc = 1D / (1D - percentageToSaturation);
+ if(lastFedAspect != null) {
+ if(aspect.equals(lastFedAspect)) {
+ inc *= evaluateFeedingDenialFunc((lastFedRow > 0 ? lastFedRow : 1));
+ } else {
+ inc *= -10;
+ }
+ }
+ this.overallHappiness += inc; //The node doesn't like to be forced to eat the same every time.
+ if(this.overallHappiness < 0) this.overallHappiness = 0;
+ }
+ return mayAdd;
+ } else {
+ //The node does not know that aspect yet/hasn't created an immunity to it yet.
+ //The node gets to know a new aspect, thus the happiness increases.
+ this.overallHappiness = overallHappiness / SATURATION_DIFFICULTY;
+ return true;
+ }
+ }
+
+ private double evaluateFeedingDenialFunc(double i) {
+ return Math.pow(2D, (i / 6D));
+ }
+
+ private void handleOverfeed() {
+ System.out.println("OVERFED");
+ //TODO let node collapse if overfed & still feeding...
+ }
+
+ public void readFromNBT(NBTTagCompound nbtTagCompound) {
+ this.isSaturated = nbtTagCompound.getBoolean("overallSaturated");
+ this.overallHappiness = nbtTagCompound.getDouble("overallHappiness");
+
+ if(nbtTagCompound.hasKey("lastFed")) {
+ this.lastFedAspect = Aspect.getAspect(nbtTagCompound.getString("lastFedAspect"));
+ this.lastFedRow = nbtTagCompound.getInteger("lastFedRow");
+ }
+
+ NBTTagList list = nbtTagCompound.getTagList("saturationValues", 10);
+ for (int i = 0; i < list.tagCount(); i++) {
+ NBTTagCompound aspectCompound = list.getCompoundTagAt(i);
+ String name = aspectCompound.getString("aspectName");
+ double saturation = aspectCompound.getDouble("aspectSaturation");
+ Aspect a = Aspect.getAspect(name);
+ if(a != null) {
+ aspectSaturation.put(a, saturation);
+ }
+ }
+ }
+
+ public void writeToNBT(NBTTagCompound nbtTagCompound) {
+ nbtTagCompound.setBoolean("overallSaturated", isSaturated);
+ nbtTagCompound.setDouble("overallHappiness", overallHappiness);
+ if(lastFedAspect != null) {
+ nbtTagCompound.setString("lastFedAspect", lastFedAspect.getTag());
+ nbtTagCompound.setInteger("lastFedRow", lastFedRow);
+ }
+
+ NBTTagList list = new NBTTagList();
+ for(Aspect a : aspectSaturation.keySet()) {
+ double saturation = aspectSaturation.get(a);
+ NBTTagCompound compound = new NBTTagCompound();
+ compound.setString("aspectName", a.getTag());
+ compound.setDouble("aspectSaturation", saturation);
+ list.appendTag(compound);
+ }
+ nbtTagCompound.setTag("saturationValues", list);
+ }
+
+ public static enum AspectType {
+
+ WISP, WISP_ESSENCE, ASPECT_ORB
+
+ }
+
+}
diff --git a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileExtendedNode.java b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileExtendedNode.java
index 018990b..9085064 100644
--- a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileExtendedNode.java
+++ b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileExtendedNode.java
@@ -25,6 +25,7 @@ import java.util.Random;
public class TileExtendedNode extends TileNode {
public boolean growing = new Random().nextBoolean();
+ private GrowingNodeBehavior behavior = new GrowingNodeBehavior();
@Override
public void updateEntity() {
@@ -34,14 +35,13 @@ public class TileExtendedNode extends TileNode {
needUpdate = handleGrowingNode(false);
- if (needUpdate) {
+ if(!worldObj.isRemote && needUpdate) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
markDirty();
+ System.out.println(needUpdate);
}
}
- //TODO add growing ai stuff
- //TODO handle growth percentages.
private boolean handleGrowingNode(boolean needUpdate) {
if(!growing) return needUpdate;
List aspectOrbs = this.worldObj.getEntitiesWithinAABB(EntityAspectOrb.class, AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord, this.zCoord, this.xCoord + 1, this.yCoord + 1, this.zCoord + 1).expand(15.0D, 15.0D, 15.0D));
@@ -52,21 +52,14 @@ public class TileExtendedNode extends TileNode {
double d = getDistanceTo(aspectOrb.posX, aspectOrb.posY, aspectOrb.posZ);
if (d < 1.0D) { //prev: 2.0D
Aspect aspect = aspectOrb.getAspect();
- int aspectValue = aspectOrb.getAspectValue();
if (getAspects().getAmount(aspect) < getNodeVisBase(aspect)) {
addToContainer(aspect, 1);
needUpdate = true;
} else {
//Adding it permanently
- boolean mayAdd;
- if(aspect.isPrimal()) {
- mayAdd = this.worldObj.rand.nextInt(1 + getNodeVisBase(aspect) * 2) < aspectValue;
- } else {
- mayAdd = true;
- }
- if (mayAdd) {
- getAspectsBase().add(aspect, 1);
+ if(!worldObj.isRemote && behavior.doesAccept(aspect)) {
+ behavior.addAspect(GrowingNodeBehavior.AspectType.ASPECT_ORB, getAspectsBase(), aspect, 1);
needUpdate = true;
}
}
@@ -93,14 +86,8 @@ public class TileExtendedNode extends TileNode {
needUpdate = true;
} else {
//Adding it permanently
- boolean mayAdd;
- if(aspect.isPrimal()) {
- mayAdd = this.worldObj.rand.nextInt(1 + getNodeVisBase(aspect) * 2) < 1;
- } else {
- mayAdd = true;
- }
- if (mayAdd) {
- getAspectsBase().add(aspect, 1);
+ if(!worldObj.isRemote && behavior.doesAccept(aspect)) {
+ behavior.addAspect(GrowingNodeBehavior.AspectType.WISP_ESSENCE, getAspectsBase(), aspect, 1);
needUpdate = true;
}
}
@@ -120,20 +107,17 @@ public class TileExtendedNode extends TileNode {
if (d < 1.0D) { //prev: 2.0D
Aspect aspect = Aspect.getAspect(wisp.getType());
- if (getAspects().getAmount(aspect) < getNodeVisBase(aspect)) {
- addToContainer(aspect, 1);
- needUpdate = true;
- } else {
- //Adding it permanently
- boolean mayAdd;
- if(aspect.isPrimal()) {
- mayAdd = this.worldObj.rand.nextInt(1 + getNodeVisBase(aspect) * 2) < 2;
- } else {
- mayAdd = true;
- }
- if (mayAdd) {
- getAspectsBase().add(aspect, 1);
+ if(aspect != null) {
+ if (getAspects().getAmount(aspect) < getNodeVisBase(aspect)) {
+ addToContainer(aspect, 1);
needUpdate = true;
+ } else {
+ //Adding it permanently
+
+ if(!worldObj.isRemote && behavior.doesAccept(aspect)) {
+ behavior.addAspect(GrowingNodeBehavior.AspectType.WISP, getAspectsBase(), aspect, 1);
+ needUpdate = true;
+ }
}
}
wisp.setDead();
@@ -164,7 +148,13 @@ public class TileExtendedNode extends TileNode {
super.readCustomNBT(nbttagcompound);
NBTTagCompound compound = nbttagcompound.getCompoundTag("Gadomancy");
+
this.growing = compound.getBoolean("growing");
+
+ if(growing) {
+ NBTTagCompound growingNodeBehavior = compound.getCompoundTag("NodeBehavior");
+ behavior.readFromNBT(growingNodeBehavior);
+ }
}
@Override
@@ -174,6 +164,12 @@ public class TileExtendedNode extends TileNode {
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("growing", growing);
+ if(growing) {
+ NBTTagCompound behaviorCompound = new NBTTagCompound();
+ behavior.writeToNBT(behaviorCompound);
+ compound.setTag("NodeBehavior", behaviorCompound);
+ }
+
nbttagcompound.setTag("Gadomancy", compound);
}
diff --git a/src/main/java/makeo/gadomancy/common/events/EventHandlerWorld.java b/src/main/java/makeo/gadomancy/common/events/EventHandlerWorld.java
index 90a632d..50f40a1 100644
--- a/src/main/java/makeo/gadomancy/common/events/EventHandlerWorld.java
+++ b/src/main/java/makeo/gadomancy/common/events/EventHandlerWorld.java
@@ -5,22 +5,41 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import makeo.gadomancy.common.Gadomancy;
import makeo.gadomancy.common.blocks.tiles.TileStickyJar;
import makeo.gadomancy.common.registration.RegisteredBlocks;
+import makeo.gadomancy.common.registration.RegisteredIntegrations;
import makeo.gadomancy.common.registration.RegisteredItems;
import makeo.gadomancy.common.utils.GolemEnumHelper;
+import makeo.gadomancy.common.utils.JarMultiblockHandler;
+import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.WorldEvent;
+import net.minecraftforge.oredict.OreDictionary;
+import thaumcraft.api.ThaumcraftApiHelper;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.api.nodes.INode;
+import thaumcraft.common.blocks.BlockMagicalLog;
+import thaumcraft.common.config.ConfigBlocks;
+import thaumcraft.common.items.wands.ItemWandCasting;
+import thaumcraft.common.lib.research.ResearchManager;
import thaumcraft.common.tiles.TileJarFillable;
+import thaumcraft.common.tiles.TileJarNode;
+import thaumcraft.common.tiles.TileOwned;
+import thaumcraft.common.tiles.TileWarded;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
/**
@@ -28,20 +47,20 @@ import java.util.Map;
* Gadomancy is Open Source and distributed under the
* GNU LESSER GENERAL PUBLIC LICENSE
* for more read the LICENSE file
- *
+ *
* Created by makeo @ 05.07.2015 13:20
*/
public class EventHandlerWorld {
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(EntityEvent.EntityConstructing e) {
- if(e.entity instanceof EntityPlayer) {
+ if (e.entity instanceof EntityPlayer) {
//e.entity.registerExtendedProperties(Gadomancy.MODID, new ExtendedPlayerProperties((EntityPlayer) e.entity));
}
}
@SubscribeEvent(priority = EventPriority.NORMAL)
public void on(WorldEvent.Load e) {
- if(!e.world.isRemote && e.world.equals(MinecraftServer.getServer().getEntityWorld())) {
+ if (!e.world.isRemote && e.world.equals(MinecraftServer.getServer().getEntityWorld())) {
Gadomancy.loadModData();
GolemEnumHelper.validateSavedMapping();
@@ -51,7 +70,7 @@ public class EventHandlerWorld {
@SubscribeEvent(priority = EventPriority.NORMAL)
public void on(WorldEvent.Unload e) {
- if(!e.world.isRemote && e.world.equals(MinecraftServer.getServer().getEntityWorld())) {
+ if (!e.world.isRemote && e.world.equals(MinecraftServer.getServer().getEntityWorld())) {
Gadomancy.unloadModData();
}
}
@@ -61,18 +80,18 @@ public class EventHandlerWorld {
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void on(BlockEvent.PlaceEvent e) {
- if(e.isCanceled()) {
- if(interacts != null)
+ if (e.isCanceled()) {
+ if (interacts != null)
interacts.remove(e.player);
} else {
- if(!e.world.isRemote && isStickyJar(e.itemInHand)) {
+ if (!e.world.isRemote && isStickyJar(e.itemInHand)) {
TileEntity parent = e.world.getTileEntity(e.x, e.y, e.z);
- if(parent instanceof TileJarFillable) {
+ if (parent instanceof TileJarFillable) {
int metadata = e.world.getBlockMetadata(e.x, e.y, e.z);
e.world.setBlock(e.x, e.y, e.z, RegisteredBlocks.blockStickyJar, metadata, 2);
TileEntity tile = e.world.getTileEntity(e.x, e.y, e.z);
- if(tile instanceof TileStickyJar) {
+ if (tile instanceof TileStickyJar) {
Integer sideHit = interacts.get(e.player);
((TileStickyJar) tile).init((TileJarFillable) parent, e.placedBlock, metadata,
ForgeDirection.getOrientation(sideHit == null ? 1 : sideHit).getOpposite());
@@ -85,13 +104,127 @@ public class EventHandlerWorld {
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(PlayerInteractEvent e) {
- if(!e.world.isRemote && e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK
+ if (!e.world.isRemote && e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK
&& isStickyJar(e.entityPlayer.getHeldItem())) {
- if(interacts == null) {
+ if (interacts == null) {
interacts = new HashMap();
}
interacts.put(e.entityPlayer, e.face);
}
+
+ if (e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
+ ItemStack i = e.entityPlayer.getHeldItem();
+ if (i != null && (i.getItem() instanceof ItemWandCasting)) {
+ Block target = e.world.getBlock(e.x, e.y, e.z);
+ if (target.equals(Blocks.glass)) {
+ if (ResearchManager.isResearchComplete(e.entityPlayer.getCommandSenderName(), "NODEJAR")) {
+ tryTCJarNodeCreation(i, e.entityPlayer, e.world, e.x, e.y, e.z);
+ }
+ } else if (target.equals(ConfigBlocks.blockWarded)) {
+ if (RegisteredIntegrations.automagy.isPresent() &&
+ ResearchManager.isResearchComplete(e.entityPlayer.getCommandSenderName(), "ADVNODEJAR")) {
+ tryAutomagyJarNodeCreation(i, e.entityPlayer, e.world, e.x, e.y, e.z);
+ }
+ }
+ }
+ }
+ }
+
+ private void tryTCJarNodeCreation(ItemStack wandStack, EntityPlayer player, World world, int x, int y, int z) {
+ JarMultiblockHandler.JarPieceEvaluationRunnable slabRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
+ @Override
+ public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
+ Block block = world.getBlock(absX, absY, absZ);
+ int md = world.getBlockMetadata(absX, absY, absZ);
+ return containsMatch(false, OreDictionary.getOres("slabWood"), new ItemStack(block, 1, md));
+ }
+ };
+ JarMultiblockHandler.JarPieceEvaluationRunnable glassRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
+ @Override
+ public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
+ return world.getBlock(absX, absY, absZ) == Blocks.glass;
+ }
+ };
+ JarMultiblockHandler.JarPieceEvaluationRunnable nodeRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
+ @Override
+ public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
+ TileEntity tile = world.getTileEntity(absX, absY, absZ);
+ if ((tile == null) || (!(tile instanceof INode)) || ((tile instanceof TileJarNode))) {
+ return false;
+ }
+ return true;
+ }
+ };
+ int[] result = JarMultiblockHandler.evaluateIfValidJarIsPresent(world, x, y, z, player, slabRunnable, glassRunnable, nodeRunnable);
+
+ if (result == null){
+ return;
+ }
+
+ if(!ThaumcraftApiHelper.consumeVisFromWandCrafting(wandStack, player, new AspectList().add(Aspect.FIRE, 70).add(Aspect.EARTH, 70).add(Aspect.ORDER, 70).add(Aspect.AIR, 70).add(Aspect.ENTROPY, 70).add(Aspect.WATER, 70), true))
+ return;
+
+ if(world.isRemote) return;
+ JarMultiblockHandler.replaceTCJar(world, result[0], result[1], result[2]);
+ }
+
+ private void tryAutomagyJarNodeCreation(ItemStack wandStack, EntityPlayer player, World world, int x, int y, int z) {
+ JarMultiblockHandler.JarPieceEvaluationRunnable silverWoodRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
+ @Override
+ public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
+ TileEntity te = world.getTileEntity(absX, absY, absZ);
+ if ((te instanceof TileWarded)) {
+ TileWarded warded = (TileWarded) te;
+ if ((warded.block == ConfigBlocks.blockMagicalLog) && (BlockMagicalLog.limitToValidMetadata(warded.blockMd) == 1)) {
+ return player.getCommandSenderName().hashCode() == warded.owner;
+ }
+ }
+ return false;
+ }
+ };
+ JarMultiblockHandler.JarPieceEvaluationRunnable glassRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
+ @Override
+ public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
+ if ((world.getBlock(absX, absY, absZ) == ConfigBlocks.blockCosmeticOpaque) && (world.getBlockMetadata(absX, absY, absZ) == 2)) {
+ TileEntity te = world.getTileEntity(absX, absY, absZ);
+ if ((te instanceof TileOwned)) {
+ return player.getCommandSenderName().equals(((TileOwned) te).owner);
+ }
+ }
+ return false;
+ }
+ };
+ JarMultiblockHandler.JarPieceEvaluationRunnable nodeRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
+ @Override
+ public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
+ TileEntity tile = world.getTileEntity(absX, absY, absZ);
+ if ((tile == null) || (!(tile instanceof INode)) || ((tile instanceof TileJarNode))) {
+ return false;
+ }
+ return true;
+ }
+ };
+ int[] result = JarMultiblockHandler.evaluateIfValidJarIsPresent(world, x, y, z, player, silverWoodRunnable, glassRunnable, nodeRunnable);
+
+ if (result == null){
+ return;
+ }
+
+ if(!RegisteredIntegrations.automagy.handleNodeJarVisCost(wandStack, player)) return;
+
+ if(world.isRemote) return;
+ JarMultiblockHandler.replaceAutomagyJar(world, result[0], result[1], result[2]);
+ }
+
+ private boolean containsMatch(boolean strict, List inputs, ItemStack... targets) {
+ for (ItemStack input : inputs) {
+ for (ItemStack target : targets) {
+ if (OreDictionary.itemMatches(input, target, strict)) {
+ return true;
+ }
+ }
+ }
+ return false;
}
private boolean isStickyJar(ItemStack stack) {
@@ -101,8 +234,8 @@ public class EventHandlerWorld {
@SubscribeEvent(priority = EventPriority.NORMAL)
public void on(ItemTooltipEvent e) {
- if(e.toolTip.size() > 0 && e.itemStack.hasTagCompound()) {
- if(e.itemStack.stackTagCompound.getBoolean("isStickyJar")) {
+ if (e.toolTip.size() > 0 && e.itemStack.hasTagCompound()) {
+ if (e.itemStack.stackTagCompound.getBoolean("isStickyJar")) {
e.toolTip.add(1, "\u00a7a" + StatCollector.translateToLocal("gadomancy.lore.stickyjar"));
}
}
diff --git a/src/main/java/makeo/gadomancy/common/integration/IntegrationAutomagy.java b/src/main/java/makeo/gadomancy/common/integration/IntegrationAutomagy.java
index fbe32e7..9ba5c85 100644
--- a/src/main/java/makeo/gadomancy/common/integration/IntegrationAutomagy.java
+++ b/src/main/java/makeo/gadomancy/common/integration/IntegrationAutomagy.java
@@ -1,9 +1,17 @@
package makeo.gadomancy.common.integration;
+import makeo.gadomancy.common.CommonProxy;
+import makeo.gadomancy.common.registration.ModSubstitutions;
import makeo.gadomancy.common.registration.RegisteredBlocks;
import makeo.gadomancy.common.registration.RegisteredItems;
import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import thaumcraft.api.ThaumcraftApiHelper;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.common.config.ConfigBlocks;
/**
* This class is part of the Gadomancy Mod
@@ -14,6 +22,10 @@ import net.minecraft.item.Item;
* Created by makeo @ 04.10.2015 02:30
*/
public class IntegrationAutomagy extends IntegrationMod {
+
+ //Keep in sync with Automagy some time...
+ private static final AspectList visCostAdvNodeJar = new AspectList().add(Aspect.FIRE, 125).add(Aspect.EARTH, 125).add(Aspect.ORDER, 125).add(Aspect.AIR, 125).add(Aspect.ENTROPY, 125).add(Aspect.WATER, 125);
+
@Override
public String getModId() {
return "Automagy";
@@ -26,5 +38,12 @@ public class IntegrationAutomagy extends IntegrationMod {
RegisteredBlocks.registerStickyJar(infinityJar, 3, false, true);
RegisteredItems.registerStickyJar(Item.getItemFromBlock(infinityJar), 3);
}
+ CommonProxy.unregisterWandHandler("Automagy", ConfigBlocks.blockWarded, -1);
+
+ ModSubstitutions.replaceAutomagyResearch();
+ }
+
+ public boolean handleNodeJarVisCost(ItemStack wandStack, EntityPlayer player) {
+ return ThaumcraftApiHelper.consumeVisFromWandCrafting(wandStack, player, visCostAdvNodeJar, true);
}
}
diff --git a/src/main/java/makeo/gadomancy/common/registration/ModSubstitutions.java b/src/main/java/makeo/gadomancy/common/registration/ModSubstitutions.java
new file mode 100644
index 0000000..17a5ec8
--- /dev/null
+++ b/src/main/java/makeo/gadomancy/common/registration/ModSubstitutions.java
@@ -0,0 +1,60 @@
+package makeo.gadomancy.common.registration;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import makeo.gadomancy.common.CommonProxy;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import thaumcraft.api.research.ResearchCategories;
+import thaumcraft.api.research.ResearchItem;
+import thaumcraft.api.research.ResearchPage;
+import thaumcraft.common.blocks.BlockAiryItem;
+import thaumcraft.common.config.ConfigBlocks;
+
+import java.util.List;
+
+/**
+ * This class is part of the Gadomancy Mod
+ * Gadomancy is Open Source and distributed under the
+ * GNU LESSER GENERAL PUBLIC LICENSE
+ * for more read the LICENSE file
+ *
+ * Created by HellFirePvP @ 24.10.2015 16:48
+ */
+public class ModSubstitutions {
+
+ public static void preInit() {
+ try {
+ RegisteredItems.itemBlockAiryCopy = new BlockAiryItem(RegisteredBlocks.blockNode);
+ GameRegistry.addSubstitutionAlias("Thaumcraft:blockAiry", GameRegistry.Type.BLOCK, RegisteredBlocks.blockNode);
+ GameRegistry.addSubstitutionAlias("Thaumcraft:blockAiry", GameRegistry.Type.ITEM, RegisteredItems.itemBlockAiryCopy);
+ ConfigBlocks.blockAiry = RegisteredBlocks.blockNode;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void init() {
+
+ }
+
+ public static void postInit() {
+ CommonProxy.unregisterWandHandler("Thaumcraft", Blocks.glass, -1);
+
+ //TC fix
+ ResearchItem ri = ResearchCategories.getResearchList("BASICS").research.get("NODEJAR");
+ ResearchPage page = ri.getPages()[1];
+ List recipe = (List) page.recipe;
+ List blocks = (List) recipe.get(4);
+ blocks.set(22, new ItemStack(RegisteredItems.itemBlockAiryCopy, 1, 5));
+ }
+
+ public static void replaceAutomagyResearch() {
+ //Automagy fix
+ ResearchItem ri = ResearchCategories.getResearchList("AUTOMAGY").research.get("ADVNODEJAR");
+ ResearchPage page = ri.getPages()[1];
+ List recipe = (List) page.recipe;
+ List blocks = (List) recipe.get(4);
+ blocks.set(22, new ItemStack(RegisteredItems.itemBlockAiryCopy, 1, 5));
+ }
+}
diff --git a/src/main/java/makeo/gadomancy/common/registration/RegisteredItems.java b/src/main/java/makeo/gadomancy/common/registration/RegisteredItems.java
index 3136b2e..6a77a28 100644
--- a/src/main/java/makeo/gadomancy/common/registration/RegisteredItems.java
+++ b/src/main/java/makeo/gadomancy/common/registration/RegisteredItems.java
@@ -32,6 +32,7 @@ public class RegisteredItems {
public static Item itemTransformationFocus;
public static Item itemGolemCoreBreak;
+ @Deprecated
public static Item itemBlockAiryCopy; //!!!!!!!!!!DO NOT TOUCH THIS OR USE THIS ANYWHERE!!!!!!!!!!
public static void preInit() {
diff --git a/src/main/java/makeo/gadomancy/common/utils/JarMultiblockHandler.java b/src/main/java/makeo/gadomancy/common/utils/JarMultiblockHandler.java
new file mode 100644
index 0000000..e2c34f4
--- /dev/null
+++ b/src/main/java/makeo/gadomancy/common/utils/JarMultiblockHandler.java
@@ -0,0 +1,146 @@
+package makeo.gadomancy.common.utils;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.api.nodes.INode;
+import thaumcraft.api.nodes.NodeModifier;
+import thaumcraft.api.nodes.NodeType;
+import thaumcraft.common.config.ConfigBlocks;
+import thaumcraft.common.tiles.TileJarNode;
+
+/**
+ * This class is part of the Gadomancy Mod
+ * Gadomancy is Open Source and distributed under the
+ * GNU LESSER GENERAL PUBLIC LICENSE
+ * for more read the LICENSE file
+ *
+ * Created by HellFirePvP @ 24.10.2015 18:09
+ */
+public class JarMultiblockHandler {
+
+ public static int[] evaluateIfValidJarIsPresent(World world, int x, int y, int z, EntityPlayer player, JarPieceEvaluationRunnable topRunnable, JarPieceEvaluationRunnable glassRunnable, JarPieceEvaluationRunnable centerRunnable) {
+ for (int xx = x - 2; xx <= x; xx++) {
+ for (int yy = y - 3; yy <= y; yy++) {
+ for (int zz = z - 2; zz <= z; zz++) {
+ if (isValidJarAt(world, xx, yy, zz, player, topRunnable, glassRunnable, centerRunnable)) {
+ return new int[] {xx, yy, zz};
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public static boolean isValidJarAt(World world, int x, int y, int z, EntityPlayer player, JarPieceEvaluationRunnable topRunnable, JarPieceEvaluationRunnable glassRunnable, JarPieceEvaluationRunnable centerRunnable) {
+ int[][][] blueprint = {{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}, {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}, {{2, 2, 2}, {2, 3, 2}, {2, 2, 2}}, {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}};
+ for (int yy = 0; yy < 4; yy++) {
+ for (int xx = 0; xx < 3; xx++) {
+ for (int zz = 0; zz < 3; zz++) {
+ int index = blueprint[yy][xx][zz];
+ if (index == 1) {
+ if (!topRunnable.isValidPieceAt(world, x + xx, y - yy + 2, z + zz, player)) return false;
+ }
+ if (index == 2) {
+ if (!glassRunnable.isValidPieceAt(world, x + xx, y - yy + 2, z + zz, player)) return false;
+ }
+ if (index == 3) {
+ if (!centerRunnable.isValidPieceAt(world, x + xx, y - yy + 2, z + zz, player)) return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ //TODO spawn growingNodeJar and handle renders and such nasty stuff...
+
+ public static void replaceTCJar(World world, int x, int y, int z) {
+ int[][][] blueprint = {{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}, {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}, {{2, 2, 2}, {2, 3, 2}, {2, 2, 2}}, {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}};
+ for (int yy = 0; yy < 4; yy++) {
+ for (int xx = 0; xx < 3; xx++) {
+ for (int zz = 0; zz < 3; zz++) {
+ if (blueprint[yy][xx][zz] == 3) {
+ TileEntity tile = world.getTileEntity(x + xx, y - yy + 2, z + zz);
+ INode node = (INode) tile;
+ AspectList na = node.getAspects().copy();
+ int nt = node.getNodeType().ordinal();
+ int nm = -1;
+ if (node.getNodeModifier() != null) {
+ nm = node.getNodeModifier().ordinal();
+ }
+ if (world.rand.nextFloat() < 0.75F) {
+ if (node.getNodeModifier() == null) {
+ nm = NodeModifier.PALE.ordinal();
+ } else if (node.getNodeModifier() == NodeModifier.BRIGHT) {
+ nm = -1;
+ } else if (node.getNodeModifier() == NodeModifier.PALE) {
+ nm = NodeModifier.FADING.ordinal();
+ }
+ }
+ String nid = node.getId();
+ node.setAspects(new AspectList());
+ world.removeTileEntity(x + xx, y - yy + 2, z + zz);
+ world.setBlock(x + xx, y - yy + 2, z + zz, ConfigBlocks.blockJar, 2, 3);
+ tile = world.getTileEntity(x + xx, y - yy + 2, z + zz);
+ TileJarNode jar = (TileJarNode) tile;
+ jar.setAspects(na);
+ if (nm >= 0) {
+ jar.setNodeModifier(NodeModifier.values()[nm]);
+ }
+ jar.setNodeType(NodeType.values()[nt]);
+ jar.setId(nid);
+ world.addBlockEvent(x + xx, y - yy + 2, z + zz, ConfigBlocks.blockJar, 9, 0);
+ } else {
+ world.setBlockToAir(x + xx, y - yy + 2, z + zz);
+ }
+ }
+ }
+ }
+ world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "thaumcraft:wand", 1.0F, 1.0F);
+ }
+
+ public static void replaceAutomagyJar(World world, int x, int y, int z) {
+ int[][][] blueprint = {{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}, {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}, {{2, 2, 2}, {2, 3, 2}, {2, 2, 2}}, {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}};
+ for (int yy = 0; yy < 4; yy++) {
+ for (int xx = 0; xx < 3; xx++) {
+ for (int zz = 0; zz < 3; zz++) {
+ int index = blueprint[yy][xx][zz];
+ if (index == 3) {
+ TileEntity tile = world.getTileEntity(x + xx, y - yy + 2, z + zz);
+ INode node = (INode) tile;
+ AspectList na = node.getAspects().copy();
+ int nt = node.getNodeType().ordinal();
+ int nm = -1;
+ if (node.getNodeModifier() != null) {
+ nm = node.getNodeModifier().ordinal();
+ }
+ String nid = node.getId();
+ node.setAspects(new AspectList());
+ world.removeTileEntity(x + xx, y - yy + 2, z + zz);
+ world.setBlock(x + xx, y - yy + 2, z + zz, ConfigBlocks.blockJar, 2, 3);
+ tile = world.getTileEntity(x + xx, y - yy + 2, z + zz);
+ TileJarNode jar = (TileJarNode) tile;
+ jar.setAspects(na);
+ if (nm >= 0) {
+ jar.setNodeModifier(NodeModifier.values()[nm]);
+ }
+ jar.setNodeType(NodeType.values()[nt]);
+ jar.setId(nid);
+ world.addBlockEvent(x + xx, y - yy + 2, z + zz, ConfigBlocks.blockJar, 9, 0);
+ } else {
+ world.setBlockToAir(x + xx, y - yy + 2, z + zz);
+ }
+ }
+ }
+ }
+ }
+
+ public abstract static class JarPieceEvaluationRunnable {
+
+ public abstract boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player);
+
+ }
+
+}