Monolith teleportation

This commit is contained in:
SD 2021-02-17 10:18:29 +05:30
parent fb21975e64
commit 36d57601b7
No known key found for this signature in database
GPG key ID: E36B57EE08544BC5

View file

@ -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);
}
}