diff --git a/build.gradle b/build.gradle index bc618f2..5ce91c0 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "1.7.10-1.0.1" +version = "1.7.10-1.0.2" group= "makeo.gadomancy" archivesBaseName = "gadomancy" diff --git a/src/main/java/makeo/gadomancy/client/ClientProxy.java b/src/main/java/makeo/gadomancy/client/ClientProxy.java index cf065f4..e083596 100644 --- a/src/main/java/makeo/gadomancy/client/ClientProxy.java +++ b/src/main/java/makeo/gadomancy/client/ClientProxy.java @@ -10,23 +10,10 @@ import makeo.gadomancy.client.gui.InfusionClawGui; import makeo.gadomancy.client.renderers.block.BlockExtendedNodeJarRenderer; import makeo.gadomancy.client.renderers.block.RenderBlockTransparent; import makeo.gadomancy.client.renderers.entity.RenderAdditionalGolemBase; -import makeo.gadomancy.client.renderers.item.ItemExNodeRenderer; -import makeo.gadomancy.client.renderers.item.ItemJarExtendedNodeRenderer; -import makeo.gadomancy.client.renderers.item.ItemRenderRemoteJar; -import makeo.gadomancy.client.renderers.item.ItemRenderTileEntity; -import makeo.gadomancy.client.renderers.tile.RenderTileArcaneDropper; -import makeo.gadomancy.client.renderers.tile.RenderTileExtendedNode; -import makeo.gadomancy.client.renderers.tile.RenderTileExtendedNodeJar; -import makeo.gadomancy.client.renderers.tile.RenderTileInfusionClaw; -import makeo.gadomancy.client.renderers.tile.RenderTileRemoteJar; -import makeo.gadomancy.client.renderers.tile.RenderTileStickyJar; +import makeo.gadomancy.client.renderers.item.*; +import makeo.gadomancy.client.renderers.tile.*; import makeo.gadomancy.common.CommonProxy; -import makeo.gadomancy.common.blocks.tiles.TileArcaneDropper; -import makeo.gadomancy.common.blocks.tiles.TileExtendedNode; -import makeo.gadomancy.common.blocks.tiles.TileExtendedNodeJar; -import makeo.gadomancy.common.blocks.tiles.TileInfusionClaw; -import makeo.gadomancy.common.blocks.tiles.TileRemoteJar; -import makeo.gadomancy.common.blocks.tiles.TileStickyJar; +import makeo.gadomancy.common.blocks.tiles.*; import makeo.gadomancy.common.registration.RegisteredBlocks; import makeo.gadomancy.common.registration.RegisteredItems; import makeo.gadomancy.common.utils.Injector; @@ -87,6 +74,12 @@ public class ClientProxy extends CommonProxy { RenderTileExtendedNodeJar nodeJarRenderer = new RenderTileExtendedNodeJar(); ClientRegistry.bindTileEntitySpecialRenderer(TileExtendedNodeJar.class, nodeJarRenderer); + ClientRegistry.bindTileEntitySpecialRenderer(TileNodeManipulator.class, new RenderTileNodeManipulator()); + + ClientRegistry.bindTileEntitySpecialRenderer(TileManipulatorPillar.class, new RenderTileManipulatorPillar()); + RenderTileManipulationFocus renderTileManipulationFocus = new RenderTileManipulationFocus(); + ClientRegistry.bindTileEntitySpecialRenderer(TileManipulationFocus.class, renderTileManipulationFocus); + //Items TileArcaneDropper fakeTile = new TileArcaneDropper(); fakeTile.blockMetadata = 8 | ForgeDirection.SOUTH.ordinal(); @@ -99,6 +92,10 @@ public class ClientProxy extends CommonProxy { MinecraftForgeClient.registerItemRenderer(RegisteredItems.itemExtendedNodeJar, new ItemJarExtendedNodeRenderer()); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RegisteredBlocks.blockRemoteJar), new ItemRenderRemoteJar(renderTileRemoteJar)); + ItemRenderStoneMachine itemRenderStoneMachine = new ItemRenderStoneMachine(); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RegisteredBlocks.blockStoneMachine), itemRenderStoneMachine); + itemRenderStoneMachine.registerRenderer(0, new TileManipulationFocus(), renderTileManipulationFocus); + //Blocks RegisteredBlocks.rendererTransparentBlock = registerBlockRenderer(new RenderBlockTransparent()); RegisteredBlocks.rendererExtendedNodeJarBlock = registerBlockRenderer(new BlockExtendedNodeJarRenderer()); diff --git a/src/main/java/makeo/gadomancy/client/events/RenderEventHandler.java b/src/main/java/makeo/gadomancy/client/events/RenderEventHandler.java index 388a9cf..27d05d7 100644 --- a/src/main/java/makeo/gadomancy/client/events/RenderEventHandler.java +++ b/src/main/java/makeo/gadomancy/client/events/RenderEventHandler.java @@ -87,6 +87,6 @@ public class RenderEventHandler { @SubscribeEvent public void worldRenderEvent(RenderWorldLastEvent event) { ExtendedTypeDisplayManager.notifyRenderTick(); - MultiTickEffectDispatcher.notifyRenderTick(Minecraft.getMinecraft().theWorld); + MultiTickEffectDispatcher.notifyRenderTick(Minecraft.getMinecraft().theWorld, event.partialTicks); } } diff --git a/src/main/java/makeo/gadomancy/client/models/ModelManipulatorPart.java b/src/main/java/makeo/gadomancy/client/models/ModelManipulatorPart.java new file mode 100644 index 0000000..d27cf2d --- /dev/null +++ b/src/main/java/makeo/gadomancy/client/models/ModelManipulatorPart.java @@ -0,0 +1,70 @@ +package makeo.gadomancy.client.models; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +/** + * 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 makeo @ 28.10.2015 12:31 + */ +public class ModelManipulatorPart extends ModelBase { + //fields + ModelRenderer shape2; + ModelRenderer shape3; + ModelRenderer shape4; + ModelRenderer shape5; + + public ModelManipulatorPart() { + textureWidth = 8; + textureHeight = 16; + + shape2 = new ModelRenderer(this, 0, 5); + shape2.addBox(-1F, -2F, 0.41F, 2, 2, 1); + shape2.setRotationPoint(0F, 22F, 4F); + shape2.setTextureSize(8, 16); + shape2.mirror = true; + setRotation(shape2, 0F, 0F, 0F); + shape3 = new ModelRenderer(this, 0, 8); + shape3.addBox(-1F, -3.4F, 1F, 2, 2, 1); + shape3.setRotationPoint(0F, 22F, 4F); + shape3.setTextureSize(8, 16); + shape3.mirror = true; + setRotation(shape3, 0.3490659F, 0F, 0F); + shape4 = new ModelRenderer(this, 0, 0); + shape4.addBox(-1F, -1F, 0F, 2, 4, 1); + shape4.setRotationPoint(0F, 22F, 4F); + shape4.setTextureSize(8, 16); + shape4.mirror = true; + setRotation(shape4, -0.7853982F, 0F, 0F); + shape5 = new ModelRenderer(this, 0, 11); + shape5.addBox(-1F, -4.25F, 2.24F, 2, 2, 1); + shape5.setRotationPoint(0F, 22F, 4F); + shape5.setTextureSize(8, 16); + shape5.mirror = true; + setRotation(shape5, 0.7853982F, 0F, 0F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + shape2.render(f5); + shape3.render(f5); + shape4.render(f5); + shape5.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + } +} diff --git a/src/main/java/makeo/gadomancy/client/models/ModelSmallCube.java b/src/main/java/makeo/gadomancy/client/models/ModelSmallCube.java new file mode 100644 index 0000000..869066c --- /dev/null +++ b/src/main/java/makeo/gadomancy/client/models/ModelSmallCube.java @@ -0,0 +1,42 @@ +package makeo.gadomancy.client.models; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +/** + * 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 makeo @ 27.10.2015 23:40 + */ +public class ModelSmallCube extends ModelBase { + //fields + ModelRenderer shape1; + + public ModelSmallCube() { + textureWidth = 8; + textureHeight = 4; + + shape1 = new ModelRenderer(this, 0, 0); + shape1.addBox(-1F, -3F, -1F, 2, 2, 2); + shape1.setRotationPoint(0F, 0F, 0F); + shape1.setTextureSize(8, 4); + shape1.mirror = true; + setRotation(shape1, 0F, 0F, 0F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + shape1.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } +} diff --git a/src/main/java/makeo/gadomancy/client/renderers/entity/PlayerCameraRenderer.java b/src/main/java/makeo/gadomancy/client/renderers/entity/PlayerCameraRenderer.java index edb2674..186574e 100644 --- a/src/main/java/makeo/gadomancy/client/renderers/entity/PlayerCameraRenderer.java +++ b/src/main/java/makeo/gadomancy/client/renderers/entity/PlayerCameraRenderer.java @@ -5,9 +5,12 @@ import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.entity.player.EntityPlayer; /** - * User: makeo - * Date: 09.07.2015 - * Time: 02:34 + * 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 makeo @ 09.07.2015 02:34 */ public class PlayerCameraRenderer extends EntityRenderer { private final Minecraft minecraft; diff --git a/src/main/java/makeo/gadomancy/client/renderers/item/ItemRenderRemoteJar.java b/src/main/java/makeo/gadomancy/client/renderers/item/ItemRenderRemoteJar.java index 004297f..07cec93 100644 --- a/src/main/java/makeo/gadomancy/client/renderers/item/ItemRenderRemoteJar.java +++ b/src/main/java/makeo/gadomancy/client/renderers/item/ItemRenderRemoteJar.java @@ -1,12 +1,12 @@ package makeo.gadomancy.client.renderers.item; +import cpw.mods.fml.client.registry.RenderingRegistry; import makeo.gadomancy.client.renderers.tile.RenderTileRemoteJar; import makeo.gadomancy.common.blocks.tiles.TileRemoteJar; import makeo.gadomancy.common.registration.RegisteredBlocks; import makeo.gadomancy.common.utils.NBTHelper; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.item.ItemStack; -import net.minecraft.src.FMLRenderAccessLibrary; import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; import thaumcraft.api.aspects.AspectList; @@ -48,7 +48,7 @@ public class ItemRenderRemoteJar extends ItemRenderTileEntity { GL11.glPushMatrix(); GL11.glTranslatef(0.5f, 0.5f, 0.5f); - FMLRenderAccessLibrary.renderInventoryBlock(RenderBlocks.getInstance(), RegisteredBlocks.blockRemoteJar, 0, RegisteredBlocks.blockRemoteJar.getRenderType()); + RenderingRegistry.instance().renderInventoryBlock(RenderBlocks.getInstance(), RegisteredBlocks.blockRemoteJar, 0, RegisteredBlocks.blockRemoteJar.getRenderType()); GL11.glPopMatrix(); } } diff --git a/src/main/java/makeo/gadomancy/client/renderers/item/ItemRenderStoneMachine.java b/src/main/java/makeo/gadomancy/client/renderers/item/ItemRenderStoneMachine.java new file mode 100644 index 0000000..6bfb31e --- /dev/null +++ b/src/main/java/makeo/gadomancy/client/renderers/item/ItemRenderStoneMachine.java @@ -0,0 +1,58 @@ +package makeo.gadomancy.client.renderers.item; + +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import org.lwjgl.opengl.GL11; + +import java.util.HashMap; +import java.util.Map; + +/** + * 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 makeo @ 28.10.2015 23:27 + */ +public class ItemRenderStoneMachine extends ItemRenderTileEntity { + private final Map renderers = new HashMap(); + + public ItemRenderStoneMachine() { } + + private static class RenderInfo { + private TileEntity tile; + private TileEntitySpecialRenderer renderer; + } + + public void registerRenderer(int metadata, TileEntity tile, TileEntitySpecialRenderer renderer) { + RenderInfo info = new RenderInfo(); + info.renderer = renderer; + info.tile = tile; + renderers.put(metadata, info); + + if(tile.getWorldObj() == null) { + tile.setWorldObj(FAKE_WORLD); + } + } + + @Override + public void renderItem(ItemRenderType type, ItemStack stack, Object... data) { + RenderInfo info = renderers.get(stack.getItemDamage()); + + tile = info.tile; + renderer = info.renderer; + + if(stack.getItemDamage() == 0) { + GL11.glTranslatef(0, 2/16f, 0); + } + + super.renderItem(type, stack, data); + } + + @Override + public boolean handleRenderType(ItemStack stack, ItemRenderType type) { + return renderers.containsKey(stack.getItemDamage()); + } +} diff --git a/src/main/java/makeo/gadomancy/client/renderers/item/ItemRenderTileEntity.java b/src/main/java/makeo/gadomancy/client/renderers/item/ItemRenderTileEntity.java index 5cde4e4..1ba8c81 100644 --- a/src/main/java/makeo/gadomancy/client/renderers/item/ItemRenderTileEntity.java +++ b/src/main/java/makeo/gadomancy/client/renderers/item/ItemRenderTileEntity.java @@ -17,13 +17,13 @@ import org.lwjgl.opengl.GL11; * Created by makeo @ 29.09.2015 18:29 */ public class ItemRenderTileEntity implements IItemRenderer { - private static final World FAKE_WORLD = new FakeWorld(); + protected static final World FAKE_WORLD = new FakeWorld(); - private final TileEntitySpecialRenderer render; - protected final T tile; + protected TileEntitySpecialRenderer renderer; + protected T tile; - public ItemRenderTileEntity(TileEntitySpecialRenderer render, T tile) { - this.render = render; + public ItemRenderTileEntity(TileEntitySpecialRenderer renderer, T tile) { + this.renderer = renderer; this.tile = tile; if(tile.getWorldObj() == null) { @@ -31,6 +31,8 @@ public class ItemRenderTileEntity implements IItemRenderer } } + protected ItemRenderTileEntity() { } + @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { return true; @@ -50,6 +52,6 @@ public class ItemRenderTileEntity implements IItemRenderer GL11.glTranslatef(0, -0.1f, 0); } - this.render.renderTileEntityAt(tile, 0.0D, 0.0D, 0.0D, 0.0F); + this.renderer.renderTileEntityAt(tile, 0.0D, 0.0D, 0.0D, 0.0F); } } 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 2a5b459..804dc35 100644 --- a/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileExtendedNode.java +++ b/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileExtendedNode.java @@ -1,6 +1,6 @@ package makeo.gadomancy.client.renderers.tile; -import makeo.gadomancy.common.blocks.tiles.ExtendedNodeType; +import makeo.gadomancy.common.node.ExtendedNodeType; import makeo.gadomancy.common.blocks.tiles.TileExtendedNode; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; diff --git a/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileManipulationFocus.java b/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileManipulationFocus.java new file mode 100644 index 0000000..7cfef48 --- /dev/null +++ b/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileManipulationFocus.java @@ -0,0 +1,46 @@ +package makeo.gadomancy.client.renderers.tile; + +import makeo.gadomancy.client.models.ModelManipulatorPart; +import makeo.gadomancy.common.blocks.tiles.TileManipulationFocus; +import makeo.gadomancy.common.utils.SimpleResourceLocation; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import org.lwjgl.opengl.GL11; + +/** + * 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 makeo @ 28.10.2015 18:00 + */ +public class RenderTileManipulationFocus extends TileEntitySpecialRenderer { + private static final ModelManipulatorPart RANDOM_FOCUS = new ModelManipulatorPart(); + + public void renderTileEntityAt(TileManipulationFocus tile, double x, double y, double z, float partialTicks) { + GL11.glPushMatrix(); + GL11.glTranslated(x, y, z); + + bindTexture(new SimpleResourceLocation("models/manipulation_focus_" + tile.fociId + ".png")); + + GL11.glRotatef(180, 1, 0, 0); + GL11.glTranslatef(0.5f, -1.5f + (2/16f), -0.5f); + + if(tile.fociId == 0) { + GL11.glPushMatrix(); + for(int i = 0; i < 4; i++) { + RANDOM_FOCUS.render(null, 0, 0, 0, 0, 0, 0.0625f); + GL11.glRotatef(90, 0, 1, 0); + } + GL11.glPopMatrix(); + } + + GL11.glPopMatrix(); + } + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) { + renderTileEntityAt((TileManipulationFocus)tile, x, y, z, partialTicks); + } +} diff --git a/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileManipulatorPillar.java b/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileManipulatorPillar.java new file mode 100644 index 0000000..dd63136 --- /dev/null +++ b/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileManipulatorPillar.java @@ -0,0 +1,37 @@ +package makeo.gadomancy.client.renderers.tile; + +import makeo.gadomancy.common.utils.Injector; +import makeo.gadomancy.common.utils.SimpleResourceLocation; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import thaumcraft.client.lib.UtilsFX; +import thaumcraft.client.renderers.tile.TileInfusionPillarRenderer; + +import java.util.Map; + +/** + * 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 makeo @ 27.10.2015 13:23 + */ +public class RenderTileManipulatorPillar extends TileInfusionPillarRenderer { + private static final String TC_TEXTURE = "textures/models/pillar.png"; + private static final ResourceLocation TEXTURE = new SimpleResourceLocation("models/manipulator_pillar.png"); + private static final Map BOUND_TEXTURES = new Injector(UtilsFX.class).getField("boundTextures"); + + @Override + public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) { + ResourceLocation originalTexture = BOUND_TEXTURES.get(TC_TEXTURE); + BOUND_TEXTURES.put(TC_TEXTURE, TEXTURE); + super.renderTileEntityAt(par1TileEntity, par2, par4, par6, par8); + + if(originalTexture != null) { + BOUND_TEXTURES.put(TC_TEXTURE, originalTexture); + } else { + BOUND_TEXTURES.remove(TC_TEXTURE); + } + } +} diff --git a/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileNodeManipulator.java b/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileNodeManipulator.java new file mode 100644 index 0000000..df57888 --- /dev/null +++ b/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileNodeManipulator.java @@ -0,0 +1,52 @@ +package makeo.gadomancy.client.renderers.tile; + +import makeo.gadomancy.client.models.ModelSmallCube; +import makeo.gadomancy.client.renderers.block.BlockNodeManipulatorRenderer; +import makeo.gadomancy.common.registration.RegisteredBlocks; +import makeo.gadomancy.common.utils.SimpleResourceLocation; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import org.lwjgl.opengl.GL11; +import thaumcraft.client.renderers.tile.TileWandPedestalRenderer; + +/** + * 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 makeo @ 27.10.2015 15:19 + */ +public class RenderTileNodeManipulator extends TileWandPedestalRenderer { + private static final ModelSmallCube MODEL = new ModelSmallCube(); + private static final SimpleResourceLocation TEXTURE = new SimpleResourceLocation("models/small_cube.png"); + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partitalTicks) { + super.renderTileEntityAt(tile, x, y, z, partitalTicks); + } + + public static void renderColorCubes(float r, float g, float b, float a) { + GL11.glPushMatrix(); + GL11.glColor4f(r, g, b, a); + + Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURE); + + for(int i = 0; i < 4; i++) { + GL11.glPushMatrix(); + + ForgeDirection dir = ForgeDirection.getOrientation(i + 2); + GL11.glTranslatef(dir.offsetX * (-6/16f), 0, dir.offsetZ * (-6/16f)); + + MODEL.render(null, 0, 0, 0, 0, 0, 0.0625f); + GL11.glPopMatrix(); + } + + GL11.glColor4f(1, 1, 1, 1); + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/makeo/gadomancy/client/transformation/FakeEntityGolemBase.java b/src/main/java/makeo/gadomancy/client/transformation/FakeEntityGolemBase.java index 17acfbe..bb8d873 100644 --- a/src/main/java/makeo/gadomancy/client/transformation/FakeEntityGolemBase.java +++ b/src/main/java/makeo/gadomancy/client/transformation/FakeEntityGolemBase.java @@ -6,9 +6,12 @@ import thaumcraft.common.entities.golems.EntityGolemBase; import thaumcraft.common.entities.golems.EnumGolemType; /** - * User: makeo - * Date: 05.07.2015 - * Time: 15:47 + * 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 makeo @ 05.07.2015 15:47 */ public class FakeEntityGolemBase extends EntityGolemBase { private EntityGolemBase golem; diff --git a/src/main/java/makeo/gadomancy/client/transformation/TransformationHelper.java b/src/main/java/makeo/gadomancy/client/transformation/TransformationHelper.java index 0198ee0..2ecbef4 100644 --- a/src/main/java/makeo/gadomancy/client/transformation/TransformationHelper.java +++ b/src/main/java/makeo/gadomancy/client/transformation/TransformationHelper.java @@ -17,9 +17,12 @@ import java.util.List; import java.util.Map; /** - * User: makeo - * Date: 04.07.2015 - * Time: 02:38 + * 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 makeo @ 04.07.2015 02:38 */ @SideOnly(Side.CLIENT) public class TransformationHelper { diff --git a/src/main/java/makeo/gadomancy/client/util/ExtendedTypeDisplayManager.java b/src/main/java/makeo/gadomancy/client/util/ExtendedTypeDisplayManager.java index 739625b..f6da503 100644 --- a/src/main/java/makeo/gadomancy/client/util/ExtendedTypeDisplayManager.java +++ b/src/main/java/makeo/gadomancy/client/util/ExtendedTypeDisplayManager.java @@ -1,7 +1,7 @@ package makeo.gadomancy.client.util; import makeo.gadomancy.client.events.ResourceReloadListener; -import makeo.gadomancy.common.blocks.tiles.ExtendedNodeType; +import makeo.gadomancy.common.node.ExtendedNodeType; import net.minecraft.util.StatCollector; import thaumcraft.api.nodes.NodeType; diff --git a/src/main/java/makeo/gadomancy/client/util/MultiTickEffectDispatcher.java b/src/main/java/makeo/gadomancy/client/util/MultiTickEffectDispatcher.java index 2ee8574..49c7e00 100644 --- a/src/main/java/makeo/gadomancy/client/util/MultiTickEffectDispatcher.java +++ b/src/main/java/makeo/gadomancy/client/util/MultiTickEffectDispatcher.java @@ -1,7 +1,9 @@ package makeo.gadomancy.client.util; import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; import net.minecraft.world.World; +import thaumcraft.client.lib.UtilsFX; import thaumcraft.common.Thaumcraft; import java.util.ArrayList; @@ -21,23 +23,54 @@ public class MultiTickEffectDispatcher { private static ReentrantLock renderLock = new ReentrantLock(); private static List vortexDigInfos = new ArrayList(); + private static List floatyLineInfos = new ArrayList(); - public static void notifyRenderTick(World currentRenderWorld) { + public static void notifyRenderTick(World currentRenderWorld, float partialTicks) { renderLock.lock(); try { handleVortexDiggingEffects(currentRenderWorld); + handleWispyLineEffects(currentRenderWorld, partialTicks); } finally { renderLock.unlock(); } } + private static void handleWispyLineEffects(World currentRenderWorld, float partialTicks) { + Iterator it = floatyLineInfos.iterator(); + while(it.hasNext()) { + FloatyLineInfo info = it.next(); + if(info.dimId != currentRenderWorld.provider.dimensionId) { + it.remove(); + continue; + } + info.renderTicks++; + if(info.renderTicks > info.tickCap) { + it.remove(); + continue; + } + + if(info.randomOffset == -1) { + info.randomOffset = currentRenderWorld.rand.nextInt(20); + } + + float ticks = Minecraft.getMinecraft().renderViewEntity.ticksExisted + info.randomOffset + partialTicks; + UtilsFX.drawFloatyLine(info.pedestalX, info.pedestalY, info.pedestalZ, info.originX, info.originY, info.originZ, partialTicks, info.colorAsInt, "textures/misc/wispy.png", -0.02F, Math.min(ticks, 10.0F) / 10.0F); + } + } + private static void handleVortexDiggingEffects(World currentRenderWorld) { Iterator it = vortexDigInfos.iterator(); while(it.hasNext()) { VortexDigInfo info = it.next(); - if(info.dimId != currentRenderWorld.provider.dimensionId) it.remove(); + if(info.dimId != currentRenderWorld.provider.dimensionId) { + it.remove(); + continue; + } info.renderTicks++; - if(info.renderTicks > 7) it.remove(); + if(info.renderTicks > info.tickCap) { + it.remove(); + continue; + } Thaumcraft.proxy.boreDigFx(currentRenderWorld, info.tX, info.tY, info.tZ, info.oX, info.oY, info.oZ, info.blockInstance, info.meta); } @@ -52,6 +85,38 @@ public class MultiTickEffectDispatcher { } } + public static void registerFloatyLine(FloatyLineInfo info) { + renderLock.lock(); + try { + floatyLineInfos.add(info); + } finally { + renderLock.unlock(); + } + } + + public static class FloatyLineInfo { + + private int dimId; + private double pedestalX, pedestalY, pedestalZ; + private double originX, originY, originZ; + private int renderTicks = 0; + private int tickCap; + private int colorAsInt; + private int randomOffset = -1; + + public FloatyLineInfo(int dimId, double pedestalX, double pedestalY, double pedestalZ, double originX, double originY, double originZ, int tickCap, int colorAsInt) { + this.dimId = dimId; + this.pedestalX = pedestalX; + this.pedestalY = pedestalY; + this.pedestalZ = pedestalZ; + this.originX = originX; + this.originY = originY; + this.originZ = originZ; + this.tickCap = tickCap; + this.colorAsInt = colorAsInt; + } + } + public static class VortexDigInfo { private int dimId; @@ -60,8 +125,9 @@ public class MultiTickEffectDispatcher { private Block blockInstance; private int meta; private int renderTicks = 0; + private int tickCap; - public VortexDigInfo(int dimId, int oX, int oY, int oZ, int tX, int tY, int tZ, Block blockInstance, int meta) { + public VortexDigInfo(int dimId, int oX, int oY, int oZ, int tX, int tY, int tZ, Block blockInstance, int meta, int tickDuration) { this.dimId = dimId; this.oX = oX; this.oY = oY; @@ -71,6 +137,7 @@ public class MultiTickEffectDispatcher { this.tZ = tZ; this.blockInstance = blockInstance; this.meta = meta; + this.tickCap = tickDuration; } } diff --git a/src/main/java/makeo/gadomancy/client/util/UtilsFX.java b/src/main/java/makeo/gadomancy/client/util/UtilsFX.java new file mode 100644 index 0000000..0b19bed --- /dev/null +++ b/src/main/java/makeo/gadomancy/client/util/UtilsFX.java @@ -0,0 +1,50 @@ +package makeo.gadomancy.client.util; + +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.world.World; +import thaumcraft.common.Thaumcraft; + +import java.awt.*; + +/** + * 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 @ 30.10.2015 20:08 + */ +public class UtilsFX { + + private static final Color[] runeColors = new Color[] { new Color(0xB60707), new Color(0xEE3782), new Color(0xF37B20), new Color(0xFF6722), new Color(0xFF6D30), new Color(0xFF0000) }; + + public static void doRuneEffects(World world, int x, int y, int z) { + if(world.isRemote) { + int cnt = 20; + while(cnt > 0) { + cnt--; + Color rand = runeColors[world.rand.nextInt(runeColors.length)]; + Thaumcraft.proxy.blockRunes(world, x + randomOffset(world), y + randomOffset(world), z + randomOffset(world), + rand.getRed() / 255F, rand.getGreen() / 255F, rand.getBlue() / 255F, world.rand.nextInt(10) + 30, -0.01F - (world.rand.nextBoolean() ? world.rand.nextBoolean() ? 0.02F : 0.01F : 0F)); + } + } + } + + private static float randomOffset(World worldObj) { + return (worldObj.rand.nextFloat() * (worldObj.rand.nextBoolean() ? 1 : -1)) / 2F; + } + + public static void doSparkleEffectsAround(World world, int x, int y, int z) { + doSparkleEffects(world, x, y, z); + doSparkleEffects(world, x + 1, y, z); + doSparkleEffects(world, x, y, z + 1); + doSparkleEffects(world, x - 1, y, z); + doSparkleEffects(world, x, y, z - 1); + doSparkleEffects(world, x, y - 1, z); + doSparkleEffects(world, x, y + 1, z); + } + + public static void doSparkleEffects(World world, int x, int y, int z) { + Thaumcraft.proxy.blockSparkle(world, x, y, z, -9999, 10); + } +} diff --git a/src/main/java/makeo/gadomancy/common/CommonProxy.java b/src/main/java/makeo/gadomancy/common/CommonProxy.java index 18fcbe0..b47aa44 100644 --- a/src/main/java/makeo/gadomancy/common/CommonProxy.java +++ b/src/main/java/makeo/gadomancy/common/CommonProxy.java @@ -74,6 +74,8 @@ public class CommonProxy implements IGuiHandler { RegisteredResearches.postInit(); + RegisteredItems.postInit(); + ModSubstitutions.postInit(); } diff --git a/src/main/java/makeo/gadomancy/common/Gadomancy.java b/src/main/java/makeo/gadomancy/common/Gadomancy.java index b980f2f..d29179b 100644 --- a/src/main/java/makeo/gadomancy/common/Gadomancy.java +++ b/src/main/java/makeo/gadomancy/common/Gadomancy.java @@ -25,7 +25,7 @@ public class Gadomancy public static final String MODID = "gadomancy"; public static final String NAME = "Gadomancy"; - public static final String VERSION = "1.0.0"; + public static final String VERSION = "1.0.2"; private static final String PROXY_CLIENT = "makeo.gadomancy.client.ClientProxy"; private static final String PROXY_SERVER = "makeo.gadomancy.common.CommonProxy"; diff --git a/src/main/java/makeo/gadomancy/common/blocks/BlockNodeManipulator.java b/src/main/java/makeo/gadomancy/common/blocks/BlockNodeManipulator.java new file mode 100644 index 0000000..1b5d1ac --- /dev/null +++ b/src/main/java/makeo/gadomancy/common/blocks/BlockNodeManipulator.java @@ -0,0 +1,98 @@ +package makeo.gadomancy.common.blocks; + +import makeo.gadomancy.common.Gadomancy; +import makeo.gadomancy.common.blocks.tiles.TileNodeManipulator; +import makeo.gadomancy.common.registration.RegisteredBlocks; +import makeo.gadomancy.common.registration.RegisteredItems; +import makeo.gadomancy.common.registration.RegisteredRecipes; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import thaumcraft.api.ThaumcraftApiHelper; +import thaumcraft.common.blocks.BlockStoneDevice; +import thaumcraft.common.items.wands.ItemWandCasting; +import thaumcraft.common.lib.research.ResearchManager; +import thaumcraft.common.lib.utils.InventoryUtils; + +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 @ 26.10.2015 19:23 + */ +public class BlockNodeManipulator extends BlockStoneDevice { + + public BlockNodeManipulator() { + setBlockName("blockNodeManipulator"); + setCreativeTab(RegisteredItems.creativeTab); + } + + @Override + public void registerBlockIcons(IIconRegister ir) { + super.registerBlockIcons(ir); + + iconPedestal[1] = ir.registerIcon(Gadomancy.MODID + ":manipulator_bot"); + iconWandPedestal[0] = ir.registerIcon(Gadomancy.MODID + ":manipulator_side"); + iconWandPedestal[1] = ir.registerIcon(Gadomancy.MODID + ":manipulator_top"); + + iconWandPedestalFocus[0] = ir.registerIcon(Gadomancy.MODID + ":manipulator_focus_side"); + iconWandPedestalFocus[1] = ir.registerIcon(Gadomancy.MODID + ":manipulator_focus_top"); + iconWandPedestalFocus[2] = ir.registerIcon(Gadomancy.MODID + ":manipulator_focus_bot"); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return null; + } + + //TC stuff... + @Override + public TileEntity createTileEntity(World world, int metadata) { + if (metadata == 5) + return new TileNodeManipulator(); + return null; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int rs) { + int ret = super.getComparatorInputOverride(world, x, y, z, rs); + + TileEntity te = world.getTileEntity(x, y, z); + if (te != null && te instanceof TileNodeManipulator) return 0; + return ret; + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + par3List.add(new ItemStack(par1, 1, 5)); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) { + TileNodeManipulator tile = (TileNodeManipulator) world.getTileEntity(x, y, z); + ItemStack heldItem = player.getHeldItem(); + if(tile.isInMultiblock()) { + super.onBlockActivated(world, x, y, z, player, side, par7, par8, par9); + } else if(!world.isRemote && heldItem != null && heldItem.getItem() instanceof ItemWandCasting) { + tile.checkMultiblock(); + if (tile.isMultiblockStructurePresent()) { + if(!ResearchManager.isResearchComplete(player.getCommandSenderName(), Gadomancy.MODID.toUpperCase() + ".NODE_MANIPULATOR")) return false; + if (ThaumcraftApiHelper.consumeVisFromWandCrafting(player.getCurrentEquippedItem(), player, RegisteredRecipes.costsNodeManipulatorMultiblock, true)) { + tile.formMultiblock(); + return true; + } + } + } + return false; + } +} diff --git a/src/main/java/makeo/gadomancy/common/blocks/BlockStoneMachine.java b/src/main/java/makeo/gadomancy/common/blocks/BlockStoneMachine.java new file mode 100644 index 0000000..e8bc542 --- /dev/null +++ b/src/main/java/makeo/gadomancy/common/blocks/BlockStoneMachine.java @@ -0,0 +1,186 @@ +package makeo.gadomancy.common.blocks; + +import makeo.gadomancy.common.blocks.tiles.TileManipulationFocus; +import makeo.gadomancy.common.blocks.tiles.TileManipulatorPillar; +import makeo.gadomancy.common.registration.RegisteredBlocks; +import makeo.gadomancy.common.registration.RegisteredItems; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import thaumcraft.common.config.ConfigBlocks; + +import java.util.List; +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 makeo @ 27.10.2015 13:16 + */ +public class BlockStoneMachine extends Block { + public BlockStoneMachine() { + super(Material.rock); + setHardness(3.0F); + setResistance(25.0F); + setStepSound(Block.soundTypeStone); + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + setCreativeTab(RegisteredItems.creativeTab); + } + + private IIcon pillarIcon; + private IIcon focusIcon; + + @Override + public void registerBlockIcons(IIconRegister ir) { + pillarIcon = ir.registerIcon("thaumcraft:es_1"); + focusIcon = ir.registerIcon("thaumcraft:thaumiumblock"); + } + + @Override + public IIcon getIcon(int side, int metadata) { + if(metadata == 11 || metadata == 15) { + return pillarIcon; + } else if(metadata == 0) { + return focusIcon; + } + + return super.getIcon(side, metadata); + } + + @Override + public boolean hasTileEntity(int metadata) { + return metadata == 15 || metadata == 0; + } + + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + list.add(new ItemStack(item, 1, 0)); + list.add(new ItemStack(item, 1, 15)); + list.add(new ItemStack(item, 1, 11)); + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { + int metadata = world.getBlockMetadata(x, y, z); + if(metadata == 11 || metadata == 15) { + return new ItemStack(getItemDropped(metadata, null, 0), 1, damageDropped(metadata)); + } + + return super.getPickBlock(target, world, x, y, z, player); + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + if(metadata == 15) { + return new TileManipulatorPillar(); + } else if(metadata == 0) { + return new TileManipulationFocus(); + } + return null; + } + + @Override + public int damageDropped(int metadata) { + return metadata; + } + + @Override + public Item getItemDropped(int metadata, Random random, int fortune) { + if(metadata == 11 || metadata == 15) { + return Item.getItemFromBlock(ConfigBlocks.blockCosmeticSolid); + } + + return super.getItemDropped(metadata, random, fortune); + } + + @Override + public boolean canReplace(World world, int x, int y, int z, int side, ItemStack stack) { + if(stack.getItemDamage() == 0 && (y < 1 || world.getBlock(x, y - 1, z) != RegisteredBlocks.blockNodeManipulator)) { + return false; + } + return super.canReplace(world, x, y, z, side, stack); + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + int metadata = world.getBlockMetadata(x, y, z); + if(metadata == 15) { + if(world.getBlock(x, y + 1, z) != this || world.getBlockMetadata(x, y + 1, z) != 11) { + dropBlockAsItem(world, x, y, z, metadata, 0); + world.setBlockToAir(x, y, z); + } + } else if(metadata == 11) { + if(world.getBlock(x, y - 1, z) != this || world.getBlockMetadata(x, y - 1, z) != 15) { + dropBlockAsItem(world, x, y, z, metadata, 0); + world.setBlockToAir(x, y, z); + } + } else if(metadata == 0) { + if(world.getBlock(x, y - 1, z) != RegisteredBlocks.blockNodeManipulator || world.getBlockMetadata(x, y - 1, z) != 5) { + dropBlockAsItem(world, x, y, z, metadata, 0); + world.setBlockToAir(x, y, z); + } + } + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + if(world.getBlockMetadata(x, y, z) == 0 && world.getBlock(x, y - 1, z).equals(RegisteredBlocks.blockNodeManipulator) && world.getBlockMetadata(x, y - 1, z) == 5) { + world.getBlock(x, y - 1, z).onBlockActivated(world, x, y - 1, z, p_149727_5_, p_149727_6_, p_149727_7_, p_149727_8_, p_149727_9_); + } + return super.onBlockActivated(world, x, y, z, p_149727_5_, p_149727_6_, p_149727_7_, p_149727_8_, p_149727_9_); + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + int metadata = world.getBlockMetadata(x, y, z); + if(metadata == 15) { + setBlockBounds(0, 0, 0, 1, 0.5f, 1); + } else if(metadata == 11) { + setBlockBounds(0.0F, -1.0F, 0.0F, 1.0F, -0.5F, 1.0F); + } else if(metadata == 0) { + setBlockBounds(3/16f, 0, 3/16f, 1-(3/16f), 6/16f, 1-(3/16f)); + } + super.setBlockBoundsBasedOnState(world, x, y, z); + } + + @Override + public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List list, Entity entity) { + int metadata = world.getBlockMetadata(x, y, z); + if(metadata == 11 || metadata == 15) { + setBlockBounds(0, 0, 0, 1, 1, 1); + } else if(metadata == 0) { + setBlockBoundsBasedOnState(world, x, y, z); + } + + super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, list, entity); + } + + public boolean isOpaqueCube() +/* 97: */ { +/* 98: 96 */ return false; +/* 99: */ } + + public boolean renderAsNormalBlock() +/* 102: */ { +/* 103:102 */ return false; +/* 104: */ } + + @Override + public int getRenderType() { + return -1; + } +} 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 4979a87..3a76127 100644 --- a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileExtendedNode.java +++ b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileExtendedNode.java @@ -4,21 +4,21 @@ import cpw.mods.fml.common.network.NetworkRegistry; import makeo.gadomancy.common.Gadomancy; import makeo.gadomancy.common.network.PacketHandler; import makeo.gadomancy.common.network.packets.PacketTCNodeBolt; +import makeo.gadomancy.common.node.ExtendedNodeType; +import makeo.gadomancy.common.node.GrowingNodeBehavior; import makeo.gadomancy.common.utils.ExplosionHelper; +import makeo.gadomancy.common.utils.ResearchHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.Item; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.world.EnumDifficulty; -import thaumcraft.api.ThaumcraftApi; import thaumcraft.api.aspects.Aspect; -import thaumcraft.api.aspects.AspectList; import thaumcraft.api.aspects.IEssentiaContainerItem; import thaumcraft.api.nodes.INode; import thaumcraft.common.Thaumcraft; @@ -42,7 +42,7 @@ import java.util.Random; * * Created by HellFirePvP @ 21.10.2015 23:39 */ -public class TileExtendedNode extends TileNode { +public class TileExtendedNode extends TileNode implements INode { public int ticksExisted = 0; private ExtendedNodeType extendedNodeType; @@ -56,26 +56,6 @@ public class TileExtendedNode extends TileNode { this.behavior = new GrowingNodeBehavior(this); } - public void addTypeSpecificAspects(ExtendedNodeType extendedNodeType) { - if(extendedNodeType == null) return; - switch (extendedNodeType) { - case GROWING: - List compounds = Aspect.getCompoundAspects(); - int count = 1; - if(worldObj.rand.nextInt(3) == 0) count++; - while(count > 0) { - count--; - Aspect random = compounds.get(worldObj.rand.nextInt(compounds.size())); - int val = getAspectsBase().getAmount(random) + worldObj.rand.nextInt(40) + 20; - getAspectsBase().add(random, val); - getAspects().add(random, val); - } - break; - case STARVING: - break; - } - } - @Override public void updateEntity() { super.updateEntity(); @@ -120,15 +100,7 @@ public class TileExtendedNode extends TileNode { if(livingEntity instanceof EntityPlayer && ((EntityPlayer) livingEntity).capabilities.isCreativeMode) continue; if(!behavior.mayZapNow()) continue; - String research = Gadomancy.MODID.toUpperCase() + ".GROWING_AGGRESSION"; - List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).expand(6.0D, 6.0D, 6.0D)); - for(Object pl : players) { - EntityPlayer player = (EntityPlayer) pl; - if(!ResearchManager.isResearchComplete(player.getCommandSenderName(), research) && ResearchManager.doesPlayerHaveRequisites(player.getCommandSenderName(), research)) { - thaumcraft.common.lib.network.PacketHandler.INSTANCE.sendTo(new PacketResearchComplete(research), (EntityPlayerMP)player); - Thaumcraft.proxy.getResearchManager().completeResearch(player, research); - } - } + ResearchHelper.distributeResearch(Gadomancy.MODID.toUpperCase() + ".GROWING_AGGRESSION", worldObj, xCoord, yCoord, zCoord, 6); livingEntity.attackEntityFrom(DamageSource.magic, behavior.getZapDamage()); PacketTCNodeBolt packet = new PacketTCNodeBolt(xCoord + 0.5F, yCoord + 0.5F, zCoord + 0.5F, (float) livingEntity.posX, (float) (livingEntity.posY + livingEntity.height), (float) livingEntity.posZ); @@ -191,11 +163,14 @@ public class TileExtendedNode extends TileNode { TileEntity t = worldObj.getTileEntity(xCoord + xx, yCoord + yy, zCoord + zz); if(t != null && t instanceof TileNode && !(xx == 0 && yy == 0 && zz == 0)) { TileNode node = (TileNode) t; - behavior.lockOnTo(node); - - worldObj.markBlockForUpdate(xCoord + xx, yCoord + yy, zCoord + zz); - node.markDirty(); - needUpdate = true; + int thisSize = getAspectsBase().visSize(); + int othersSize = node.getAspectsBase().visSize(); + if(thisSize >= othersSize) { + behavior.lockOnTo(node); + worldObj.markBlockForUpdate(xCoord + xx, yCoord + yy, zCoord + zz); + node.markDirty(); + needUpdate = true; + } } } else { needUpdate = behavior.updateBehavior(needUpdate); diff --git a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileExtendedNodeJar.java b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileExtendedNodeJar.java index 6362d54..bb7c22f 100644 --- a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileExtendedNodeJar.java +++ b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileExtendedNodeJar.java @@ -1,5 +1,6 @@ package makeo.gadomancy.common.blocks.tiles; +import makeo.gadomancy.common.node.ExtendedNodeType; import makeo.gadomancy.common.utils.Injector; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; @@ -14,7 +15,6 @@ import thaumcraft.api.nodes.NodeModifier; import thaumcraft.api.nodes.NodeType; import thaumcraft.common.Thaumcraft; import thaumcraft.common.config.ConfigBlocks; -import thaumcraft.common.tiles.TileJar; import thaumcraft.common.tiles.TileJarNode; import thaumcraft.common.tiles.TileNode; diff --git a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileManipulationFocus.java b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileManipulationFocus.java new file mode 100644 index 0000000..eb66316 --- /dev/null +++ b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileManipulationFocus.java @@ -0,0 +1,30 @@ +package makeo.gadomancy.common.blocks.tiles; + +import net.minecraft.nbt.NBTTagCompound; + +/** + * 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 makeo @ 28.10.2015 16:27 + */ +public class TileManipulationFocus extends SynchronizedTileEntity { + public int fociId; + + @Override + public boolean canUpdate() { + return false; + } + + @Override + public void readCustomNBT(NBTTagCompound compound) { + fociId = compound.getInteger("fociId"); + } + + @Override + public void writeCustomNBT(NBTTagCompound compound) { + compound.setInteger("fociId", fociId); + } +} diff --git a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileManipulatorPillar.java b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileManipulatorPillar.java new file mode 100644 index 0000000..960a626 --- /dev/null +++ b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileManipulatorPillar.java @@ -0,0 +1,20 @@ +package makeo.gadomancy.common.blocks.tiles; + +import thaumcraft.common.tiles.TileInfusionPillar; + +/** + * 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 makeo @ 27.10.2015 13:21 + */ +public class TileManipulatorPillar extends TileInfusionPillar { + + public void setOrientation(byte orientation) { + this.orientation = orientation; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + markDirty(); + } +} \ No newline at end of file diff --git a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileNodeManipulator.java b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileNodeManipulator.java new file mode 100644 index 0000000..6cf252c --- /dev/null +++ b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileNodeManipulator.java @@ -0,0 +1,389 @@ +package makeo.gadomancy.common.blocks.tiles; + +import cpw.mods.fml.common.network.NetworkRegistry; +import makeo.gadomancy.common.network.PacketHandler; +import makeo.gadomancy.common.network.packets.PacketStartAnimation; +import makeo.gadomancy.common.network.packets.PacketTCNodeBolt; +import makeo.gadomancy.common.network.packets.PacketTCWispyLine; +import makeo.gadomancy.common.node.NodeManipulatorResult; +import makeo.gadomancy.common.node.NodeManipulatorResultHandler; +import makeo.gadomancy.common.registration.RegisteredBlocks; +import makeo.gadomancy.common.registration.RegisteredMultiblocks; +import makeo.gadomancy.common.utils.MultiblockHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.api.aspects.IAspectContainer; +import thaumcraft.api.wands.IWandable; +import thaumcraft.common.items.wands.ItemWandCasting; +import thaumcraft.common.lib.utils.InventoryUtils; +import thaumcraft.common.tiles.TileWandPedestal; + +import java.util.ArrayList; +import java.util.Collections; +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 @ 26.10.2015 20:16 + */ +public class TileNodeManipulator extends TileWandPedestal implements IAspectContainer, IWandable { + + private static final int POSSIBLE_WORK_START = 70; + private static final int WORK_ASPECT_CAP = 150; + + private boolean multiblockStructurePresent = false; + private boolean isMultiblock = false; + + private int workPhase = 0; + private AspectList workAspectList = new AspectList(); + + private boolean isManipulating = false; + private int manipulatorTick = 0; + + @Override + public void updateEntity() { + + if(worldObj.isRemote) return; + + if(isInMultiblock()) { + checkMultiblockTick(); + } + if(isInMultiblock()) { + multiblockTick(); + } + } + + private void multiblockTick() { + if(!isManipulating) { + doAspectChecks(); + } else { + manipulationTick(); + } + } + + private void manipulationTick() { + manipulatorTick++; + if(manipulatorTick < 300) { + if(manipulatorTick % 16 == 0) { + PacketStartAnimation packet = new PacketStartAnimation(PacketStartAnimation.ID_RUNES, xCoord, yCoord, zCoord); + PacketHandler.INSTANCE.sendToAllAround(packet, getTargetPoint(32)); + } + if(worldObj.rand.nextInt(4) == 0) { + Vec3 rel = getRelPillarLoc(worldObj.rand.nextInt(4)); + PacketTCNodeBolt bolt = new PacketTCNodeBolt(xCoord + 0.5F, yCoord + 2.5F, zCoord + 0.5F, (float) (xCoord + 0.5F + rel.xCoord), (float) (yCoord + 2.5F + rel.yCoord), (float) (zCoord + 0.5F + rel.zCoord)); + PacketHandler.INSTANCE.sendToAllAround(bolt, getTargetPoint(32)); + } + } else { + scheduleManipulation(); + } + } + + private Vec3 getRelPillarLoc(int pillarId) { + switch (pillarId) { + case 0: + return Vec3.createVectorHelper(0.7, -0.6, 0.7); + case 1: + return Vec3.createVectorHelper(-0.7, -0.6, 0.7); + case 2: + return Vec3.createVectorHelper(-0.7, -0.6, -0.7); + case 3: + return Vec3.createVectorHelper(0.7, -0.6, -0.7); + } + return Vec3.createVectorHelper(0, 0, 0); + } + + private void scheduleManipulation() { + manipulatorTick = 0; + isManipulating = false; + workAspectList = new AspectList(); + + TileEntity te = worldObj.getTileEntity(xCoord, yCoord + 2, zCoord); + if(te == null || !(te instanceof TileExtendedNode)) return; + TileExtendedNode node = (TileExtendedNode) te; + NodeManipulatorResult result; + do { + result = NodeManipulatorResultHandler.getRandomResult(node); + } while (!result.affect(node)); + PacketStartAnimation packet = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, xCoord, yCoord + 2, zCoord); + PacketHandler.INSTANCE.sendToAllAround(packet, getTargetPoint(32)); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockForUpdate(xCoord, yCoord + 2, zCoord); + markDirty(); + node.markDirty(); + } + + private void doAspectChecks() { + if(canDrainFromWand()) { + Aspect a = drainAspectFromWand(); + if(a != null) { + playAspectDrainFromWand(a); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + markDirty(); + } + } else { + checkIfEnoughVis(); + } + } + + private void checkIfEnoughVis() { + boolean enough = true; + for(Aspect a : Aspect.getPrimalAspects()) { + if(workAspectList.getAmount(a) < POSSIBLE_WORK_START) { + enough = false; + break; + } + } + if(enough) { + isManipulating = true; + } + } + + private Aspect drainAspectFromWand() { + ItemStack stack = getStackInSlot(0); + if(stack == null || !(stack.getItem() instanceof ItemWandCasting)) return null; //Should never happen.. + AspectList aspects = ((ItemWandCasting) stack.getItem()).getAllVis(stack); + for(Aspect a : getRandomlyOrderedPrimalAspectList()) { + if(aspects.getAmount(a) >= 100 && workAspectList.getAmount(a) < WORK_ASPECT_CAP) { + int amt = aspects.getAmount(a); + ((ItemWandCasting) stack.getItem()).storeVis(stack, a, amt - 100); + workAspectList.add(a, 1); + return a; + } + } + return null; + } + + private List getRandomlyOrderedPrimalAspectList() { + ArrayList primals = (ArrayList) Aspect.getPrimalAspects().clone(); + Collections.shuffle(primals); + return primals; + } + + private boolean canDrainFromWand() { + ItemStack stack = getStackInSlot(0); + if(stack == null || !(stack.getItem() instanceof ItemWandCasting)) return false; + AspectList aspects = ((ItemWandCasting) stack.getItem()).getAllVis(stack); + for(Aspect a : Aspect.getPrimalAspects()) { + if(aspects.getAmount(a) < 100) continue; + if(workAspectList.getAmount(a) < WORK_ASPECT_CAP) return true; + } + return false; + } + + private void checkMultiblockTick() { + checkMultiblock(); + if(!isMultiblockStructurePresent()) { + breakMultiblock(); + isMultiblock = false; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + markDirty(); + } + } + + private void playAspectDrainFromWand(Aspect drained) { + if(drained == null) return; + NetworkRegistry.TargetPoint point = getTargetPoint(32); + PacketTCWispyLine line = new PacketTCWispyLine(worldObj.provider.dimensionId, xCoord + 0.5, yCoord + 0.8, zCoord + 0.5, + xCoord + 0.5, yCoord + 1.4 + (((double) worldObj.rand.nextInt(4)) / 10D), zCoord + 0.5, 40, drained.getColor()); + PacketHandler.INSTANCE.sendToAllAround(line, point); + } + + @Override + public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) { + return super.receiveClientEvent(p_145842_1_, p_145842_2_); + } + + private void dropWand() { + if(getStackInSlot(0) != null) + InventoryUtils.dropItems(worldObj, xCoord, yCoord, zCoord); + } + + public void breakMultiblock() { + MultiblockHelper.MultiblockPattern compareableCompleteStructure = RegisteredMultiblocks.completeNodeManipulatorMultiblock; + MultiblockHelper.MultiblockPattern toRestore = RegisteredMultiblocks.incompleteNodeManipulatorMultiblock; + for(MultiblockHelper.IntVec3 v : compareableCompleteStructure.keySet()) { + MultiblockHelper.BlockInfo info = compareableCompleteStructure.get(v); + MultiblockHelper.BlockInfo restoreInfo = toRestore.get(v); + if(info.block == RegisteredBlocks.blockNode || info.block == Blocks.air || info.block == RegisteredBlocks.blockNodeManipulator || restoreInfo == null) continue; + int absX = v.x + xCoord; + int absY = v.y + yCoord; + int absZ = v.z + zCoord; + if(worldObj.getBlock(absX, absY, absZ) == info.block && worldObj.getBlockMetadata(absX, absY, absZ) == info.meta) { + worldObj.setBlock(absX, absY, absZ, Blocks.air, 0, 0); + worldObj.setBlock(absX, absY, absZ, restoreInfo.block, restoreInfo.meta, 0); + worldObj.markBlockForUpdate(absX, absY, absZ); + } + } + + dropWand(); + } + + public void formMultiblock() { + MultiblockHelper.MultiblockPattern toBuild = RegisteredMultiblocks.completeNodeManipulatorMultiblock; + for(MultiblockHelper.IntVec3 v : toBuild.keySet()) { + MultiblockHelper.BlockInfo info = toBuild.get(v); + if(info.block == RegisteredBlocks.blockNode || info.block == Blocks.air || info.block == RegisteredBlocks.blockNodeManipulator) continue; + int absX = v.x + xCoord; + int absY = v.y + yCoord; + int absZ = v.z + zCoord; + worldObj.setBlock(absX, absY, absZ, Blocks.air, 0, 0); + worldObj.setBlock(absX, absY, absZ, info.block, info.meta, 0); + worldObj.markBlockForUpdate(absX, absY, absZ); + } + NetworkRegistry.TargetPoint target = getTargetPoint(32); + TileManipulatorPillar pillar = (TileManipulatorPillar) worldObj.getTileEntity(xCoord + 1, yCoord, zCoord + 1); //wrong + pillar.setOrientation((byte) 5); + PacketStartAnimation animation = new PacketStartAnimation(PacketStartAnimation.ID_RUNES, pillar.xCoord, pillar.yCoord, pillar.zCoord); + PacketHandler.INSTANCE.sendToAllAround(animation, target); + TileManipulatorPillar pillar2 = (TileManipulatorPillar) worldObj.getTileEntity(xCoord - 1, yCoord, zCoord + 1); + pillar2.setOrientation((byte) 3); + animation = new PacketStartAnimation(PacketStartAnimation.ID_RUNES, pillar2.xCoord, pillar2.yCoord, pillar2.zCoord); + PacketHandler.INSTANCE.sendToAllAround(animation, target); + TileManipulatorPillar pillar3 = (TileManipulatorPillar) worldObj.getTileEntity(xCoord + 1, yCoord, zCoord - 1); //wrong + pillar3.setOrientation((byte) 4); + animation = new PacketStartAnimation(PacketStartAnimation.ID_RUNES, pillar3.xCoord, pillar3.yCoord, pillar3.zCoord); + PacketHandler.INSTANCE.sendToAllAround(animation, target); + animation = new PacketStartAnimation(PacketStartAnimation.ID_RUNES, xCoord - 1, yCoord, zCoord - 1); + PacketHandler.INSTANCE.sendToAllAround(animation, target); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + markDirty(); + this.isMultiblock = true; + } + + @Override + public void readCustomNBT(NBTTagCompound compound) { + super.readCustomNBT(compound); + + NBTTagCompound tag = compound.getCompoundTag("Gadomancy"); + this.multiblockStructurePresent = tag.getBoolean("mBlockPresent"); + this.isMultiblock = tag.getBoolean("mBlockState"); + this.isManipulating = tag.getBoolean("manipulating"); + this.manipulatorTick = tag.getInteger("manipulatorTick"); + this.workPhase = tag.getInteger("workPhase"); + workAspectList.readFromNBT(tag, "workAspectList"); + } + + @Override + public void writeCustomNBT(NBTTagCompound compound) { + super.writeCustomNBT(compound); + + NBTTagCompound tag = new NBTTagCompound(); + tag.setBoolean("mBlockPresent", this.multiblockStructurePresent); + tag.setBoolean("mBlockState", this.isMultiblock); + tag.setBoolean("manipulating", this.isManipulating); + tag.setInteger("manipulatorTick", this.manipulatorTick); + tag.setInteger("workPhase", this.workPhase); + workAspectList.writeToNBT(tag, "workAspectList"); + compound.setTag("Gadomancy", tag); + } + + public boolean isInMultiblock() { + return isMultiblock; + } + + public boolean isMultiblockStructurePresent() { + return multiblockStructurePresent; + } + + public boolean checkMultiblock() { + boolean prevState = isMultiblockStructurePresent(); + MultiblockHelper.MultiblockPattern patternToCheck; + if(prevState) { //If there is already a multiblock formed... + if(isInMultiblock()) { //If we were actually in multiblock before + patternToCheck = RegisteredMultiblocks.completeNodeManipulatorMultiblock; + } else { //If we were'nt in multiblock eventhough it would be possible. + patternToCheck = RegisteredMultiblocks.incompleteNodeManipulatorMultiblock; + } + this.multiblockStructurePresent = MultiblockHelper.isMultiblockPresent(worldObj, xCoord, yCoord, zCoord, patternToCheck); + } else { //If there was no multiblock formed before.. + patternToCheck = RegisteredMultiblocks.incompleteNodeManipulatorMultiblock; + this.multiblockStructurePresent = MultiblockHelper.isMultiblockPresent(worldObj, xCoord, yCoord, zCoord, patternToCheck); + } + return isMultiblockStructurePresent(); + } + + @Override + public boolean canInsertItem(int par1, ItemStack par2ItemStack, int par3) { + return isInMultiblock() && super.canInsertItem(par1, par2ItemStack, par3); + } + + public NetworkRegistry.TargetPoint getTargetPoint(double radius) { + return new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, radius); + } + + @Override + public AspectList getAspects() { + return workAspectList; + } + + @Override + public void setAspects(AspectList aspectList) { + + } + + @Override + public boolean doesContainerAccept(Aspect aspect) { + return false; + } + + @Override + public int addToContainer(Aspect aspect, int i) { + return 0; + } + + @Override + public boolean takeFromContainer(Aspect aspect, int i) { + return false; + } + + @Override + public boolean takeFromContainer(AspectList aspectList) { + return false; + } + + @Override + public boolean doesContainerContainAmount(Aspect aspect, int i) { + return false; + } + + @Override + public boolean doesContainerContain(AspectList aspectList) { + return false; + } + + @Override + public int containerContains(Aspect aspect) { + return 0; + } + + @Override + public int onWandRightClick(World world, ItemStack stack, EntityPlayer player, int i, int i2, int i3, int i4, int i5) { + return 0; + } + + @Override + public ItemStack onWandRightClick(World world, ItemStack stack, EntityPlayer player) { + return null; + } + + @Override + public void onUsingWandTick(ItemStack stack, EntityPlayer player, int i) { + + } + + @Override + public void onWandStoppedUsing(ItemStack stack, World world, EntityPlayer player, int i) { + + } +} diff --git a/src/main/java/makeo/gadomancy/common/events/EventHandlerWorld.java b/src/main/java/makeo/gadomancy/common/events/EventHandlerWorld.java index c703732..8b03412 100644 --- a/src/main/java/makeo/gadomancy/common/events/EventHandlerWorld.java +++ b/src/main/java/makeo/gadomancy/common/events/EventHandlerWorld.java @@ -3,6 +3,7 @@ package makeo.gadomancy.common.events; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import makeo.gadomancy.common.Gadomancy; +import makeo.gadomancy.common.blocks.tiles.TileNodeManipulator; import makeo.gadomancy.common.blocks.tiles.TileStickyJar; import makeo.gadomancy.common.registration.RegisteredBlocks; import makeo.gadomancy.common.registration.RegisteredIntegrations; @@ -102,6 +103,19 @@ public class EventHandlerWorld { } } + @SubscribeEvent + public void onBreak(BlockEvent.BreakEvent event) { + if(!event.world.isRemote) { + if(event.block == RegisteredBlocks.blockNodeManipulator) { + TileEntity te = event.world.getTileEntity(event.x, event.y, event.z); + if(te != null && te instanceof TileNodeManipulator) { + if(((TileNodeManipulator) te).isInMultiblock()) + ((TileNodeManipulator) te).breakMultiblock(); + } + } + } + } + @SubscribeEvent(priority = EventPriority.LOWEST) public void on(PlayerInteractEvent e) { if (!e.world.isRemote && e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK diff --git a/src/main/java/makeo/gadomancy/common/items/ItemBlockStoneMachine.java b/src/main/java/makeo/gadomancy/common/items/ItemBlockStoneMachine.java new file mode 100644 index 0000000..b94ecd0 --- /dev/null +++ b/src/main/java/makeo/gadomancy/common/items/ItemBlockStoneMachine.java @@ -0,0 +1,41 @@ +package makeo.gadomancy.common.items; + +import makeo.gadomancy.common.blocks.BlockStoneMachine; +import net.minecraft.block.Block; +import net.minecraft.block.BlockBrewingStand; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +/** + * 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 makeo @ 27.10.2015 17:05 + */ +public class ItemBlockStoneMachine extends ItemBlock { + public ItemBlockStoneMachine(Block block) { + super(block); + } + + @Override + public IIcon getIconFromDamage(int metadata) { + if(metadata == 11 || metadata == 15) { + return this.field_150939_a.getIcon(0, metadata); + } + return super.getIconFromDamage(metadata); + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return getUnlocalizedName() + "." + stack.getItemDamage(); + } + + @Override + public int getMetadata(int metadata) { + return metadata; + } +} diff --git a/src/main/java/makeo/gadomancy/common/items/ItemExtendedNodeJar.java b/src/main/java/makeo/gadomancy/common/items/ItemExtendedNodeJar.java index 92aaedc..c07d658 100644 --- a/src/main/java/makeo/gadomancy/common/items/ItemExtendedNodeJar.java +++ b/src/main/java/makeo/gadomancy/common/items/ItemExtendedNodeJar.java @@ -1,6 +1,6 @@ package makeo.gadomancy.common.items; -import makeo.gadomancy.common.blocks.tiles.ExtendedNodeType; +import makeo.gadomancy.common.node.ExtendedNodeType; import makeo.gadomancy.common.blocks.tiles.TileExtendedNodeJar; import makeo.gadomancy.common.registration.RegisteredBlocks; import net.minecraft.block.Block; @@ -23,9 +23,7 @@ import thaumcraft.api.nodes.NodeModifier; import thaumcraft.api.nodes.NodeType; import thaumcraft.common.Thaumcraft; import thaumcraft.common.blocks.ItemJarNode; -import thaumcraft.common.config.ConfigBlocks; import thaumcraft.common.config.ConfigItems; -import thaumcraft.common.tiles.TileJarNode; import java.util.List; @@ -44,7 +42,7 @@ public class ItemExtendedNodeJar extends Item implements IEssentiaContainerItem public ItemExtendedNodeJar() { setMaxDamage(0); setMaxStackSize(1); - setUnlocalizedName("ItemExtendedNodeJar"); + setUnlocalizedName("BlockJarNodeItem"); } @Override diff --git a/src/main/java/makeo/gadomancy/common/items/ItemNodeManipulator.java b/src/main/java/makeo/gadomancy/common/items/ItemNodeManipulator.java new file mode 100644 index 0000000..9b86095 --- /dev/null +++ b/src/main/java/makeo/gadomancy/common/items/ItemNodeManipulator.java @@ -0,0 +1,20 @@ +package makeo.gadomancy.common.items; + +import net.minecraft.block.Block; +import thaumcraft.common.blocks.BlockStoneDeviceItem; + +/** + * 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 @ 27.10.2015 13:00 + */ +public class ItemNodeManipulator extends BlockStoneDeviceItem { + + public ItemNodeManipulator(Block par1) { + super(par1); + } + +} diff --git a/src/main/java/makeo/gadomancy/common/network/PacketHandler.java b/src/main/java/makeo/gadomancy/common/network/PacketHandler.java index c81ea27..0170082 100644 --- a/src/main/java/makeo/gadomancy/common/network/PacketHandler.java +++ b/src/main/java/makeo/gadomancy/common/network/PacketHandler.java @@ -7,6 +7,7 @@ import makeo.gadomancy.common.Gadomancy; import makeo.gadomancy.common.network.packets.PacketAnimationAbsorb; import makeo.gadomancy.common.network.packets.PacketStartAnimation; import makeo.gadomancy.common.network.packets.PacketTCNodeBolt; +import makeo.gadomancy.common.network.packets.PacketTCWispyLine; import makeo.gadomancy.common.network.packets.PacketUpdateGolemTypeOrder; /** @@ -27,5 +28,6 @@ public class PacketHandler { INSTANCE.registerMessage(PacketStartAnimation.class, PacketStartAnimation.class, id++, Side.CLIENT); INSTANCE.registerMessage(PacketAnimationAbsorb.class, PacketAnimationAbsorb.class, id++, Side.CLIENT); INSTANCE.registerMessage(PacketTCNodeBolt.class, PacketTCNodeBolt.class, id++, Side.CLIENT); + INSTANCE.registerMessage(PacketTCWispyLine.class, PacketTCWispyLine.class, id++, Side.CLIENT); } } diff --git a/src/main/java/makeo/gadomancy/common/network/packets/PacketAbortTransform.java b/src/main/java/makeo/gadomancy/common/network/packets/PacketAbortTransform.java index f056417..79da376 100644 --- a/src/main/java/makeo/gadomancy/common/network/packets/PacketAbortTransform.java +++ b/src/main/java/makeo/gadomancy/common/network/packets/PacketAbortTransform.java @@ -8,9 +8,12 @@ import io.netty.buffer.ByteBuf; import makeo.gadomancy.client.transformation.TransformationHelper; /** - * User: makeo - * Date: 03.07.2015 - * Time: 21:42 + * 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 makeo @ 03.07.2015 21:42 */ public class PacketAbortTransform implements IMessage, IMessageHandler { private int entityId; diff --git a/src/main/java/makeo/gadomancy/common/network/packets/PacketAnimationAbsorb.java b/src/main/java/makeo/gadomancy/common/network/packets/PacketAnimationAbsorb.java index 81dc2fb..0d0b2e3 100644 --- a/src/main/java/makeo/gadomancy/common/network/packets/PacketAnimationAbsorb.java +++ b/src/main/java/makeo/gadomancy/common/network/packets/PacketAnimationAbsorb.java @@ -25,16 +25,18 @@ public class PacketAnimationAbsorb implements IMessage, IMessageHandler + * Created by HellFirePvP @ 28.10.2015 23:28 + */ +public class PacketTCWispyLine implements IMessage, IMessageHandler { + + private int dimId; + private double pedestalX, pedestalY, pedestalZ; + private double originX, originY, originZ; + private int tickCap; + private int colorAsInt; + + public PacketTCWispyLine() {} + + public PacketTCWispyLine(int dimId, double pedestalX, double pedestalY, double pedestalZ, double originX, double originY, double originZ, int tickCap, int colorAsInt) { + this.dimId = dimId; + this.pedestalX = pedestalX; + this.pedestalY = pedestalY; + this.pedestalZ = pedestalZ; + this.originX = originX; + this.originY = originY; + this.originZ = originZ; + this.tickCap = tickCap; + this.colorAsInt = colorAsInt; + } + + @Override + public void fromBytes(ByteBuf buf) { + dimId = buf.readInt(); + pedestalX = buf.readDouble(); + pedestalY = buf.readDouble(); + pedestalZ = buf.readDouble(); + originX = buf.readDouble(); + originY = buf.readDouble(); + originZ = buf.readDouble(); + tickCap = buf.readInt(); + colorAsInt = buf.readInt(); + } + + @Override + public void toBytes(ByteBuf buf) { + buf.writeInt(dimId); + buf.writeDouble(pedestalX); + buf.writeDouble(pedestalY); + buf.writeDouble(pedestalZ); + buf.writeDouble(originX); + buf.writeDouble(originY); + buf.writeDouble(originZ); + buf.writeInt(tickCap); + buf.writeInt(colorAsInt); + } + + @Override + public IMessage onMessage(PacketTCWispyLine p, MessageContext ctx) { + MultiTickEffectDispatcher.FloatyLineInfo info = + new MultiTickEffectDispatcher.FloatyLineInfo(p.dimId, p.pedestalX, p.pedestalY, p.pedestalZ, + p.originX, p.originY, p.originZ, p.tickCap, p.colorAsInt); + MultiTickEffectDispatcher.registerFloatyLine(info); + return null; + } +} diff --git a/src/main/java/makeo/gadomancy/common/blocks/tiles/ExtendedNodeType.java b/src/main/java/makeo/gadomancy/common/node/ExtendedNodeType.java similarity index 78% rename from src/main/java/makeo/gadomancy/common/blocks/tiles/ExtendedNodeType.java rename to src/main/java/makeo/gadomancy/common/node/ExtendedNodeType.java index 97b2158..37dda47 100644 --- a/src/main/java/makeo/gadomancy/common/blocks/tiles/ExtendedNodeType.java +++ b/src/main/java/makeo/gadomancy/common/node/ExtendedNodeType.java @@ -1,4 +1,4 @@ -package makeo.gadomancy.common.blocks.tiles; +package makeo.gadomancy.common.node; /** * This class is part of the Gadomancy Mod @@ -10,7 +10,6 @@ package makeo.gadomancy.common.blocks.tiles; */ public enum ExtendedNodeType { - GROWING, - STARVING + GROWING } diff --git a/src/main/java/makeo/gadomancy/common/blocks/tiles/GrowingNodeBehavior.java b/src/main/java/makeo/gadomancy/common/node/GrowingNodeBehavior.java similarity index 86% rename from src/main/java/makeo/gadomancy/common/blocks/tiles/GrowingNodeBehavior.java rename to src/main/java/makeo/gadomancy/common/node/GrowingNodeBehavior.java index 5369cbb..3442822 100644 --- a/src/main/java/makeo/gadomancy/common/blocks/tiles/GrowingNodeBehavior.java +++ b/src/main/java/makeo/gadomancy/common/node/GrowingNodeBehavior.java @@ -1,28 +1,23 @@ -package makeo.gadomancy.common.blocks.tiles; +package makeo.gadomancy.common.node; import cpw.mods.fml.common.network.NetworkRegistry; import makeo.gadomancy.common.Gadomancy; +import makeo.gadomancy.common.blocks.tiles.TileExtendedNode; import makeo.gadomancy.common.network.PacketHandler; import makeo.gadomancy.common.network.packets.PacketAnimationAbsorb; import makeo.gadomancy.common.network.packets.PacketTCNodeBolt; import makeo.gadomancy.common.registration.RegisteredBlocks; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; +import makeo.gadomancy.common.utils.ResearchHelper; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Vec3; import net.minecraft.world.World; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; -import thaumcraft.common.Thaumcraft; import thaumcraft.common.entities.EntityAspectOrb; -import thaumcraft.common.lib.network.playerdata.PacketResearchComplete; -import thaumcraft.common.lib.research.ResearchManager; import thaumcraft.common.tiles.TileNode; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; /** @@ -35,9 +30,9 @@ import java.util.Map; */ public class GrowingNodeBehavior { - public static final double SATURATION_DIFFICULTY = 10D; - public static final double SATURATION_CAP = 100D; - public static final int HAPPINESS_CAP = 1000; + public static final double SATURATION_DIFFICULTY = 15D; + public static final double SATURATION_CAP = 90D; + public static final int HAPPINESS_CAP = 500; //The node the growing node attacks. private TileNode fixedNode; @@ -72,15 +67,7 @@ public class GrowingNodeBehavior { addSaturation(aspect, increasedSaturation); owningNode.getAspectsBase().add(aspect, value); - String research = Gadomancy.MODID.toUpperCase() + ".GROWING_GROWTH"; - List players = owningNode.getWorldObj().getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(owningNode.xCoord, owningNode.yCoord, owningNode.zCoord, owningNode.xCoord + 1, owningNode.yCoord + 1, owningNode.zCoord + 1).expand(6.0D, 6.0D, 6.0D)); - for(Object pl : players) { - EntityPlayer player = (EntityPlayer) pl; - if(!ResearchManager.isResearchComplete(player.getCommandSenderName(), research) && ResearchManager.doesPlayerHaveRequisites(player.getCommandSenderName(), research)) { - thaumcraft.common.lib.network.PacketHandler.INSTANCE.sendTo(new PacketResearchComplete(research), (EntityPlayerMP)player); - Thaumcraft.proxy.getResearchManager().completeResearch(player, research); - } - } + ResearchHelper.distributeResearch(Gadomancy.MODID.toUpperCase() + ".GROWING_GROWTH", owningNode.getWorldObj(), owningNode.xCoord, owningNode.yCoord, owningNode.zCoord, 6); computeOverallSaturation(); } @@ -181,10 +168,7 @@ public class GrowingNodeBehavior { int x = fixedNode.xCoord; int y = fixedNode.yCoord; int z = fixedNode.zCoord; - owningNode.getWorldObj().setBlockToAir(x, y, z); - owningNode.getWorldObj().removeTileEntity(x, y, z); - owningNode.getWorldObj().markBlockForUpdate(x, y, z); - this.fixedNode = null; + removeFixedNode(x, y, z); return needUpdate; } Aspect a = baseAspects.getAspects()[owningNode.getWorldObj().rand.nextInt(baseAspects.getAspects().length)]; @@ -199,6 +183,8 @@ public class GrowingNodeBehavior { int oz = owningNode.zCoord; currentAspects.reduce(a, 1); + ResearchHelper.distributeResearch(Gadomancy.MODID.toUpperCase() + ".GROWING_ATTACK", owningNode.getWorldObj(), owningNode.xCoord, owningNode.yCoord, owningNode.zCoord, 16); + EntityAspectOrb aspectOrb = new EntityAspectOrb(world, fx + 0.5D, fy + 0.5D, fz + 0.5D, a, 1); Vec3 dir = Vec3.createVectorHelper(fx + 0.5D, fy + 0.5D, fz + 0.5D).subtract(Vec3.createVectorHelper(ox + 0.5D, oy + 0.5D, oz + 0.5D)).normalize(); dir.addVector(randOffset(), randOffset(), randOffset()).normalize(); @@ -209,22 +195,47 @@ public class GrowingNodeBehavior { PacketTCNodeBolt bolt = new PacketTCNodeBolt(ox + 0.5F, oy + 0.5F, oz + 0.5F, fx + 0.5F, fy + 0.5F, fz + 0.5F); PacketHandler.INSTANCE.sendToAllAround(bolt, point); - PacketAnimationAbsorb packet = new PacketAnimationAbsorb(ox, oy, oz, fx, fy, fz); + PacketAnimationAbsorb packet = new PacketAnimationAbsorb(ox, oy, oz, fx, fy, fz, 7); PacketHandler.INSTANCE.sendToAllAround(packet, point); world.markBlockForUpdate(fx, fy, fz); fixedNode.markDirty(); needUpdate = true; - + } else { + if(baseAspects.size() <= 1) { + int x = fixedNode.xCoord; + int y = fixedNode.yCoord; + int z = fixedNode.zCoord; + removeFixedNode(x, y, z); + needUpdate = true; + } + baseAspects.remove(a); + currentAspects.remove(a); + return needUpdate; } } else { + if(baseAspects.size() <= 1) { + int x = fixedNode.xCoord; + int y = fixedNode.yCoord; + int z = fixedNode.zCoord; + removeFixedNode(x, y, z); + needUpdate = true; + } baseAspects.remove(a); currentAspects.remove(a); + return needUpdate; } } return needUpdate; } + private void removeFixedNode(int x, int y, int z) { + owningNode.getWorldObj().setBlockToAir(x, y, z); + owningNode.getWorldObj().removeTileEntity(x, y, z); + owningNode.getWorldObj().markBlockForUpdate(x, y, z); + this.fixedNode = null; + } + private float randOffset() { return owningNode.getWorldObj().rand.nextFloat() / 3; } @@ -263,9 +274,7 @@ public class GrowingNodeBehavior { return (Math.log(i) / 6) + 1; } - private void handleOverfeed() { - //TODO let node collapse if overfed & still feeding... - } + private void handleOverfeed() {} public void readFromNBT(NBTTagCompound nbtTagCompound) { this.isSaturated = nbtTagCompound.getBoolean("overallSaturated"); diff --git a/src/main/java/makeo/gadomancy/common/node/NodeManipulatorResult.java b/src/main/java/makeo/gadomancy/common/node/NodeManipulatorResult.java new file mode 100644 index 0000000..0d57eca --- /dev/null +++ b/src/main/java/makeo/gadomancy/common/node/NodeManipulatorResult.java @@ -0,0 +1,26 @@ +package makeo.gadomancy.common.node; + +import makeo.gadomancy.common.blocks.tiles.TileExtendedNode; +import net.minecraft.util.WeightedRandom; + +/** + * 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 @ 28.10.2015 11:45 + */ +public abstract class NodeManipulatorResult extends WeightedRandom.Item { + + public NodeManipulatorResult(int chanceToRoll) { + super(chanceToRoll); + } + + public boolean canAffect(TileExtendedNode node) { + return true; + } + + public abstract boolean affect(TileExtendedNode node); + +} diff --git a/src/main/java/makeo/gadomancy/common/node/NodeManipulatorResultHandler.java b/src/main/java/makeo/gadomancy/common/node/NodeManipulatorResultHandler.java new file mode 100644 index 0000000..a2447f3 --- /dev/null +++ b/src/main/java/makeo/gadomancy/common/node/NodeManipulatorResultHandler.java @@ -0,0 +1,89 @@ +package makeo.gadomancy.common.node; + +import makeo.gadomancy.common.blocks.tiles.TileExtendedNode; +import makeo.gadomancy.common.registration.RegisteredManipulations; +import net.minecraft.util.WeightedRandom; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.common.lib.research.ResearchManager; + +import java.util.ArrayList; +import java.util.List; +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 @ 28.10.2015 11:43 + */ +public class NodeManipulatorResultHandler { + + private static List possibleResults = new ArrayList(); + + private NodeManipulatorResultHandler() {} + + public static NodeManipulatorResult getRandomResult(TileExtendedNode affectedNode) { + return getRandomResult(affectedNode.getWorldObj().rand, affectedNode); + } + + public static NodeManipulatorResult getRandomResult(Random random, TileExtendedNode affectedNode) { + List localResults = new ArrayList(); + for(NodeManipulatorResult result : possibleResults) { + if(result.canAffect(affectedNode)) localResults.add(result); + } + if(localResults.isEmpty()) return null; + return (NodeManipulatorResult) WeightedRandom.getRandomItem(random, localResults); + } + + public static void combine(AspectList containingList, Aspect a, Aspect b) { + if(!canCombine(a, b)) return; + Aspect combination = NodeManipulatorResultHandler.getCombination(a, b); + int lowerAmount; + if(containingList.getAmount(a) < containingList.getAmount(b)) { + lowerAmount = containingList.getAmount(a); + } else { + lowerAmount = containingList.getAmount(b); + } + containingList.remove(a, lowerAmount); + containingList.remove(b, lowerAmount); + containingList.add(combination, lowerAmount); + } + + public static boolean canCombine(Aspect a, Aspect b) { + return getCombination(a, b) != null; + } + + public static Aspect getCombination(Aspect a, Aspect b) { + for(Aspect aspect : Aspect.getCompoundAspects()) { + Aspect[] components = aspect.getComponents(); + if((components[0] == a && components[1] == b) || + components[0] == b && components[1] == a) { + return aspect; + } + } + return null; + } + + static { + //Aspect combination pair + possibleResults.add(RegisteredManipulations.resultBreakCompounds); + possibleResults.add(RegisteredManipulations.resultCombineAspects); + + //Modifier pair + possibleResults.add(RegisteredManipulations.resultIncreaseModifier); + possibleResults.add(RegisteredManipulations.resultDecreaseModifier); + + //Switch node Type + possibleResults.add(RegisteredManipulations.resultSwitchType); + + //Almighty Growing + possibleResults.add(RegisteredManipulations.resultApplyGrowing); + + //Let the node gain primals + possibleResults.add(RegisteredManipulations.resultGainPrimal); + } + +} diff --git a/src/main/java/makeo/gadomancy/common/registration/RegisteredBlocks.java b/src/main/java/makeo/gadomancy/common/registration/RegisteredBlocks.java index 8ef592c..574c399 100644 --- a/src/main/java/makeo/gadomancy/common/registration/RegisteredBlocks.java +++ b/src/main/java/makeo/gadomancy/common/registration/RegisteredBlocks.java @@ -2,25 +2,17 @@ package makeo.gadomancy.common.registration; import cpw.mods.fml.common.registry.GameRegistry; import makeo.gadomancy.api.ClickBehavior; -import makeo.gadomancy.common.blocks.BlockArcaneDropper; -import makeo.gadomancy.common.blocks.BlockExtendedNodeJar; -import makeo.gadomancy.common.blocks.BlockInfusionClaw; -import makeo.gadomancy.common.blocks.BlockNode; -import makeo.gadomancy.common.blocks.BlockRemoteJar; -import makeo.gadomancy.common.blocks.BlockStickyJar; -import makeo.gadomancy.common.blocks.tiles.TileArcaneDropper; -import makeo.gadomancy.common.blocks.tiles.TileExtendedNode; -import makeo.gadomancy.common.blocks.tiles.TileExtendedNodeJar; -import makeo.gadomancy.common.blocks.tiles.TileInfusionClaw; -import makeo.gadomancy.common.blocks.tiles.TileRemoteJar; -import makeo.gadomancy.common.blocks.tiles.TileStickyJar; +import makeo.gadomancy.common.blocks.*; +import makeo.gadomancy.common.blocks.tiles.*; import makeo.gadomancy.common.items.ItemBlockRemoteJar; +import makeo.gadomancy.common.items.ItemBlockStoneMachine; +import makeo.gadomancy.common.items.ItemNodeManipulator; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import thaumcraft.common.Thaumcraft; +import thaumcraft.common.blocks.BlockStoneDeviceItem; import thaumcraft.common.config.ConfigBlocks; import thaumcraft.common.tiles.TileInfusionMatrix; @@ -47,6 +39,8 @@ public class RegisteredBlocks { public static BlockRemoteJar blockRemoteJar; public static BlockNode blockNode; public static BlockExtendedNodeJar blockExtendedNodeJar; + public static BlockNodeManipulator blockNodeManipulator; + public static BlockStoneMachine blockStoneMachine; public static void init() { registerBlocks(); @@ -65,6 +59,8 @@ public class RegisteredBlocks { blockRemoteJar = registerBlock(new BlockRemoteJar(), ItemBlockRemoteJar.class); blockNode = (BlockNode) new BlockNode().setBlockName("blockAiry"); blockExtendedNodeJar = registerBlock(new BlockExtendedNodeJar()); + blockNodeManipulator = registerBlock(new BlockNodeManipulator(), ItemNodeManipulator.class); + blockStoneMachine = registerBlock(new BlockStoneMachine(), ItemBlockStoneMachine.class); } private static T registerBlock(String name, T block) { @@ -97,6 +93,9 @@ public class RegisteredBlocks { registerTile(TileRemoteJar.class); registerTile(TileExtendedNode.class); registerTile(TileExtendedNodeJar.class); + registerTile(TileNodeManipulator.class); + registerTile(TileManipulatorPillar.class); + registerTile(TileManipulationFocus.class); } private static void registerTile(Class tile, String name) { diff --git a/src/main/java/makeo/gadomancy/common/registration/RegisteredItems.java b/src/main/java/makeo/gadomancy/common/registration/RegisteredItems.java index 4bdc076..5b898a6 100644 --- a/src/main/java/makeo/gadomancy/common/registration/RegisteredItems.java +++ b/src/main/java/makeo/gadomancy/common/registration/RegisteredItems.java @@ -6,8 +6,12 @@ import makeo.gadomancy.common.items.*; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import thaumcraft.api.ThaumcraftApi; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; import thaumcraft.common.config.ConfigBlocks; import thaumcraft.common.config.ConfigItems; +import thaumcraft.common.lib.crafting.ThaumcraftCraftingManager; import java.util.ArrayList; import java.util.List; @@ -50,6 +54,10 @@ public class RegisteredItems { registerDefaultStickyJars(); } + public static void postInit() { + registerItemAspects(); + } + //Items private static void registerItems() { itemFakeModIcon = registerItem(new ItemFakeModIcon()); @@ -69,6 +77,12 @@ public class RegisteredItems { return registerItem(item, item.getClass().getSimpleName()); } + private static void registerItemAspects() { + AspectList oldAspects = ThaumcraftCraftingManager.getObjectTags(new ItemStack(RegisteredBlocks.blockStoneMachine)); + + ThaumcraftApi.registerObjectTag(new ItemStack(Item.getItemFromBlock(RegisteredBlocks.blockStoneMachine)), new int[]{11, 15}, new AspectList()); + ThaumcraftApi.registerObjectTag(new ItemStack(Item.getItemFromBlock(RegisteredBlocks.blockStoneMachine)), new int[]{0}, oldAspects); + } //Sticky jars private static void registerDefaultStickyJars() { diff --git a/src/main/java/makeo/gadomancy/common/registration/RegisteredManipulations.java b/src/main/java/makeo/gadomancy/common/registration/RegisteredManipulations.java new file mode 100644 index 0000000..b120fe4 --- /dev/null +++ b/src/main/java/makeo/gadomancy/common/registration/RegisteredManipulations.java @@ -0,0 +1,208 @@ +package makeo.gadomancy.common.registration; + +import makeo.gadomancy.common.Gadomancy; +import makeo.gadomancy.common.blocks.tiles.TileExtendedNode; +import makeo.gadomancy.common.node.ExtendedNodeType; +import makeo.gadomancy.common.node.NodeManipulatorResult; +import makeo.gadomancy.common.node.NodeManipulatorResultHandler; +import makeo.gadomancy.common.utils.ResearchHelper; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.api.nodes.NodeModifier; +import thaumcraft.api.nodes.NodeType; + +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 @ 28.10.2015 11:52 + */ +public class RegisteredManipulations { + + public static NodeManipulatorResult resultBreakCompounds = new NodeManipulatorResult(4) { + @Override + public boolean affect(TileExtendedNode node) { + AspectList baseList = node.getAspectsBase(); + AspectList list = node.getAspects(); + for(Aspect a : baseList.getAspects()) { + if(!a.isPrimal()) { + Aspect[] subComponents = a.getComponents(); + int initialValue = baseList.getAmount(a); + list.remove(a); + baseList.remove(a); + baseList.add(subComponents[0], initialValue); + list.add(subComponents[0], initialValue); + baseList.add(subComponents[1], initialValue); + list.add(subComponents[1], initialValue); + return true; + } + } + return false; + } + }; + + public static NodeManipulatorResult resultCombineAspects = new NodeManipulatorResult(5) { + @Override + public boolean affect(TileExtendedNode node) { + AspectList base = node.getAspectsBase(); + if(base.getAspects().length < 2) + return false; + if(base.getAspects().length == 2) { + if(!NodeManipulatorResultHandler.canCombine(base.getAspects()[0], base.getAspects()[1])) return false; + NodeManipulatorResultHandler.combine(base, base.getAspects()[0], base.getAspects()[1]); + NodeManipulatorResultHandler.combine(node.getAspects(), base.getAspects()[0], base.getAspects()[1]); + return true; + } + if(base.getAspects().length > 2) { + int actuallyCombined = 0; + int combineCount = node.getWorldObj().rand.nextInt(1) + 1; + doLabel: + do { + if(base.getAspects().length < 2) break; + + int randIndexForA = node.getWorldObj().rand.nextInt(base.getAspects().length); + for (int i = 0; i < base.getAspects().length; i++) { + int indexA = (i + randIndexForA) % base.getAspects().length; + Aspect a = base.getAspects()[indexA]; + int randIndexForB = node.getWorldObj().rand.nextInt(base.getAspects().length); + for (int j = 0; j < base.getAspects().length; j++) { + int indexB = (j + randIndexForB) % base.getAspects().length; + Aspect b = base.getAspects()[indexB]; + + if(NodeManipulatorResultHandler.canCombine(a, b)) { + NodeManipulatorResultHandler.combine(base, a, b); + NodeManipulatorResultHandler.combine(node.getAspects(), a, b); + combineCount--; + actuallyCombined++; + continue doLabel; + } else if(base.getAspects().length <= 2) { + break doLabel; + } + + } + } + combineCount--; + } while (combineCount > 0); + if(actuallyCombined > 0) return true; + } + return false; + } + }; + + public static NodeManipulatorResult resultIncreaseModifier = new NodeManipulatorResult(4) { + + @Override + public boolean canAffect(TileExtendedNode node) { + return node.getNodeModifier() != NodeModifier.BRIGHT; + } + + @Override + public boolean affect(TileExtendedNode node) { + if(node.getNodeModifier() == null) { + node.setNodeModifier(NodeModifier.BRIGHT); + return true; + } + switch (node.getNodeModifier()) { + case BRIGHT: + return false; + case PALE: + node.setNodeModifier(null); + break; + case FADING: + node.setNodeModifier(NodeModifier.PALE); + break; + } + return true; + } + }; + + public static NodeManipulatorResult resultDecreaseModifier = new NodeManipulatorResult(5) { + + @Override + public boolean canAffect(TileExtendedNode node) { + return node.getNodeModifier() != NodeModifier.FADING; + } + + @Override + public boolean affect(TileExtendedNode node) { + if(node.getNodeModifier() == null) { + node.setNodeModifier(NodeModifier.PALE); + return true; + } + switch (node.getNodeModifier()) { + case BRIGHT: + node.setNodeModifier(null); + break; + case PALE: + node.setNodeModifier(NodeModifier.FADING); + break; + case FADING: + return false; + } + return true; + } + }; + + public static NodeManipulatorResult resultGainPrimal = new NodeManipulatorResult(3) { + @Override + public boolean affect(TileExtendedNode node) { + List primals = Aspect.getPrimalAspects(); + int modulo = primals.size(); + int index = node.getWorldObj().rand.nextInt(primals.size()); + for (int i = 0; i < primals.size(); i++) { + int get = (index + i) % modulo; + Aspect rand = primals.get(get); + if(node.getAspectsBase().getAmount(rand) <= 0) { + int randGain = node.getWorldObj().rand.nextInt(8) + 3; + node.getAspectsBase().add(rand, randGain); + node.getAspects().add(rand, randGain); + return true; + } + } + return false; + } + }; + + public static NodeManipulatorResult resultSwitchType = new NodeManipulatorResult(2) { + @Override + public boolean affect(TileExtendedNode node) { + NodeType newType = node.getNodeType(); + int random = node.getWorldObj().rand.nextInt(40); + if(random > 38) { + if(!(node.getExtendedNodeType() != null && node.getExtendedNodeType().equals(ExtendedNodeType.GROWING))) newType = NodeType.HUNGRY; //1 of 40 + } else if(random > 37) { + newType = NodeType.TAINTED; //1 of 40 + } else if(random > 34) { + newType = NodeType.UNSTABLE; //3 of 40 + } else if(random > 29) { + newType = NodeType.DARK; //5 of 40 + } else if(random > 24) { + newType = NodeType.PURE; //5 of 40 + } else if(random > 14) { + newType = NodeType.NORMAL; //10 of 40 + } + //15 of 40 chance nothing happens + boolean changed = !newType.equals(node.getNodeType()); + if(changed) node.setNodeType(newType); + return changed; + } + }; + + public static NodeManipulatorResult resultApplyGrowing = new NodeManipulatorResult(1) { + @Override + public boolean affect(TileExtendedNode node) { + boolean isGrowingAlready = node.getExtendedNodeType() != null && node.getExtendedNodeType().equals(ExtendedNodeType.GROWING); + if(isGrowingAlready) if(node.getNodeType().equals(NodeType.HUNGRY)) isGrowingAlready = false; + if(!isGrowingAlready) { + node.setExtendedNodeType(ExtendedNodeType.GROWING); + ResearchHelper.distributeResearch(Gadomancy.MODID.toUpperCase() + ".GROWING", node.getWorldObj(), node.xCoord, node.yCoord, node.zCoord, 12); + } + return isGrowingAlready; + } + }; + +} diff --git a/src/main/java/makeo/gadomancy/common/registration/RegisteredMultiblocks.java b/src/main/java/makeo/gadomancy/common/registration/RegisteredMultiblocks.java new file mode 100644 index 0000000..f6cc162 --- /dev/null +++ b/src/main/java/makeo/gadomancy/common/registration/RegisteredMultiblocks.java @@ -0,0 +1,25 @@ +package makeo.gadomancy.common.registration; + +import makeo.gadomancy.common.utils.MultiblockHelper; +import net.minecraft.init.Blocks; +import thaumcraft.common.config.ConfigBlocks; + +/** + * 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 @ 27.10.2015 14:05 + */ +public class RegisteredMultiblocks { + public static final MultiblockHelper.MultiblockPattern incompleteNodeManipulatorMultiblock = new MultiblockHelper.MultiblockPattern(RegisteredBlocks.blockNodeManipulator, 5) + .addBlock(0, 2, 0, RegisteredBlocks.blockNode, 0).addBlock(0, 1, 0, RegisteredBlocks.blockStoneMachine, 0) + .addBlock(1, 0, 1, ConfigBlocks.blockCosmeticSolid, 15).addBlock(-1, 0, 1, ConfigBlocks.blockCosmeticSolid, 15).addBlock(-1, 0, -1, ConfigBlocks.blockCosmeticSolid, 15).addBlock(1, 0, -1, ConfigBlocks.blockCosmeticSolid, 15) + .addBlock(1, 1, 1, ConfigBlocks.blockCosmeticSolid, 11).addBlock(-1, 1, 1, ConfigBlocks.blockCosmeticSolid, 11).addBlock(-1, 1, -1, ConfigBlocks.blockCosmeticSolid, 11).addBlock(1, 1, -1, ConfigBlocks.blockCosmeticSolid, 11); + + public static final MultiblockHelper.MultiblockPattern completeNodeManipulatorMultiblock = new MultiblockHelper.MultiblockPattern(RegisteredBlocks.blockNodeManipulator, 5) + .addBlock(0, 2, 0, RegisteredBlocks.blockNode, 0).addBlock(0, 1, 0, RegisteredBlocks.blockStoneMachine, 0) + .addBlock(1, 0, 1, RegisteredBlocks.blockStoneMachine, 15).addBlock(-1, 0, 1, RegisteredBlocks.blockStoneMachine, 15).addBlock(-1, 0, -1, RegisteredBlocks.blockStoneMachine, 15).addBlock(1, 0, -1, RegisteredBlocks.blockStoneMachine, 15) + .addBlock(1, 1, 1, RegisteredBlocks.blockStoneMachine, 11).addBlock(-1, 1, 1, RegisteredBlocks.blockStoneMachine, 11).addBlock(-1, 1, -1, RegisteredBlocks.blockStoneMachine, 11).addBlock(1, 1, -1, RegisteredBlocks.blockStoneMachine, 11); +} diff --git a/src/main/java/makeo/gadomancy/common/registration/RegisteredRecipes.java b/src/main/java/makeo/gadomancy/common/registration/RegisteredRecipes.java index aa44739..c7f8bb5 100644 --- a/src/main/java/makeo/gadomancy/common/registration/RegisteredRecipes.java +++ b/src/main/java/makeo/gadomancy/common/registration/RegisteredRecipes.java @@ -1,6 +1,7 @@ package makeo.gadomancy.common.registration; import makeo.gadomancy.api.golems.AdditionalGolemType; +import makeo.gadomancy.common.Gadomancy; import makeo.gadomancy.common.crafting.InfusionUpgradeRecipe; import makeo.gadomancy.common.crafting.RecipeStickyJar; import makeo.gadomancy.common.research.SimpleResearchItem; @@ -31,10 +32,16 @@ import java.util.List; public class RegisteredRecipes { private RegisteredRecipes() {} + public static AspectList costsNodeManipulatorMultiblock = new AspectList().add(Aspect.FIRE, 100).add(Aspect.WATER, 100).add(Aspect.EARTH, 100).add(Aspect.AIR, 100).add(Aspect.ORDER, 100).add(Aspect.ENTROPY, 100); + + public static List multiblockNodeManipulator; + public static InfusionRecipe recipeGolemSilverwood; public static InfusionRecipe[] recipesGolemRunicShield; public static InfusionRecipe recipeGolemCoreBreak; public static InfusionRecipe recipeInfusionClaw; + public static InfusionRecipe recipeNodeManipulator; + public static InfusionRecipe recipeRandomizationFocus; public static IArcaneRecipe recipeStickyJar; public static IArcaneRecipe recipeArcaneDropper; @@ -70,6 +77,24 @@ public class RegisteredRecipes { new ItemStack(ConfigBlocks.blockStoneDevice, 1, 5), new ItemStack[]{new ItemStack(ConfigItems.itemFocusPrimal), /*new ItemStack(Items.redstone),*/ new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 6), new ItemStack(ConfigItems.itemGolemCore, 1, 8), new ItemStack(ConfigItems.itemResource, 1, 16), new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 6), new ItemStack(ConfigItems.itemResource, 1, 15), /*new ItemStack(Items.redstone),*/ new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 6), new ItemStack(ConfigItems.itemZombieBrain), new ItemStack(ConfigItems.itemResource, 1, 16), new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 6)}); recipeRemoteJar = ThaumcraftApi.addArcaneCraftingRecipe(SimpleResearchItem.getFullName("REMOTEJAR"), new ItemStack(RegisteredBlocks.blockRemoteJar), new AspectList().add(Aspect.WATER, 10).add(Aspect.EARTH, 10).add(Aspect.ORDER, 10), "GJG", "GMG", 'G', new ItemStack(ConfigBlocks.blockMagicalLog), 'J', new ItemStack(ConfigBlocks.blockJar), 'M', new ItemStack(ConfigBlocks.blockMirror, 1, 6)); + + recipeNodeManipulator = ThaumcraftApi.addInfusionCraftingRecipe(Gadomancy.MODID.toUpperCase() + ".NODE_MANIPULATOR", + new ItemStack(RegisteredBlocks.blockNodeManipulator, 1, 5), 10, + new AspectList().add(Aspect.AURA, 42).add(Aspect.ELDRITCH, 22).add(Aspect.MAGIC, 38).add(Aspect.MECHANISM, 28).add(Aspect.DARKNESS, 14), + new ItemStack(ConfigBlocks.blockStoneDevice, 1, 5), + new ItemStack[] {new ItemStack(ConfigBlocks.blockStoneDevice, 1, 9), new ItemStack(ConfigBlocks.blockCrystal, 1, 6), new ItemStack(ConfigItems.itemResource, 1, 17), new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 11), new ItemStack(ConfigItems.itemResource, 1, 1), new ItemStack(ConfigItems.itemResource, 1, 15), new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 3), new ItemStack(ConfigBlocks.blockCrystal, 1, 6), new ItemStack(ConfigItems.itemResource, 1, 17), new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 11), new ItemStack(ConfigItems.itemResource, 1, 1), new ItemStack(ConfigItems.itemResource, 1, 15)}); + + recipeRandomizationFocus = ThaumcraftApi.addInfusionCraftingRecipe(Gadomancy.MODID.toUpperCase() + ".NODE_MANIPULATOR", + new ItemStack(RegisteredBlocks.blockStoneMachine, 1, 0), 7, + new AspectList().add(Aspect.ELDRITCH, 18).add(Aspect.MAGIC, 18).add(Aspect.MECHANISM, 20).add(Aspect.DARKNESS, 28).add(Aspect.ORDER, 30), + new ItemStack(ConfigBlocks.blockStoneDevice, 1, 8), + new ItemStack[] {new ItemStack(ConfigItems.itemResource, 1, 15), new ItemStack(ConfigItems.itemResource, 1, 16), new ItemStack(ConfigBlocks.blockCrystal, 1, 6), new ItemStack(ConfigItems.itemResource, 1, 16), new ItemStack(ConfigItems.itemResource, 1, 15), new ItemStack(ConfigItems.itemResource, 1, 16), new ItemStack(ConfigBlocks.blockCrystal, 1, 6), new ItemStack(ConfigItems.itemResource, 1, 16)}); + + multiblockNodeManipulator = Arrays.asList(costsNodeManipulatorMultiblock, 3, 3, 3, + Arrays.asList( + null, null, null, null, new ItemStack(RegisteredBlocks.blockNode, 1, 5), null, null, null, null, + new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 11), null, new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 11), null, new ItemStack(RegisteredBlocks.blockStoneMachine, 1, 0), null, new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 11), null, new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 11), + new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 15), null, new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 15), null, new ItemStack(RegisteredBlocks.blockNodeManipulator, 1, 5), null, new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 15), null, new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 15))); } private static IArcaneRecipe[] stickyJarRecipes = null; diff --git a/src/main/java/makeo/gadomancy/common/registration/RegisteredResearches.java b/src/main/java/makeo/gadomancy/common/registration/RegisteredResearches.java index 3e2b8d5..193c0ac 100644 --- a/src/main/java/makeo/gadomancy/common/registration/RegisteredResearches.java +++ b/src/main/java/makeo/gadomancy/common/registration/RegisteredResearches.java @@ -37,9 +37,13 @@ public class RegisteredResearches { public static ResearchItem researchGolemCoreBreak; public static ResearchItem researchInfusionClaw; public static ResearchItem researchRemoteJar; + public static ResearchItem researchNodeManipulator; + + //Growing nodes stuff public static ResearchItem researchGrowingNodes; public static ResearchItem researchGrowingNodeAgression; public static ResearchItem researchGrowingNodeGrowth; + public static ResearchItem researchGrowingNodeAttackNodes; public static ResearchItem researchGrowingNodeGrowthClue; public static void init() { @@ -74,34 +78,52 @@ public class RegisteredResearches { ResearchItem researchFocusPrimal = PseudoResearchItem.create("FOCUSPRIMAL", -2, -3).registerResearchItem(); + ResearchItem researchItemVoidMetal = PseudoResearchItem.create("VOIDMETAL", -3, 4).registerResearchItem(); + ResearchItem researchNodeStabilizer = PseudoResearchItem.create("NODESTABILIZER", -3, 6).registerResearchItem(); + ResearchItem researchWardingStone = PseudoResearchItem.create("PAVEWARD", -1, 6).registerResearchItem(); + researchInfusionClaw = new SimpleResearchItem("INFUSIONCLAW", -1, -3, 5, new ItemStack(RegisteredBlocks.blockInfusionClaw), new AspectList().add(Aspect.ELDRITCH, 8).add(Aspect.MECHANISM, 8).add(Aspect.MAGIC, 8).add(Aspect.ORDER, 8).add(Aspect.DARKNESS, 4)) .setParents(researchFocusPrimal.key).setConcealed() .setPages(new ResearchPage("gadomancy.research_page.INFUSIONCLAW.1"), new ResearchPage(RegisteredRecipes.recipeInfusionClaw)).registerResearchItem(); + researchNodeManipulator = new ResearchItem(Gadomancy.MODID.toUpperCase() + ".NODE_MANIPULATOR", Gadomancy.MODID, + new AspectList().add(Aspect.ELDRITCH, 1).add(Aspect.AURA, 1).add(Aspect.DARKNESS, 1).add(Aspect.MAGIC, 1).add(Aspect.GREED, 1).add(Aspect.VOID, 1).add(Aspect.MECHANISM, 1).add(Aspect.EXCHANGE, 1), + -1, 4, 2, new ItemStack(RegisteredBlocks.blockNodeManipulator, 1, 5)) + .setConcealed().setSpecial() + .setParents(researchItemVoidMetal.key, researchNodeStabilizer.key, researchWardingStone.key) + .setPages(new ResearchPage("gadomancy.research_page.NODE_MANIPULATOR.1"), new ResearchPage(RegisteredRecipes.recipeNodeManipulator), new ResearchPage("gadomancy.research_page.NODE_MANIPULATOR.3"), new ResearchPage(RegisteredRecipes.recipeRandomizationFocus), new ResearchPage(RegisteredRecipes.multiblockNodeManipulator), new ResearchPage("gadomancy.research_page.NODE_MANIPULATOR.6")).registerResearchItem(); + researchGrowingNodes = new ResearchItem(Gadomancy.MODID.toUpperCase() + ".GROWING", Gadomancy.MODID, new AspectList(), 2, 2, 5, new ResourceLocation("thaumcraft", "textures/misc/r_nodes.png")) - .setSpecial().setLost() - .setPages(new ResearchPage("gadomancy.research_page.GROWING.1"), new ResearchPage("gadomancy.research_page.GROWING.2"));//.registerResearchItem(); + .setSpecial().setLost().setConcealed() + .setParents(Gadomancy.MODID.toUpperCase() + ".NODE_MANIPULATOR") + .setPages(new ResearchPage("gadomancy.research_page.GROWING.1"), new ResearchPage("gadomancy.research_page.GROWING.2")).registerResearchItem(); researchGrowingNodeAgression = new ResearchItem(Gadomancy.MODID.toUpperCase() + ".GROWING_AGGRESSION", Gadomancy.MODID, new AspectList(), 5, 3, 6, new ItemStack(ConfigBlocks.blockAiry, 1, 5)) .setLost() .setParents(Gadomancy.MODID.toUpperCase() + ".GROWING") - .setPages(new ResearchPage("gadomancy.research_page.GROWING_AGGRESSION.1"));//.registerResearchItem(); + .setPages(new ResearchPage("gadomancy.research_page.GROWING_AGGRESSION.1")).registerResearchItem(); - researchGrowingNodeGrowth = new ResearchItem(Gadomancy.MODID.toUpperCase() + ".GROWING_GROWTH", Gadomancy.MODID, new AspectList(), 3, 5, 6, new ResourceLocation("thaumcraft", "textures/misc/r_nodes_2.png")) + researchGrowingNodeGrowth = new ResearchItem(Gadomancy.MODID.toUpperCase() + ".GROWING_GROWTH", Gadomancy.MODID, new AspectList(), 3, 5, 6, new ResourceLocation("gadomancy", "textures/misc/r_node_star.png")) .setLost() .setParents(Gadomancy.MODID.toUpperCase() + ".GROWING") - .setPages(new ResearchPage("gadomancy.research_page.GROWING_GROWTH.1"), new ResearchPage("gadomancy.research_page.GROWING_GROWTH.2"));//.registerResearchItem(); + .setPages(new ResearchPage("gadomancy.research_page.GROWING_GROWTH.1"), new ResearchPage("gadomancy.research_page.GROWING_GROWTH.2")).registerResearchItem(); + + researchGrowingNodeAttackNodes = new ResearchItem(Gadomancy.MODID.toUpperCase() + ".GROWING_ATTACK", Gadomancy.MODID, new AspectList(), 4, 4, 6, new ResourceLocation("gadomancy", "textures/misc/r_node_dark.png")) + .setLost() + .setParents(Gadomancy.MODID.toUpperCase() + ".GROWING") + .setPages(new ResearchPage("gadomancy.research_page.GROWING_ATTACK.1")).registerResearchItem(); researchGrowingNodeGrowthClue = new ResearchItem(Gadomancy.MODID.toUpperCase() + ".GROWING_GROWTHCLUE", Gadomancy.MODID, new AspectList().add(Aspect.AURA, 10).add(Aspect.MAGIC, 15).add(Aspect.ELDRITCH, 5).add(Aspect.VOID, 12).add(Aspect.ENERGY, 12).add(Aspect.ENTROPY, 8).add(Aspect.DEATH, 3) .add(Aspect.GREED, 10).add(Aspect.HUNGER, 10).add(Aspect.MECHANISM, 12).add(Aspect.DARKNESS, 12), - 6, 6, 2, new ItemStack(ConfigBlocks.blockAiry, 1, 0)) + 6, 6, 2, new ItemStack(ConfigBlocks.blockAiry, 1, 5)) .setSpecial().setRound().setConcealed() - .setParents(Gadomancy.MODID.toUpperCase() + ".GROWING_AGGRESSION", Gadomancy.MODID.toUpperCase() + ".GROWING_GROWTH") - .setPages(new ResearchPage("gadomancy.research_page.GROWING_GROWTHCLUE.1"), new ResearchPage("gadomancy.research_page.GROWING_GROWTHCLUE.2"));//.registerResearchItem(); + .setParents(Gadomancy.MODID.toUpperCase() + ".GROWING_AGGRESSION", Gadomancy.MODID.toUpperCase() + ".GROWING_GROWTH", Gadomancy.MODID.toUpperCase() + ".GROWING_ATTACK") + .setPages(new ResearchPage("gadomancy.research_page.GROWING_GROWTHCLUE.1"), new ResearchPage("gadomancy.research_page.GROWING_GROWTHCLUE.2")).registerResearchItem(); - //ThaumcraftApi.addWarpToResearch(Gadomancy.MODID.toUpperCase() + ".GROWING_GROWTHCLUE", 3); + ThaumcraftApi.addWarpToResearch(Gadomancy.MODID.toUpperCase() + ".NODE_MANIPULATOR", 4); + ThaumcraftApi.addWarpToResearch(Gadomancy.MODID.toUpperCase() + ".GROWING_GROWTHCLUE", 3); } public static void postInit() { diff --git a/src/main/java/makeo/gadomancy/common/utils/ExplosionHelper.java b/src/main/java/makeo/gadomancy/common/utils/ExplosionHelper.java index 4526fa9..cac5f48 100644 --- a/src/main/java/makeo/gadomancy/common/utils/ExplosionHelper.java +++ b/src/main/java/makeo/gadomancy/common/utils/ExplosionHelper.java @@ -132,7 +132,7 @@ public class ExplosionHelper { Block b = world.getBlock(xx, yy, zz); float hardness = b.getBlockHardness(world, xx, yy, zz); if(b != Blocks.air && hardness > 0 && hardness <= 50 && b != RegisteredBlocks.blockNode) { - PacketAnimationAbsorb absorb = new PacketAnimationAbsorb(x, y, z, xx, yy, zz); + PacketAnimationAbsorb absorb = new PacketAnimationAbsorb(x, y, z, xx, yy, zz, 7); PacketHandler.INSTANCE.sendToAllAround(absorb, new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, 32D)); pastTickBlocks.add(Vec3.createVectorHelper(xx, yy, zz)); } diff --git a/src/main/java/makeo/gadomancy/common/utils/JarMultiblockHandler.java b/src/main/java/makeo/gadomancy/common/utils/JarMultiblockHandler.java index 70dd44d..506edc3 100644 --- a/src/main/java/makeo/gadomancy/common/utils/JarMultiblockHandler.java +++ b/src/main/java/makeo/gadomancy/common/utils/JarMultiblockHandler.java @@ -1,6 +1,6 @@ package makeo.gadomancy.common.utils; -import makeo.gadomancy.common.blocks.tiles.ExtendedNodeType; +import makeo.gadomancy.common.node.ExtendedNodeType; import makeo.gadomancy.common.blocks.tiles.TileExtendedNode; import makeo.gadomancy.common.blocks.tiles.TileExtendedNodeJar; import makeo.gadomancy.common.registration.RegisteredBlocks; @@ -19,7 +19,6 @@ import thaumcraft.api.aspects.AspectList; import thaumcraft.api.nodes.INode; import thaumcraft.api.nodes.NodeModifier; import thaumcraft.api.nodes.NodeType; -import thaumcraft.common.blocks.BlockJar; import thaumcraft.common.blocks.BlockMagicalLog; import thaumcraft.common.config.ConfigBlocks; import thaumcraft.common.lib.research.ResearchManager; diff --git a/src/main/java/makeo/gadomancy/common/utils/MultiblockHelper.java b/src/main/java/makeo/gadomancy/common/utils/MultiblockHelper.java new file mode 100644 index 0000000..099960c --- /dev/null +++ b/src/main/java/makeo/gadomancy/common/utils/MultiblockHelper.java @@ -0,0 +1,82 @@ +package makeo.gadomancy.common.utils; + +import net.minecraft.block.Block; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +import java.util.LinkedHashMap; + +/** + * 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 @ 27.10.2015 13:56 + */ +public class MultiblockHelper { + + public static boolean isMultiblockPresent(World world, int x, int y, int z, MultiblockPattern pattern) { + for(IntVec3 vec : pattern.keySet()) { + BlockInfo expected = pattern.get(vec); + Block realBlock = world.getBlock(x + vec.x, y + vec.y, z + vec.z); + int realMeta = world.getBlockMetadata(x + vec.x, y + vec.y, z + vec.z); + if(expected.block != realBlock || expected.meta != realMeta) return false; + } + return true; + } + + public static class MultiblockPattern extends LinkedHashMap { + + public MultiblockPattern(Block originBlock, int originMeta) { + put(createIntVec3(0, 0, 0), new BlockInfo(originBlock, originMeta)); + } + + public MultiblockPattern addBlock(int relativeX, int relativeY, int relativeZ, Block expectedBlock, int expectedMeta) { + put(createIntVec3(relativeX, relativeY, relativeZ), new BlockInfo(expectedBlock, expectedMeta)); + return this; + } + + private IntVec3 createIntVec3(int x, int y, int z) { + return new IntVec3(x, y, z); + } + + } + + public static class IntVec3 { + public int x, y, z; + + public IntVec3(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + IntVec3 intVec3 = (IntVec3) o; + return x == intVec3.x && y == intVec3.y && z == intVec3.z; + + } + + @Override + public int hashCode() { + int result = x; + result = 31 * result + y; + result = 31 * result + z; + return result; + } + } + + public static class BlockInfo { + public Block block; + public int meta; + + private BlockInfo(Block block, int meta) { + this.block = block; + this.meta = meta; + } + } +} diff --git a/src/main/java/makeo/gadomancy/common/utils/ResearchHelper.java b/src/main/java/makeo/gadomancy/common/utils/ResearchHelper.java new file mode 100644 index 0000000..7c3f473 --- /dev/null +++ b/src/main/java/makeo/gadomancy/common/utils/ResearchHelper.java @@ -0,0 +1,34 @@ +package makeo.gadomancy.common.utils; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; +import thaumcraft.common.Thaumcraft; +import thaumcraft.common.lib.network.playerdata.PacketResearchComplete; +import thaumcraft.common.lib.research.ResearchManager; + +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 @ 30.10.2015 21:23 + */ +public class ResearchHelper { + + public static void distributeResearch(String research, World world, double x, double y, double z, double radius) { + List players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(radius, radius, radius)); + for(Object pl : players) { + EntityPlayer player = (EntityPlayer) pl; + if(!ResearchManager.isResearchComplete(player.getCommandSenderName(), research) && ResearchManager.doesPlayerHaveRequisites(player.getCommandSenderName(), research)) { + thaumcraft.common.lib.network.PacketHandler.INSTANCE.sendTo(new PacketResearchComplete(research), (EntityPlayerMP)player); + Thaumcraft.proxy.getResearchManager().completeResearch(player, research); + } + } + } + +} diff --git a/src/main/resources/assets/gadomancy/lang/en_US.lang b/src/main/resources/assets/gadomancy/lang/en_US.lang index 0862c3c..c5ce1ad 100644 --- a/src/main/resources/assets/gadomancy/lang/en_US.lang +++ b/src/main/resources/assets/gadomancy/lang/en_US.lang @@ -1,6 +1,5 @@ item.ItemGolemPlacer.silverwood.name=Silverwood Golem item.ItemTransformationFocus.name=[WIP] Wand Focus: Transformation -item.ItemExtendedNodeJar.name=Node in a Jar itemGroup.gadomancy=Gadomancy tc.research_category.gadomancy=Gadomancy @@ -33,10 +32,16 @@ tc.research_name.GADOMANCY.REMOTEJAR=Mirrored Jars tc.research_text.GADOMANCY.REMOTEJAR=Mirrored transportation gadomancy.research_page.REMOTEJAR.1=Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr. +tc.research_name.GADOMANCY.NODE_MANIPULATOR=Node Manipulator +tc.research_text.GADOMANCY.NODE_MANIPULATOR=Almost like roulette +gadomancy.research_page.NODE_MANIPULATOR.1=By infusing your ordinary Wand Recharge Pedestal with the stabilizing factors of a Node Stabilizer and the Paving Stone of Warding along with some of the most ancient ingredients that share the highest affinity when it comes to channeling Vis in its most pure form, one of the most dangerous machines fell into your possession: The Node Manipulator. A machine so capable of changing the way an aura node transports Vis from their end to our end. +gadomancy.research_page.NODE_MANIPULATOR.3=This doesn't seem to be enough though. Even by adding one of your newest inventions, the Void Seeds, to it, it doesn't seem to be capable of holding the Node in position... You figured out that a focus, enhanced by Void Metal, might be strong enough to keep it in position. Still the machine isn't capable of modifying a node on its own. Placing some manipulation pillars near the machine should help fixing that issue. +gadomancy.research_page.NODE_MANIPULATOR.6=This machine doesn't work for free obviously. Once there is a node above the Node Manipulator and the pillars are formed, you need to place a wand or a staff into the Manipulator and it will drain the Vis from the wand into the manipulator. Once at least 70 of each Vis is stored, the Manipulator starts manipulating the node. However, you can store more than 70 Vis in the Manipulator. The more the better maybe...? You don't know the possible outcomes yet, but you should at least try it a few times.. What could possibly go wrong? + tc.research_name.GADOMANCY.GROWING=Growing Nodes tc.research_text.GADOMANCY.GROWING=Hungry Nodes v2.0 gadomancy.research_page.GROWING.1=This node is something... different.
You did expect an Energized Node to be the only stable connection between us and the source of all Vis, but this Aura Node seems very stable too. Energizing an Aura Node channels Vis from its source to our end and breaks it down to the purest primal Aspects.
But... this node behaves so different from the other nodes. It seems to search for something... It seems... restless... -gadomancy.research_page.GROWING.2=What is it searching for? Judging from my knowledge so far it can be compared to a hungry Aura Node, but still... You should keep an Eye on this. +gadomancy.research_page.GROWING.2=What is it searching for? Judging from my knowledge so far it can be compared to a hungry Aura Node, but still... You should really keep a close eye on this new type of nodes. tc.research_name.GADOMANCY.GROWING_AGGRESSION=Aggressive Behavior tc.research_text.GADOMANCY.GROWING_AGGRESSION=Taking a step back @@ -47,10 +52,14 @@ tc.research_text.GADOMANCY.GROWING_GROWTH=A picky one. gadomancy.research_page.GROWING_GROWTH.1=I was right! The node has similarities to a hungry node! It grew bigger than before!
But it looks light the node only attracts things that contains Vis in its purest form. So the node should attract things like Wisps or Ethereal Essence. Hmm... As far as my research goes, it seems that the more pure the aspect is, the more likely it will fuse with the node. It seems that the node attracts Aspect Orbs and Wisps the most as they are the most pure. gadomancy.research_page.GROWING_GROWTH.2=Materialized or solid vis in forms of essentia like Mana Beans, Ethereal Essence or Crystallized Essentia may work too, but may have bad outcome in the end...
Still it is by far more fascinating than a hungry node. In contrast to its hungry brother, this node seems to keep the complexity of its gained compound aspects instead of breaking them down to primal aspects. After all it does seem that this node does not like primal aspects at all..? +tc.research_name.GADOMANCY.GROWING_ATTACK=Destroying Behavior +tc.research_text.GADOMANCY.GROWING_ATTACK=Stop bullying! +gadomancy.research_page.GROWING_ATTACK.1=Whoa, what an interesting sight! It seems the growing node does not only bully the other nodes as we know it - it's more like completely destroying the other node. If the growing node can find another node within range it attacks it and breaks the other node into little Aspect orbs.
Further research shows that the node stabilizers cannot stop the growing node from destroying other nodes. But it seems like the growing node does not attack bigger nodes than themselves. + tc.research_name.GADOMANCY.GROWING_GROWTHCLUE=Secrets of growth tc.research_text.GADOMANCY.GROWING_GROWTHCLUE=Growing explained gadomancy.research_page.GROWING_GROWTHCLUE.1=This is it! I think i solved the puzzle of the growth and dangers of a growing node! It looks so simple: Just don't feed it the same aspects. That's what our node hates. It just wants variety and new aspects. If you feed it the same over and over it gets angry and stops growing if its too saturated. It only accepts pure aspects though. Ethereal Essence, Crystallized Essence and Mana beans are weak forms of materialized Vis. It seems the node doesn't like that... -gadomancy.research_page.GROWING_GROWTHCLUE.2=In contrast to that it seems that it really likes Wisps or Aspect Orbs. Still one of the best and most expensive things might be offering other Aura Nodes to the growing node.
But there are high risks too. The more saturated the node gets, the harder and more often the node does attack its surroundings. I wonder what happens once the node is fully saturated..? +gadomancy.research_page.GROWING_GROWTHCLUE.2=In contrast to that it seems that it really likes Wisps or Aspect Orbs. Still one of the best and most expensive things might be offering other Aura Nodes to the growing node... But there are high risks too. The more saturated the node gets, the harder and more often the node does attack its surroundings. I wonder what happens once the node is fully saturated..? gadomancy.golemblurb.default=?? gadomancy.golemblurb.breakcore=Master, should I break everything, or something specific? @@ -67,6 +76,10 @@ tile.BlockInfusionClaw.name=Infusion Claw tile.BlockRemoteJar.name=Mirrored Jar tile.BlockNode.name=Aura Node tile.BlockExtendedNodeJar.name=Node in a Jar +tile.BlockNodeManipulator.5.name=Node Manipulator +tile.BlockStoneMachine.0.name=Randomization Focus +tile.BlockStoneMachine.11.name=Manipulation Pillar +tile.BlockStoneMachine.15.name=Manipulation Pillar gadomancy.nodes.GROWING=Growing gadomancy.nodes.STARVING=Starving diff --git a/src/main/resources/assets/gadomancy/textures/blocks/manipulator_bot.png b/src/main/resources/assets/gadomancy/textures/blocks/manipulator_bot.png new file mode 100644 index 0000000..c819db6 Binary files /dev/null and b/src/main/resources/assets/gadomancy/textures/blocks/manipulator_bot.png differ diff --git a/src/main/resources/assets/gadomancy/textures/blocks/manipulator_focus_bot.png b/src/main/resources/assets/gadomancy/textures/blocks/manipulator_focus_bot.png new file mode 100644 index 0000000..2713486 Binary files /dev/null and b/src/main/resources/assets/gadomancy/textures/blocks/manipulator_focus_bot.png differ diff --git a/src/main/resources/assets/gadomancy/textures/blocks/manipulator_focus_side.png b/src/main/resources/assets/gadomancy/textures/blocks/manipulator_focus_side.png new file mode 100644 index 0000000..02eadab Binary files /dev/null and b/src/main/resources/assets/gadomancy/textures/blocks/manipulator_focus_side.png differ diff --git a/src/main/resources/assets/gadomancy/textures/blocks/manipulator_focus_top.png b/src/main/resources/assets/gadomancy/textures/blocks/manipulator_focus_top.png new file mode 100644 index 0000000..b0969a7 Binary files /dev/null and b/src/main/resources/assets/gadomancy/textures/blocks/manipulator_focus_top.png differ diff --git a/src/main/resources/assets/gadomancy/textures/blocks/manipulator_side.png b/src/main/resources/assets/gadomancy/textures/blocks/manipulator_side.png new file mode 100644 index 0000000..f8b0a9a Binary files /dev/null and b/src/main/resources/assets/gadomancy/textures/blocks/manipulator_side.png differ diff --git a/src/main/resources/assets/gadomancy/textures/blocks/manipulator_top.png b/src/main/resources/assets/gadomancy/textures/blocks/manipulator_top.png new file mode 100644 index 0000000..278c0b9 Binary files /dev/null and b/src/main/resources/assets/gadomancy/textures/blocks/manipulator_top.png differ diff --git a/src/main/resources/assets/gadomancy/textures/misc/r_node_dark.png b/src/main/resources/assets/gadomancy/textures/misc/r_node_dark.png new file mode 100644 index 0000000..c0cf68f Binary files /dev/null and b/src/main/resources/assets/gadomancy/textures/misc/r_node_dark.png differ diff --git a/src/main/resources/assets/gadomancy/textures/misc/r_node_star.png b/src/main/resources/assets/gadomancy/textures/misc/r_node_star.png new file mode 100644 index 0000000..ed490af Binary files /dev/null and b/src/main/resources/assets/gadomancy/textures/misc/r_node_star.png differ diff --git a/src/main/resources/assets/gadomancy/textures/models/jar_overlay.png b/src/main/resources/assets/gadomancy/textures/models/jar_overlay.png deleted file mode 100644 index 08b13ea..0000000 Binary files a/src/main/resources/assets/gadomancy/textures/models/jar_overlay.png and /dev/null differ diff --git a/src/main/resources/assets/gadomancy/textures/models/manipulation_focus_0.png b/src/main/resources/assets/gadomancy/textures/models/manipulation_focus_0.png new file mode 100644 index 0000000..ea273fe Binary files /dev/null and b/src/main/resources/assets/gadomancy/textures/models/manipulation_focus_0.png differ diff --git a/src/main/resources/assets/gadomancy/textures/models/manipulator_pillar.png b/src/main/resources/assets/gadomancy/textures/models/manipulator_pillar.png new file mode 100644 index 0000000..0147954 Binary files /dev/null and b/src/main/resources/assets/gadomancy/textures/models/manipulator_pillar.png differ diff --git a/src/main/resources/assets/gadomancy/textures/models/small_cube.png b/src/main/resources/assets/gadomancy/textures/models/small_cube.png new file mode 100644 index 0000000..53c358e Binary files /dev/null and b/src/main/resources/assets/gadomancy/textures/models/small_cube.png differ