Monolith teleportation
This commit is contained in:
parent
fb21975e64
commit
36d57601b7
1 changed files with 8 additions and 4 deletions
|
@ -8,6 +8,9 @@ import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
||||||
import org.dimdev.dimdoors.entity.MonolithEntity;
|
import org.dimdev.dimdoors.entity.MonolithEntity;
|
||||||
import org.dimdev.dimdoors.item.ModItems;
|
import org.dimdev.dimdoors.item.ModItems;
|
||||||
import org.dimdev.dimdoors.sound.ModSoundEvents;
|
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.TargetPredicate;
|
||||||
import net.minecraft.entity.ai.goal.Goal;
|
import net.minecraft.entity.ai.goal.Goal;
|
||||||
|
@ -18,6 +21,8 @@ import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.network.ServerSidePacketRegistry;
|
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 net.minecraft.predicate.entity.EntityPredicates.EXCEPT_SPECTATOR;
|
||||||
import static org.dimdev.dimdoors.entity.MonolithEntity.MAX_AGGRO;
|
import static org.dimdev.dimdoors.entity.MonolithEntity.MAX_AGGRO;
|
||||||
|
|
||||||
|
@ -65,7 +70,7 @@ public class MonolithAggroGoal extends Goal {
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
int i = random.nextInt(64);
|
int i = random.nextInt(64);
|
||||||
if (this.target instanceof ServerPlayerEntity) {
|
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(0).damage(i, random, (ServerPlayerEntity) this.target);
|
||||||
this.target.getInventory().armor.get(1).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);
|
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());
|
PacketByteBuf data = new PacketByteBuf(Unpooled.buffer());
|
||||||
data.writeInt(this.mob.getAggro());
|
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
|
// 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()) {
|
if (this.mob.getAggro() >= MAX_AGGRO && DimensionalDoorsInitializer.getConfig().getMonolithsConfig().monolithTeleportation && !this.target.isCreative() && this.mob.isDangerous()) {
|
||||||
this.mob.setAggro(0);
|
this.mob.setAggro(0);
|
||||||
//Location destination = LimboDimension.getLimboSkySpawn(player);
|
this.target.teleport(this.target.getX(), this.target.getY() + 256, this.target.getZ());
|
||||||
//TeleportUtil.teleport(player, destination, 0, 0);
|
|
||||||
this.target.world.playSound(null, new BlockPos(this.target.getPos()), ModSoundEvents.CRACK, SoundCategory.HOSTILE, 13, 1);
|
this.target.world.playSound(null, new BlockPos(this.target.getPos()), ModSoundEvents.CRACK, SoundCategory.HOSTILE, 13, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue