Skip to content

Commit

Permalink
Add blindness config
Browse files Browse the repository at this point in the history
  • Loading branch information
WenXin20 committed Sep 1, 2024
1 parent beda211 commit 9dffe56
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
42 changes: 28 additions & 14 deletions src/main/java/com/wenxin2/warp_pipes/blocks/WarpPipeBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -611,83 +611,97 @@ 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));
if (Config.BLINDNESS_EFFECT.get())
((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));
if (Config.BLINDNESS_EFFECT.get())
((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, 20, 0, true, false));
if (Config.BLINDNESS_EFFECT.get())
((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, 20, 0, true, false));
if (Config.BLINDNESS_EFFECT.get())
((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, 20, 0, true, false));
if (Config.BLINDNESS_EFFECT.get())
((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, 20, 0, true, false));
if (Config.BLINDNESS_EFFECT.get())
((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, 20, 0, true, false));
if (Config.BLINDNESS_EFFECT.get())
((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, 20, 0, true, false));
if (Config.BLINDNESS_EFFECT.get())
((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, 20, 0, true, false));
if (Config.BLINDNESS_EFFECT.get())
((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, 20, 0, true, false));
if (Config.BLINDNESS_EFFECT.get())
((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, 20, 0, true, false));
if (Config.BLINDNESS_EFFECT.get())
((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, 20, 0, true, false));
if (Config.BLINDNESS_EFFECT.get())
((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, 20, 0, true, false));
if (Config.BLINDNESS_EFFECT.get())
((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, 20, 0, true, false));
if (Config.BLINDNESS_EFFECT.get())
((Player) passengerEntity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 20, 0, true, false));
entity.unRide();
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/wenxin2/warp_pipes/init/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class Config
public static ModConfigSpec.BooleanValue ALLOW_FAST_TRAVEL;
public static ModConfigSpec.BooleanValue ALLOW_PIPE_UNWAXING;
public static ModConfigSpec.BooleanValue CREATIVE_BUBBLES;
public static ModConfigSpec.BooleanValue BLINDNESS_EFFECT;
public static ModConfigSpec.BooleanValue CREATIVE_CLOSE_PIPES;
public static ModConfigSpec.BooleanValue CREATIVE_WATER_SPOUT;
public static ModConfigSpec.BooleanValue CREATIVE_WRENCH_PIPE_LINKING;
Expand Down Expand Up @@ -65,6 +66,10 @@ private Config() {
.comment("Allow pipes to be unwaxed with an axe.")
.comment("§9[Default: false]")
.define("allow_pipe_unwaxing", false);
BLINDNESS_EFFECT = BUILDER.translation("configuration.warp_pipes.blidness_effect")
.comment("Warping gives the player a brief blindness effect.")
.comment("§9[Default: true]")
.define("blidness_effect", true);
WAX_DISABLES_BUBBLES = BUILDER.translation("configuration.warp_pipes.wax_disables_bubbles")
.comment("Allows waxing pipes to disable the Pipe Bubbles button.")
.comment("§9[Default: true]")
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/warp_pipes/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
"warp_pipes.configuration.Debug": "Debug Config",
"configuration.warp_pipes.allow_fast_travel": "Allow Fast Travel",
"configuration.warp_pipes.allow_pipe_unwaxing": "Allow Pipe Unwaxing",
"configuration.warp_pipes.blindness_effect": "Blindness When Warping",
"configuration.warp_pipes.creative_wrench_pipe_linking": "Link Pipes Creative Only",
"configuration.warp_pipes.debug_pipe_bubbles_selection_box": "Pipe Bubbles Debug Selection Box",
"configuration.warp_pipes.debug_selection_box": "Clear Pipes Debug Selection Box",
Expand Down

0 comments on commit 9dffe56

Please sign in to comment.