diff --git a/src/main/java/makeo/gadomancy/client/ClientProxy.java b/src/main/java/makeo/gadomancy/client/ClientProxy.java index 5c27893..0ede834 100644 --- a/src/main/java/makeo/gadomancy/client/ClientProxy.java +++ b/src/main/java/makeo/gadomancy/client/ClientProxy.java @@ -5,6 +5,7 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.FMLLog; import makeo.gadomancy.client.events.RenderEventHandler; +import makeo.gadomancy.client.events.RenderWorldTickListener; import makeo.gadomancy.client.events.ResourceReloadListener; import makeo.gadomancy.client.gui.InfusionClawGui; import makeo.gadomancy.client.renderers.block.RenderBlockTransparent; @@ -105,6 +106,7 @@ public class ClientProxy extends CommonProxy { } MinecraftForge.EVENT_BUS.register(new RenderEventHandler()); + MinecraftForge.EVENT_BUS.register(new RenderWorldTickListener()); super.postInitalize(); } diff --git a/src/main/java/makeo/gadomancy/client/events/RenderEventHandler.java b/src/main/java/makeo/gadomancy/client/events/RenderEventHandler.java index 0c758a1..cef50fb 100644 --- a/src/main/java/makeo/gadomancy/client/events/RenderEventHandler.java +++ b/src/main/java/makeo/gadomancy/client/events/RenderEventHandler.java @@ -1,16 +1,23 @@ package makeo.gadomancy.client.events; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import makeo.gadomancy.client.util.GrowingDisplayManager; +import makeo.gadomancy.common.blocks.tiles.TileExtendedNode; import makeo.gadomancy.common.registration.RegisteredBlocks; import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MovingObjectPosition; import net.minecraftforge.client.event.DrawBlockHighlightEvent; import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; import thaumcraft.api.BlockCoordinates; import thaumcraft.api.IArchitect; +import thaumcraft.api.nodes.INode; import thaumcraft.api.wands.ItemFocusBasic; import thaumcraft.client.lib.REHWandHandler; +import thaumcraft.common.items.relics.ItemThaumometer; import thaumcraft.common.items.wands.ItemWandCasting; import java.util.ArrayList; @@ -29,7 +36,8 @@ public class RenderEventHandler { @SubscribeEvent public void on(DrawBlockHighlightEvent e) { - if(e.currentItem != null && e.currentItem.getItem() instanceof ItemWandCasting) { + if(e.currentItem == null) return; + if(e.currentItem.getItem() instanceof ItemWandCasting) { ItemFocusBasic focus = ((ItemWandCasting) e.currentItem.getItem()).getFocus(e.currentItem); if(focus == null || !(focus instanceof IArchitect)) { Block block = e.player.worldObj.getBlock(e.target.blockX, e.target.blockY, e.target.blockZ); @@ -53,6 +61,18 @@ public class RenderEventHandler { GL11.glPopAttrib(); } } + } else if(e.currentItem.getItem() instanceof ItemThaumometer) { + if(e.target.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) return; + int blockX = e.target.blockX; + int blockY = e.target.blockY; + 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()); + } } } } diff --git a/src/main/java/makeo/gadomancy/client/events/RenderWorldTickListener.java b/src/main/java/makeo/gadomancy/client/events/RenderWorldTickListener.java new file mode 100644 index 0000000..d94f3a1 --- /dev/null +++ b/src/main/java/makeo/gadomancy/client/events/RenderWorldTickListener.java @@ -0,0 +1,22 @@ +package makeo.gadomancy.client.events; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import makeo.gadomancy.client.util.GrowingDisplayManager; +import net.minecraftforge.client.event.RenderWorldLastEvent; + +/** + * 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 @ 23.10.2015 23:09 + */ +public class RenderWorldTickListener { + + @SubscribeEvent + public void worldRenderEvent(RenderWorldLastEvent event) { + GrowingDisplayManager.notifyRenderTick(); + } + +} 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 abc82f1..83c9423 100644 --- a/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileExtendedNode.java +++ b/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileExtendedNode.java @@ -1,11 +1,9 @@ package makeo.gadomancy.client.renderers.tile; +import makeo.gadomancy.client.renderers.tile.tc.RenderTileNodeBasic; import makeo.gadomancy.common.blocks.tiles.TileExtendedNode; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; -import org.lwjgl.opengl.GL11; -import thaumcraft.client.renderers.tile.TileNodeRenderer; /** * This class is part of the Gadomancy Mod @@ -15,19 +13,15 @@ import thaumcraft.client.renderers.tile.TileNodeRenderer; * * Created by HellFirePvP @ 22.10.2015 19:44 */ -public class RenderTileExtendedNode extends TileNodeRenderer { +public class RenderTileExtendedNode extends TileEntitySpecialRenderer { @Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) { - if(!(tile instanceof TileExtendedNode)) return; + if (!(tile instanceof TileExtendedNode)) return; TileExtendedNode node = (TileExtendedNode) tile; - EntityLivingBase renderView = Minecraft.getMinecraft().renderViewEntity; - renderView.posX += node.xMoved; - renderView.posY += node.yMoved; - renderView.posZ += node.zMoved; - super.renderTileEntityAt(tile, 0, 0, 0, partialTicks); - renderView.posX -= node.xMoved; - renderView.posY -= node.yMoved; - renderView.posZ -= node.zMoved; + 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); } } 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 new file mode 100644 index 0000000..f84c68a --- /dev/null +++ b/src/main/java/makeo/gadomancy/client/renderers/tile/tc/RenderTileNodeBasic.java @@ -0,0 +1,239 @@ +package makeo.gadomancy.client.renderers.tile.tc; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; +import org.lwjgl.opengl.GL11; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.api.nodes.INode; +import thaumcraft.api.nodes.IRevealer; +import thaumcraft.api.nodes.NodeModifier; +import thaumcraft.api.nodes.NodeType; +import thaumcraft.client.lib.UtilsFX; +import thaumcraft.common.items.relics.ItemThaumometer; +import thaumcraft.common.tiles.TileJarNode; +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 + * Thaumcraft: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1292130 + *

+ * Created by Azanor + * Modified by HellFirePvP @ 23.10.2015 20:04 + */ +public class RenderTileNodeBasic { + + /* + Changes overview: + (Note: Changes are visible by "Gadomancy START" to "Gadomancy END" or by a comment in the end of the line!) + + - 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. + + Changes made by HellFirePvP + */ + + public static final ResourceLocation nodetex = new ResourceLocation("thaumcraft", "textures/misc/nodes.png"); + + //Gadomancy: changed params x, y, z from int to double + public static void renderNode(EntityLivingBase viewer, double viewDistance, boolean visible, boolean depthIgnore, float size, double x, double y, double z, float partialTicks, AspectList aspects, NodeType type, NodeModifier mod) { + long nt = System.nanoTime(); + + UtilsFX.bindTexture(nodetex); + int frames = 32; + if ((aspects.size() > 0) && (visible)) { + double distance = viewer.getDistance(x, y, z); //Gadomancy: Removed '+ 0.5D' to coords. + if (distance > viewDistance) { + return; + } + float alpha = (float) ((viewDistance - distance) / viewDistance); + if (mod != null) { + switch (mod) { + 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); + if (depthIgnore) { + GL11.glDisable(2929); + } + GL11.glDisable(2884); + + long time = nt / 5000000L; + float bscale = 0.25F; + + GL11.glPushMatrix(); + float rad = 6.283186F; + GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha); + + + int i = (int) ((nt / 40000000L + x) % frames); + + int count = 0; + float scale = 0.0F; + float angle = 0.0F; + float average = 0.0F; + for (Aspect aspect : aspects.getAspects()) { + if (aspect.getBlend() == 771) { + alpha = (float) (alpha * 1.5D); + } + average += aspects.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 * (aspects.getAmount(aspect) / 50.0F); + scale *= size; + angle = (float) (time % (5000 + 500 * count)) / (5000.0F + 500 * count) * rad; + //Gadomancy (following line): Removed '+ 0.5D' to coords. + UtilsFX.renderFacingStrip(x, y, z, angle, scale, alpha / Math.max(1.0F, aspects.size() / 2.0F), frames, 0, i, partialTicks, aspect.getColor()); + GL11.glDisable(3042); + GL11.glPopMatrix(); + count++; + if (aspect.getBlend() == 771) { + alpha = (float) (alpha / 1.5D); + } + } + average /= aspects.size(); + GL11.glPushMatrix(); + GL11.glEnable(3042); + i = (int) ((nt / 40000000L + x) % frames); + scale = 0.1F + average / 150.0F; + scale *= size; + int strip = 1; + switch (type) { + case NORMAL: + GL11.glBlendFunc(770, 1); + break; + case UNSTABLE: + GL11.glBlendFunc(770, 1); + strip = 6; + angle = 0.0F; + 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); + //Gadomancy (following line): Removed '+ 0.5D' to coords. + UtilsFX.renderFacingStrip(x, y, z, angle, scale, alpha, frames, strip, i, partialTicks, 16777215); + GL11.glDisable(3042); + GL11.glPopMatrix(); + + GL11.glPopMatrix(); + + GL11.glEnable(2884); + if (depthIgnore) { + GL11.glEnable(2929); + } + GL11.glDepthMask(true); + GL11.glAlphaFunc(516, 0.1F); + GL11.glPopMatrix(); + } else { + GL11.glPushMatrix(); + GL11.glAlphaFunc(516, 0.003921569F); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 1); + GL11.glDepthMask(false); + + int i = (int) ((nt / 40000000L + x) % frames); + GL11.glColor4f(1.0F, 0.0F, 1.0F, 0.1F); + //Gadomancy (following line): Removed '+ 0.5D' to coords. + UtilsFX.renderFacingStrip(x, y, z, 0.0F, 0.5F, 0.1F, frames, 1, i, partialTicks, 16777215); + + GL11.glDepthMask(true); + GL11.glDisable(3042); + GL11.glAlphaFunc(516, 0.1F); + GL11.glPopMatrix(); + } + } + + public static void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) { + if (!(tile instanceof INode)) { + return; + } + float size = 1.0F; + INode node = (INode) tile; + double viewDistance = 64.0D; + EntityLivingBase viewer = Minecraft.getMinecraft().renderViewEntity; + boolean condition = false; + boolean depthIgnore = false; + if ((viewer instanceof EntityPlayer)) { + if ((tile != null) && ((tile instanceof TileJarNode))) { + condition = true; + size = 0.7F; + } 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; + } else if ((((EntityPlayer) viewer).inventory.getCurrentItem() != null) && ((((EntityPlayer) viewer).inventory.getCurrentItem().getItem() instanceof ItemThaumometer))) { + //Gadomancy: Changed from tile.xCoord, ... to x, y, z to make it dependent from params + if (UtilsFX.isVisibleTo(0.44F, viewer, x, y, z)) { + condition = true; + depthIgnore = true; + viewDistance = 48.0D; + } + } + } + //Gadomancy: Changed from tile.xCoord, ... to x, y, z to make it dependent from params + renderNode(viewer, viewDistance, condition, depthIgnore, size, x, y, z, partialTicks, ((INode) tile).getAspects(), ((INode) tile).getNodeType(), ((INode) tile).getNodeModifier()); + if (((tile instanceof TileNode)) && (((TileNode) tile).drainEntity != null) && (((TileNode) tile).drainCollision != null)) { + Entity drainEntity = ((TileNode) tile).drainEntity; + if (((drainEntity instanceof EntityPlayer)) && (!((EntityPlayer) drainEntity).isUsingItem())) { + ((TileNode) tile).drainEntity = null; + ((TileNode) tile).drainCollision = null; + return; + } + MovingObjectPosition drainCollision = ((TileNode) tile).drainCollision; + GL11.glPushMatrix(); + + float f10 = 0.0F; + int iiud = ((EntityPlayer) drainEntity).getItemInUseDuration(); + if ((drainEntity instanceof EntityPlayer)) { + f10 = MathHelper.sin(iiud / 10.0F) * 10.0F; + } + Vec3 vec3 = Vec3.createVectorHelper(-0.1D, -0.1D, 0.5D); + vec3.rotateAroundX(-(drainEntity.prevRotationPitch + (drainEntity.rotationPitch - drainEntity.prevRotationPitch) * partialTicks) * 3.141593F / 180.0F); + vec3.rotateAroundY(-(drainEntity.prevRotationYaw + (drainEntity.rotationYaw - drainEntity.prevRotationYaw) * partialTicks) * 3.141593F / 180.0F); + vec3.rotateAroundY(-f10 * 0.01F); + vec3.rotateAroundX(-f10 * 0.015F); + double d3 = drainEntity.prevPosX + (drainEntity.posX - drainEntity.prevPosX) * partialTicks + vec3.xCoord; + double d4 = drainEntity.prevPosY + (drainEntity.posY - drainEntity.prevPosY) * partialTicks + vec3.yCoord; + double d5 = drainEntity.prevPosZ + (drainEntity.posZ - drainEntity.prevPosZ) * partialTicks + vec3.zCoord; + double d6 = drainEntity == Minecraft.getMinecraft().thePlayer ? 0.0D : drainEntity.getEyeHeight(); + + UtilsFX.drawFloatyLine(d3, d4 + d6, d5, drainCollision.blockX + 0.5D, drainCollision.blockY + 0.5D, drainCollision.blockZ + 0.5D, partialTicks, ((TileNode) tile).color.getRGB(), "textures/misc/wispy.png", -0.02F, Math.min(iiud, 10) / 10.0F); + + GL11.glPopMatrix(); + } + } + +} diff --git a/src/main/java/makeo/gadomancy/client/util/GrowingDisplayManager.java b/src/main/java/makeo/gadomancy/client/util/GrowingDisplayManager.java new file mode 100644 index 0000000..acaf982 --- /dev/null +++ b/src/main/java/makeo/gadomancy/client/util/GrowingDisplayManager.java @@ -0,0 +1,62 @@ +package makeo.gadomancy.client.util; + +import makeo.gadomancy.client.events.ResourceReloadListener; +import net.minecraft.util.StatCollector; +import thaumcraft.api.nodes.NodeType; + +/** + * 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 @ 23.10.2015 22:53 + */ +public class GrowingDisplayManager { + + private static int timeout = 7; + private static int currTime = 0; + + private static boolean changedLanguageFile = false; + private static String currentNodeId = null; + private static String changedEntry = null; + private static String oldName = null; + + public static void notifyRenderTick() { + if(currTime > timeout) { + if(changedLanguageFile) { + resetLanguageFile(); + } + } else { + currTime++; + } + } + + private static void resetLanguageFile() { + currentNodeId = null; + ResourceReloadListener.languageList.put(changedEntry, oldName); + changedLanguageFile = false; + } + + public static void notifyDisplayTick(String id, NodeType nodeType) { + currTime = 0; + + if(currentNodeId != null && !currentNodeId.equals(id)) { + //New node. + resetLanguageFile(); + } + + if(!changedLanguageFile) { + String toChance = "nodetype." + nodeType + ".name"; + String name = StatCollector.translateToLocal(toChance); + String growingStr = StatCollector.translateToLocal("gadomancy.nodes.growing"); + String newName = name + ", " + growingStr; + ResourceReloadListener.languageList.put(toChance, newName); + + oldName = name; + changedEntry = toChance; + changedLanguageFile = true; + currentNodeId = id; + } + } +} diff --git a/src/main/java/makeo/gadomancy/common/blocks/BlockNode.java b/src/main/java/makeo/gadomancy/common/blocks/BlockNode.java index 03d838c..a2e8207 100644 --- a/src/main/java/makeo/gadomancy/common/blocks/BlockNode.java +++ b/src/main/java/makeo/gadomancy/common/blocks/BlockNode.java @@ -16,7 +16,9 @@ public class BlockNode extends thaumcraft.common.blocks.BlockAiry { @Override public TileEntity createTileEntity(World world, int metadata) { - if(metadata == 0) return new TileExtendedNode(); + if(metadata == 0) { + return new TileExtendedNode(); + } return super.createTileEntity(world, metadata); } } 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 146dc2c..018990b 100644 --- a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileExtendedNode.java +++ b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileExtendedNode.java @@ -1,8 +1,17 @@ package makeo.gadomancy.common.blocks.tiles; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.common.entities.EntityAspectOrb; +import thaumcraft.common.entities.monster.EntityWisp; +import thaumcraft.common.items.ItemWispEssence; import thaumcraft.common.tiles.TileNode; +import java.util.List; import java.util.Random; /** @@ -15,19 +24,139 @@ import java.util.Random; */ public class TileExtendedNode extends TileNode { - public boolean growing = false; - public double xMoved, yMoved, zMoved; - - public TileExtendedNode() { - this.xMoved = 0.5; - this.yMoved = 0.5; - this.zMoved = 0.5; - this.growing = new Random().nextBoolean(); - } + public boolean growing = new Random().nextBoolean(); @Override public void updateEntity() { super.updateEntity(); + + boolean needUpdate; + + needUpdate = handleGrowingNode(false); + + if (needUpdate) { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + markDirty(); + } + } + + //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)); + if ((aspectOrbs != null) && (aspectOrbs.size() > 0)) { + for (Object orb : aspectOrbs) { + EntityAspectOrb aspectOrb = (EntityAspectOrb) orb; + if ((aspectOrb.isEntityAlive()) && (!aspectOrb.isEntityInvulnerable())) { + 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); + needUpdate = true; + } + } + aspectOrb.setDead(); + } + } + applyMovementVectors(aspectOrb); + } + } + List items = this.worldObj.getEntitiesWithinAABB(EntityItem.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)); + if ((items != null) && (items.size() > 0)) { + for (Object item : items) { + EntityItem entityItem = (EntityItem) item; + if(!(entityItem.getEntityItem().getItem() instanceof ItemWispEssence)) continue; + if ((entityItem.isEntityAlive()) && (!entityItem.isEntityInvulnerable())) { + double d = getDistanceTo(entityItem.posX, entityItem.posY, entityItem.posZ); + if (d < 1.0D) { //prev: 2.0D + ItemWispEssence essence = (ItemWispEssence) entityItem.getEntityItem().getItem(); + AspectList list = essence.getAspects(entityItem.getEntityItem()); + if(!(list == null || list.size() == 0)) { + Aspect aspect = list.getAspects()[0]; + 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) < 1; + } else { + mayAdd = true; + } + if (mayAdd) { + getAspectsBase().add(aspect, 1); + needUpdate = true; + } + } + } + entityItem.setDead(); + } + } + applyMovementVectors(entityItem); + } + } + List wisps = this.worldObj.getEntitiesWithinAABB(EntityWisp.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)); + if ((wisps != null) && (wisps.size() > 0)) { + for (Object wispObj : wisps) { + EntityWisp wisp = (EntityWisp) wispObj; + if ((wisp.isEntityAlive()) && (!wisp.isEntityInvulnerable())) { + double d = getDistanceTo(wisp.posX, wisp.posY, wisp.posZ); + 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); + needUpdate = true; + } + } + wisp.setDead(); + } + } + applyMovementVectors(wisp); + } + } + return needUpdate; + } + + private void applyMovementVectors(Entity entity) { + double var3 = (this.xCoord + 0.5D - entity.posX) / 15.0D; + double var5 = (this.yCoord + 0.5D - entity.posY) / 15.0D; + double var7 = (this.zCoord + 0.5D - entity.posZ) / 15.0D; + double var9 = Math.sqrt(var3 * var3 + var5 * var5 + var7 * var7); + double var11 = 1.0D - var9; + if (var11 > 0.0D) { + var11 *= var11; + entity.motionX += var3 / var9 * var11 * 0.15D; + entity.motionY += var5 / var9 * var11 * 0.25D; + entity.motionZ += var7 / var9 * var11 * 0.15D; + } } @Override @@ -36,7 +165,6 @@ public class TileExtendedNode extends TileNode { NBTTagCompound compound = nbttagcompound.getCompoundTag("Gadomancy"); this.growing = compound.getBoolean("growing"); - } @Override diff --git a/src/main/resources/assets/gadomancy/lang/en_US.lang b/src/main/resources/assets/gadomancy/lang/en_US.lang index 646a128..a8a9894 100644 --- a/src/main/resources/assets/gadomancy/lang/en_US.lang +++ b/src/main/resources/assets/gadomancy/lang/en_US.lang @@ -43,6 +43,8 @@ tile.BlockInfusionClaw.name=Infusion Claw tile.BlockRemoteJar.name=[WIP] Mirrored Jar tile.BlockNode.name=Aura Node +gadomancy.nodes.growing=Growing + gadomancy.info.InfusionClaw.owner=You are now the owner. gadomancy.info.InfusionClaw.waila=ยง7Owner: gadomancy.info.InfusionClaw.lock=Keep useable wand \ No newline at end of file