Skip to content

Commit

Permalink
:fix: Compass are...
Browse files Browse the repository at this point in the history
  • Loading branch information
fantomitechno committed Jan 3, 2024
1 parent 7b7ecef commit 5da3b22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
org.gradle.parallel = true

# Mod Properties
version = 0.1.3
version = 0.1.4
# Notes: when debugging, use rc's, so it would become: 0.X.X-rc.X
maven_group = dev.renoux
archives_base_name = enderrelay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;

import java.util.Objects;
import java.util.Optional;

public class EnderRelayBlockEntity extends BlockEntity {
Expand Down Expand Up @@ -79,7 +80,7 @@ public EnderRelayBlockEntity(BlockPos blockPos, BlockState blockState) {
@Override
protected void saveAdditional(CompoundTag compoundTag) {
super.saveAdditional(compoundTag);
if (this.teleportPlace != null) {
if (!this.teleportPlace.equals(new BlockPos(0, 0, 0))) {
compoundTag.put("teleportPlace", NbtUtils.writeBlockPos(this.teleportPlace));
compoundTag.putString("name", Component.Serializer.toJson(this.name));
}
Expand All @@ -97,7 +98,7 @@ public void load(BlockPos pos, Component name) {
}

public static void teleportPlayer(Level world, BlockPos pos, BlockState state, ServerPlayer player, EnderRelayBlockEntity blockEntity) {
if (blockEntity.teleportPlace == null) {
if (blockEntity.teleportPlace.equals(new BlockPos(0, 0, 0))) {
player.displayClientMessage(Component.translatable("block.enderrelay.nowhere"), true);
return;
}
Expand All @@ -109,11 +110,11 @@ public static void teleportPlayer(Level world, BlockPos pos, BlockState state, S
return;
}
world.setBlock(pos, state.setValue(EnderRelayBlock.CHARGE, Integer.valueOf(state.getValue(EnderRelayBlock.CHARGE) - 1)), 3);
player.connection.send(new ClientboundSoundPacket(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, pos.getX(), pos.getY(), pos.getZ(), 1.0F, 1.0F, world.getRandom().nextLong()));
if (world.getBlockState(pos).getValue(EnderRelayBlock.CHARGE) == 0) {
blockEntity.teleportPlace = null;
blockEntity.teleportPlace = new BlockPos(0, 0, 0);
blockEntity.name = null;
}
player.connection.send(new ClientboundSoundPacket(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, pos.getX(), pos.getY(), pos.getZ(), 1.0F, 1.0F, world.getRandom().nextLong()));
Vec3 coords = optional.get();
player.teleportTo(coords.x, coords.y, coords.z);
}
Expand Down

0 comments on commit 5da3b22

Please sign in to comment.