- NodeManipulator: Added effects, fixxed inventory bug,

This commit is contained in:
HellFirePvP committed 2015-10-28 00:42:39 +01:00
1 parent 872a94910f
commit bd1ec252e7
5 files changed
+71 -16

No files matched your search

@@ -95,22 +95,26 @@ public class BlockNodeManipulator extends BlockStoneDevice {
if(world.isRemote) return true;
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof TileNodeManipulator && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemWandCasting) {
if (te != null && te instanceof TileNodeManipulator) {
TileNodeManipulator manipulator = (TileNodeManipulator) te;
manipulator.checkMultiblock();
if (manipulator.isMultiblockStructurePresent()) {
if (manipulator.isInMultiblock()) {
return tryAddWand(manipulator, x, y, z, player);
} else if (ThaumcraftApiHelper.consumeVisFromWandCrafting(player.getCurrentEquippedItem(), player, RegisteredRecipes.costsNodeManipulatorMultiblock, true)) {
manipulator.formMultiblock();
return true;
if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemWandCasting) {
manipulator.checkMultiblock();
if (manipulator.isMultiblockStructurePresent()) {
if (manipulator.isInMultiblock()) {
return tryAddWandOrRemove(manipulator, x, y, z, player);
} else if (ThaumcraftApiHelper.consumeVisFromWandCrafting(player.getCurrentEquippedItem(), player, RegisteredRecipes.costsNodeManipulatorMultiblock, true)) {
manipulator.formMultiblock();
return true;
}
}
} else {
tryAddWandOrRemove(manipulator, x, y, z, player);
}
}
return true;
}
private boolean tryAddWand(TileNodeManipulator manipulator, int x, int y, int z, EntityPlayer player) {
private boolean tryAddWandOrRemove(TileNodeManipulator manipulator, int x, int y, int z, EntityPlayer player) {
World world = manipulator.getWorldObj();
if (manipulator.getStackInSlot(0) != null) {
InventoryUtils.dropItemsAtEntity(world, x, y, z, player);
@@ -1,7 +1,11 @@
package makeo.gadomancy.common.blocks.tiles;
import net.minecraft.world.World;
import thaumcraft.common.Thaumcraft;
import thaumcraft.common.tiles.TileInfusionPillar;
import java.awt.*;
/**
* This class is part of the Gadomancy Mod
* Gadomancy is Open Source and distributed under the
@@ -12,4 +16,22 @@ import thaumcraft.common.tiles.TileInfusionPillar;
*/
public class TileManipulatorPillar extends TileInfusionPillar {
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;
}
}
@@ -1,5 +1,8 @@
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.registration.RegisteredBlocks;
import makeo.gadomancy.common.registration.RegisteredMultiblocks;
import makeo.gadomancy.common.utils.MultiblockHelper;
@@ -39,14 +42,19 @@ public class TileNodeManipulator extends TileWandPedestal implements IAspectCont
checkMultiblock();
if(!isMultiblockStructurePresent()) {
breakMultiblock();
isMultiblock = false;
}
}
}
@Override
public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) {
return super.receiveClientEvent(p_145842_1_, p_145842_2_);
}
public void breakMultiblock() {
//TODO break pillars.
//bb wand
if(getStackInSlot(0) != null)
InventoryUtils.dropItems(worldObj, xCoord, yCoord, zCoord);
}
@@ -63,17 +71,26 @@ public class TileNodeManipulator extends TileWandPedestal implements IAspectCont
worldObj.setBlock(absX, absY, absZ, info.block, info.meta, 0);
worldObj.markBlockForUpdate(absX, absY, absZ);
}
NetworkRegistry.TargetPoint target = new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 32);
TileManipulatorPillar pillar = (TileManipulatorPillar) worldObj.getTileEntity(xCoord + 1, yCoord, zCoord + 1); //wrong
pillar.orientation = 5;
worldObj.markBlockForUpdate(pillar.xCoord, pillar.yCoord, pillar.zCoord);
PacketStartAnimation animation = new PacketStartAnimation(PacketStartAnimation.ID_PILLAR_RUNES, pillar.xCoord, pillar.yCoord, pillar.zCoord);
PacketHandler.INSTANCE.sendToAllAround(animation, target);
pillar.markDirty();
TileManipulatorPillar pillar2 = (TileManipulatorPillar) worldObj.getTileEntity(xCoord - 1, yCoord, zCoord + 1);
pillar2.orientation = 3; //correct
worldObj.markBlockForUpdate(pillar2.xCoord, pillar2.yCoord, pillar2.zCoord);
animation = new PacketStartAnimation(PacketStartAnimation.ID_PILLAR_RUNES, pillar2.xCoord, pillar2.yCoord, pillar2.zCoord);
PacketHandler.INSTANCE.sendToAllAround(animation, target);
pillar2.markDirty();
TileManipulatorPillar pillar3 = (TileManipulatorPillar) worldObj.getTileEntity(xCoord + 1, yCoord, zCoord - 1); //wrong
pillar3.orientation = 4;
worldObj.markBlockForUpdate(pillar3.xCoord, pillar3.yCoord, pillar3.zCoord);
animation = new PacketStartAnimation(PacketStartAnimation.ID_PILLAR_RUNES, pillar3.xCoord, pillar3.yCoord, pillar3.zCoord);
PacketHandler.INSTANCE.sendToAllAround(animation, target);
animation = new PacketStartAnimation(PacketStartAnimation.ID_PILLAR_RUNES, xCoord - 1, yCoord, zCoord - 1);
PacketHandler.INSTANCE.sendToAllAround(animation, target);
pillar3.markDirty();
markDirty();
this.isMultiblock = true;
@@ -83,14 +100,19 @@ public class TileNodeManipulator extends TileWandPedestal implements IAspectCont
public void readCustomNBT(NBTTagCompound compound) {
super.readCustomNBT(compound);
NBTTagCompound tag = compound.getCompoundTag("Gadomancy");
this.multiblockStructurePresent = tag.getBoolean("mBlockPresent");
this.isMultiblock = tag.getBoolean("mBlockState");
}
@Override
public void writeCustomNBT(NBTTagCompound compound) {
super.writeCustomNBT(compound);
NBTTagCompound tag = new NBTTagCompound();
tag.setBoolean("mBlockPresent", this.multiblockStructurePresent);
tag.setBoolean("mBlockState", this.isMultiblock);
compound.setTag("Gadomancy", tag);
}
public boolean isInMultiblock() {
@@ -115,15 +137,17 @@ public class TileNodeManipulator extends TileWandPedestal implements IAspectCont
patternToCheck = RegisteredMultiblocks.incompleteNodeManipulatorMultiblock;
this.multiblockStructurePresent = MultiblockHelper.isMultiblockPresent(worldObj, xCoord, yCoord, zCoord, patternToCheck);
}
markDirty();
return isMultiblockStructurePresent();
}
@Override
public boolean canInsertItem(int par1, ItemStack par2ItemStack, int par3) {
return isInMultiblock() && super.canInsertItem(par1, par2ItemStack, par3);
}
@Override
public AspectList getAspects() {
return null;
return new AspectList();
}
@Override
@@ -8,6 +8,8 @@ import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import makeo.gadomancy.common.blocks.tiles.TileExtendedNode;
import makeo.gadomancy.common.blocks.tiles.TileInfusionClaw;
import makeo.gadomancy.common.blocks.tiles.TileManipulatorPillar;
import makeo.gadomancy.common.blocks.tiles.TileNodeManipulator;
import makeo.gadomancy.common.utils.ExplosionHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.tileentity.TileEntity;
@@ -26,6 +28,7 @@ public class PacketStartAnimation implements IMessage, IMessageHandler<PacketSta
public static final byte ID_INFUSIONCLAW = 0;
public static final byte ID_EX_VORTEX = 1;
public static final byte ID_BURST = 2;
public static final byte ID_PILLAR_RUNES = 3;
private byte annimationId;
private int x;
@@ -75,6 +78,9 @@ public class PacketStartAnimation implements IMessage, IMessageHandler<PacketSta
case ID_BURST:
Thaumcraft.proxy.burst(Minecraft.getMinecraft().theWorld, message.x + 0.5F, message.y + 0.5F, message.z + 0.5F, Minecraft.getMinecraft().theWorld.rand.nextInt(3) + 1);
break;
case ID_PILLAR_RUNES:
TileManipulatorPillar.doRuneEffects(Minecraft.getMinecraft().theWorld, message.x, message.y, message.z);
break;
}
return null;
}
@@ -18,7 +18,6 @@ public class RegisteredMultiblocks {
.addBlock(0, 2, 0, RegisteredBlocks.blockNode, 0).addBlock(0, 1, 0, Blocks.air, 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);
//.addBlock(1, 2, 1, ConfigBlocks.blockCrystal, 6).addBlock(-1, 2, 1, ConfigBlocks.blockCrystal, 6).addBlock(-1, 2, -1, ConfigBlocks.blockCrystal, 6).addBlock(1, 2, -1, ConfigBlocks.blockCrystal, 6);
public static final MultiblockHelper.MultiblockPattern completeNodeManipulatorMultiblock = new MultiblockHelper.MultiblockPattern(RegisteredBlocks.blockNodeManipulator, 5)
.addBlock(0, 2, 0, RegisteredBlocks.blockNode, 0).addBlock(0, 1, 0, Blocks.air, 0)