-
-
Save PlatinPython/70443135e678142f77c5d77e55c2be60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net.minecraft.block.Blocks; | |
import net.minecraft.client.Minecraft; | |
import net.minecraft.client.gui.screen.Screen; | |
import net.minecraft.util.text.StringTextComponent; | |
import net.minecraftforge.api.distmarker.Dist; | |
import net.minecraftforge.event.entity.player.PlayerInteractEvent; | |
import net.minecraftforge.eventbus.api.SubscribeEvent; | |
import net.minecraftforge.fml.client.gui.widget.Slider; | |
import net.minecraftforge.fml.common.Mod; | |
@Mod("sliderbug") | |
public class SliderBug1165 { | |
public SliderBug1165() { | |
} | |
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, modid = "sliderbug", value = Dist.CLIENT) | |
public static class Client { | |
@SubscribeEvent | |
public static void onBlockRightClick(PlayerInteractEvent.RightClickBlock event) { | |
class TestScreen extends Screen { | |
protected TestScreen() { | |
super(StringTextComponent.EMPTY); | |
} | |
@Override | |
protected void init() { | |
addButton(new Slider(this.width / 2 - 100, | |
this.height / 2 - 30, | |
200, | |
20, | |
new StringTextComponent("Slider 1: "), | |
StringTextComponent.EMPTY, | |
0D, | |
200D, | |
100D, | |
false, | |
true, | |
(b) -> {})); | |
addButton(new Slider(this.width / 2 - 100, | |
this.height / 2 + 10, | |
200, | |
20, | |
new StringTextComponent("Slider 2: "), | |
StringTextComponent.EMPTY, | |
0D, | |
200D, | |
100D, | |
false, | |
true, | |
(b) -> {})); | |
} | |
} | |
if (event.getWorld().getBlockState(event.getPos()).is(Blocks.DIAMOND_BLOCK)) | |
Minecraft.getInstance().setScreen(new TestScreen()); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net.minecraft.client.Minecraft; | |
import net.minecraft.client.gui.screens.Screen; | |
import net.minecraft.network.chat.TextComponent; | |
import net.minecraft.world.level.block.Blocks; | |
import net.minecraftforge.api.distmarker.Dist; | |
import net.minecraftforge.client.gui.widget.Slider; | |
import net.minecraftforge.event.entity.player.PlayerInteractEvent; | |
import net.minecraftforge.eventbus.api.SubscribeEvent; | |
import net.minecraftforge.fml.common.Mod; | |
@Mod("sliderbug") | |
public class SliderBug1181 { | |
public SliderBug1181() { | |
} | |
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, modid = "sliderbug", value = Dist.CLIENT) | |
public static class Client { | |
@SubscribeEvent | |
public static void onBlockRightClick(PlayerInteractEvent.RightClickBlock event) { | |
if (!event.getWorld().isClientSide) return; | |
class TestScreen extends Screen { | |
protected TestScreen() { | |
super(TextComponent.EMPTY); | |
} | |
@Override | |
protected void init() { | |
addRenderableWidget(new Slider(this.width / 2 - 100, | |
this.height / 2 - 30, | |
200, | |
20, | |
new TextComponent("Slider 1: "), | |
TextComponent.EMPTY, | |
0D, | |
200D, | |
100D, | |
false, | |
true, | |
(b) -> {})); | |
addRenderableWidget(new Slider(this.width / 2 - 100, | |
this.height / 2 + 10, | |
200, | |
20, | |
new TextComponent("Slider 2: "), | |
TextComponent.EMPTY, | |
0D, | |
200D, | |
100D, | |
false, | |
true, | |
(b) -> {})); | |
} | |
} | |
if (event.getWorld().getBlockState(event.getPos()).is(Blocks.DIAMOND_BLOCK)) | |
Minecraft.getInstance().setScreen(new TestScreen()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment