net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint Java Examples
The following examples show how to use
net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint.
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: NetworkHandler.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
public static void broadcastBreakParticles(World world, Block block, BlockPos pos) { PacketBreakParticle packet = new PacketBreakParticle(block, pos); TargetPoint point = new TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 15); INSTANCE.sendToAllAround(packet, point); }
Example #2
Source File: ItemHeartUpgrade.java From Cyberware with MIT License | 4 votes |
@SubscribeEvent public void handleDeath(LivingDeathEvent event) { EntityLivingBase e = event.getEntityLiving(); ItemStack test = new ItemStack(this, 1, 0); if (CyberwareAPI.isCyberwareInstalled(e, test) && !event.isCanceled()) { ICyberwareUserData cyberware = CyberwareAPI.getCapability(e); ItemStack stack = CyberwareAPI.getCyberware(e, test); if ((!CyberwareAPI.getCyberwareNBT(stack).hasKey("used")) && cyberware.usePower(test, this.getPowerConsumption(test), false)) { ItemStack[] items = cyberware.getInstalledCyberware(EnumSlot.HEART); ItemStack[] itemsNew = items.clone(); for (int i = 0; i < items.length; i++) { ItemStack item = items[i]; if (item != null && item.getItem() == this && item.getItemDamage() == 0) { itemsNew[i] = null; break; } } if (e instanceof EntityPlayer) { cyberware.setInstalledCyberware(e, EnumSlot.HEART, itemsNew); cyberware.updateCapacity(); if (!e.worldObj.isRemote) { CyberwareAPI.updateData(e); } } else { stack = CyberwareAPI.getCyberware(e, test); NBTTagCompound com = CyberwareAPI.getCyberwareNBT(stack); com.setBoolean("used", true); stack.getTagCompound().setTag(CyberwareAPI.DATA_TAG, com); CyberwareAPI.updateData(e); } e.setHealth(e.getMaxHealth() / 3F); CyberwarePacketHandler.INSTANCE.sendToAllAround(new ParticlePacket(1, (float) e.posX, (float) e.posY + e.height / 2F, (float) e.posZ), new TargetPoint(e.worldObj.provider.getDimension(), e.posX, e.posY, e.posZ, 20)); event.setCanceled(true); } } }
Example #3
Source File: OpenTileEntity.java From OpenModsLib with MIT License | 4 votes |
public TargetPoint getDimCoords() { return new TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 0); }
Example #4
Source File: BlockEventPacket.java From OpenModsLib with MIT License | 4 votes |
public TargetPoint getDimCoords() { return new TargetPoint(dimension, blockPos.getX(), blockPos.getY(), blockPos.getZ(), 0); }
Example #5
Source File: FmlPacketSenderFactory.java From OpenModsLib with MIT License | 4 votes |
public static ITargetedPacketSender<TargetPoint> createBlockTrackersSender(Channel channel) { return new FmlTargetedPacketSender<>(channel, OutboundTarget.TRACKING_POINT); }
Example #6
Source File: FmlPacketSenderFactory.java From OpenModsLib with MIT License | 4 votes |
public static ITargetedPacketSender<TargetPoint> createPointSender(Channel channel) { return new FmlTargetedPacketSender<>(channel, OutboundTarget.ALLAROUNDPOINT); }
Example #7
Source File: PacketHandler.java From EnderZoo with Creative Commons Zero v1.0 Universal | 4 votes |
public static void sendToAllAround(IMessage message, Entity e, int range) { INSTANCE.sendToAllAround(message, new TargetPoint(e.getEntityWorld().provider.getDimension(), e.posX, e.posY, e.posZ, range)); }
Example #8
Source File: BackpacksChannel.java From WearableBackpacks with MIT License | 4 votes |
/** Sends a message to everyone around a point. */ public void sendToAllAround(IMessage message, World world, double x, double y, double z, double distance) { sendToAllAround(message, new TargetPoint(world.provider.getDimension(), x, y, z, distance)); }
Example #9
Source File: PacketHandler.java From ExNihiloAdscensio with MIT License | 4 votes |
public static void sendToAllAround(IMessage message, TileEntity te, int range) { BlockPos pos = te.getPos(); INSTANCE.sendToAllAround(message, new TargetPoint(te.getWorld().provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), range)); }
Example #10
Source File: ItemBrainUpgrade.java From Cyberware with MIT License | 4 votes |
@SubscribeEvent(priority=EventPriority.HIGHEST) public void handleHurt(LivingAttackEvent event) { EntityLivingBase e = event.getEntityLiving(); if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 4)) && isMatrixWorking(e)) { if (!e.worldObj.isRemote && event.getSource() instanceof EntityDamageSource) { Entity attacker = ((EntityDamageSource) event.getSource()).getSourceOfDamage(); if (e instanceof EntityPlayer) { String str = e.getEntityId() + " " + e.ticksExisted + " " + attacker.getEntityId(); if (lastHits.contains(str)) { return; } else { lastHits.add(str); } } boolean armor = false; for (ItemStack stack : e.getArmorInventoryList()) { if (stack != null && stack.getItem() instanceof ItemArmor) { if (((ItemArmor) stack.getItem()).getArmorMaterial().getDamageReductionAmount(EntityEquipmentSlot.CHEST) > 4) { return; } } else if (stack != null && stack.getItem() instanceof ISpecialArmor) { if (((ISpecialArmor) stack.getItem()).getProperties(e, stack, event.getSource(), event.getAmount(), 1).AbsorbRatio * 25D > 4) { return; } } if (stack != null) { armor = true; } } if (!((float) e.hurtResistantTime > (float) e.maxHurtResistantTime / 2.0F)) { Random random = e.getRNG(); if (random.nextFloat() < (armor ? LibConstants.DODGE_ARMOR : LibConstants.DODGE_NO_ARMOR)) { event.setCanceled(true); e.hurtResistantTime = e.maxHurtResistantTime; e.hurtTime = e.maxHurtTime = 10; ReflectionHelper.setPrivateValue(EntityLivingBase.class, e, 9999F, 46); CyberwarePacketHandler.INSTANCE.sendToAllAround(new DodgePacket(e.getEntityId()), new TargetPoint(e.worldObj.provider.getDimension(), e.posX, e.posY, e.posZ, 50)); } } } } }
Example #11
Source File: NetworkHandler.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
public static TargetPoint blockPoint(World world, BlockPos blockPos) { return new TargetPoint(world.provider.getDimension(), blockPos.getX() + 0.5, blockPos.getY() + 0.5, blockPos.getZ() + 0.5, 128.0); }
Example #12
Source File: AnimatedMachineTileBase.java From EmergingTechnology with MIT License | 4 votes |
public TargetPoint getTargetPoint() { return PacketHandler.getTargetPoint(this.getWorld(), this.getPos()); }
Example #13
Source File: WindTileEntity.java From EmergingTechnology with MIT License | 3 votes |
private void setTurbineState(TurbineSpeedEnum speed) { if (speed != this.speed) { TargetPoint targetPoint = this.getTargetPoint(); if (targetPoint == null) return; PacketHandler.INSTANCE.sendToAllTracking(new WindGeneratorAnimationPacket(this.getPos(), speed), targetPoint); } this.speed = speed; }
Example #14
Source File: HarvesterTileEntity.java From EmergingTechnology with MIT License | 3 votes |
private void animateHarvest() { TargetPoint targetPoint = getTargetPoint(); if (targetPoint == null) return; PacketHandler.INSTANCE.sendToAllTracking( new HarvesterStartAnimationPacket(this.getPos()), targetPoint); }
Example #15
Source File: ScrubberTileEntity.java From EmergingTechnology with MIT License | 3 votes |
private void setTurbineState(TurbineSpeedEnum speed) { if (speed != this.speed) { TargetPoint targetPoint = getTargetPoint(); if (targetPoint == null) return; PacketHandler.INSTANCE.sendToAllTracking(new ScrubberAnimationPacket(this.getPos(), speed), targetPoint); } this.speed = speed; }
Example #16
Source File: TidalGeneratorTileEntity.java From EmergingTechnology with MIT License | 3 votes |
private void setTurbineState(TurbineSpeedEnum speed) { if (speed != this.speed) { TargetPoint targetPoint = this.getTargetPoint(); if (targetPoint == null) return; PacketHandler.INSTANCE.sendToAllTracking(new TidalGeneratorAnimationPacket(this.getPos(), speed), targetPoint); } this.speed = speed; }
Example #17
Source File: PacketHandler.java From EmergingTechnology with MIT License | 3 votes |
public static TargetPoint getTargetPoint(World world, BlockPos blockPos) { if (world == null) return null; WorldProvider provider = world.provider; int dimension = provider.getDimension(); return new TargetPoint(dimension, blockPos.getX(), blockPos.getY(), blockPos.getZ(), 5); }