private boolean isCorrectSplashPacket(SPacketSoundEffect packet) { EntityPlayerSP me = getLocalPlayer(); return packet.getSound().equals(SoundEvents.ENTITY_BOBBER_SPLASH) && ( me != null && me.fishEntity != null && ( max_sound_distance.get() == 0 || // disables this check (me.fishEntity.getPositionVector().distanceTo(new Vec3d(packet.getX(), packet.getY(), packet.getZ())) <= max_sound_distance.get()) ) ); }
@SubscribeEvent public void onPacketIncoming(PacketEvent.Incoming.Pre event) { if(event.getPacket() instanceof SPacketSoundEffect) { SPacketSoundEffect packet = (SPacketSoundEffect)event.getPacket(); if(isCorrectSplashPacket(packet)) { rightClick(); } } }
@Override public void onReceivedPacket(PacketInputEvent event) { // check packet type if(!(event.getPacket() instanceof SPacketSoundEffect)) return; // check sound type if(!WSoundEvents.isBobberSplash((SPacketSoundEffect)event.getPacket())) return; // catch fish rightClick(); }
public static void playSound(World worldObj, SoundEvent soundName, double x, double y, double z, double volume, double pitch) { SPacketSoundEffect soundEffect = new SPacketSoundEffect(soundName, SoundCategory.BLOCKS, x, y, z, (float) volume, (float) pitch); for (int j = 0; j < worldObj.playerEntities.size(); ++j) { EntityPlayerMP entityplayermp = (EntityPlayerMP)worldObj.playerEntities.get(j); double d7 = x - entityplayermp.posX; double d8 = y - entityplayermp.posY; double d9 = z - entityplayermp.posZ; double d10 = d7 * d7 + d8 * d8 + d9 * d9; if (d10 <= 256.0D) { entityplayermp.connection.sendPacket(soundEffect); } } }
public static boolean isBobberSplash(SPacketSoundEffect soundEffect) { return SoundEvents.ENTITY_BOBBER_SPLASH.equals(soundEffect.getSound()); }
/** * Displays the GUI for interacting with a chest inventory. */ public void displayGUIChest(IInventory chestInventory) { if (chestInventory instanceof ILootContainer && ((ILootContainer)chestInventory).getLootTable() != null && this.isSpectator()) { this.addChatComponentMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)), true); } else { if (this.openContainer != this.inventoryContainer) { this.closeScreen(); } if (chestInventory instanceof ILockableContainer) { ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory; if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator()) { this.connection.sendPacket(new SPacketChat(new TextComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2)); this.connection.sendPacket(new SPacketSoundEffect(SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.posX, this.posY, this.posZ, 1.0F, 1.0F)); return; } } this.getNextWindowId(); if (chestInventory instanceof IInteractionObject) { this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory())); this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this); } else { this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory())); this.openContainer = new ContainerChest(this.inventory, chestInventory, this); } this.openContainer.windowId = this.currentWindowId; this.openContainer.addListener(this); } }
public void handleSoundEffect(SPacketSoundEffect packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); this.gameController.world.playSound(this.gameController.player, packetIn.getX(), packetIn.getY(), packetIn.getZ(), packetIn.getSound(), packetIn.getCategory(), packetIn.getVolume(), packetIn.getPitch()); }
public void playSoundToAllNearExcept(@Nullable EntityPlayer player, SoundEvent soundIn, SoundCategory category, double x, double y, double z, float volume, float pitch) { this.mcServer.getPlayerList().sendToAllNearExcept(player, x, y, z, volume > 1.0F ? (double)(16.0F * volume) : 16.0D, this.theWorldServer.provider.getDimensionType().getId(), new SPacketSoundEffect(soundIn, category, x, y, z, volume, pitch)); }
public void playSoundToAllNearExcept(@Nullable EntityPlayer player, SoundEvent soundIn, SoundCategory category, double x, double y, double z, float volume, float pitch) { this.mcServer.getPlayerList().sendToAllNearExcept(player, x, y, z, volume > 1.0F ? (double)(16.0F * volume) : 16.0D, this.theWorldServer.provider.getDimension(), new SPacketSoundEffect(soundIn, category, x, y, z, volume, pitch)); }
/** * Displays the GUI for interacting with a chest inventory. */ public void displayGUIChest(IInventory chestInventory) { if (chestInventory instanceof ILootContainer && ((ILootContainer)chestInventory).getLootTable() != null && this.isSpectator()) { this.addChatMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED))); } else { if (this.openContainer != this.inventoryContainer) { this.closeScreen(); } if (chestInventory instanceof ILockableContainer) { ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory; if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator()) { this.connection.sendPacket(new SPacketChat(new TextComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2)); this.connection.sendPacket(new SPacketSoundEffect(SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.posX, this.posY, this.posZ, 1.0F, 1.0F)); return; } } this.getNextWindowId(); if (chestInventory instanceof IInteractionObject) { this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory())); this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this); } else { this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory())); this.openContainer = new ContainerChest(this.inventory, chestInventory, this); } this.openContainer.windowId = this.currentWindowId; this.openContainer.addListener(this); net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer)); } }
public void handleSoundEffect(SPacketSoundEffect packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); this.gameController.theWorld.playSound(this.gameController.thePlayer, packetIn.getX(), packetIn.getY(), packetIn.getZ(), packetIn.getSound(), packetIn.getCategory(), packetIn.getVolume(), packetIn.getPitch()); }
@Override public void playSoundToAllNearExcept(EntityPlayer player, SoundEvent sound, SoundCategory category, double x, double y, double z, float volume, float pitch) { double range = volume > 1.0F ? 16.0F * volume : 16.0; this.server.getPlayerList().sendToAllNearExcept(player, x, y, z, range, this.blockSystem.provider.getDimension(), new SPacketSoundEffect(sound, category, x, y, z, volume, pitch)); }
@Override public boolean execute(EntityPlayerMP target) { SoundEvent sound = CollectionUtils.getRandom(sounds); target.connection.sendPacket(new SPacketSoundEffect(sound, SoundCategory.MASTER, target.posX, target.posY, target.posZ, 1, 1)); return true; }
void handleSoundEffect(SPacketSoundEffect packetIn);