Skip to content

Commit

Permalink
Blindness effect when warping
Browse files Browse the repository at this point in the history
  • Loading branch information
WenXin20 committed Aug 11, 2024
1 parent 55cf981 commit 05b5db0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/com/wenxin2/warp_pipes/blocks/WarpPipeBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import net.minecraft.world.InteractionHand;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.SimpleMenuProvider;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -620,69 +622,83 @@ public static void warp(Entity entity, BlockPos warpPos, Level world, BlockState
if (state.getBlock() instanceof ClearWarpPipeBlock && !state.getValue(ENTRANCE)) {
if (entity instanceof Player) {
entity.teleportTo(warpPos.getX() + 0.5, warpPos.getY() - 1.0, warpPos.getZ() + 0.5);
((Player) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 1, 0));
} else {
entity.teleportTo(warpPos.getX() + 0.5, warpPos.getY() - 1.0, warpPos.getZ() + 0.5);
if (passengerEntity instanceof Player) {
((Player) passengerEntity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 1, 0));
entity.unRide();
}
}
}
if (world.getBlockState(warpPos).getValue(FACING) == Direction.UP && state.getValue(ENTRANCE)) {
if (entity instanceof Player) {
entity.teleportTo(warpPos.getX() + 0.5, warpPos.getY() + 1.0, warpPos.getZ() + 0.5);
((Player) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 1, 0));
} else {
entity.teleportTo(warpPos.getX() + 0.5, warpPos.getY() + 1.0, warpPos.getZ() + 0.5);
if (passengerEntity instanceof Player) {
((Player) passengerEntity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 1, 0));
entity.unRide();
}
}
}
if (world.getBlockState(warpPos).getValue(FACING) == Direction.DOWN && state.getValue(ENTRANCE)) {
if (entity instanceof Player) {
entity.teleportTo(warpPos.getX() + 0.5, warpPos.getY() - entity.getBbHeight(), warpPos.getZ() + 0.5);
((Player) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 1, 0));
} else {
entity.teleportTo(warpPos.getX() + 0.5, warpPos.getY() - entity.getBbHeight(), warpPos.getZ() + 0.5);
if (passengerEntity instanceof Player) {
((Player) passengerEntity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 1, 0));
entity.unRide();
}
}
}
if (world.getBlockState(warpPos).getValue(FACING) == Direction.NORTH && state.getValue(ENTRANCE)) {
if (entity instanceof Player) {
entity.teleportTo(warpPos.getX() + 0.5, warpPos.getY(), warpPos.getZ() - entity.getBbWidth());
((Player) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 1, 0));
} else {
entity.teleportTo(warpPos.getX() + 0.5, warpPos.getY(), warpPos.getZ() - entity.getBbWidth());
if (passengerEntity instanceof Player) {
((Player) passengerEntity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 1, 0));
entity.unRide();
}
}
}
if (world.getBlockState(warpPos).getValue(FACING) == Direction.SOUTH && state.getValue(ENTRANCE)) {
if (entity instanceof Player) {
entity.teleportTo(warpPos.getX() + 0.5, warpPos.getY(), warpPos.getZ() + entity.getBbWidth() + 1.0);
((Player) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 1, 0));
} else {
entity.teleportTo(warpPos.getX() + 0.5, warpPos.getY(), warpPos.getZ() + entity.getBbWidth() + 1.0);
if (passengerEntity instanceof Player) {
((Player) passengerEntity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 1, 0));
entity.unRide();
}
}
}
if (world.getBlockState(warpPos).getValue(FACING) == Direction.EAST && state.getValue(ENTRANCE)) {
if (entity instanceof Player) {
entity.teleportTo(warpPos.getX() + entity.getBbWidth() + 1.0, warpPos.getY(), warpPos.getZ() + 0.5);
((Player) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 1, 0));
} else {
entity.teleportTo(warpPos.getX() + entity.getBbWidth() + 1.0, warpPos.getY(), warpPos.getZ() + 0.5);
if (passengerEntity instanceof Player) {
((Player) passengerEntity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 1, 0));
entity.unRide();
}
}
}
if (world.getBlockState(warpPos).getValue(FACING) == Direction.WEST && state.getValue(ENTRANCE)) {
if (entity instanceof Player) {
entity.teleportTo(warpPos.getX() - entity.getBbWidth(), warpPos.getY(), warpPos.getZ() + 0.5);
((Player) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 1, 0));
} else {
entity.teleportTo(warpPos.getX() - entity.getBbWidth(), warpPos.getY(), warpPos.getZ() + 0.5);
if (passengerEntity instanceof Player) {
((Player) passengerEntity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 1, 0));
entity.unRide();
}
}
Expand Down

0 comments on commit 05b5db0

Please sign in to comment.