Skip to content

Commit

Permalink
Add creative only tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
WenXin20 committed Aug 31, 2024
1 parent de74d50 commit c35063d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public class WarpPipeScreen extends AbstractContainerScreen<WarpPipeMenu> {
Inventory inventory;

public static BlockPos lastClickedPos = null;
public static ExtendedSlider waterSpoutSlider;
public static ExtendedSlider bubblesSlider;
public ExtendedSlider waterSpoutSlider;
public ExtendedSlider bubblesSlider;
private String pipeName = "";
private Level world;

Expand Down Expand Up @@ -230,9 +230,8 @@ public void init() {
}

final Component height = Component.translatable("menu.warp_pipes.warp_pipe.water_spout_slider.height");
waterSpoutSlider = this.addRenderableWidget(new WaterSpoutSlider(x + 61, y + 18, 108, 24,
this.waterSpoutSlider = this.addRenderableWidget(new WaterSpoutSlider(x + 61, y + 18, 108, 24,
height, Component.literal(""), 0D, 16D, spoutHeight, 1D, 0, true));
waterSpoutSlider.setTooltip(Tooltip.create(Component.translatable("menu.warp_pipes.warp_pipe.water_spout_slider.tooltip")));

final Component bubbles = Component.translatable("menu.warp_pipes.warp_pipe.bubbles_button");
this.bubblesButton = this.addRenderableWidget(new Button.Builder(bubbles, (b) -> {
Expand All @@ -252,10 +251,9 @@ public void init() {
}
}

final Component distance = Component.translatable("menu.warp_pipes.warp_pipe.bubbles_slider.height");
bubblesSlider = this.addRenderableWidget(new BubblesSlider(x + 61, y + 45, 108, 24,
final Component distance = Component.translatable("menu.warp_pipes.warp_pipe.bubbles_slider.distance");
this.bubblesSlider = this.addRenderableWidget(new BubblesSlider(x + 61, y + 45, 108, 24,
distance, Component.literal(""), 0D, 16D, bubblesDistance, 1D, 0, true));
bubblesSlider.setTooltip(Tooltip.create(Component.translatable("menu.warp_pipes.warp_pipe.bubbles_slider.tooltip")));
}

@Override
Expand All @@ -272,6 +270,7 @@ protected void renderTooltip(GuiGraphics graphics, int mouseX, int mouseY) {

Component tooltip = Component.literal("");
BlockEntity blockEntity = world.getBlockEntity(this.getClickedPos());
Player player = this.inventory.player;

if (this.getClickedPos() != null && blockEntity instanceof WarpPipeBlockEntity pipeBlockEntity && pipeBlockEntity.isWaxed() && Config.WAX_DISABLES_RENAMING.get())
tooltip = Component.translatable("menu.warp_pipes.warp_pipe.rename_button_waxed.tooltip");
Expand All @@ -281,10 +280,14 @@ protected void renderTooltip(GuiGraphics graphics, int mouseX, int mouseY) {
if (this.getClickedPos() != null) {
BlockState state = world.getBlockState(this.getClickedPos());
if (state.getBlock() instanceof WarpPipeBlock && state.getValue(WarpPipeBlock.CLOSED)) {
if (blockEntity instanceof WarpPipeBlockEntity pipeBlockEntity && pipeBlockEntity.isWaxed() && Config.WAX_DISABLES_CLOSING.get())
if (!player.isCreative() && Config.CREATIVE_CLOSE_PIPES.get())
tooltip = Component.translatable("menu.warp_pipes.warp_pipe.open_button_creative.tooltip");
else if (blockEntity instanceof WarpPipeBlockEntity pipeBlockEntity && pipeBlockEntity.isWaxed() && Config.WAX_DISABLES_CLOSING.get())
tooltip = Component.translatable("menu.warp_pipes.warp_pipe.open_button_waxed.tooltip");
else tooltip = Component.translatable("menu.warp_pipes.warp_pipe.open_button.tooltip");
} else if (blockEntity instanceof WarpPipeBlockEntity pipeBlockEntity && pipeBlockEntity.isWaxed() && Config.WAX_DISABLES_CLOSING.get())
} else if (!player.isCreative() && Config.CREATIVE_CLOSE_PIPES.get())
tooltip = Component.translatable("menu.warp_pipes.warp_pipe.close_button_creative.tooltip");
else if (blockEntity instanceof WarpPipeBlockEntity pipeBlockEntity && pipeBlockEntity.isWaxed() && Config.WAX_DISABLES_CLOSING.get())
tooltip = Component.translatable("menu.warp_pipes.warp_pipe.close_button_waxed.tooltip");
else tooltip = Component.translatable("menu.warp_pipes.warp_pipe.close_button.tooltip");
}
Expand All @@ -293,26 +296,52 @@ protected void renderTooltip(GuiGraphics graphics, int mouseX, int mouseY) {
if (this.getClickedPos() != null) {
BlockState state = world.getBlockState(this.getClickedPos());
if (state.getBlock() instanceof WarpPipeBlock && state.getValue(WarpPipeBlock.WATER_SPOUT)) {
if (blockEntity instanceof WarpPipeBlockEntity pipeBlockEntity && pipeBlockEntity.isWaxed() && Config.WAX_DISABLES_WATER_SPOUTS.get())
if (!player.isCreative() && Config.CREATIVE_WATER_SPOUT.get())
tooltip = Component.translatable("menu.warp_pipes.warp_pipe.water_spout_off_button_creative.tooltip");
else if (blockEntity instanceof WarpPipeBlockEntity pipeBlockEntity && pipeBlockEntity.isWaxed() && Config.WAX_DISABLES_WATER_SPOUTS.get())
tooltip = Component.translatable("menu.warp_pipes.warp_pipe.water_spout_off_button_waxed.tooltip");
else tooltip = Component.translatable("menu.warp_pipes.warp_pipe.water_spout_off_button.tooltip");
} else if (blockEntity instanceof WarpPipeBlockEntity pipeBlockEntity && pipeBlockEntity.isWaxed() && Config.WAX_DISABLES_WATER_SPOUTS.get())
} else if (!player.isCreative() && Config.CREATIVE_WATER_SPOUT.get())
tooltip = Component.translatable("menu.warp_pipes.warp_pipe.water_spout_on_button_creative.tooltip");
else if (blockEntity instanceof WarpPipeBlockEntity pipeBlockEntity && pipeBlockEntity.isWaxed() && Config.WAX_DISABLES_WATER_SPOUTS.get())
tooltip = Component.translatable("menu.warp_pipes.warp_pipe.water_spout_on_button_waxed.tooltip");
else tooltip = Component.translatable("menu.warp_pipes.warp_pipe.water_spout_on_button.tooltip");
}
this.waterSpoutButton.setTooltip(Tooltip.create(tooltip));

if (this.getClickedPos() != null) {
if (!player.isCreative() && Config.CREATIVE_WATER_SPOUT.get())
tooltip = Component.translatable("menu.warp_pipes.warp_pipe.water_spout_slider_creative.tooltip");
else if (blockEntity instanceof WarpPipeBlockEntity pipeBlockEntity && pipeBlockEntity.isWaxed() && Config.WAX_DISABLES_WATER_SPOUTS.get())
tooltip = Component.translatable("menu.warp_pipes.warp_pipe.water_spout_slider_waxed.tooltip");
else tooltip = Component.translatable("menu.warp_pipes.warp_pipe.water_spout_slider.tooltip");
}
this.waterSpoutSlider.setTooltip(Tooltip.create(tooltip));

if (this.getClickedPos() != null) {
BlockState state = world.getBlockState(this.getClickedPos());
if (state.getBlock() instanceof WarpPipeBlock && state.getValue(WarpPipeBlock.BUBBLES)) {
if (blockEntity instanceof WarpPipeBlockEntity pipeBlockEntity && pipeBlockEntity.isWaxed() && Config.WAX_DISABLES_BUBBLES.get())
if (!player.isCreative() && Config.CREATIVE_BUBBLES.get())
tooltip = Component.translatable("menu.warp_pipes.warp_pipe.bubbles_off_button_creative.tooltip");
else if (blockEntity instanceof WarpPipeBlockEntity pipeBlockEntity && pipeBlockEntity.isWaxed() && Config.WAX_DISABLES_BUBBLES.get())
tooltip = Component.translatable("menu.warp_pipes.warp_pipe.bubbles_off_button_waxed.tooltip");
else tooltip = Component.translatable("menu.warp_pipes.warp_pipe.bubbles_off_button.tooltip");
} else if (blockEntity instanceof WarpPipeBlockEntity pipeBlockEntity && pipeBlockEntity.isWaxed() && Config.WAX_DISABLES_BUBBLES.get())
} else if (!player.isCreative() && Config.CREATIVE_BUBBLES.get())
tooltip = Component.translatable("menu.warp_pipes.warp_pipe.bubbles_on_button_creative.tooltip");
else if (blockEntity instanceof WarpPipeBlockEntity pipeBlockEntity && pipeBlockEntity.isWaxed() && Config.WAX_DISABLES_BUBBLES.get())
tooltip = Component.translatable("menu.warp_pipes.warp_pipe.bubbles_on_button_waxed.tooltip");
else tooltip = Component.translatable("menu.warp_pipes.warp_pipe.bubbles_on_button.tooltip");
}
this.bubblesButton.setTooltip(Tooltip.create(tooltip));

if (this.getClickedPos() != null) {
if (!player.isCreative() && Config.CREATIVE_BUBBLES.get())
tooltip = Component.translatable("menu.warp_pipes.warp_pipe.bubbles_slider_creative.tooltip");
else if (blockEntity instanceof WarpPipeBlockEntity pipeBlockEntity && pipeBlockEntity.isWaxed() && Config.WAX_DISABLES_BUBBLES.get())
tooltip = Component.translatable("menu.warp_pipes.warp_pipe.bubbles_slider_waxed.tooltip");
else tooltip = Component.translatable("menu.warp_pipes.warp_pipe.bubbles_slider.tooltip");
}
this.bubblesSlider.setTooltip(Tooltip.create(tooltip));
}

@Override
Expand Down
12 changes: 11 additions & 1 deletion src/main/resources/assets/warp_pipes/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
"menu.warp_pipes.warp_pipe.close_button": "",
"menu.warp_pipes.warp_pipe.close_button.tooltip": "Close Pipe",
"menu.warp_pipes.warp_pipe.open_button.tooltip": "Open Pipe",
"menu.warp_pipes.warp_pipe.close_button_creative.tooltip": "§mClose Pipe§r \n§cCreative Only!",
"menu.warp_pipes.warp_pipe.open_button_creative.tooltip": "§mOpen Pipe§r \n§cCreative Only!",
"menu.warp_pipes.warp_pipe.close_button_waxed.tooltip": "§mClose Pipe§r \n§cPipe is Waxed!",
"menu.warp_pipes.warp_pipe.open_button_waxed.tooltip": "§mOpen Pipe§r \n§cPipe is Waxed!",
"menu.warp_pipes.warp_pipe.close_button.narrate": "Close Pipe Toggle",
Expand All @@ -64,20 +66,28 @@
"menu.warp_pipes.warp_pipe.bubbles_button": "",
"menu.warp_pipes.warp_pipe.bubbles_on_button.tooltip": "Pipe Bubbles On",
"menu.warp_pipes.warp_pipe.bubbles_off_button.tooltip": "Pipe Bubbles Off",
"menu.warp_pipes.warp_pipe.bubbles_on_button_creative.tooltip": "§mPipe Bubbles On§r \n§cCreative Only!",
"menu.warp_pipes.warp_pipe.bubbles_off_button_creative.tooltip": "§mPipe Bubbles Off§r \n§cCreative Only!",
"menu.warp_pipes.warp_pipe.bubbles_on_button_waxed.tooltip": "§mPipe Bubbles On§r \n§cPipe is Waxed!",
"menu.warp_pipes.warp_pipe.bubbles_off_button_waxed.tooltip": "§mPipe Bubbles Off§r \n§cPipe is Waxed!",
"menu.warp_pipes.warp_pipe.bubbles_button.narrate": "Pipe Bubbles Toggle",
"menu.warp_pipes.warp_pipe.bubbles_slider.height": "Distance: ",
"menu.warp_pipes.warp_pipe.bubbles_slider.distance": "Distance: ",
"menu.warp_pipes.warp_pipe.bubbles_slider.tooltip": "Pipe Bubbles Distance",
"menu.warp_pipes.warp_pipe.bubbles_slider_creative.tooltip": "§mPipe Bubbles Distance§r \n§cCreative Only!",
"menu.warp_pipes.warp_pipe.bubbles_slider_waxed.tooltip": "§mPipe Bubbles Distance§r \n§cPipe is Waxed!",

"menu.warp_pipes.warp_pipe.water_spout_button": "",
"menu.warp_pipes.warp_pipe.water_spout_on_button.tooltip": "Water Spout On",
"menu.warp_pipes.warp_pipe.water_spout_off_button.tooltip": "Water Spout Off",
"menu.warp_pipes.warp_pipe.water_spout_on_button_creative.tooltip": "§mWater Spout On§r \n§cCreative Only!",
"menu.warp_pipes.warp_pipe.water_spout_off_button_creative.tooltip": "§mWater Spout Off§r \n§cCreative Only!",
"menu.warp_pipes.warp_pipe.water_spout_on_button_waxed.tooltip": "§mWater Spout On§r \n§cPipe is Waxed!",
"menu.warp_pipes.warp_pipe.water_spout_off_button_waxed.tooltip": "§mWater Spout Off§r \n§cPipe is Waxed!",
"menu.warp_pipes.warp_pipe.water_spout_button.narrate": "Water Spout Toggle",
"menu.warp_pipes.warp_pipe.water_spout_slider.height": "Height: ",
"menu.warp_pipes.warp_pipe.water_spout_slider.tooltip": "Water Spout Height",
"menu.warp_pipes.warp_pipe.water_spout_slider_creative.tooltip": "§mWater Spout Height§r \n§cCreative Only!",
"menu.warp_pipes.warp_pipe.water_spout_slider_waxed.tooltip": "§mWater Spout Height§r \n§cPipe is Waxed!",

"display.warp_pipes.rename_pipes.pipe_waxed": "Pipe is waxed!",
"display.warp_pipes.close_pipes.requires_creative": "Requires creative to open/close pipes!",
Expand Down

0 comments on commit c35063d

Please sign in to comment.