Advertisement
Creepinson

Untitled

Jun 23rd, 2017
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. package me.creepinson.gui;
  2.  
  3. import java.io.IOException;
  4.  
  5. import me.creepinson.entity.EntityMovingBlock;
  6. import me.creepinson.lib.util.Utils;
  7. import net.minecraft.block.state.IBlockState;
  8. import net.minecraft.client.gui.GuiButton;
  9. import net.minecraft.client.gui.GuiScreen;
  10. import net.minecraft.client.renderer.GlStateManager;
  11. import net.minecraft.init.Blocks;
  12. import net.minecraft.util.ResourceLocation;
  13. import net.minecraft.util.math.BlockPos;
  14.  
  15. public class GuiMomo extends GuiScreen {
  16.  
  17. public static GuiSliderFixed type = new GuiSliderFixed(0, 960, 540, "Walking Block Type", 0, 1, 0);
  18. public static GuiButton summon = new GuiButton(0, 960, 700, "Summon Walking Block");
  19. public IBlockState block;
  20.  
  21. public static final ResourceLocation resource = new ResourceLocation(Utils.MODID, "textures/gui/momo.png");
  22.  
  23. public void drawDefaultBackground() {
  24. super.drawDefaultBackground();
  25. GlStateManager.color(1.0F, 0.0F, 0.0F, 1.0F);
  26. this.mc.getTextureManager().bindTexture(resource);
  27. int i = (this.width - 248) / 2;
  28. int j = (this.height - 166) / 2;
  29. this.drawTexturedModalRect(i, j, 0, 0, 248, 166);
  30. }
  31.  
  32. @Override
  33. public void initGui() {
  34. super.initGui();
  35. buttonList.add(type);
  36. buttonList.add(summon);
  37. }
  38.  
  39. @Override
  40. public void drawScreen(int mouseX, int mouseY, float partialTicks) {
  41. super.drawScreen(mouseX, mouseY, partialTicks);
  42.  
  43. this.drawDefaultBackground();
  44.  
  45. }
  46.  
  47. @Override
  48. public void updateScreen() {
  49. // TODO Auto-generated method stub
  50. super.updateScreen();
  51. }
  52.  
  53. @Override
  54. protected void actionPerformed(GuiButton button) throws IOException {
  55.  
  56. if (button == type) {
  57.  
  58. if (type.sliderValue == 0) {
  59.  
  60. block = Blocks.PLANKS.getDefaultState();
  61.  
  62. }
  63. if (type.sliderValue == 1) {
  64.  
  65. block = Blocks.DIRT.getDefaultState();
  66.  
  67. }
  68.  
  69. }
  70.  
  71. if (button == summon){
  72.  
  73.  
  74. if (block == null) {
  75.  
  76. block = Blocks.STONE.getDefaultState();
  77.  
  78. }
  79.  
  80. else{
  81. BlockPos pos = new BlockPos(mc.player.posX, mc.player.posY, mc.player.posZ);
  82. EntityMovingBlock entityIn = new EntityMovingBlock(mc.world, pos);
  83. entityIn.setState(block);
  84. mc.world.spawnEntity(entityIn);
  85.  
  86.  
  87. }
  88.  
  89. }
  90.  
  91.  
  92. super.actionPerformed(button);
  93. }
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement