Search in sources :

Example 1 with TileEntityParticleEmitter

use of am2.blocks.tileentities.TileEntityParticleEmitter in project ArsMagica2 by Mithion.

the class BlockParticleEmitter method onBlockExploded.

@Override
public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) {
    TileEntity te = world.getTileEntity(x, y, z);
    TileEntityParticleEmitter te2 = null;
    if (te instanceof TileEntityParticleEmitter)
        te2 = (TileEntityParticleEmitter) te;
    if (te2 == null)
        super.onBlockExploded(world, x, y, z, explosion);
    if (te2 != null && te2.getShow())
        super.onBlockExploded(world, x, y, z, explosion);
// do not explode the block if it's invisible
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityParticleEmitter(am2.blocks.tileentities.TileEntityParticleEmitter)

Example 2 with TileEntityParticleEmitter

use of am2.blocks.tileentities.TileEntityParticleEmitter in project ArsMagica2 by Mithion.

the class AMPacketProcessorServer method handleDecoBlockUpdate.

private void handleDecoBlockUpdate(byte[] data, EntityPlayerMP player) {
    World world = player.worldObj;
    AMDataReader rdr = new AMDataReader(data, false);
    TileEntity te = world.getTileEntity(rdr.getInt(), rdr.getInt(), rdr.getInt());
    if (te == null || !(te instanceof TileEntityParticleEmitter))
        return;
    ((TileEntityParticleEmitter) te).readFromNBT(rdr.getNBTTagCompound());
    world.markBlockForUpdate(te.xCoord, te.yCoord, te.zCoord);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityParticleEmitter(am2.blocks.tileentities.TileEntityParticleEmitter) World(net.minecraft.world.World)

Example 3 with TileEntityParticleEmitter

use of am2.blocks.tileentities.TileEntityParticleEmitter in project ArsMagica2 by Mithion.

the class ItemCrystalWrench method onItemUseFirst.

@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    TileEntity te = world.getTileEntity(x, y, z);
    if (!stack.hasTagCompound())
        stack.setTagCompound(new NBTTagCompound());
    int cMode = getMode(stack);
    if (te != null && !(te instanceof IPowerNode || te instanceof TileEntityParticleEmitter) && cMode == MODE_DISCONNECT) {
        player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.wrongWrenchMode")));
        return false;
    }
    if (te != null && te instanceof IPowerNode) {
        if (cMode == MODE_DISCONNECT) {
            doDisconnect((IPowerNode) te, world, x + hitX, y + hitY, z + hitZ, player);
            return false;
        }
        if (stack.stackTagCompound.hasKey(KEY_PAIRLOC)) {
            doPairNodes(world, x, y, z, stack, player, hitX, hitY, hitZ, te);
        } else {
            storePairLocation(world, te, stack, player, x + hitX, y + hitY, z + hitZ);
        }
    } else if (te != null && te instanceof TileEntityCrystalMarker && stack.stackTagCompound != null && stack.stackTagCompound.hasKey(HAB_PAIRLOC)) {
        handleCMPair(stack, world, player, te, x + hitX, y + hitY, z + hitZ);
    } else if (player.isSneaking()) {
        handleModeChanges(stack);
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityCrystalMarker(am2.blocks.tileentities.TileEntityCrystalMarker) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TileEntityParticleEmitter(am2.blocks.tileentities.TileEntityParticleEmitter) ChatComponentText(net.minecraft.util.ChatComponentText) IPowerNode(am2.api.power.IPowerNode)

Example 4 with TileEntityParticleEmitter

use of am2.blocks.tileentities.TileEntityParticleEmitter in project ArsMagica2 by Mithion.

the class BlockParticleEmitter method onBlockActivated.

@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
    if (par1World.isRemote) {
        TileEntity te = par1World.getTileEntity(par2, par3, par4);
        if (te != null && te instanceof TileEntityParticleEmitter) {
            if (par5EntityPlayer.inventory.getCurrentItem() != null && par5EntityPlayer.inventory.getCurrentItem().getItem() == ItemsCommonProxy.crystalWrench) {
                if (ItemCrystalWrench.getMode(par5EntityPlayer.inventory.getCurrentItem()) == 0) {
                    AMCore.proxy.openParticleBlockGUI(par1World, par5EntityPlayer, (TileEntityParticleEmitter) te);
                } else {
                    if (AMCore.proxy.cwCopyLoc == null) {
                        par5EntityPlayer.addChatMessage(new ChatComponentText("Settings Copied."));
                        AMCore.proxy.cwCopyLoc = new NBTTagCompound();
                        ((TileEntityParticleEmitter) te).writeSettingsToNBT(AMCore.proxy.cwCopyLoc);
                    } else {
                        par5EntityPlayer.addChatMessage(new ChatComponentText("Settings Applied."));
                        ((TileEntityParticleEmitter) te).readSettingsFromNBT(AMCore.proxy.cwCopyLoc);
                        ((TileEntityParticleEmitter) te).syncWithServer();
                        AMCore.proxy.cwCopyLoc = null;
                    }
                }
                return true;
            } else {
                AMCore.proxy.openParticleBlockGUI(par1World, par5EntityPlayer, (TileEntityParticleEmitter) te);
                return true;
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TileEntityParticleEmitter(am2.blocks.tileentities.TileEntityParticleEmitter) ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

TileEntityParticleEmitter (am2.blocks.tileentities.TileEntityParticleEmitter)4 TileEntity (net.minecraft.tileentity.TileEntity)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 ChatComponentText (net.minecraft.util.ChatComponentText)2 IPowerNode (am2.api.power.IPowerNode)1 TileEntityCrystalMarker (am2.blocks.tileentities.TileEntityCrystalMarker)1 World (net.minecraft.world.World)1