Skip to content

Commit

Permalink
Fix blindness effect
Browse files Browse the repository at this point in the history
  • Loading branch information
WenXin20 committed Sep 1, 2024
1 parent 49afd1f commit beda211
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions src/main/java/com/wenxin2/warp_pipes/blocks/WarpPipeBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,6 @@ public void onPlace(BlockState state, Level world, BlockPos pos, BlockState neig
pipeBlockEntity.setChanged();
}

// if (!world.isClientSide) {
// WarpPipeBlockEntity pipeBlockEntity = (WarpPipeBlockEntity) world.getBlockEntity(pos);
// if (pipeBlockEntity != null) {
// pipeBlockEntity.addWarpPosition(pos);
// }
// }

if (state.getValue(FACING) == Direction.UP) {
if (blockAbove == this) {
world.setBlock(pos, state.setValue(ENTRANCE, Boolean.FALSE), 3);
Expand Down Expand Up @@ -630,71 +623,71 @@ public static void warp(Entity entity, BlockPos warpPos, Level world, BlockState
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));
((Player) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 20, 0, true, false));
} 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));
((Player) passengerEntity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 20, 0, true, false));
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));
((Player) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 20, 0, true, false));
} 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));
((Player) passengerEntity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 20, 0, true, false));
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));
((Player) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 20, 0, true, false));
} 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));
((Player) passengerEntity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 20, 0, true, false));
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));
((Player) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 20, 0, true, false));
} 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));
((Player) passengerEntity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 20, 0, true, false));
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));
((Player) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 20, 0, true, false));
} 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));
((Player) passengerEntity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 20, 0, true, false));
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));
((Player) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 20, 0, true, false));
} 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));
((Player) passengerEntity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 20, 0, true, false));
entity.unRide();
}
}
Expand Down

0 comments on commit beda211

Please sign in to comment.