From 36d57601b716ef9819ba68d0140f0b32237b80c8 Mon Sep 17 00:00:00 2001 From: SD Date: Wed, 17 Feb 2021 10:18:29 +0530 Subject: [PATCH] Monolith teleportation --- .../dimdev/dimdoors/entity/ai/MonolithAggroGoal.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/dimdev/dimdoors/entity/ai/MonolithAggroGoal.java b/src/main/java/org/dimdev/dimdoors/entity/ai/MonolithAggroGoal.java index 3a14b3b1..947f2eea 100644 --- a/src/main/java/org/dimdev/dimdoors/entity/ai/MonolithAggroGoal.java +++ b/src/main/java/org/dimdev/dimdoors/entity/ai/MonolithAggroGoal.java @@ -8,6 +8,9 @@ import org.dimdev.dimdoors.DimensionalDoorsInitializer; import org.dimdev.dimdoors.entity.MonolithEntity; import org.dimdev.dimdoors.item.ModItems; import org.dimdev.dimdoors.sound.ModSoundEvents; +import org.dimdev.dimdoors.util.Location; +import org.dimdev.dimdoors.util.TeleportUtil; +import org.dimdev.dimdoors.world.ModDimensions; import net.minecraft.entity.ai.TargetPredicate; import net.minecraft.entity.ai.goal.Goal; @@ -18,6 +21,8 @@ import net.minecraft.sound.SoundCategory; import net.minecraft.util.math.BlockPos; import net.fabricmc.fabric.api.network.ServerSidePacketRegistry; +import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; + import static net.minecraft.predicate.entity.EntityPredicates.EXCEPT_SPECTATOR; import static org.dimdev.dimdoors.entity.MonolithEntity.MAX_AGGRO; @@ -65,7 +70,7 @@ public class MonolithAggroGoal extends Goal { Random random = new Random(); int i = random.nextInt(64); if (this.target instanceof ServerPlayerEntity) { - if (i < 6) { + if (i < 4) { this.target.getInventory().armor.get(0).damage(i, random, (ServerPlayerEntity) this.target); this.target.getInventory().armor.get(1).damage(i, random, (ServerPlayerEntity) this.target); this.target.getInventory().armor.get(2).damage(i, random, (ServerPlayerEntity) this.target); @@ -91,14 +96,13 @@ public class MonolithAggroGoal extends Goal { PacketByteBuf data = new PacketByteBuf(Unpooled.buffer()); data.writeInt(this.mob.getAggro()); - ServerSidePacketRegistry.INSTANCE.sendToPlayer(this.target, DimensionalDoorsInitializer.MONOLITH_PARTICLE_PACKET, data); + ServerPlayNetworking.send((ServerPlayerEntity) this.target, DimensionalDoorsInitializer.MONOLITH_PARTICLE_PACKET, data); } // Teleport the target player if various conditions are met if (this.mob.getAggro() >= MAX_AGGRO && DimensionalDoorsInitializer.getConfig().getMonolithsConfig().monolithTeleportation && !this.target.isCreative() && this.mob.isDangerous()) { this.mob.setAggro(0); - //Location destination = LimboDimension.getLimboSkySpawn(player); - //TeleportUtil.teleport(player, destination, 0, 0); + this.target.teleport(this.target.getX(), this.target.getY() + 256, this.target.getZ()); this.target.world.playSound(null, new BlockPos(this.target.getPos()), ModSoundEvents.CRACK, SoundCategory.HOSTILE, 13, 1); } }