Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.creepinson.gui;
- import java.io.IOException;
- import me.creepinson.entity.EntityMovingBlock;
- import me.creepinson.lib.util.Utils;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.client.gui.GuiButton;
- import net.minecraft.client.gui.GuiScreen;
- import net.minecraft.client.renderer.GlStateManager;
- import net.minecraft.init.Blocks;
- import net.minecraft.util.ResourceLocation;
- import net.minecraft.util.math.BlockPos;
- public class GuiMomo extends GuiScreen {
- public static GuiSliderFixed type = new GuiSliderFixed(0, 960, 540, "Walking Block Type", 0, 1, 0);
- public static GuiButton summon = new GuiButton(0, 960, 700, "Summon Walking Block");
- public IBlockState block;
- public static final ResourceLocation resource = new ResourceLocation(Utils.MODID, "textures/gui/momo.png");
- public void drawDefaultBackground() {
- super.drawDefaultBackground();
- GlStateManager.color(1.0F, 0.0F, 0.0F, 1.0F);
- this.mc.getTextureManager().bindTexture(resource);
- int i = (this.width - 248) / 2;
- int j = (this.height - 166) / 2;
- this.drawTexturedModalRect(i, j, 0, 0, 248, 166);
- }
- @Override
- public void initGui() {
- super.initGui();
- buttonList.add(type);
- buttonList.add(summon);
- }
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- super.drawScreen(mouseX, mouseY, partialTicks);
- this.drawDefaultBackground();
- }
- @Override
- public void updateScreen() {
- // TODO Auto-generated method stub
- super.updateScreen();
- }
- @Override
- protected void actionPerformed(GuiButton button) throws IOException {
- if (button == type) {
- if (type.sliderValue == 0) {
- block = Blocks.PLANKS.getDefaultState();
- }
- if (type.sliderValue == 1) {
- block = Blocks.DIRT.getDefaultState();
- }
- }
- if (button == summon){
- if (block == null) {
- block = Blocks.STONE.getDefaultState();
- }
- else{
- BlockPos pos = new BlockPos(mc.player.posX, mc.player.posY, mc.player.posZ);
- EntityMovingBlock entityIn = new EntityMovingBlock(mc.world, pos);
- entityIn.setState(block);
- mc.world.spawnEntity(entityIn);
- }
- }
- super.actionPerformed(button);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement