Skip to content

Commit 3545f95

Browse files
committed
Improved teleport sound
1 parent d36adc1 commit 3545f95

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/main/java/com/buuz135/portality/handler/TeleportHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public void tick() {
148148
entry.getValue().ticks++;
149149
if (entry.getValue().ticks > 2 && !entry.getValue().moved) {
150150
if (!entry.getKey().level().isClientSide)
151-
entry.getKey().level().getEntitiesOfClass(ServerPlayer.class, new AABB(entry.getKey().blockPosition()).inflate(16)).forEach(entityPlayer -> entityPlayer.playNotifySound(PortalitySoundHandler.PORTAL_TP.get(), SoundSource.BLOCKS, 0.5f, 1f));
151+
entry.getKey().level().getEntitiesOfClass(ServerPlayer.class, new AABB(entry.getKey().blockPosition()).inflate(8)).forEach(entityPlayer -> entityPlayer.playNotifySound(PortalitySoundHandler.PORTAL_TP.get(), SoundSource.BLOCKS, 0.25f, 0.5f));
152152
entry.getValue().moved = true;
153153
Level tpWorld = entry.getKey().level();
154154
Direction tpFacing = Direction.NORTH;

src/main/java/com/buuz135/portality/network/PortalTeleportMessage.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
import com.hrznstudio.titanium.network.Message;
2929
import net.minecraft.client.Minecraft;
3030
import net.minecraft.client.player.LocalPlayer;
31+
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
3132
import net.minecraft.core.Direction;
33+
import net.minecraft.sounds.SoundSource;
3234
import net.minecraft.world.phys.Vec3;
3335
import net.neoforged.neoforge.network.handling.IPayloadContext;
3436

@@ -50,7 +52,7 @@ public PortalTeleportMessage() {
5052
protected void handleMessage(IPayloadContext context) {
5153
Minecraft.getInstance().submitAsync(() -> {
5254
//Minecraft.getMinecraft().player.playSound(new SoundEvent(ResourceLocation.fromNamespaceAndPath("entity.shulker.teleport")), 1, 1);
53-
Minecraft.getInstance().player.playSound(PortalitySoundHandler.PORTAL_TP.get(), 0.1f, 1f);
55+
Minecraft.getInstance().getSoundManager().play(new SimpleSoundInstance(PortalitySoundHandler.PORTAL_TP.get(), SoundSource.BLOCKS, 0.25f, 0.5f, Minecraft.getInstance().level.getRandom(), Minecraft.getInstance().player.getOnPos()));
5456
if (PortalityConfig.LAUNCH_PLAYERS) {
5557
Direction facing = Direction.values()[this.facing];
5658
Vec3 vector = new Vec3(facing.getNormal().getX(), facing.getNormal().getY(), facing.getNormal().getZ()).scale(2 * length / (double) PortalityConfig.MAX_PORTAL_LENGTH);

src/main/java/com/buuz135/portality/tile/ControllerTile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ public void setColor(int color) {
568568
@OnlyIn(Dist.CLIENT)
569569
@Override
570570
public ItemInteractionResult onActivated(Player playerIn, InteractionHand hand, Direction facing, double hitX, double hitY, double hitZ) {
571-
if (super.onActivated(playerIn, hand, facing, hitX, hitY, hitZ) != ItemInteractionResult.SUCCESS) {
571+
if (super.onActivated(playerIn, hand, facing, hitX, hitY, hitZ) != ItemInteractionResult.SUCCESS && this.isFormed) {
572572
Minecraft.getInstance().submitAsync(() -> OpenGui.open(0, this));
573573
return ItemInteractionResult.SUCCESS;
574574
}

0 commit comments

Comments
 (0)