Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix server-side sounds sometimes not being audible, Open to LAN issues with isRemote check #2

Merged
merged 1 commit into from
Mar 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.sortme.ItemScatterer;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundEvents;
import net.minecraft.sound.SoundCategory;
import net.minecraft.state.StateFactory;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties;
Expand Down Expand Up @@ -64,20 +66,20 @@ public void onEntityCollision(BlockState state, World world, BlockPos pos, Entit
TeleporterBlockEntity teleporter = (TeleporterBlockEntity) world.getBlockEntity(pos);
if(teleporter.hasCrystal() && teleporter.isInDimension(entity))
{
entity.playSound(SoundEvents.ENTITY_ENDERMAN_TELEPORT, 1.0F, 1.0F);
if(entity instanceof ServerPlayerEntity && world.getServer() != null && !world.getServer().isRemote())
if(entity instanceof ServerPlayerEntity && !world.isClient) // !world.getServer().isRemote())
{
BlockPos teleporterPos = teleporter.getTeleportPosition();
ServerPlayerEntity splayer = (ServerPlayerEntity) entity;

splayer.velocityModified = true;

splayer.networkHandler.teleportRequest(teleporterPos.getX() + 0.5, teleporterPos.getY(), teleporterPos.getZ() + 0.5, entity.yaw, entity.pitch, EnumSet.noneOf(net.minecraft.client.network.packet.PlayerPositionLookS2CPacket.Flag.class));
BlockPos playerPos = new BlockPos(teleporterPos.getX() + 0.5, teleporterPos.getY(), teleporterPos.getZ() + 0.5);
splayer.networkHandler.teleportRequest(playerPos.getX(), playerPos.getY(), playerPos.getZ(), entity.yaw, entity.pitch, EnumSet.noneOf(net.minecraft.client.network.packet.PlayerPositionLookS2CPacket.Flag.class));

splayer.setVelocity(0, 0.5, 0); // originally just a velocityY =
splayer.setVelocity(0, 0, 0); // originally just a velocityY =
splayer.velocityDirty = true; // maybe scheduleVelocityUpdate ?

splayer.playSound(SoundEvents.ENTITY_ENDERMAN_TELEPORT, 1.0F, 1.0F);
world.playSound(null, playerPos, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCK, 1.0F, 1.0F);
}
}
}
Expand Down