thaumcraft.common.lib.network.PacketHandler Java Examples

The following examples show how to use thaumcraft.common.lib.network.PacketHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TileEssentiaCompressor.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
private boolean doDrain(Aspect a, List<WorldCoordinates> coordinates) {
    for (WorldCoordinates coordinate : coordinates) {
        TileEntity sourceTile = worldObj.getTileEntity(coordinate.x, coordinate.y, coordinate.z);
        if ((sourceTile == null) || (!(sourceTile instanceof IAspectSource))) {
            continue;
        }
        if(sourceTile instanceof TileEssentiaCompressor) continue;
        IAspectSource as = (IAspectSource)sourceTile;
        AspectList contains = as.getAspects();
        if(contains == null || contains.visSize() > al.visSize()) continue;
        if(!canAccept(a)) continue;
        if (as.takeFromContainer(a, 1)) {
            PacketHandler.INSTANCE.sendToAllAround(new PacketFXEssentiaSource(xCoord, yCoord + 1, zCoord,
                    (byte)(xCoord - coordinate.x), (byte)(yCoord - coordinate.y + 1), (byte)(zCoord - coordinate.z),
                    a.getColor()), new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord + 1, zCoord, 32.0D));
            return true;
        }
    }
    return false;
}
 
Example #2
Source File: ItemStreamChainsaw.java    From Electro-Magic-Tools with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) {
    World world = player.worldObj;
    Block bi = world.getBlock(x, y, z);
    if ((!player.isSneaking()) && (Utils.isWoodLog(world, x, y, z))) {
        if (!world.isRemote) {
            BlockUtils.breakFurthestBlock(world, x, y, z, bi, player);
            PacketHandler.INSTANCE.sendToAllAround(new PacketFXBlockBubble(x, y, z, new Color(0.33F, 0.33F, 1.0F).getRGB()), new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, 32.0D));

            world.playSoundEffect(x, y, z, "thaumcraft:bubble", 0.15F, 1.0F);
        }
        ElectricItem.manager.use(itemstack, cost, player);
        return true;
    }
    return super.onBlockStartBreak(itemstack, x, y, z, player);
}
 
Example #3
Source File: ItemCrystalwell.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean isSelected) {

    if(world.isRemote)
        return;
    if(Config.researchDifficulty == -1 && entity.ticksExisted % 200 == 0 && (entity instanceof EntityPlayer)){
        EntityPlayer player = (EntityPlayer)entity;
        Aspect aspect = (Aspect)Aspect.getPrimalAspects().get(world.rand.nextInt(6));
        short amount = (short)(world.rand.nextInt(4) + 1);
        Thaumcraft.proxy.playerKnowledge.addAspectPool(player.getCommandSenderName(), aspect, amount);
        PacketHandler.INSTANCE.sendTo(new PacketAspectPool(aspect.getTag(), amount, Short.valueOf(Thaumcraft.proxy.playerKnowledge.getAspectPoolFor(player.getCommandSenderName(), aspect))), (EntityPlayerMP) player);
        ResearchManager.scheduleSave(player);
        stack.setItemDamage(stack.getItemDamage() + 1);
        if(stack.getItemDamage() >= stack.getMaxDamage())
            ((EntityPlayer)entity).inventory.setInventorySlotContents(slot, null);
    }
}
 
Example #4
Source File: GolemUpgradeRunicShield.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void sendShieldEffect(EntityGolemBase golem, DamageSource source) {
    int target = -1;
    if (source.getEntity() != null) {
        target = source.getEntity().getEntityId();
    } else if (source == DamageSource.fall) {
        target = -2;
    } else if (source == DamageSource.fallingBlock) {
        target = -3;
    }

    PacketHandler.INSTANCE.sendToAllAround(new PacketFXShield(golem.getEntityId(), target),
            new NetworkRegistry.TargetPoint(golem.worldObj.provider.dimensionId, golem.posX, golem.posY, golem.posZ, 64.0D));
}
 
Example #5
Source File: TileEssentiaCompressor.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void consumeElements() {
    if(coordPedestal != null) {
        if(!checkPedestal(coordPedestal)) {
            consumeTick = 0;
            coordPedestal = null;
            return;
        }
        consumeTick++;
        if(consumeTick <= 400) {
            PacketAnimationAbsorb absorb = new PacketAnimationAbsorb(
                    xCoord, yCoord + 1, zCoord,
                    coordPedestal.getBlockX(), coordPedestal.getBlockY() + 1, coordPedestal.getBlockZ(),
                    5, Block.getIdFromBlock(ConfigBlocks.blockCosmeticSolid), 1);
            makeo.gadomancy.common.network.PacketHandler.INSTANCE.sendToAllAround(absorb, new NetworkRegistry.TargetPoint(
                    getWorldObj().provider.dimensionId,
                    xCoord, yCoord, zCoord, 16));
        } else {
            TilePedestal te = (TilePedestal) worldObj.getTileEntity(
                    coordPedestal.getBlockX(), coordPedestal.getBlockY(), coordPedestal.getBlockZ());
            te.setInventorySlotContents(0, null);
            te.markDirty();
            worldObj.markBlockForUpdate(
                    coordPedestal.getBlockX(), coordPedestal.getBlockY(), coordPedestal.getBlockZ());
            consumeTick = 0;
            coordPedestal = null;
            incSize += 1;
            worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
            markDirty();
        }
    } else {
        for (int xx = -3; xx <= 3; xx++) {
            for (int zz = -3; zz <= 3; zz++) {
                Vector3 offset = new Vector3(xCoord + xx, yCoord, zCoord + zz);
                if(checkPedestal(offset)) {
                    this.coordPedestal = offset;
                    this.consumeTick = 0;
                    return;
                }
            }
        }
        this.coordPedestal = null;
        this.consumeTick = 0;
    }
}