Skip to content

Commit

Permalink
Expose the world via IModuleGuiBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
josephcsible committed Nov 11, 2018
1 parent 71436d8 commit fa6b845
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mcjty.rftools.api.screens;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;

/**
* A builder to help create gui's for your screen modules. The 'tagname' parameter is what will
Expand All @@ -24,6 +25,8 @@ public interface IModuleGuiBuilder {

NBTTagCompound getCurrentData();

World getWorld();

IModuleGuiBuilder label(String text);

IModuleGuiBuilder leftLabel(String text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import mcjty.rftools.api.screens.*;
import mcjty.rftools.api.screens.data.IModuleDataString;
import mcjty.rftools.blocks.screens.modulesclient.helper.ScreenTextHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.nbt.NBTTagCompound;
Expand Down Expand Up @@ -61,8 +60,7 @@ public void mouseClick(World world, int x, int y, boolean clicked) {

@Override
public void createGui(IModuleGuiBuilder guiBuilder) {
// @todo Hacky, solve this better
World world = Minecraft.getMinecraft().player.getEntityWorld();
World world = guiBuilder.getWorld();
NBTTagCompound currentData = guiBuilder.getCurrentData();
IModuleGuiBuilder.Choice[] choices = EMPTY_CHOICES;
if((currentData.hasKey("monitordim") ? currentData.getInteger("monitordim") : currentData.getInteger("dim")) == world.provider.getDimension()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public NBTTagCompound getCurrentData() {
return currentData;
}

@Override
public World getWorld() {
return mc.player.getEntityWorld();
}

public IModuleGuiChanged getModuleGuiChanged() {
return moduleGuiChanged;
}
Expand Down Expand Up @@ -231,7 +236,7 @@ public ScreenModuleGuiBuilder block(String tagnamePos) {
// For compatibility reasons.
dim = currentData.getInteger("dim");
}
World world = mc.player.getEntityWorld();
World world = getWorld();
if (dim == world.provider.getDimension()) {
int x = currentData.getInteger(tagnamePos+"x");
int y = currentData.getInteger(tagnamePos+"y");
Expand Down

0 comments on commit fa6b845

Please sign in to comment.