mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-27 15:33:18 +00:00
Inital 1.8 patch update. 'It compiles!'
This commit is contained in:
1 parent
ebb91ba280
commit
1ac0c5d87f
104 files changed
+1300
-1790
No files matched your search
@@ -14,6 +14,7 @@ package cpw.mods.fml.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -26,7 +27,7 @@ import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiIngameMenu;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
@@ -130,10 +131,8 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
|
||||
private DummyModContainer optifineContainer;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private boolean guiLoaded;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private boolean serverIsRunning;
|
||||
|
||||
private MissingModsException modsMissing;
|
||||
@@ -152,7 +151,6 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
|
||||
private List<IResourcePack> resourcePackList;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private IReloadableResourceManager resourceManager;
|
||||
|
||||
private Map<String, IResourcePack> resourcePackMap;
|
||||
@@ -301,7 +299,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
|
||||
// Reload resources
|
||||
client.refreshResources();
|
||||
RenderingRegistry.instance().loadEntityRenderers((Map<Class<? extends Entity>, Render>)RenderManager.instance.entityRenderMap);
|
||||
//RenderingRegistry.instance().loadEntityRenderers((Map<Class<? extends Entity>, Render>)Minecraft.getMinecraft().func_175598_ae().entityRenderMap);
|
||||
guiFactories = HashBiMap.create();
|
||||
for (ModContainer mc : Loader.instance().getActiveModList())
|
||||
{
|
||||
@@ -326,7 +324,6 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
client.gameSettings.loadOptions(); //Reload options to load any mod added keybindings.
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void extendModList()
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -463,16 +460,16 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
{
|
||||
if (Thread.interrupted()) throw new InterruptedException();
|
||||
|
||||
client.loadingScreen.resetProgresAndWorkingMessage("");
|
||||
client.loadingScreen.displayLoadingString("");
|
||||
|
||||
Thread.sleep(50);
|
||||
}
|
||||
|
||||
client.loadingScreen.resetProgresAndWorkingMessage(""); // make sure the blank screen is being drawn at the end
|
||||
client.loadingScreen.displayLoadingString(""); // make sure the blank screen is being drawn at the end
|
||||
}
|
||||
}
|
||||
|
||||
public boolean handleLoadingScreen(ScaledResolution scaledResolution)
|
||||
public boolean handleLoadingScreen(ScaledResolution scaledResolution) throws IOException
|
||||
{
|
||||
if (client.currentScreen instanceof GuiNotification)
|
||||
{
|
||||
@@ -497,7 +494,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
return client.theWorld;
|
||||
}
|
||||
|
||||
public EntityClientPlayerMP getClientPlayerEntity()
|
||||
public EntityPlayerSP getClientPlayerEntity()
|
||||
{
|
||||
return client.thePlayer;
|
||||
}
|
||||
@@ -630,7 +627,6 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
|
||||
public void startIntegratedServer(String id, String name, WorldSettings settings)
|
||||
{
|
||||
playClientBlock = new CountDownLatch(1);
|
||||
}
|
||||
|
||||
public File getSavesDir()
|
||||
@@ -774,10 +770,10 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
return null;
|
||||
}
|
||||
this.client.getTextureManager().bindTexture(iconSheet);
|
||||
Gui.func_146110_a(x + width - 18, y + 10, 0, (float)idx, 16, 16, 256.0f, 256.0f);
|
||||
Gui.drawModalRectWithCustomSizedTexture(x + width - 18, y + 10, 0, (float)idx, 16, 16, 256.0f, 256.0f);
|
||||
if (blocked)
|
||||
{
|
||||
Gui.func_146110_a(x + width - 18, y + 10, 0, 80, 16, 16, 256.0f, 256.0f);
|
||||
Gui.drawModalRectWithCustomSizedTexture(x + width - 18, y + 10, 0, 80, 16, 16, 256.0f, 256.0f);
|
||||
}
|
||||
|
||||
return relativeMouseX > width - 15 && relativeMouseX < width && relativeMouseY > 10 && relativeMouseY < 26 ? tooltip : null;
|
||||
@@ -795,7 +791,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
ServerData serverData = new ServerData("Command Line", host+":"+port);
|
||||
try
|
||||
{
|
||||
osp.func_147224_a(serverData);
|
||||
osp.ping(serverData);
|
||||
startupConnectionData.await(30, TimeUnit.SECONDS);
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -817,46 +813,20 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
{
|
||||
showGuiScreen(new GuiConnecting(guiMultiplayer, client, serverEntry));
|
||||
}
|
||||
playClientBlock = new CountDownLatch(1);
|
||||
}
|
||||
|
||||
public void connectToRealmsServer(String host, int port)
|
||||
{
|
||||
playClientBlock = new CountDownLatch(1);
|
||||
}
|
||||
|
||||
private CountDownLatch playClientBlock;
|
||||
public void connectToRealmsServer(String host, int port){}
|
||||
|
||||
public void setPlayClient(NetHandlerPlayClient netHandlerPlayClient)
|
||||
{
|
||||
if (playClientBlock == null)
|
||||
playClientBlock = new CountDownLatch(1);
|
||||
playClientBlock.countDown();
|
||||
this.currentPlayClient = new WeakReference<NetHandlerPlayClient>(netHandlerPlayClient);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void waitForPlayClient()
|
||||
{
|
||||
boolean gotIt = false;
|
||||
try
|
||||
{
|
||||
gotIt = playClientBlock.await(5,TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e)
|
||||
{
|
||||
}
|
||||
if (!gotIt)
|
||||
{
|
||||
throw new RuntimeException("Timeout waiting for client thread to catch up!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set<String> channelSet, String channel, Side side)
|
||||
{
|
||||
if (side == Side.CLIENT)
|
||||
{
|
||||
waitForPlayClient();
|
||||
bus.post(new FMLNetworkEvent.CustomPacketRegistrationEvent<NetHandlerPlayClient>(manager, channelSet, channel, side, NetHandlerPlayClient.class));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -27,6 +27,7 @@ import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -106,7 +107,7 @@ public class GuiModList extends GuiScreen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
if (button.enabled)
|
||||
{
|
||||
switch (button.id)
|
||||
@@ -193,12 +194,13 @@ public class GuiModList extends GuiScreen
|
||||
cachedLogoDimensions.width *= scale;
|
||||
cachedLogoDimensions.height *= scale;
|
||||
int top = 32;
|
||||
Tessellator tess = Tessellator.instance;
|
||||
tess.startDrawingQuads();
|
||||
tess.addVertexWithUV(offset, top + cachedLogoDimensions.height, zLevel, 0, 1);
|
||||
tess.addVertexWithUV(offset + cachedLogoDimensions.width, top + cachedLogoDimensions.height, zLevel, 1, 1);
|
||||
tess.addVertexWithUV(offset + cachedLogoDimensions.width, top, zLevel, 1, 0);
|
||||
tess.addVertexWithUV(offset, top, zLevel, 0, 0);
|
||||
Tessellator tess = Tessellator.func_178181_a();
|
||||
WorldRenderer world = tess.func_178180_c();
|
||||
world.func_178970_b();
|
||||
world.func_178985_a(offset, top + cachedLogoDimensions.height, zLevel, 0, 1);
|
||||
world.func_178985_a(offset + cachedLogoDimensions.width, top + cachedLogoDimensions.height, zLevel, 1, 1);
|
||||
world.func_178985_a(offset + cachedLogoDimensions.width, top, zLevel, 1, 0);
|
||||
world.func_178985_a(offset, top, zLevel, 0, 0);
|
||||
tess.draw();
|
||||
|
||||
shifty += 65;
|
||||
@@ -209,7 +211,7 @@ public class GuiModList extends GuiScreen
|
||||
;
|
||||
}
|
||||
}
|
||||
this.fontRendererObj.drawStringWithShadow(selectedMod.getMetadata().name, offset, shifty, 0xFFFFFF);
|
||||
this.fontRendererObj.func_175063_a(selectedMod.getMetadata().name, offset, shifty, 0xFFFFFF);
|
||||
shifty += 12;
|
||||
|
||||
shifty = drawLine(String.format("Version: %s (%s)", selectedMod.getDisplayVersion(), selectedMod.getVersion()), offset, shifty);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class GuiOldSaveLoadConfirm extends GuiYesNo implements GuiYesNoCallback
|
||||
|
||||
for (k = 0; k < this.labelList.size(); ++k)
|
||||
{
|
||||
((GuiLabel)this.labelList.get(k)).func_146159_a(this.mc, p_73863_1_, p_73863_2_);
|
||||
((GuiLabel)this.labelList.get(k)).drawLabel(this.mc, p_73863_1_, p_73863_2_);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -263,7 +264,8 @@ public abstract class GuiScrollingList
|
||||
}
|
||||
|
||||
this.applyScrollLimits();
|
||||
Tessellator var18 = Tessellator.instance;
|
||||
Tessellator tess = Tessellator.func_178181_a();
|
||||
WorldRenderer worldr = tess.func_178180_c();
|
||||
if (this.client.theWorld != null)
|
||||
{
|
||||
this.drawGradientRect(this.left, this.top, this.right, this.bottom, -1072689136, -804253680);
|
||||
@@ -275,20 +277,20 @@ public abstract class GuiScrollingList
|
||||
this.client.renderEngine.bindTexture(Gui.optionsBackground);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
float var17 = 32.0F;
|
||||
var18.startDrawingQuads();
|
||||
var18.setColorOpaque_I(2105376);
|
||||
var18.addVertexWithUV((double)this.left, (double)this.bottom, 0.0D, (double)((float)this.left / var17), (double)((float)(this.bottom + (int)this.scrollDistance) / var17));
|
||||
var18.addVertexWithUV((double)this.right, (double)this.bottom, 0.0D, (double)((float)this.right / var17), (double)((float)(this.bottom + (int)this.scrollDistance) / var17));
|
||||
var18.addVertexWithUV((double)this.right, (double)this.top, 0.0D, (double)((float)this.right / var17), (double)((float)(this.top + (int)this.scrollDistance) / var17));
|
||||
var18.addVertexWithUV((double)this.left, (double)this.top, 0.0D, (double)((float)this.left / var17), (double)((float)(this.top + (int)this.scrollDistance) / var17));
|
||||
var18.draw();
|
||||
worldr.func_178970_b();
|
||||
worldr.func_178991_c(2105376);
|
||||
worldr.func_178985_a((double)this.left, (double)this.bottom, 0.0D, (double)((float)this.left / var17), (double)((float)(this.bottom + (int)this.scrollDistance) / var17));
|
||||
worldr.func_178985_a((double)this.right, (double)this.bottom, 0.0D, (double)((float)this.right / var17), (double)((float)(this.bottom + (int)this.scrollDistance) / var17));
|
||||
worldr.func_178985_a((double)this.right, (double)this.top, 0.0D, (double)((float)this.right / var17), (double)((float)(this.top + (int)this.scrollDistance) / var17));
|
||||
worldr.func_178985_a((double)this.left, (double)this.top, 0.0D, (double)((float)this.left / var17), (double)((float)(this.top + (int)this.scrollDistance) / var17));
|
||||
tess.draw();
|
||||
}
|
||||
// boxRight = this.listWidth / 2 - 92 - 16;
|
||||
var10 = this.top + 4 - (int)this.scrollDistance;
|
||||
|
||||
if (this.field_27262_q)
|
||||
{
|
||||
this.func_27260_a(boxRight, var10, var18);
|
||||
this.func_27260_a(boxRight, var10, tess);
|
||||
}
|
||||
|
||||
int var14;
|
||||
@@ -306,22 +308,22 @@ public abstract class GuiScrollingList
|
||||
int var15 = boxRight;
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
var18.startDrawingQuads();
|
||||
var18.setColorOpaque_I(8421504);
|
||||
var18.addVertexWithUV((double)var14, (double)(var19 + var13 + 2), 0.0D, 0.0D, 1.0D);
|
||||
var18.addVertexWithUV((double)var15, (double)(var19 + var13 + 2), 0.0D, 1.0D, 1.0D);
|
||||
var18.addVertexWithUV((double)var15, (double)(var19 - 2), 0.0D, 1.0D, 0.0D);
|
||||
var18.addVertexWithUV((double)var14, (double)(var19 - 2), 0.0D, 0.0D, 0.0D);
|
||||
var18.setColorOpaque_I(0);
|
||||
var18.addVertexWithUV((double)(var14 + 1), (double)(var19 + var13 + 1), 0.0D, 0.0D, 1.0D);
|
||||
var18.addVertexWithUV((double)(var15 - 1), (double)(var19 + var13 + 1), 0.0D, 1.0D, 1.0D);
|
||||
var18.addVertexWithUV((double)(var15 - 1), (double)(var19 - 1), 0.0D, 1.0D, 0.0D);
|
||||
var18.addVertexWithUV((double)(var14 + 1), (double)(var19 - 1), 0.0D, 0.0D, 0.0D);
|
||||
var18.draw();
|
||||
worldr.func_178970_b();
|
||||
worldr.func_178991_c(8421504);
|
||||
worldr.func_178985_a((double)var14, (double)(var19 + var13 + 2), 0.0D, 0.0D, 1.0D);
|
||||
worldr.func_178985_a((double)var15, (double)(var19 + var13 + 2), 0.0D, 1.0D, 1.0D);
|
||||
worldr.func_178985_a((double)var15, (double)(var19 - 2), 0.0D, 1.0D, 0.0D);
|
||||
worldr.func_178985_a((double)var14, (double)(var19 - 2), 0.0D, 0.0D, 0.0D);
|
||||
worldr.func_178991_c(0);
|
||||
worldr.func_178985_a((double)(var14 + 1), (double)(var19 + var13 + 1), 0.0D, 0.0D, 1.0D);
|
||||
worldr.func_178985_a((double)(var15 - 1), (double)(var19 + var13 + 1), 0.0D, 1.0D, 1.0D);
|
||||
worldr.func_178985_a((double)(var15 - 1), (double)(var19 - 1), 0.0D, 1.0D, 0.0D);
|
||||
worldr.func_178985_a((double)(var14 + 1), (double)(var19 - 1), 0.0D, 0.0D, 0.0D);
|
||||
tess.draw();
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
this.drawSlot(var11, boxRight, var19, var13, var18);
|
||||
this.drawSlot(var11, boxRight, var19, var13, tess);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,22 +339,22 @@ public abstract class GuiScrollingList
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
var18.startDrawingQuads();
|
||||
var18.setColorRGBA_I(0, 0);
|
||||
var18.addVertexWithUV((double)this.left, (double)(this.top + var20), 0.0D, 0.0D, 1.0D);
|
||||
var18.addVertexWithUV((double)this.right, (double)(this.top + var20), 0.0D, 1.0D, 1.0D);
|
||||
var18.setColorRGBA_I(0, 255);
|
||||
var18.addVertexWithUV((double)this.right, (double)this.top, 0.0D, 1.0D, 0.0D);
|
||||
var18.addVertexWithUV((double)this.left, (double)this.top, 0.0D, 0.0D, 0.0D);
|
||||
var18.draw();
|
||||
var18.startDrawingQuads();
|
||||
var18.setColorRGBA_I(0, 255);
|
||||
var18.addVertexWithUV((double)this.left, (double)this.bottom, 0.0D, 0.0D, 1.0D);
|
||||
var18.addVertexWithUV((double)this.right, (double)this.bottom, 0.0D, 1.0D, 1.0D);
|
||||
var18.setColorRGBA_I(0, 0);
|
||||
var18.addVertexWithUV((double)this.right, (double)(this.bottom - var20), 0.0D, 1.0D, 0.0D);
|
||||
var18.addVertexWithUV((double)this.left, (double)(this.bottom - var20), 0.0D, 0.0D, 0.0D);
|
||||
var18.draw();
|
||||
worldr.func_178970_b();
|
||||
worldr.func_178974_a(0, 0);
|
||||
worldr.func_178985_a((double)this.left, (double)(this.top + var20), 0.0D, 0.0D, 1.0D);
|
||||
worldr.func_178985_a((double)this.right, (double)(this.top + var20), 0.0D, 1.0D, 1.0D);
|
||||
worldr.func_178974_a(0, 255);
|
||||
worldr.func_178985_a((double)this.right, (double)this.top, 0.0D, 1.0D, 0.0D);
|
||||
worldr.func_178985_a((double)this.left, (double)this.top, 0.0D, 0.0D, 0.0D);
|
||||
tess.draw();
|
||||
worldr.func_178970_b();
|
||||
worldr.func_178974_a(0, 255);
|
||||
worldr.func_178985_a((double)this.left, (double)this.bottom, 0.0D, 0.0D, 1.0D);
|
||||
worldr.func_178985_a((double)this.right, (double)this.bottom, 0.0D, 1.0D, 1.0D);
|
||||
worldr.func_178974_a(0, 0);
|
||||
worldr.func_178985_a((double)this.right, (double)(this.bottom - var20), 0.0D, 1.0D, 0.0D);
|
||||
worldr.func_178985_a((double)this.left, (double)(this.bottom - var20), 0.0D, 0.0D, 0.0D);
|
||||
tess.draw();
|
||||
var19 = this.getContentHeight() - (this.bottom - this.top - 4);
|
||||
|
||||
if (var19 > 0)
|
||||
@@ -376,27 +378,27 @@ public abstract class GuiScrollingList
|
||||
var14 = this.top;
|
||||
}
|
||||
|
||||
var18.startDrawingQuads();
|
||||
var18.setColorRGBA_I(0, 255);
|
||||
var18.addVertexWithUV((double)scrollBarXStart, (double)this.bottom, 0.0D, 0.0D, 1.0D);
|
||||
var18.addVertexWithUV((double)scrollBarXEnd, (double)this.bottom, 0.0D, 1.0D, 1.0D);
|
||||
var18.addVertexWithUV((double)scrollBarXEnd, (double)this.top, 0.0D, 1.0D, 0.0D);
|
||||
var18.addVertexWithUV((double)scrollBarXStart, (double)this.top, 0.0D, 0.0D, 0.0D);
|
||||
var18.draw();
|
||||
var18.startDrawingQuads();
|
||||
var18.setColorRGBA_I(8421504, 255);
|
||||
var18.addVertexWithUV((double)scrollBarXStart, (double)(var14 + var13), 0.0D, 0.0D, 1.0D);
|
||||
var18.addVertexWithUV((double)scrollBarXEnd, (double)(var14 + var13), 0.0D, 1.0D, 1.0D);
|
||||
var18.addVertexWithUV((double)scrollBarXEnd, (double)var14, 0.0D, 1.0D, 0.0D);
|
||||
var18.addVertexWithUV((double)scrollBarXStart, (double)var14, 0.0D, 0.0D, 0.0D);
|
||||
var18.draw();
|
||||
var18.startDrawingQuads();
|
||||
var18.setColorRGBA_I(12632256, 255);
|
||||
var18.addVertexWithUV((double)scrollBarXStart, (double)(var14 + var13 - 1), 0.0D, 0.0D, 1.0D);
|
||||
var18.addVertexWithUV((double)(scrollBarXEnd - 1), (double)(var14 + var13 - 1), 0.0D, 1.0D, 1.0D);
|
||||
var18.addVertexWithUV((double)(scrollBarXEnd - 1), (double)var14, 0.0D, 1.0D, 0.0D);
|
||||
var18.addVertexWithUV((double)scrollBarXStart, (double)var14, 0.0D, 0.0D, 0.0D);
|
||||
var18.draw();
|
||||
worldr.func_178970_b();
|
||||
worldr.func_178974_a(0, 255);
|
||||
worldr.func_178985_a((double)scrollBarXStart, (double)this.bottom, 0.0D, 0.0D, 1.0D);
|
||||
worldr.func_178985_a((double)scrollBarXEnd, (double)this.bottom, 0.0D, 1.0D, 1.0D);
|
||||
worldr.func_178985_a((double)scrollBarXEnd, (double)this.top, 0.0D, 1.0D, 0.0D);
|
||||
worldr.func_178985_a((double)scrollBarXStart, (double)this.top, 0.0D, 0.0D, 0.0D);
|
||||
tess.draw();
|
||||
worldr.func_178970_b();
|
||||
worldr.func_178974_a(8421504, 255);
|
||||
worldr.func_178985_a((double)scrollBarXStart, (double)(var14 + var13), 0.0D, 0.0D, 1.0D);
|
||||
worldr.func_178985_a((double)scrollBarXEnd, (double)(var14 + var13), 0.0D, 1.0D, 1.0D);
|
||||
worldr.func_178985_a((double)scrollBarXEnd, (double)var14, 0.0D, 1.0D, 0.0D);
|
||||
worldr.func_178985_a((double)scrollBarXStart, (double)var14, 0.0D, 0.0D, 0.0D);
|
||||
tess.draw();
|
||||
worldr.func_178970_b();
|
||||
worldr.func_178974_a(12632256, 255);
|
||||
worldr.func_178985_a((double)scrollBarXStart, (double)(var14 + var13 - 1), 0.0D, 0.0D, 1.0D);
|
||||
worldr.func_178985_a((double)(scrollBarXEnd - 1), (double)(var14 + var13 - 1), 0.0D, 1.0D, 1.0D);
|
||||
worldr.func_178985_a((double)(scrollBarXEnd - 1), (double)var14, 0.0D, 1.0D, 0.0D);
|
||||
worldr.func_178985_a((double)scrollBarXStart, (double)var14, 0.0D, 0.0D, 0.0D);
|
||||
tess.draw();
|
||||
}
|
||||
|
||||
this.func_27257_b(mouseX, mouseY);
|
||||
@@ -408,17 +410,18 @@ public abstract class GuiScrollingList
|
||||
|
||||
private void overlayBackground(int p_22239_1_, int p_22239_2_, int p_22239_3_, int p_22239_4_)
|
||||
{
|
||||
Tessellator var5 = Tessellator.instance;
|
||||
Tessellator var5 = Tessellator.func_178181_a();
|
||||
WorldRenderer worldr = var5.func_178180_c();
|
||||
this.client.renderEngine.bindTexture(Gui.optionsBackground);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
float var6 = 32.0F;
|
||||
var5.startDrawingQuads();
|
||||
var5.setColorRGBA_I(4210752, p_22239_4_);
|
||||
var5.addVertexWithUV(0.0D, (double)p_22239_2_, 0.0D, 0.0D, (double)((float)p_22239_2_ / var6));
|
||||
var5.addVertexWithUV((double)this.listWidth + 30, (double)p_22239_2_, 0.0D, (double)((float)(this.listWidth + 30) / var6), (double)((float)p_22239_2_ / var6));
|
||||
var5.setColorRGBA_I(4210752, p_22239_3_);
|
||||
var5.addVertexWithUV((double)this.listWidth + 30, (double)p_22239_1_, 0.0D, (double)((float)(this.listWidth + 30) / var6), (double)((float)p_22239_1_ / var6));
|
||||
var5.addVertexWithUV(0.0D, (double)p_22239_1_, 0.0D, 0.0D, (double)((float)p_22239_1_ / var6));
|
||||
worldr.func_178970_b();
|
||||
worldr.func_178974_a(4210752, p_22239_4_);
|
||||
worldr.func_178985_a(0.0D, (double)p_22239_2_, 0.0D, 0.0D, (double)((float)p_22239_2_ / var6));
|
||||
worldr.func_178985_a((double)this.listWidth + 30, (double)p_22239_2_, 0.0D, (double)((float)(this.listWidth + 30) / var6), (double)((float)p_22239_2_ / var6));
|
||||
worldr.func_178974_a(4210752, p_22239_3_);
|
||||
worldr.func_178985_a((double)this.listWidth + 30, (double)p_22239_1_, 0.0D, (double)((float)(this.listWidth + 30) / var6), (double)((float)p_22239_1_ / var6));
|
||||
worldr.func_178985_a(0.0D, (double)p_22239_1_, 0.0D, 0.0D, (double)((float)p_22239_1_ / var6));
|
||||
var5.draw();
|
||||
}
|
||||
|
||||
@@ -437,14 +440,15 @@ public abstract class GuiScrollingList
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(f1, f2, f3, f);
|
||||
tessellator.addVertex((double)par3, (double)par2, 0.0D);
|
||||
tessellator.addVertex((double)par1, (double)par2, 0.0D);
|
||||
tessellator.setColorRGBA_F(f5, f6, f7, f4);
|
||||
tessellator.addVertex((double)par1, (double)par4, 0.0D);
|
||||
tessellator.addVertex((double)par3, (double)par4, 0.0D);
|
||||
Tessellator tessellator = Tessellator.func_178181_a();
|
||||
WorldRenderer worldrenderer = tessellator.func_178180_c();
|
||||
worldrenderer.func_178970_b();
|
||||
worldrenderer.func_178960_a(f1, f2, f3, f);
|
||||
worldrenderer.func_178984_b((double)par3, (double)par2, 0.0D);
|
||||
worldrenderer.func_178984_b((double)par1, (double)par2, 0.0D);
|
||||
worldrenderer.func_178960_a(f5, f6, f7, f4);
|
||||
worldrenderer.func_178984_b((double)par1, (double)par4, 0.0D);
|
||||
worldrenderer.func_178984_b((double)par3, (double)par4, 0.0D);
|
||||
tessellator.draw();
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
@@ -17,12 +17,12 @@ import net.minecraft.client.gui.GuiButton;
|
||||
|
||||
/**
|
||||
* This class provides a button that fixes several bugs present in the vanilla GuiButton drawing code.
|
||||
* The gist of it is that it allows buttons of any size without gaps in the graphics and with the
|
||||
* The gist of it is that it allows buttons of any size without gaps in the graphics and with the
|
||||
* borders drawn properly. It also prevents button text from extending out of the sides of the button by
|
||||
* trimming the end of the string and adding an ellipsis.<br/><br/>
|
||||
*
|
||||
*
|
||||
* The code that handles drawing the button is in GuiUtils.
|
||||
*
|
||||
*
|
||||
* @author bspkrs
|
||||
*/
|
||||
public class GuiButtonExt extends GuiButton
|
||||
@@ -31,12 +31,12 @@ public class GuiButtonExt extends GuiButton
|
||||
{
|
||||
super(id, xPos, yPos, displayString);
|
||||
}
|
||||
|
||||
|
||||
public GuiButtonExt(int id, int xPos, int yPos, int width, int height, String displayString)
|
||||
{
|
||||
super(id, xPos, yPos, width, height, displayString);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draws this button to the screen.
|
||||
*/
|
||||
@@ -45,12 +45,12 @@ public class GuiButtonExt extends GuiButton
|
||||
{
|
||||
if (this.visible)
|
||||
{
|
||||
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||
int k = this.getHoverState(this.field_146123_n);
|
||||
this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||
int k = this.getHoverState(this.hovered);
|
||||
GuiUtils.drawContinuousTexturedBox(buttonTextures, this.xPosition, this.yPosition, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.zLevel);
|
||||
this.mouseDragged(mc, mouseX, mouseY);
|
||||
int color = 14737632;
|
||||
|
||||
|
||||
if (packedFGColour != 0)
|
||||
{
|
||||
color = packedFGColour;
|
||||
@@ -59,19 +59,19 @@ public class GuiButtonExt extends GuiButton
|
||||
{
|
||||
color = 10526880;
|
||||
}
|
||||
else if (this.field_146123_n)
|
||||
else if (this.hovered)
|
||||
{
|
||||
color = 16777120;
|
||||
}
|
||||
|
||||
|
||||
String buttonText = this.displayString;
|
||||
int strWidth = mc.fontRenderer.getStringWidth(buttonText);
|
||||
int ellipsisWidth = mc.fontRenderer.getStringWidth("...");
|
||||
|
||||
int strWidth = mc.fontRendererObj.getStringWidth(buttonText);
|
||||
int ellipsisWidth = mc.fontRendererObj.getStringWidth("...");
|
||||
|
||||
if (strWidth > width - 6 && strWidth > ellipsisWidth)
|
||||
buttonText = mc.fontRenderer.trimStringToWidth(buttonText, width - 6 - ellipsisWidth).trim() + "...";
|
||||
|
||||
this.drawCenteredString(mc.fontRenderer, buttonText, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, color);
|
||||
buttonText = mc.fontRendererObj.trimStringToWidth(buttonText, width - 6 - ellipsisWidth).trim() + "...";
|
||||
|
||||
this.drawCenteredString(mc.fontRendererObj, buttonText, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,33 +17,33 @@ import net.minecraft.client.gui.GuiButton;
|
||||
|
||||
/**
|
||||
* This class provides a checkbox style control.
|
||||
*
|
||||
*
|
||||
* @author bspkrs
|
||||
*/
|
||||
public class GuiCheckBox extends GuiButton
|
||||
{
|
||||
private boolean isChecked;
|
||||
private int boxWidth;
|
||||
|
||||
|
||||
public GuiCheckBox(int id, int xPos, int yPos, String displayString, boolean isChecked)
|
||||
{
|
||||
super(id, xPos, yPos, displayString);
|
||||
this.isChecked = isChecked;
|
||||
this.boxWidth = 11;
|
||||
this.height = 11;
|
||||
this.width = this.boxWidth + 2 + Minecraft.getMinecraft().fontRenderer.getStringWidth(displayString);
|
||||
this.width = this.boxWidth + 2 + Minecraft.getMinecraft().fontRendererObj.getStringWidth(displayString);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY)
|
||||
{
|
||||
if (this.visible)
|
||||
{
|
||||
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.boxWidth && mouseY < this.yPosition + this.height;
|
||||
this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.boxWidth && mouseY < this.yPosition + this.height;
|
||||
GuiUtils.drawContinuousTexturedBox(buttonTextures, this.xPosition, this.yPosition, 0, 46, this.boxWidth, this.height, 200, 20, 2, 3, 2, 2, this.zLevel);
|
||||
this.mouseDragged(mc, mouseX, mouseY);
|
||||
int color = 14737632;
|
||||
|
||||
|
||||
if (packedFGColour != 0)
|
||||
{
|
||||
color = packedFGColour;
|
||||
@@ -52,14 +52,14 @@ public class GuiCheckBox extends GuiButton
|
||||
{
|
||||
color = 10526880;
|
||||
}
|
||||
|
||||
|
||||
if (this.isChecked)
|
||||
this.drawCenteredString(mc.fontRenderer, "x", this.xPosition + this.boxWidth / 2 + 1, this.yPosition + 1, 14737632);
|
||||
|
||||
this.drawString(mc.fontRenderer, displayString, xPosition + this.boxWidth + 2, yPosition + 2, color);
|
||||
this.drawCenteredString(mc.fontRendererObj, "x", this.xPosition + this.boxWidth / 2 + 1, this.yPosition + 1, 14737632);
|
||||
|
||||
this.drawString(mc.fontRendererObj, displayString, xPosition + this.boxWidth + 2, yPosition + 2, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft p_146116_1_, int p_146116_2_, int p_146116_3_)
|
||||
{
|
||||
@@ -68,15 +68,15 @@ public class GuiCheckBox extends GuiButton
|
||||
this.isChecked = !this.isChecked;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean isChecked()
|
||||
{
|
||||
return this.isChecked;
|
||||
}
|
||||
|
||||
|
||||
public void setIsChecked(boolean isChecked)
|
||||
{
|
||||
this.isChecked = isChecked;
|
||||
|
||||
@@ -15,6 +15,7 @@ package cpw.mods.fml.client.config;
|
||||
import static cpw.mods.fml.client.config.GuiUtils.RESET_CHAR;
|
||||
import static cpw.mods.fml.client.config.GuiUtils.UNDO_CHAR;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -37,7 +38,7 @@ import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
/**
|
||||
* This class is the base GuiScreen for all config GUI screens. It can be extended by mods to provide the top-level config screen
|
||||
* that will be called when the Config button is clicked from the Main Menu Mods list.
|
||||
*
|
||||
*
|
||||
* @author bspkrs
|
||||
*/
|
||||
public class GuiConfig extends GuiScreen
|
||||
@@ -74,13 +75,13 @@ public class GuiConfig extends GuiScreen
|
||||
/**
|
||||
* GuiConfig constructor that will use ConfigChangedEvent when editing is concluded. If a non-null value is passed for configID,
|
||||
* the OnConfigChanged and PostConfigChanged events will be posted when the Done button is pressed if any configElements were changed
|
||||
* (includes child screens). If configID is not defined, the events will be posted if the parent gui is null or if the parent gui
|
||||
* (includes child screens). If configID is not defined, the events will be posted if the parent gui is null or if the parent gui
|
||||
* is not an instance of GuiConfig.
|
||||
*
|
||||
* @param parentScreen the parent GuiScreen object
|
||||
* @param configElements a List of IConfigProperty objects
|
||||
* @param modID the mod ID for the mod whose config settings will be edited
|
||||
* @param configID an identifier that will be passed to the OnConfigChanged and PostConfigChanged events. Setting this value will force
|
||||
* @param configID an identifier that will be passed to the OnConfigChanged and PostConfigChanged events. Setting this value will force
|
||||
* the save action to be called when the Done button is pressed on this screen if any configElements were changed.
|
||||
* @param allRequireWorldRestart send true if all configElements on this screen require a world restart
|
||||
* @param allRequireMcRestart send true if all configElements on this screen require MC to be restarted
|
||||
@@ -88,7 +89,7 @@ public class GuiConfig extends GuiScreen
|
||||
* edited.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public GuiConfig(GuiScreen parentScreen, List<IConfigElement> configElements, String modID, String configID,
|
||||
public GuiConfig(GuiScreen parentScreen, List<IConfigElement> configElements, String modID, String configID,
|
||||
boolean allRequireWorldRestart, boolean allRequireMcRestart, String title)
|
||||
{
|
||||
this(parentScreen, configElements, modID, configID, allRequireWorldRestart, allRequireMcRestart, title, null);
|
||||
@@ -107,7 +108,7 @@ public class GuiConfig extends GuiScreen
|
||||
* edited.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public GuiConfig(GuiScreen parentScreen, List<IConfigElement> configElements, String modID,
|
||||
public GuiConfig(GuiScreen parentScreen, List<IConfigElement> configElements, String modID,
|
||||
boolean allRequireWorldRestart, boolean allRequireMcRestart, String title)
|
||||
{
|
||||
this(parentScreen, configElements, modID, null, allRequireWorldRestart, allRequireMcRestart, title, null);
|
||||
@@ -128,7 +129,7 @@ public class GuiConfig extends GuiScreen
|
||||
* currently being edited.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public GuiConfig(GuiScreen parentScreen, List<IConfigElement> configElements, String modID,
|
||||
public GuiConfig(GuiScreen parentScreen, List<IConfigElement> configElements, String modID,
|
||||
boolean allRequireWorldRestart, boolean allRequireMcRestart, String title, String titleLine2)
|
||||
{
|
||||
this(parentScreen, configElements, modID, null, allRequireWorldRestart, allRequireMcRestart, title, titleLine2);
|
||||
@@ -136,8 +137,8 @@ public class GuiConfig extends GuiScreen
|
||||
|
||||
/**
|
||||
* GuiConfig constructor that will use ConfigChangedEvent when editing is concluded. titleLine2 is specified in this constructor.
|
||||
* If a non-null value is passed for configID, the OnConfigChanged and PostConfigChanged events will be posted when the Done button is
|
||||
* pressed if any configElements were changed (includes child screens). If configID is not defined, the events will be posted if the parent
|
||||
* If a non-null value is passed for configID, the OnConfigChanged and PostConfigChanged events will be posted when the Done button is
|
||||
* pressed if any configElements were changed (includes child screens). If configID is not defined, the events will be posted if the parent
|
||||
* gui is null or if the parent gui is not an instance of GuiConfig.
|
||||
*
|
||||
* @param parentScreen the parent GuiScreen object
|
||||
@@ -152,7 +153,7 @@ public class GuiConfig extends GuiScreen
|
||||
* currently being edited.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public GuiConfig(GuiScreen parentScreen, List<IConfigElement> configElements, String modID, String configID,
|
||||
public GuiConfig(GuiScreen parentScreen, List<IConfigElement> configElements, String modID, String configID,
|
||||
boolean allRequireWorldRestart, boolean allRequireMcRestart, String title, String titleLine2)
|
||||
{
|
||||
this.mc = Minecraft.getMinecraft();
|
||||
@@ -193,12 +194,12 @@ public class GuiConfig extends GuiScreen
|
||||
this.needsRefresh = false;
|
||||
}
|
||||
|
||||
int undoGlyphWidth = mc.fontRenderer.getStringWidth(UNDO_CHAR) * 2;
|
||||
int resetGlyphWidth = mc.fontRenderer.getStringWidth(RESET_CHAR) * 2;
|
||||
int doneWidth = Math.max(mc.fontRenderer.getStringWidth(I18n.format("gui.done")) + 20, 100);
|
||||
int undoWidth = mc.fontRenderer.getStringWidth(" " + I18n.format("fml.configgui.tooltip.undoChanges")) + undoGlyphWidth + 20;
|
||||
int resetWidth = mc.fontRenderer.getStringWidth(" " + I18n.format("fml.configgui.tooltip.resetToDefault")) + resetGlyphWidth + 20;
|
||||
int checkWidth = mc.fontRenderer.getStringWidth(I18n.format("fml.configgui.applyGlobally")) + 13;
|
||||
int undoGlyphWidth = mc.fontRendererObj.getStringWidth(UNDO_CHAR) * 2;
|
||||
int resetGlyphWidth = mc.fontRendererObj.getStringWidth(RESET_CHAR) * 2;
|
||||
int doneWidth = Math.max(mc.fontRendererObj.getStringWidth(I18n.format("gui.done")) + 20, 100);
|
||||
int undoWidth = mc.fontRendererObj.getStringWidth(" " + I18n.format("fml.configgui.tooltip.undoChanges")) + undoGlyphWidth + 20;
|
||||
int resetWidth = mc.fontRendererObj.getStringWidth(" " + I18n.format("fml.configgui.tooltip.resetToDefault")) + resetGlyphWidth + 20;
|
||||
int checkWidth = mc.fontRendererObj.getStringWidth(I18n.format("fml.configgui.applyGlobally")) + 13;
|
||||
int buttonWidthHalf = (doneWidth + 5 + undoWidth + 5 + resetWidth + 5 + checkWidth) / 2;
|
||||
this.buttonList.add(new GuiButtonExt(2000, this.width / 2 - buttonWidthHalf, this.height - 29, doneWidth, 20, I18n.format("gui.done")));
|
||||
this.buttonList.add(this.btnDefaultAll = new GuiUnicodeGlyphButton(2001, this.width / 2 - buttonWidthHalf + doneWidth + 5 + undoWidth + 5,
|
||||
@@ -218,14 +219,14 @@ public class GuiConfig extends GuiScreen
|
||||
public void onGuiClosed()
|
||||
{
|
||||
this.entryList.onGuiClosed();
|
||||
|
||||
|
||||
if (this.configID != null && this.parentScreen instanceof GuiConfig)
|
||||
{
|
||||
GuiConfig parentGuiConfig = (GuiConfig) this.parentScreen;
|
||||
parentGuiConfig.needsRefresh = true;
|
||||
parentGuiConfig.initGui();
|
||||
}
|
||||
|
||||
|
||||
if (!(this.parentScreen instanceof GuiConfig))
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
}
|
||||
@@ -238,7 +239,7 @@ public class GuiConfig extends GuiScreen
|
||||
boolean flag = true;
|
||||
try
|
||||
{
|
||||
if ((configID != null || this.parentScreen == null || !(this.parentScreen instanceof GuiConfig))
|
||||
if ((configID != null || this.parentScreen == null || !(this.parentScreen instanceof GuiConfig))
|
||||
&& (this.entryList.hasChangedEntry(true)))
|
||||
{
|
||||
boolean requiresMcRestart = this.entryList.saveConfigElements();
|
||||
@@ -249,14 +250,14 @@ public class GuiConfig extends GuiScreen
|
||||
FMLCommonHandler.instance().bus().post(event);
|
||||
if (!event.getResult().equals(Result.DENY))
|
||||
FMLCommonHandler.instance().bus().post(new PostConfigChangedEvent(modID, configID, isWorldRunning, requiresMcRestart));
|
||||
|
||||
|
||||
if (requiresMcRestart)
|
||||
{
|
||||
flag = false;
|
||||
mc.displayGuiScreen(new GuiMessageDialog(parentScreen, "fml.configgui.gameRestartTitle",
|
||||
mc.displayGuiScreen(new GuiMessageDialog(parentScreen, "fml.configgui.gameRestartTitle",
|
||||
new ChatComponentText(I18n.format("fml.configgui.gameRestartRequired")), "fml.configgui.confirmRestartMessage"));
|
||||
}
|
||||
|
||||
|
||||
if (this.parentScreen instanceof GuiConfig)
|
||||
((GuiConfig) this.parentScreen).needsRefresh = true;
|
||||
}
|
||||
@@ -266,7 +267,7 @@ public class GuiConfig extends GuiScreen
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
if (flag)
|
||||
this.mc.displayGuiScreen(this.parentScreen);
|
||||
}
|
||||
@@ -281,7 +282,7 @@ public class GuiConfig extends GuiScreen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int mouseEvent)
|
||||
protected void mouseClicked(int x, int y, int mouseEvent) throws IOException
|
||||
{
|
||||
if (mouseEvent != 0 || !this.entryList.func_148179_a(x, y, mouseEvent))
|
||||
{
|
||||
@@ -291,11 +292,11 @@ public class GuiConfig extends GuiScreen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseMovedOrUp(int x, int y, int mouseEvent)
|
||||
protected void mouseReleased(int x, int y, int mouseEvent)
|
||||
{
|
||||
if (mouseEvent != 0 || !this.entryList.func_148181_b(x, y, mouseEvent))
|
||||
{
|
||||
super.mouseMovedOrUp(x, y, mouseEvent);
|
||||
super.mouseReleased(x, y, mouseEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,10 +326,10 @@ public class GuiConfig extends GuiScreen
|
||||
|
||||
if (title2 != null)
|
||||
{
|
||||
int strWidth = mc.fontRenderer.getStringWidth(title2);
|
||||
int elipsisWidth = mc.fontRenderer.getStringWidth("...");
|
||||
int strWidth = mc.fontRendererObj.getStringWidth(title2);
|
||||
int elipsisWidth = mc.fontRendererObj.getStringWidth("...");
|
||||
if (strWidth > width - 6 && strWidth > elipsisWidth)
|
||||
title2 = mc.fontRenderer.trimStringToWidth(title2, width - 6 - elipsisWidth).trim() + "...";
|
||||
title2 = mc.fontRendererObj.trimStringToWidth(title2, width - 6 - elipsisWidth).trim() + "...";
|
||||
this.drawCenteredString(this.fontRendererObj, title2, this.width / 2, 18, 16777215);
|
||||
}
|
||||
|
||||
@@ -337,16 +338,16 @@ public class GuiConfig extends GuiScreen
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
this.entryList.drawScreenPost(mouseX, mouseY, partialTicks);
|
||||
if (this.undoHoverChecker.checkHover(mouseX, mouseY))
|
||||
this.drawToolTip(this.mc.fontRenderer.listFormattedStringToWidth(I18n.format("fml.configgui.tooltip.undoAll"), 300), mouseX, mouseY);
|
||||
this.drawToolTip(this.mc.fontRendererObj.listFormattedStringToWidth(I18n.format("fml.configgui.tooltip.undoAll"), 300), mouseX, mouseY);
|
||||
if (this.resetHoverChecker.checkHover(mouseX, mouseY))
|
||||
this.drawToolTip(this.mc.fontRenderer.listFormattedStringToWidth(I18n.format("fml.configgui.tooltip.resetAll"), 300), mouseX, mouseY);
|
||||
this.drawToolTip(this.mc.fontRendererObj.listFormattedStringToWidth(I18n.format("fml.configgui.tooltip.resetAll"), 300), mouseX, mouseY);
|
||||
if (this.checkBoxHoverChecker.checkHover(mouseX, mouseY))
|
||||
this.drawToolTip(this.mc.fontRenderer.listFormattedStringToWidth(I18n.format("fml.configgui.tooltip.applyGlobally"), 300), mouseX, mouseY);
|
||||
this.drawToolTip(this.mc.fontRendererObj.listFormattedStringToWidth(I18n.format("fml.configgui.tooltip.applyGlobally"), 300), mouseX, mouseY);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void drawToolTip(List stringList, int x, int y)
|
||||
{
|
||||
this.func_146283_a(stringList, x, y);
|
||||
this.drawHoveringText(stringList, x, y);
|
||||
}
|
||||
}
|
||||
@@ -96,9 +96,9 @@ public class GuiConfigEntries extends GuiListExtended
|
||||
|
||||
// protects against language keys that are not defined in the .lang file
|
||||
if (!I18n.format(configElement.getLanguageKey()).equals(configElement.getLanguageKey()))
|
||||
length = mc.fontRenderer.getStringWidth(I18n.format(configElement.getLanguageKey()));
|
||||
length = mc.fontRendererObj.getStringWidth(I18n.format(configElement.getLanguageKey()));
|
||||
else
|
||||
length = mc.fontRenderer.getStringWidth(configElement.getName());
|
||||
length = mc.fontRendererObj.getStringWidth(configElement.getName());
|
||||
|
||||
if (length > this.maxLabelTextWidth)
|
||||
this.maxLabelTextWidth = length;
|
||||
@@ -575,10 +575,10 @@ public class GuiConfigEntries extends GuiListExtended
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, Tessellator tessellator, int mouseX, int mouseY, boolean isSelected)
|
||||
public void func_180790_a(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected)
|
||||
{
|
||||
this.btnValue.packedFGColour = GuiUtils.getColorCode(this.configElement.getValidValues()[currentIndex].charAt(0), true);
|
||||
super.drawEntry(slotIndex, x, y, listWidth, slotHeight, tessellator, mouseX, mouseY, isSelected);
|
||||
super.func_180790_a(slotIndex, x, y, listWidth, slotHeight, mouseX, mouseY, isSelected);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -927,9 +927,9 @@ public class GuiConfigEntries extends GuiListExtended
|
||||
public abstract void valueButtonPressed(int slotIndex);
|
||||
|
||||
@Override
|
||||
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, Tessellator tessellator, int mouseX, int mouseY, boolean isSelected)
|
||||
public void func_180790_a(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected)
|
||||
{
|
||||
super.drawEntry(slotIndex, x, y, listWidth, slotHeight, tessellator, mouseX, mouseY, isSelected);
|
||||
super.func_180790_a(slotIndex, x, y, listWidth, slotHeight, mouseX, mouseY, isSelected);
|
||||
this.btnValue.width = this.owningEntryList.controlWidth;
|
||||
this.btnValue.xPosition = this.owningScreen.entryList.controlX;
|
||||
this.btnValue.yPosition = y;
|
||||
@@ -945,7 +945,7 @@ public class GuiConfigEntries extends GuiListExtended
|
||||
{
|
||||
if (this.btnValue.mousePressed(this.mc, x, y))
|
||||
{
|
||||
btnValue.func_146113_a(mc.getSoundHandler());
|
||||
btnValue.playPressSound(mc.getSoundHandler());
|
||||
valueButtonPressed(index);
|
||||
updateValueButtonText();
|
||||
return true;
|
||||
@@ -1205,15 +1205,15 @@ public class GuiConfigEntries extends GuiListExtended
|
||||
{
|
||||
super(owningScreen, owningEntryList, configElement);
|
||||
beforeValue = configElement.get().toString();
|
||||
this.textFieldValue = new GuiTextField(this.mc.fontRenderer, this.owningEntryList.controlX + 1, 0, this.owningEntryList.controlWidth - 3, 16);
|
||||
this.textFieldValue = new GuiTextField(10, this.mc.fontRendererObj, this.owningEntryList.controlX + 1, 0, this.owningEntryList.controlWidth - 3, 16);
|
||||
this.textFieldValue.setMaxStringLength(10000);
|
||||
this.textFieldValue.setText(configElement.get().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, Tessellator tessellator, int mouseX, int mouseY, boolean isSelected)
|
||||
public void func_180790_a(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected)
|
||||
{
|
||||
super.drawEntry(slotIndex, x, y, listWidth, slotHeight, tessellator, mouseX, mouseY, isSelected);
|
||||
super.func_180790_a(slotIndex, x, y, listWidth, slotHeight, mouseX, mouseY, isSelected);
|
||||
this.textFieldValue.xPosition = this.owningEntryList.controlX + 2;
|
||||
this.textFieldValue.yPosition = y + 1;
|
||||
this.textFieldValue.width = this.owningEntryList.controlWidth - 4;
|
||||
@@ -1350,14 +1350,14 @@ public class GuiConfigEntries extends GuiListExtended
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, Tessellator tessellator, int mouseX, int mouseY, boolean isSelected)
|
||||
public void func_180790_a(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected)
|
||||
{
|
||||
this.btnSelectCategory.xPosition = listWidth / 2 - 150;
|
||||
this.btnSelectCategory.yPosition = y;
|
||||
this.btnSelectCategory.enabled = enabled();
|
||||
this.btnSelectCategory.drawButton(this.mc, mouseX, mouseY);
|
||||
|
||||
super.drawEntry(slotIndex, x, y, listWidth, slotHeight, tessellator, mouseX, mouseY, isSelected);
|
||||
super.func_180790_a(slotIndex, x, y, listWidth, slotHeight, mouseX, mouseY, isSelected);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1376,7 +1376,7 @@ public class GuiConfigEntries extends GuiListExtended
|
||||
{
|
||||
if (this.btnSelectCategory.mousePressed(this.mc, x, y))
|
||||
{
|
||||
btnSelectCategory.func_146113_a(mc.getSoundHandler());
|
||||
btnSelectCategory.playPressSound(mc.getSoundHandler());
|
||||
Minecraft.getMinecraft().displayGuiScreen(childScreen);
|
||||
return true;
|
||||
}
|
||||
@@ -1532,30 +1532,30 @@ public class GuiConfigEntries extends GuiListExtended
|
||||
comment = I18n.format(configElement.getLanguageKey() + ".tooltip").replace("\\n", "\n");
|
||||
|
||||
if (!comment.equals(configElement.getLanguageKey() + ".tooltip"))
|
||||
toolTip = new ArrayList<String>(this.mc.fontRenderer.listFormattedStringToWidth(
|
||||
toolTip = new ArrayList<String>(this.mc.fontRendererObj.listFormattedStringToWidth(
|
||||
EnumChatFormatting.GREEN + name + "\n" + EnumChatFormatting.YELLOW + comment, 300));
|
||||
else if (configElement.getComment() != null && !configElement.getComment().trim().isEmpty())
|
||||
toolTip = new ArrayList<String>(this.mc.fontRenderer.listFormattedStringToWidth(
|
||||
toolTip = new ArrayList<String>(this.mc.fontRendererObj.listFormattedStringToWidth(
|
||||
EnumChatFormatting.GREEN + name + "\n" + EnumChatFormatting.YELLOW + configElement.getComment(), 300));
|
||||
else
|
||||
toolTip = new ArrayList<String>(this.mc.fontRenderer.listFormattedStringToWidth(
|
||||
toolTip = new ArrayList<String>(this.mc.fontRendererObj.listFormattedStringToWidth(
|
||||
EnumChatFormatting.GREEN + name + "\n" + EnumChatFormatting.RED + "No tooltip defined.", 300));
|
||||
|
||||
if ((configElement.getType() == ConfigGuiType.INTEGER
|
||||
&& (Integer.valueOf(configElement.getMinValue().toString()) != Integer.MIN_VALUE || Integer.valueOf(configElement.getMaxValue().toString()) != Integer.MAX_VALUE))
|
||||
|| (configElement.getType() == ConfigGuiType.DOUBLE
|
||||
&& (Double.valueOf(configElement.getMinValue().toString()) != -Double.MAX_VALUE || Double.valueOf(configElement.getMaxValue().toString()) != Double.MAX_VALUE)))
|
||||
toolTip.addAll(this.mc.fontRenderer.listFormattedStringToWidth(
|
||||
toolTip.addAll(this.mc.fontRendererObj.listFormattedStringToWidth(
|
||||
EnumChatFormatting.AQUA + I18n.format("fml.configgui.tooltip.defaultNumeric", configElement.getMinValue(), configElement.getMaxValue(), configElement.getDefault()), 300));
|
||||
else if (configElement.getType() != ConfigGuiType.CONFIG_CATEGORY)
|
||||
toolTip.addAll(this.mc.fontRenderer.listFormattedStringToWidth(EnumChatFormatting.AQUA + I18n.format("fml.configgui.tooltip.default", configElement.getDefault()),300));
|
||||
toolTip.addAll(this.mc.fontRendererObj.listFormattedStringToWidth(EnumChatFormatting.AQUA + I18n.format("fml.configgui.tooltip.default", configElement.getDefault()),300));
|
||||
|
||||
if (configElement.requiresMcRestart() || owningScreen.allRequireMcRestart)
|
||||
toolTip.add(EnumChatFormatting.RED + "[" + I18n.format("fml.configgui.gameRestartTitle") + "]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, Tessellator tessellator, int mouseX, int mouseY, boolean isSelected)
|
||||
public void func_180790_a(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected)
|
||||
{
|
||||
boolean isChanged = isChanged();
|
||||
|
||||
@@ -1564,10 +1564,10 @@ public class GuiConfigEntries extends GuiListExtended
|
||||
String label = (!isValidValue ? EnumChatFormatting.RED.toString() :
|
||||
(isChanged ? EnumChatFormatting.WHITE.toString() : EnumChatFormatting.GRAY.toString()))
|
||||
+ (isChanged ? EnumChatFormatting.ITALIC.toString() : "") + this.name;
|
||||
this.mc.fontRenderer.drawString(
|
||||
this.mc.fontRendererObj.drawString(
|
||||
label,
|
||||
this.owningScreen.entryList.labelX,
|
||||
y + slotHeight / 2 - this.mc.fontRenderer.FONT_HEIGHT / 2,
|
||||
y + slotHeight / 2 - this.mc.fontRendererObj.FONT_HEIGHT / 2,
|
||||
16777215);
|
||||
}
|
||||
|
||||
@@ -1609,13 +1609,13 @@ public class GuiConfigEntries extends GuiListExtended
|
||||
{
|
||||
if (this.btnDefault.mousePressed(this.mc, x, y))
|
||||
{
|
||||
btnDefault.func_146113_a(mc.getSoundHandler());
|
||||
btnDefault.playPressSound(mc.getSoundHandler());
|
||||
setToDefault();
|
||||
return true;
|
||||
}
|
||||
else if (this.btnUndoChanges.mousePressed(this.mc, x, y))
|
||||
{
|
||||
btnUndoChanges.func_146113_a(mc.getSoundHandler());
|
||||
btnUndoChanges.playPressSound(mc.getSoundHandler());
|
||||
undoChanges();
|
||||
return true;
|
||||
}
|
||||
@@ -1652,6 +1652,9 @@ public class GuiConfigEntries extends GuiListExtended
|
||||
@Override
|
||||
public abstract boolean saveConfigElement();
|
||||
|
||||
@Override
|
||||
public void func_178011_a(int p_178011_1_, int p_178011_2_, int p_178011_3_){}
|
||||
|
||||
@Override
|
||||
public boolean enabled()
|
||||
{
|
||||
@@ -1661,7 +1664,7 @@ public class GuiConfigEntries extends GuiListExtended
|
||||
@Override
|
||||
public int getLabelWidth()
|
||||
{
|
||||
return this.mc.fontRenderer.getStringWidth(this.name);
|
||||
return this.mc.fontRendererObj.getStringWidth(this.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
package cpw.mods.fml.client.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -21,7 +22,6 @@ import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import static cpw.mods.fml.client.config.GuiUtils.RESET_CHAR;
|
||||
import static cpw.mods.fml.client.config.GuiUtils.UNDO_CHAR;
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.lwjgl.input.Keyboard;
|
||||
/**
|
||||
* This class is the base screen used for editing an array-type property. It provides a list of array entries for the user to edit.
|
||||
* This screen is invoked from a GuiConfig screen by controls that use the EditListPropEntry IGuiConfigListEntry object.
|
||||
*
|
||||
*
|
||||
* @author bspkrs
|
||||
*/
|
||||
public class GuiEditArray extends GuiScreen
|
||||
@@ -50,7 +50,7 @@ public class GuiEditArray extends GuiScreen
|
||||
@SuppressWarnings("rawtypes")
|
||||
private List toolTip;
|
||||
protected boolean enabled;
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public GuiEditArray(GuiScreen parentScreen, IConfigElement configElement, int slotIndex, Object[] currentValues, boolean enabled)
|
||||
{
|
||||
@@ -64,20 +64,20 @@ public class GuiEditArray extends GuiScreen
|
||||
this.enabled = enabled;
|
||||
String propName = I18n.format(configElement.getLanguageKey());
|
||||
String comment;
|
||||
|
||||
|
||||
comment = I18n.format(configElement.getLanguageKey() + ".tooltip",
|
||||
"\n" + EnumChatFormatting.AQUA, configElement.getDefault(), configElement.getMinValue(), configElement.getMaxValue());
|
||||
|
||||
|
||||
if (!comment.equals(configElement.getLanguageKey() + ".tooltip"))
|
||||
toolTip = mc.fontRenderer.listFormattedStringToWidth(
|
||||
toolTip = mc.fontRendererObj.listFormattedStringToWidth(
|
||||
EnumChatFormatting.GREEN + propName + "\n" + EnumChatFormatting.YELLOW + comment, 300);
|
||||
else if (configElement.getComment() != null && !configElement.getComment().trim().isEmpty())
|
||||
toolTip = mc.fontRenderer.listFormattedStringToWidth(
|
||||
toolTip = mc.fontRendererObj.listFormattedStringToWidth(
|
||||
EnumChatFormatting.GREEN + propName + "\n" + EnumChatFormatting.YELLOW + configElement.getComment(), 300);
|
||||
else
|
||||
toolTip = mc.fontRenderer.listFormattedStringToWidth(
|
||||
toolTip = mc.fontRendererObj.listFormattedStringToWidth(
|
||||
EnumChatFormatting.GREEN + propName + "\n" + EnumChatFormatting.RED + "No tooltip defined.", 300);
|
||||
|
||||
|
||||
if (parentScreen instanceof GuiConfig)
|
||||
{
|
||||
this.title = ((GuiConfig) parentScreen).title;
|
||||
@@ -96,18 +96,18 @@ public class GuiEditArray extends GuiScreen
|
||||
this.tooltipHoverChecker = new HoverChecker(8, 17, 0, parentScreen.width, 800);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
this.entryList = new GuiEditArrayEntries(this, this.mc, this.configElement, this.beforeValues, this.currentValues);
|
||||
|
||||
int undoGlyphWidth = mc.fontRenderer.getStringWidth(UNDO_CHAR) * 2;
|
||||
int resetGlyphWidth = mc.fontRenderer.getStringWidth(RESET_CHAR) * 2;
|
||||
int doneWidth = Math.max(mc.fontRenderer.getStringWidth(I18n.format("gui.done")) + 20, 100);
|
||||
int undoWidth = mc.fontRenderer.getStringWidth(" " + I18n.format("fml.configgui.tooltip.undoChanges")) + undoGlyphWidth + 20;
|
||||
int resetWidth = mc.fontRenderer.getStringWidth(" " + I18n.format("fml.configgui.tooltip.resetToDefault")) + resetGlyphWidth + 20;
|
||||
int undoGlyphWidth = mc.fontRendererObj.getStringWidth(UNDO_CHAR) * 2;
|
||||
int resetGlyphWidth = mc.fontRendererObj.getStringWidth(RESET_CHAR) * 2;
|
||||
int doneWidth = Math.max(mc.fontRendererObj.getStringWidth(I18n.format("gui.done")) + 20, 100);
|
||||
int undoWidth = mc.fontRendererObj.getStringWidth(" " + I18n.format("fml.configgui.tooltip.undoChanges")) + undoGlyphWidth + 20;
|
||||
int resetWidth = mc.fontRendererObj.getStringWidth(" " + I18n.format("fml.configgui.tooltip.resetToDefault")) + resetGlyphWidth + 20;
|
||||
int buttonWidthHalf = (doneWidth + 5 + undoWidth + 5 + resetWidth) / 2;
|
||||
this.buttonList.add(btnDone = new GuiButtonExt(2000, this.width / 2 - buttonWidthHalf, this.height - 29, doneWidth, 20, I18n.format("gui.done")));
|
||||
this.buttonList.add(btnDefault = new GuiUnicodeGlyphButton(2001, this.width / 2 - buttonWidthHalf + doneWidth + 5 + undoWidth + 5,
|
||||
@@ -115,7 +115,7 @@ public class GuiEditArray extends GuiScreen
|
||||
this.buttonList.add(btnUndoChanges = new GuiUnicodeGlyphButton(2002, this.width / 2 - buttonWidthHalf + doneWidth + 5,
|
||||
this.height - 29, undoWidth, 20, " " + I18n.format("fml.configgui.tooltip.undoChanges"), UNDO_CHAR, 2.0F));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button)
|
||||
{
|
||||
@@ -142,9 +142,9 @@ public class GuiEditArray extends GuiScreen
|
||||
this.entryList = new GuiEditArrayEntries(this, this.mc, this.configElement, this.beforeValues, this.currentValues);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int mouseEvent)
|
||||
protected void mouseClicked(int x, int y, int mouseEvent) throws IOException
|
||||
{
|
||||
if (mouseEvent != 0 || !this.entryList.func_148179_a(x, y, mouseEvent))
|
||||
{
|
||||
@@ -152,16 +152,16 @@ public class GuiEditArray extends GuiScreen
|
||||
super.mouseClicked(x, y, mouseEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void mouseMovedOrUp(int x, int y, int mouseEvent)
|
||||
protected void mouseReleased(int x, int y, int mouseEvent)
|
||||
{
|
||||
if (mouseEvent != 0 || !this.entryList.func_148181_b(x, y, mouseEvent))
|
||||
{
|
||||
super.mouseMovedOrUp(x, y, mouseEvent);
|
||||
super.mouseReleased(x, y, mouseEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char eventChar, int eventKey)
|
||||
{
|
||||
@@ -170,40 +170,40 @@ public class GuiEditArray extends GuiScreen
|
||||
else
|
||||
this.entryList.keyTyped(eventChar, eventKey);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateScreen()
|
||||
{
|
||||
super.updateScreen();
|
||||
this.entryList.updateScreen();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawScreen(int par1, int par2, float par3)
|
||||
{
|
||||
this.drawDefaultBackground();
|
||||
this.entryList.drawScreen(par1, par2, par3);
|
||||
this.drawCenteredString(this.fontRendererObj, this.title, this.width / 2, 8, 16777215);
|
||||
|
||||
|
||||
if (this.titleLine2 != null)
|
||||
this.drawCenteredString(this.fontRendererObj, this.titleLine2, this.width / 2, 18, 16777215);
|
||||
|
||||
|
||||
if (this.titleLine3 != null)
|
||||
this.drawCenteredString(this.fontRendererObj, this.titleLine3, this.width / 2, 28, 16777215);
|
||||
|
||||
|
||||
this.btnDone.enabled = this.entryList.isListSavable();
|
||||
this.btnDefault.enabled = enabled && !this.entryList.isDefault();
|
||||
this.btnUndoChanges.enabled = enabled && this.entryList.isChanged();
|
||||
super.drawScreen(par1, par2, par3);
|
||||
this.entryList.drawScreenPost(par1, par2, par3);
|
||||
|
||||
|
||||
if (this.tooltipHoverChecker != null && this.tooltipHoverChecker.checkHover(par1, par2))
|
||||
drawToolTip(this.toolTip, par1, par2);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void drawToolTip(List stringList, int x, int y)
|
||||
{
|
||||
this.func_146283_a(stringList, x, y);
|
||||
this.drawHoveringText(stringList, x, y);
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ import cpw.mods.fml.common.FMLLog;
|
||||
/**
|
||||
* This class implements the scrolling list functionality of the GuiEditList screen. It also provides all the default controls
|
||||
* for editing array-type properties.
|
||||
*
|
||||
*
|
||||
* @author bspkrs
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -68,7 +68,7 @@ public class GuiEditArrayEntries extends GuiListExtended
|
||||
listEntries = new ArrayList<IArrayEntry>();
|
||||
|
||||
controlWidth = (parent.width / 2) - (configElement.isListLengthFixed() ? 0 : 48);
|
||||
|
||||
|
||||
if (configElement.isList() && configElement.getArrayEntryClass() != null)
|
||||
{
|
||||
Class<? extends IArrayEntry> clazz = configElement.getArrayEntryClass();
|
||||
@@ -141,7 +141,7 @@ public class GuiEditArrayEntries extends GuiListExtended
|
||||
listEntries.add(index, new DoubleEntry(this.owningGui, this, this.configElement, 0.0D));
|
||||
else if (configElement.isList())
|
||||
listEntries.add(index, new StringEntry(this.owningGui, this, this.configElement, ""));
|
||||
this.canAddMoreEntries = !configElement.isListLengthFixed()
|
||||
this.canAddMoreEntries = !configElement.isListLengthFixed()
|
||||
&& (configElement.getMaxListLength() == -1 || this.listEntries.size() - 1 < configElement.getMaxListLength());
|
||||
keyTyped((char) Keyboard.CHAR_NONE, Keyboard.KEY_END);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public class GuiEditArrayEntries extends GuiListExtended
|
||||
public void removeEntry(int index)
|
||||
{
|
||||
this.listEntries.remove(index);
|
||||
this.canAddMoreEntries = !configElement.isListLengthFixed()
|
||||
this.canAddMoreEntries = !configElement.isListLengthFixed()
|
||||
&& (configElement.getMaxListLength() == -1 || this.listEntries.size() - 1 < configElement.getMaxListLength());
|
||||
keyTyped((char) Keyboard.CHAR_NONE, Keyboard.KEY_END);
|
||||
}
|
||||
@@ -343,7 +343,7 @@ public class GuiEditArrayEntries extends GuiListExtended
|
||||
}
|
||||
|
||||
public static class IntegerEntry extends StringEntry
|
||||
{
|
||||
{
|
||||
public IntegerEntry(GuiEditArray owningScreen, GuiEditArrayEntries owningEntryList, IConfigElement configElement, Integer value)
|
||||
{
|
||||
super(owningScreen, owningEntryList, configElement, value);
|
||||
@@ -405,7 +405,7 @@ public class GuiEditArrayEntries extends GuiListExtended
|
||||
public StringEntry(GuiEditArray owningScreen, GuiEditArrayEntries owningEntryList, IConfigElement configElement, Object value)
|
||||
{
|
||||
super(owningScreen, owningEntryList, configElement);
|
||||
this.textFieldValue = new GuiTextField(owningEntryList.mc.fontRenderer, owningEntryList.width / 4 + 1, 0, owningEntryList.controlWidth - 3, 16);
|
||||
this.textFieldValue = new GuiTextField(0, owningEntryList.mc.fontRendererObj, owningEntryList.width / 4 + 1, 0, owningEntryList.controlWidth - 3, 16);
|
||||
this.textFieldValue.setMaxStringLength(10000);
|
||||
this.textFieldValue.setText(value.toString());
|
||||
this.isValidated = configElement.getValidationPattern() != null;
|
||||
@@ -420,9 +420,9 @@ public class GuiEditArrayEntries extends GuiListExtended
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, Tessellator tessellator, int mouseX, int mouseY, boolean isSelected)
|
||||
public void func_180790_a(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected)
|
||||
{
|
||||
super.drawEntry(slotIndex, x, y, listWidth, slotHeight, tessellator, mouseX, mouseY, isSelected);
|
||||
super.func_180790_a(slotIndex, x, y, listWidth, slotHeight, mouseX, mouseY, isSelected);
|
||||
if (configElement.isListLengthFixed() || slotIndex != owningEntryList.listEntries.size() - 1)
|
||||
{
|
||||
this.textFieldValue.setVisible(true);
|
||||
@@ -486,9 +486,9 @@ public class GuiEditArrayEntries extends GuiListExtended
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, Tessellator tessellator, int mouseX, int mouseY, boolean isSelected)
|
||||
public void func_180790_a(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected)
|
||||
{
|
||||
super.drawEntry(slotIndex, x, y, listWidth, slotHeight, tessellator, mouseX, mouseY, isSelected);
|
||||
super.func_180790_a(slotIndex, x, y, listWidth, slotHeight, mouseX, mouseY, isSelected);
|
||||
this.btnValue.xPosition = listWidth / 4;
|
||||
this.btnValue.yPosition = y;
|
||||
|
||||
@@ -507,7 +507,7 @@ public class GuiEditArrayEntries extends GuiListExtended
|
||||
{
|
||||
if (this.btnValue.mousePressed(owningEntryList.mc, x, y))
|
||||
{
|
||||
btnValue.func_146113_a(owningEntryList.mc.getSoundHandler());
|
||||
btnValue.playPressSound(owningEntryList.mc.getSoundHandler());
|
||||
value = !value;
|
||||
owningEntryList.recalculateState();
|
||||
return true;
|
||||
@@ -564,13 +564,13 @@ public class GuiEditArrayEntries extends GuiListExtended
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, Tessellator tessellator, int mouseX, int mouseY, boolean isSelected)
|
||||
public void func_180790_a(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected)
|
||||
{
|
||||
if (this.getValue() != null && this.isValidated)
|
||||
owningEntryList.mc.fontRenderer.drawString(
|
||||
owningEntryList.mc.fontRendererObj.drawString(
|
||||
isValidValue ? EnumChatFormatting.GREEN + VALID : EnumChatFormatting.RED + INVALID,
|
||||
listWidth / 4 - owningEntryList.mc.fontRenderer.getStringWidth(VALID) - 2,
|
||||
y + slotHeight / 2 - owningEntryList.mc.fontRenderer.FONT_HEIGHT / 2,
|
||||
listWidth / 4 - owningEntryList.mc.fontRendererObj.getStringWidth(VALID) - 2,
|
||||
y + slotHeight / 2 - owningEntryList.mc.fontRendererObj.FONT_HEIGHT / 2,
|
||||
16777215);
|
||||
|
||||
int half = listWidth / 2;
|
||||
@@ -610,14 +610,14 @@ public class GuiEditArrayEntries extends GuiListExtended
|
||||
{
|
||||
if (this.btnAddNewEntryAbove.mousePressed(owningEntryList.mc, x, y))
|
||||
{
|
||||
btnAddNewEntryAbove.func_146113_a(owningEntryList.mc.getSoundHandler());
|
||||
btnAddNewEntryAbove.playPressSound(owningEntryList.mc.getSoundHandler());
|
||||
owningEntryList.addNewEntry(index);
|
||||
owningEntryList.recalculateState();
|
||||
return true;
|
||||
}
|
||||
else if (this.btnRemoveEntry.mousePressed(owningEntryList.mc, x, y))
|
||||
{
|
||||
btnRemoveEntry.func_146113_a(owningEntryList.mc.getSoundHandler());
|
||||
btnRemoveEntry.playPressSound(owningEntryList.mc.getSoundHandler());
|
||||
owningEntryList.removeEntry(index);
|
||||
owningEntryList.recalculateState();
|
||||
return true;
|
||||
@@ -656,6 +656,9 @@ public class GuiEditArrayEntries extends GuiListExtended
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_178011_a(int p_178011_1_, int p_178011_2_, int p_178011_3_){}
|
||||
}
|
||||
|
||||
public static interface IArrayEntry extends GuiListExtended.IGuiListEntry
|
||||
|
||||
@@ -27,7 +27,7 @@ import static cpw.mods.fml.client.config.GuiUtils.UNDO_CHAR;
|
||||
|
||||
/**
|
||||
* This class provides a screen that allows the user to select a value from a list.
|
||||
*
|
||||
*
|
||||
* @author bspkrs
|
||||
*/
|
||||
public class GuiSelectString extends GuiScreen
|
||||
@@ -68,13 +68,13 @@ public class GuiSelectString extends GuiScreen
|
||||
"\n" + EnumChatFormatting.AQUA, configElement.getDefault(), configElement.getMinValue(), configElement.getMaxValue());
|
||||
|
||||
if (!comment.equals(configElement.getLanguageKey() + ".tooltip"))
|
||||
toolTip = mc.fontRenderer.listFormattedStringToWidth(
|
||||
toolTip = mc.fontRendererObj.listFormattedStringToWidth(
|
||||
EnumChatFormatting.GREEN + propName + "\n" + EnumChatFormatting.YELLOW + comment, 300);
|
||||
else if (configElement.getComment() != null && !configElement.getComment().trim().isEmpty())
|
||||
toolTip = mc.fontRenderer.listFormattedStringToWidth(
|
||||
toolTip = mc.fontRendererObj.listFormattedStringToWidth(
|
||||
EnumChatFormatting.GREEN + propName + "\n" + EnumChatFormatting.YELLOW + configElement.getComment(), 300);
|
||||
else
|
||||
toolTip = mc.fontRenderer.listFormattedStringToWidth(
|
||||
toolTip = mc.fontRendererObj.listFormattedStringToWidth(
|
||||
EnumChatFormatting.GREEN + propName + "\n" + EnumChatFormatting.RED + "No tooltip defined.", 300);
|
||||
|
||||
if (parentScreen instanceof GuiConfig)
|
||||
@@ -98,11 +98,11 @@ public class GuiSelectString extends GuiScreen
|
||||
{
|
||||
this.entriesList = new GuiSelectStringEntries(this, this.mc, this.configElement, this.selectableValues);
|
||||
|
||||
int undoGlyphWidth = mc.fontRenderer.getStringWidth(UNDO_CHAR) * 2;
|
||||
int resetGlyphWidth = mc.fontRenderer.getStringWidth(RESET_CHAR) * 2;
|
||||
int doneWidth = Math.max(mc.fontRenderer.getStringWidth(I18n.format("gui.done")) + 20, 100);
|
||||
int undoWidth = mc.fontRenderer.getStringWidth(" " + I18n.format("fml.configgui.tooltip.undoChanges")) + undoGlyphWidth + 20;
|
||||
int resetWidth = mc.fontRenderer.getStringWidth(" " + I18n.format("fml.configgui.tooltip.resetToDefault")) + resetGlyphWidth + 20;
|
||||
int undoGlyphWidth = mc.fontRendererObj.getStringWidth(UNDO_CHAR) * 2;
|
||||
int resetGlyphWidth = mc.fontRendererObj.getStringWidth(RESET_CHAR) * 2;
|
||||
int doneWidth = Math.max(mc.fontRendererObj.getStringWidth(I18n.format("gui.done")) + 20, 100);
|
||||
int undoWidth = mc.fontRendererObj.getStringWidth(" " + I18n.format("fml.configgui.tooltip.undoChanges")) + undoGlyphWidth + 20;
|
||||
int resetWidth = mc.fontRendererObj.getStringWidth(" " + I18n.format("fml.configgui.tooltip.resetToDefault")) + resetGlyphWidth + 20;
|
||||
int buttonWidthHalf = (doneWidth + 5 + undoWidth + 5 + resetWidth) / 2;
|
||||
this.buttonList.add(btnDone = new GuiButtonExt(2000, this.width / 2 - buttonWidthHalf, this.height - 29, doneWidth, 20, I18n.format("gui.done")));
|
||||
this.buttonList.add(btnDefault = new GuiUnicodeGlyphButton(2001, this.width / 2 - buttonWidthHalf + doneWidth + 5 + undoWidth + 5,
|
||||
@@ -139,11 +139,11 @@ public class GuiSelectString extends GuiScreen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseMovedOrUp(int x, int y, int mouseEvent)
|
||||
protected void mouseReleased(int x, int y, int mouseEvent)
|
||||
{
|
||||
if (mouseEvent != 0 || !this.entriesList.func_148181_b(x, y, mouseEvent))
|
||||
{
|
||||
super.mouseMovedOrUp(x, y, mouseEvent);
|
||||
super.mouseReleased(x, y, mouseEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,6 +172,6 @@ public class GuiSelectString extends GuiScreen
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void drawToolTip(List stringList, int x, int y)
|
||||
{
|
||||
this.func_146283_a(stringList, x, y);
|
||||
this.drawHoveringText(stringList, x, y);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import cpw.mods.fml.client.config.GuiConfigEntries.SelectValueEntry;
|
||||
|
||||
/**
|
||||
* This class implements the scrolling list functionality of the GuiSelectString screen.
|
||||
*
|
||||
*
|
||||
* @author bspkrs
|
||||
*/
|
||||
public class GuiSelectStringEntries extends GuiListExtended
|
||||
@@ -40,53 +40,53 @@ public class GuiSelectStringEntries extends GuiListExtended
|
||||
public final Map<Object, String> selectableValues;
|
||||
public int selectedIndex = -1;
|
||||
public int maxEntryWidth = 0;
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public GuiSelectStringEntries(GuiSelectString owningScreen, Minecraft mc, IConfigElement configElement, Map<Object, String> selectableValues)
|
||||
{
|
||||
super(mc, owningScreen.width, owningScreen.height, owningScreen.titleLine2 != null ? (owningScreen.titleLine3 != null ? 43 : 33) : 23,
|
||||
super(mc, owningScreen.width, owningScreen.height, owningScreen.titleLine2 != null ? (owningScreen.titleLine3 != null ? 43 : 33) : 23,
|
||||
owningScreen.height - 32, 11);
|
||||
this.owningScreen = owningScreen;
|
||||
this.mc = mc;
|
||||
this.configElement = configElement;
|
||||
this.selectableValues = selectableValues;
|
||||
this.setShowSelectionBox(true);
|
||||
|
||||
|
||||
listEntries = new ArrayList<IGuiSelectStringListEntry>();
|
||||
|
||||
|
||||
int index = 0;
|
||||
List<Entry<Object, String>> sortedList = new ArrayList<Entry<Object, String>>(selectableValues.entrySet());
|
||||
Collections.sort(sortedList, new EntryComparator());
|
||||
|
||||
|
||||
for (Entry<Object, String> entry : sortedList)
|
||||
{
|
||||
listEntries.add(new ListEntry(this, entry));
|
||||
if (mc.fontRenderer.getStringWidth(entry.getValue()) > maxEntryWidth)
|
||||
maxEntryWidth = mc.fontRenderer.getStringWidth(entry.getValue());
|
||||
|
||||
if (mc.fontRendererObj.getStringWidth(entry.getValue()) > maxEntryWidth)
|
||||
maxEntryWidth = mc.fontRendererObj.getStringWidth(entry.getValue());
|
||||
|
||||
if (owningScreen.currentValue.equals(entry.getKey()))
|
||||
{
|
||||
this.selectedIndex = index;
|
||||
}
|
||||
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class EntryComparator implements Comparator<Entry<Object, String>>
|
||||
{
|
||||
@Override
|
||||
public int compare(Entry<Object, String> o1, Entry<Object, String> o2)
|
||||
{
|
||||
int compare = o1.getValue().toLowerCase(Locale.US).compareTo(o2.getValue().toLowerCase(Locale.US));
|
||||
|
||||
|
||||
if (compare == 0)
|
||||
compare = o1.getKey().toString().toLowerCase(Locale.US).compareTo(o2.getKey().toString().toLowerCase(Locale.US));
|
||||
|
||||
|
||||
return compare;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The element in the slot that was clicked, boolean for whether it was double clicked or not
|
||||
*/
|
||||
@@ -96,7 +96,7 @@ public class GuiSelectStringEntries extends GuiListExtended
|
||||
selectedIndex = index;
|
||||
owningScreen.currentValue = listEntries.get(index).getValue();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the element passed in is currently selected
|
||||
*/
|
||||
@@ -105,13 +105,13 @@ public class GuiSelectStringEntries extends GuiListExtended
|
||||
{
|
||||
return index == selectedIndex;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getScrollBarX()
|
||||
{
|
||||
return width / 2 + this.maxEntryWidth / 2 + 5;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the width of the list
|
||||
*/
|
||||
@@ -120,29 +120,29 @@ public class GuiSelectStringEntries extends GuiListExtended
|
||||
{
|
||||
return maxEntryWidth + 5;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IGuiSelectStringListEntry getListEntry(int index)
|
||||
{
|
||||
return listEntries.get(index);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getSize()
|
||||
{
|
||||
return listEntries.size();
|
||||
}
|
||||
|
||||
|
||||
public boolean isChanged()
|
||||
{
|
||||
return owningScreen.beforeValue != null ? !owningScreen.beforeValue.equals(owningScreen.currentValue) : owningScreen.currentValue != null;
|
||||
}
|
||||
|
||||
|
||||
public boolean isDefault()
|
||||
{
|
||||
return owningScreen.currentValue != null ? owningScreen.currentValue.equals(configElement.getDefault()) : configElement.getDefault() == null;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void saveChanges()
|
||||
{
|
||||
@@ -151,47 +151,50 @@ public class GuiSelectStringEntries extends GuiListExtended
|
||||
&& ((GuiConfig) owningScreen.parentScreen).entryList.getListEntry(owningScreen.slotIndex) instanceof SelectValueEntry)
|
||||
{
|
||||
SelectValueEntry entry = (SelectValueEntry) ((GuiConfig) owningScreen.parentScreen).entryList.getListEntry(owningScreen.slotIndex);
|
||||
|
||||
|
||||
entry.setValueFromChildScreen(owningScreen.currentValue);
|
||||
}
|
||||
else
|
||||
configElement.set(owningScreen.currentValue);
|
||||
}
|
||||
|
||||
|
||||
public static class ListEntry implements IGuiSelectStringListEntry
|
||||
{
|
||||
protected final GuiSelectStringEntries owningList;
|
||||
protected final Entry<Object, String> value;
|
||||
|
||||
|
||||
public ListEntry(GuiSelectStringEntries owningList, Entry<Object, String> value)
|
||||
{
|
||||
this.owningList = owningList;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, Tessellator tessellator, int mouseX, int mouseY, boolean isSelected)
|
||||
public void func_180790_a(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected)
|
||||
{
|
||||
owningList.mc.fontRenderer.drawString(value.getValue(), x + 1, y, slotIndex == owningList.selectedIndex ? 16777215 : 14737632);
|
||||
owningList.mc.fontRendererObj.drawString(value.getValue(), x + 1, y, slotIndex == owningList.selectedIndex ? 16777215 : 14737632);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(int index, int x, int y, int mouseEvent, int relativeX, int relativeY)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int index, int x, int y, int mouseEvent, int relativeX, int relativeY)
|
||||
{}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getValue()
|
||||
{
|
||||
return value.getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_178011_a(int p_178011_1_, int p_178011_2_, int p_178011_3_){}
|
||||
}
|
||||
|
||||
|
||||
public static interface IGuiSelectStringListEntry extends GuiListExtended.IGuiListEntry
|
||||
{
|
||||
public Object getValue();
|
||||
|
||||
@@ -18,32 +18,32 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* This class provides a button that shows a string glyph at the beginning. The glyph can be scaled using the glyphScale parameter.
|
||||
*
|
||||
*
|
||||
* @author bspkrs
|
||||
*/
|
||||
public class GuiUnicodeGlyphButton extends GuiButtonExt
|
||||
{
|
||||
public String glyph;
|
||||
public float glyphScale;
|
||||
|
||||
|
||||
public GuiUnicodeGlyphButton(int id, int xPos, int yPos, int width, int height, String displayString, String glyph, float glyphScale)
|
||||
{
|
||||
super(id, xPos, yPos, width, height, displayString);
|
||||
this.glyph = glyph;
|
||||
this.glyphScale = glyphScale;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY)
|
||||
{
|
||||
if (this.visible)
|
||||
{
|
||||
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||
int k = this.getHoverState(this.field_146123_n);
|
||||
this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||
int k = this.getHoverState(this.hovered);
|
||||
GuiUtils.drawContinuousTexturedBox(buttonTextures, this.xPosition, this.yPosition, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.zLevel);
|
||||
this.mouseDragged(mc, mouseX, mouseY);
|
||||
int color = 14737632;
|
||||
|
||||
|
||||
if (packedFGColour != 0)
|
||||
{
|
||||
color = packedFGColour;
|
||||
@@ -52,31 +52,31 @@ public class GuiUnicodeGlyphButton extends GuiButtonExt
|
||||
{
|
||||
color = 10526880;
|
||||
}
|
||||
else if (this.field_146123_n)
|
||||
else if (this.hovered)
|
||||
{
|
||||
color = 16777120;
|
||||
}
|
||||
|
||||
|
||||
String buttonText = this.displayString;
|
||||
int glyphWidth = (int) (mc.fontRenderer.getStringWidth(glyph) * glyphScale);
|
||||
int strWidth = mc.fontRenderer.getStringWidth(buttonText);
|
||||
int elipsisWidth = mc.fontRenderer.getStringWidth("...");
|
||||
int glyphWidth = (int) (mc.fontRendererObj.getStringWidth(glyph) * glyphScale);
|
||||
int strWidth = mc.fontRendererObj.getStringWidth(buttonText);
|
||||
int elipsisWidth = mc.fontRendererObj.getStringWidth("...");
|
||||
int totalWidth = strWidth + glyphWidth;
|
||||
|
||||
|
||||
if (totalWidth > width - 6 && totalWidth > elipsisWidth)
|
||||
buttonText = mc.fontRenderer.trimStringToWidth(buttonText, width - 6 - elipsisWidth).trim() + "...";
|
||||
|
||||
strWidth = mc.fontRenderer.getStringWidth(buttonText);
|
||||
buttonText = mc.fontRendererObj.trimStringToWidth(buttonText, width - 6 - elipsisWidth).trim() + "...";
|
||||
|
||||
strWidth = mc.fontRendererObj.getStringWidth(buttonText);
|
||||
totalWidth = glyphWidth + strWidth;
|
||||
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(glyphScale, glyphScale, 1.0F);
|
||||
this.drawCenteredString(mc.fontRenderer, glyph,
|
||||
this.drawCenteredString(mc.fontRendererObj, glyph,
|
||||
(int) (((this.xPosition + (this.width / 2) - (strWidth / 2)) / glyphScale) - (glyphWidth / (2 * glyphScale)) + 2),
|
||||
(int) (((this.yPosition + ((this.height - 8) / glyphScale) / 2) - 1) / glyphScale), color);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
this.drawCenteredString(mc.fontRenderer, buttonText, (int) (this.xPosition + (this.width / 2) + (glyphWidth / glyphScale)),
|
||||
|
||||
this.drawCenteredString(mc.fontRendererObj, buttonText, (int) (this.xPosition + (this.width / 2) + (glyphWidth / glyphScale)),
|
||||
this.yPosition + (this.height - 8) / 2, color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,22 +15,23 @@ package cpw.mods.fml.client.config;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* This class provides several methods and constants used by the Config GUI classes.
|
||||
*
|
||||
*
|
||||
* @author bspkrs
|
||||
*/
|
||||
public class GuiUtils
|
||||
public class GuiUtils
|
||||
{
|
||||
public static final String UNDO_CHAR = "\u21B6";
|
||||
public static final String RESET_CHAR = "\u2604";
|
||||
public static final String VALID = "\u2714";
|
||||
public static final String INVALID = "\u2715";
|
||||
|
||||
|
||||
private static int[] colorCodes = new int[] { 0, 170, 43520, 43690, 11141120, 11141290, 16755200, 11184810, 5592405, 5592575, 5635925, 5636095, 16733525, 16733695, 16777045, 16777215,
|
||||
0, 42, 10752, 10794, 2752512, 2752554, 2763264, 2763306, 1381653, 1381695, 1392405, 1392447, 4134165, 4134207, 4144917, 4144959 };
|
||||
|
||||
@@ -42,7 +43,7 @@ public class GuiUtils
|
||||
* Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders
|
||||
* and filler. It is assumed that the desired texture ResourceLocation object has been bound using
|
||||
* Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).
|
||||
*
|
||||
*
|
||||
* @param x x axis offset
|
||||
* @param y y axis offset
|
||||
* @param u bound resource location image x offset
|
||||
@@ -59,12 +60,12 @@ public class GuiUtils
|
||||
{
|
||||
drawContinuousTexturedBox(x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize, zLevel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders
|
||||
* and filler. The provided ResourceLocation object will be bound using
|
||||
* Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).
|
||||
*
|
||||
*
|
||||
* @param res the ResourceLocation object that contains the desired image
|
||||
* @param x x axis offset
|
||||
* @param y y axis offset
|
||||
@@ -82,12 +83,12 @@ public class GuiUtils
|
||||
{
|
||||
drawContinuousTexturedBox(res, x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize, zLevel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders
|
||||
* and filler. The provided ResourceLocation object will be bound using
|
||||
* Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).
|
||||
*
|
||||
*
|
||||
* @param res the ResourceLocation object that contains the desired image
|
||||
* @param x x axis offset
|
||||
* @param y y axis offset
|
||||
@@ -109,12 +110,12 @@ public class GuiUtils
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(res);
|
||||
drawContinuousTexturedBox(x, y, u, v, width, height, textureWidth, textureHeight, topBorder, bottomBorder, leftBorder, rightBorder, zLevel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders
|
||||
* and filler. It is assumed that the desired texture ResourceLocation object has been bound using
|
||||
* Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).
|
||||
*
|
||||
*
|
||||
* @param x x axis offset
|
||||
* @param y y axis offset
|
||||
* @param u bound resource location image x offset
|
||||
@@ -136,7 +137,7 @@ public class GuiUtils
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
|
||||
int fillerWidth = textureWidth - leftBorder - rightBorder;
|
||||
int fillerHeight = textureHeight - topBorder - bottomBorder;
|
||||
int canvasWidth = width - leftBorder - rightBorder;
|
||||
@@ -145,7 +146,7 @@ public class GuiUtils
|
||||
int remainderWidth = canvasWidth % fillerWidth;
|
||||
int yPasses = canvasHeight / fillerHeight;
|
||||
int remainderHeight = canvasHeight % fillerHeight;
|
||||
|
||||
|
||||
// Draw Border
|
||||
// Top Left
|
||||
drawTexturedModalRect(x, y, u, v, leftBorder, topBorder, zLevel);
|
||||
@@ -155,19 +156,19 @@ public class GuiUtils
|
||||
drawTexturedModalRect(x, y + topBorder + canvasHeight, u, v + topBorder + fillerHeight, leftBorder, bottomBorder, zLevel);
|
||||
// Bottom Right
|
||||
drawTexturedModalRect(x + leftBorder + canvasWidth, y + topBorder + canvasHeight, u + leftBorder + fillerWidth, v + topBorder + fillerHeight, rightBorder, bottomBorder, zLevel);
|
||||
|
||||
|
||||
for (int i = 0; i < xPasses + (remainderWidth > 0 ? 1 : 0); i++)
|
||||
{
|
||||
// Top Border
|
||||
drawTexturedModalRect(x + leftBorder + (i * fillerWidth), y, u + leftBorder, v, (i == xPasses ? remainderWidth : fillerWidth), topBorder, zLevel);
|
||||
// Bottom Border
|
||||
drawTexturedModalRect(x + leftBorder + (i * fillerWidth), y + topBorder + canvasHeight, u + leftBorder, v + topBorder + fillerHeight, (i == xPasses ? remainderWidth : fillerWidth), bottomBorder, zLevel);
|
||||
|
||||
|
||||
// Throw in some filler for good measure
|
||||
for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++)
|
||||
drawTexturedModalRect(x + leftBorder + (i * fillerWidth), y + topBorder + (j * fillerHeight), u + leftBorder, v + topBorder, (i == xPasses ? remainderWidth : fillerWidth), (j == yPasses ? remainderHeight : fillerHeight), zLevel);
|
||||
}
|
||||
|
||||
|
||||
// Side Borders
|
||||
for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++)
|
||||
{
|
||||
@@ -177,17 +178,18 @@ public class GuiUtils
|
||||
drawTexturedModalRect(x + leftBorder + canvasWidth, y + topBorder + (j * fillerHeight), u + leftBorder + fillerWidth, v + topBorder, rightBorder, (j == yPasses ? remainderHeight : fillerHeight), zLevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void drawTexturedModalRect(int x, int y, int u, int v, int width, int height, float zLevel)
|
||||
{
|
||||
float var7 = 0.00390625F;
|
||||
float var8 = 0.00390625F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV((x + 0), (y + height), zLevel, ((u + 0) * var7), ((v + height) * var8));
|
||||
tessellator.addVertexWithUV((x + width), (y + height), zLevel, ((u + width) * var7), ((v + height) * var8));
|
||||
tessellator.addVertexWithUV((x + width), (y + 0), zLevel, ((u + width) * var7), ((v + 0) * var8));
|
||||
tessellator.addVertexWithUV((x + 0), (y + 0), zLevel, ((u + 0) * var7), ((v + 0) * var8));
|
||||
Tessellator tessellator = Tessellator.func_178181_a();
|
||||
WorldRenderer worldr = tessellator.func_178180_c();
|
||||
worldr.func_178970_b();
|
||||
worldr.func_178985_a((x + 0), (y + height), zLevel, ((u + 0) * var7), ((v + height) * var8));
|
||||
worldr.func_178985_a((x + width), (y + height), zLevel, ((u + width) * var7), ((v + height) * var8));
|
||||
worldr.func_178985_a((x + width), (y + 0), zLevel, ((u + width) * var7), ((v + 0) * var8));
|
||||
worldr.func_178985_a((x + 0), (y + 0), zLevel, ((u + 0) * var7), ((v + 0) * var8));
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.client.registry;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public interface ISimpleBlockRenderingHandler
|
||||
{
|
||||
public abstract void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer);
|
||||
|
||||
public abstract boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer);
|
||||
|
||||
public abstract boolean shouldRender3DInInventory(int modelId);
|
||||
|
||||
public abstract int getRenderId();
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderBiped;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
@@ -35,23 +35,8 @@ public class RenderingRegistry
|
||||
{
|
||||
private static final RenderingRegistry INSTANCE = new RenderingRegistry();
|
||||
|
||||
private int nextRenderId = 42;
|
||||
|
||||
private Map<Integer, ISimpleBlockRenderingHandler> blockRenderers = Maps.newHashMap();
|
||||
|
||||
private List<EntityRendererInfo> entityRenderers = Lists.newArrayList();
|
||||
|
||||
/**
|
||||
* Add a new armour prefix to the RenderPlayer
|
||||
*
|
||||
* @param armor
|
||||
*/
|
||||
public static int addNewArmourRendererPrefix(String armor)
|
||||
{
|
||||
RenderBiped.bipedArmorFilenamePrefix = ObjectArrays.concat(RenderBiped.bipedArmorFilenamePrefix, armor);
|
||||
return RenderBiped.bipedArmorFilenamePrefix.length - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an entity rendering handler. This will, after mod initialization, be inserted into the main
|
||||
* render map for entities
|
||||
@@ -64,37 +49,6 @@ public class RenderingRegistry
|
||||
instance().entityRenderers.add(new EntityRendererInfo(entityClass, renderer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a simple block rendering handler
|
||||
*
|
||||
* @param handler
|
||||
*/
|
||||
public static void registerBlockHandler(ISimpleBlockRenderingHandler handler)
|
||||
{
|
||||
instance().blockRenderers.put(handler.getRenderId(), handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the simple block rendering handler
|
||||
* This version will not call getRenderId on the passed in handler, instead using the supplied ID, so you
|
||||
* can easily re-use the same rendering handler for multiple IDs
|
||||
*
|
||||
* @param renderId
|
||||
* @param handler
|
||||
*/
|
||||
public static void registerBlockHandler(int renderId, ISimpleBlockRenderingHandler handler)
|
||||
{
|
||||
instance().blockRenderers.put(renderId, handler);
|
||||
}
|
||||
/**
|
||||
* Get the next available renderId from the block render ID list
|
||||
*/
|
||||
public static int getNextAvailableRenderId()
|
||||
{
|
||||
return instance().nextRenderId++;
|
||||
}
|
||||
|
||||
|
||||
@Deprecated public static RenderingRegistry instance()
|
||||
{
|
||||
return INSTANCE;
|
||||
@@ -111,32 +65,13 @@ public class RenderingRegistry
|
||||
private Render renderer;
|
||||
}
|
||||
|
||||
public boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelId)
|
||||
{
|
||||
if (!blockRenderers.containsKey(modelId)) { return false; }
|
||||
ISimpleBlockRenderingHandler bri = blockRenderers.get(modelId);
|
||||
return bri.renderWorldBlock(world, x, y, z, block, modelId, renderer);
|
||||
}
|
||||
|
||||
public void renderInventoryBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
|
||||
{
|
||||
if (!blockRenderers.containsKey(modelID)) { return; }
|
||||
ISimpleBlockRenderingHandler bri = blockRenderers.get(modelID);
|
||||
bri.renderInventoryBlock(block, metadata, modelID, renderer);
|
||||
}
|
||||
|
||||
public boolean renderItemAsFull3DBlock(int modelId)
|
||||
{
|
||||
ISimpleBlockRenderingHandler bri = blockRenderers.get(modelId);
|
||||
return bri != null && bri.shouldRender3DInInventory(modelId);
|
||||
}
|
||||
|
||||
/*
|
||||
public void loadEntityRenderers(Map<Class<? extends Entity>, Render> rendererMap)
|
||||
{
|
||||
for (EntityRendererInfo info : entityRenderers)
|
||||
{
|
||||
rendererMap.put(info.target, info.renderer);
|
||||
info.renderer.setRenderManager(RenderManager.instance);
|
||||
info.renderer.setRenderManager(Minecraft.getMinecraft().func_175598_ae());
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -580,11 +580,6 @@ public class FMLCommonHandler
|
||||
return sidedDelegate.getClientPlayHandler();
|
||||
}
|
||||
|
||||
public void waitForPlayClient()
|
||||
{
|
||||
sidedDelegate.waitForPlayClient();
|
||||
}
|
||||
|
||||
public void fireNetRegistrationEvent(NetworkManager manager, Set<String> channelSet, String channel, Side side)
|
||||
{
|
||||
sidedDelegate.fireNetRegistrationEvent(bus(), manager, channelSet, channel, side);
|
||||
|
||||
@@ -54,8 +54,6 @@ public interface IFMLSidedHandler
|
||||
|
||||
INetHandler getClientPlayHandler();
|
||||
|
||||
void waitForPlayClient();
|
||||
|
||||
void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set<String> channelSet, String channel, Side side);
|
||||
|
||||
boolean shouldAllowPlayerLogins();
|
||||
|
||||
@@ -105,7 +105,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
*/
|
||||
public class Loader
|
||||
{
|
||||
public static final String MC_VERSION = "1.7.10";
|
||||
public static final String MC_VERSION = "1.8";
|
||||
private static final Splitter DEPENDENCYPARTSPLITTER = Splitter.on(":").omitEmptyStrings().trimResults();
|
||||
private static final Splitter DEPENDENCYSPLITTER = Splitter.on(";").omitEmptyStrings().trimResults();
|
||||
/**
|
||||
|
||||
@@ -49,7 +49,6 @@ public enum LoaderState
|
||||
|
||||
|
||||
private Class<? extends FMLStateEvent> eventClass;
|
||||
@SuppressWarnings("unused")
|
||||
private String name;
|
||||
|
||||
private LoaderState(String name, Class<? extends FMLStateEvent> event)
|
||||
|
||||
@@ -34,7 +34,6 @@ import cpw.mods.fml.common.versioning.VersionParser;
|
||||
|
||||
public class MetadataCollection
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
private String modListVersion;
|
||||
private ModMetadata[] modList;
|
||||
private Map<String, ModMetadata> metadatas = Maps.newHashMap();
|
||||
|
||||
@@ -22,7 +22,6 @@ import cpw.mods.fml.common.versioning.VersionParser;
|
||||
|
||||
public class ModAPIManager {
|
||||
public static final ModAPIManager INSTANCE = new ModAPIManager();
|
||||
@SuppressWarnings("unused")
|
||||
private ModAPITransformer transformer;
|
||||
private ASMDataTable dataTable;
|
||||
private Map<String,APIContainer> apiContainers;
|
||||
|
||||
@@ -27,9 +27,7 @@ public class ModAnnotation
|
||||
{
|
||||
public class EnumHolder
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
private String desc;
|
||||
@SuppressWarnings("unused")
|
||||
private String value;
|
||||
|
||||
public EnumHolder(String desc, String value)
|
||||
|
||||
@@ -19,7 +19,6 @@ public class ModAnnotationVisitor extends AnnotationVisitor
|
||||
{
|
||||
private ASMModParser discoverer;
|
||||
private boolean array;
|
||||
@SuppressWarnings("unused")
|
||||
private String name;
|
||||
private boolean isSubAnnotation;
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ public class EventBus implements IEventExceptionHandler
|
||||
{
|
||||
ListenerList.resize(busID + 1);
|
||||
exceptionHandler = this;
|
||||
register(this);
|
||||
}
|
||||
|
||||
public EventBus(@Nonnull IEventExceptionHandler handler)
|
||||
|
||||
@@ -144,14 +144,7 @@ public class ByteBufUtils {
|
||||
public static void writeItemStack(ByteBuf to, ItemStack stack)
|
||||
{
|
||||
PacketBuffer pb = new PacketBuffer(to);
|
||||
try
|
||||
{
|
||||
pb.writeItemStackToBuffer(stack);
|
||||
} catch (IOException e)
|
||||
{
|
||||
// Unpossible?
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
pb.writeItemStackToBuffer(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,14 +175,7 @@ public class ByteBufUtils {
|
||||
public static void writeTag(ByteBuf to, NBTTagCompound tag)
|
||||
{
|
||||
PacketBuffer pb = new PacketBuffer(to);
|
||||
try
|
||||
{
|
||||
pb.writeNBTTagCompoundToBuffer(tag);
|
||||
} catch (IOException e)
|
||||
{
|
||||
// Unpossible?
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
pb.writeNBTTagCompoundToBuffer(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,7 +42,7 @@ public class FMLEventChannel {
|
||||
if (msg.handler() instanceof NetHandlerPlayServer)
|
||||
{
|
||||
NetHandlerPlayServer server = (NetHandlerPlayServer) msg.handler();
|
||||
event = new FMLNetworkEvent.ServerCustomPacketEvent(server.func_147362_b(), msg);
|
||||
event = new FMLNetworkEvent.ServerCustomPacketEvent(server.getNetworkManager(), msg);
|
||||
}
|
||||
return event;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class FMLEventChannel {
|
||||
else if (msg.handler() instanceof NetHandlerPlayServer)
|
||||
{
|
||||
NetHandlerPlayServer server = (NetHandlerPlayServer) msg.handler();
|
||||
event = new FMLNetworkEvent.ServerCustomPacketEvent(server.func_147362_b(), msg);
|
||||
event = new FMLNetworkEvent.ServerCustomPacketEvent(server.getNetworkManager(), msg);
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,14 @@ import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToMessageCodec;
|
||||
import io.netty.util.AttributeKey;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
|
||||
@@ -43,13 +48,13 @@ public abstract class FMLIndexedMessageToMessageCodec<A> extends MessageToMessag
|
||||
@Override
|
||||
protected final void encode(ChannelHandlerContext ctx, A msg, List<Object> out) throws Exception
|
||||
{
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
PacketBuffer buffer = new PacketBuffer(Unpooled.buffer());
|
||||
@SuppressWarnings("unchecked") // Stupid unnecessary cast I can't seem to kill
|
||||
Class<? extends A> clazz = (Class<? extends A>) msg.getClass();
|
||||
byte discriminator = types.get(clazz);
|
||||
buffer.writeByte(discriminator);
|
||||
encodeInto(ctx, msg, buffer);
|
||||
FMLProxyPacket proxy = new FMLProxyPacket(buffer.copy(), ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get());
|
||||
FMLProxyPacket proxy = new FMLProxyPacket(buffer/*.copy()*/, ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get());
|
||||
WeakReference<FMLProxyPacket> ref = ctx.attr(INBOUNDPACKETTRACKER).get().get();
|
||||
FMLProxyPacket old = ref == null ? null : ref.get();
|
||||
if (old != null)
|
||||
|
||||
@@ -13,7 +13,6 @@ import cpw.mods.fml.relauncher.Side;
|
||||
public class FMLNetworkEvent<T extends INetHandler> extends Event {
|
||||
public final T handler;
|
||||
public final NetworkManager manager;
|
||||
@SuppressWarnings("unused")
|
||||
private final Class<T> type;
|
||||
|
||||
FMLNetworkEvent(T thing, Class<T> type, NetworkManager manager)
|
||||
|
||||
@@ -9,6 +9,8 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Iterables;
|
||||
@@ -25,7 +27,7 @@ public abstract class FMLHandshakeMessage {
|
||||
public static FMLProxyPacket makeCustomChannelRegistration(Set<String> channels)
|
||||
{
|
||||
String salutation = Joiner.on('\0').join(Iterables.concat(Arrays.asList("FML|HS","FML"),channels));
|
||||
FMLProxyPacket proxy = new FMLProxyPacket(Unpooled.wrappedBuffer(salutation.getBytes(Charsets.UTF_8)), "REGISTER");
|
||||
FMLProxyPacket proxy = new FMLProxyPacket(new PacketBuffer(Unpooled.wrappedBuffer(salutation.getBytes(Charsets.UTF_8))), "REGISTER");
|
||||
return proxy;
|
||||
}
|
||||
public static class ServerHello extends FMLHandshakeMessage {
|
||||
|
||||
@@ -151,7 +151,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
|
||||
void clientListenForServerHandshake()
|
||||
{
|
||||
manager.setConnectionState(EnumConnectionState.PLAY);
|
||||
FMLCommonHandler.instance().waitForPlayClient();
|
||||
//FMLCommonHandler.instance().waitForPlayClient();
|
||||
this.netHandler = FMLCommonHandler.instance().getClientPlayHandler();
|
||||
this.state = ConnectionState.AWAITING_HANDSHAKE;
|
||||
}
|
||||
@@ -235,7 +235,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
|
||||
}
|
||||
else
|
||||
{
|
||||
manager.scheduleOutboundPacket(new S40PacketDisconnect(chatcomponenttext), new GenericFutureListener<Future<?>>()
|
||||
manager.func_179288_a(new S40PacketDisconnect(chatcomponenttext), new GenericFutureListener<Future<?>>()
|
||||
{
|
||||
@Override
|
||||
public void operationComplete(Future<?> result)
|
||||
@@ -345,7 +345,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
|
||||
|
||||
public void sendProxy(FMLProxyPacket msg)
|
||||
{
|
||||
manager.scheduleOutboundPacket(msg);
|
||||
manager.func_179290_a(msg);
|
||||
}
|
||||
|
||||
public void rejectHandshake(String result)
|
||||
@@ -455,7 +455,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
|
||||
public void abortClientHandshake(String type)
|
||||
{
|
||||
FMLLog.log(Level.INFO, "Aborting client handshake \"%s\"", type);
|
||||
FMLCommonHandler.instance().waitForPlayClient();
|
||||
//FMLCommonHandler.instance().waitForPlayClient();
|
||||
completeClientSideConnection(ConnectionType.valueOf(type));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,10 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
@@ -93,7 +94,7 @@ public class EntitySpawnHandler extends SimpleChannelInboundHandler<FMLMessage.E
|
||||
entity.serverPosY = spawnMsg.rawY;
|
||||
entity.serverPosZ = spawnMsg.rawZ;
|
||||
|
||||
EntityClientPlayerMP clientPlayer = FMLClientHandler.instance().getClientPlayerEntity();
|
||||
EntityPlayerSP clientPlayer = FMLClientHandler.instance().getClientPlayerEntity();
|
||||
if (entity instanceof IThrowableEntity)
|
||||
{
|
||||
Entity thrower = clientPlayer.getEntityId() == spawnMsg.throwerId ? clientPlayer : wc.getEntityByID(spawnMsg.throwerId);
|
||||
|
||||
@@ -85,7 +85,7 @@ public class FMLNetworkHandler
|
||||
embeddedChannel.writeOutbound(openGui);
|
||||
entityPlayerMP.openContainer = remoteGuiContainer;
|
||||
entityPlayerMP.openContainer.windowId = windowId;
|
||||
entityPlayerMP.openContainer.addCraftingToCrafters(entityPlayerMP);
|
||||
entityPlayerMP.openContainer.onCraftGuiOpened(entityPlayerMP);
|
||||
}
|
||||
}
|
||||
else if (FMLCommonHandler.instance().getSide().equals(Side.CLIENT))
|
||||
|
||||
@@ -22,32 +22,28 @@ import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.handshake.NetworkDispatcher;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class FMLProxyPacket extends Packet {
|
||||
public class FMLProxyPacket implements Packet {
|
||||
final String channel;
|
||||
private Side target;
|
||||
private final ByteBuf payload;
|
||||
private final PacketBuffer payload;
|
||||
private INetHandler netHandler;
|
||||
private NetworkDispatcher dispatcher;
|
||||
private static Multiset<String> badPackets = ConcurrentHashMultiset.create();
|
||||
private static int packetCountWarning = Integers.parseInt(System.getProperty("fml.badPacketCounter", "100"), 100);
|
||||
private FMLProxyPacket(byte[] payload, String channel)
|
||||
{
|
||||
this(Unpooled.wrappedBuffer(payload), channel);
|
||||
}
|
||||
|
||||
public FMLProxyPacket(S3FPacketCustomPayload original)
|
||||
{
|
||||
this(original.func_149168_d(), original.func_149169_c());
|
||||
this(original.func_180735_b(), original.func_149169_c());
|
||||
this.target = Side.CLIENT;
|
||||
}
|
||||
|
||||
public FMLProxyPacket(C17PacketCustomPayload original)
|
||||
{
|
||||
this(original.func_149558_e(), original.func_149559_c());
|
||||
this(original.func_180760_b(), original.func_149559_c());
|
||||
this.target = Side.SERVER;
|
||||
}
|
||||
|
||||
public FMLProxyPacket(ByteBuf payload, String channel)
|
||||
public FMLProxyPacket(PacketBuffer payload, String channel)
|
||||
{
|
||||
this.channel = channel;
|
||||
this.payload = payload;
|
||||
@@ -117,12 +113,12 @@ public class FMLProxyPacket extends Packet {
|
||||
}
|
||||
public Packet toC17Packet()
|
||||
{
|
||||
return new C17PacketCustomPayload(channel, payload.array());
|
||||
return new C17PacketCustomPayload(channel, payload);
|
||||
}
|
||||
|
||||
public Packet toS3FPacket()
|
||||
{
|
||||
return new S3FPacketCustomPayload(channel, payload.array());
|
||||
return new S3FPacketCustomPayload(channel, payload);
|
||||
}
|
||||
|
||||
public void setTarget(Side target)
|
||||
|
||||
+64
-33
@@ -8,10 +8,14 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.util.ObjectIntIdentityMap;
|
||||
import net.minecraft.util.RegistryNamespaced;
|
||||
import net.minecraft.util.RegistryNamespacedDefaultedByKey;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
@@ -20,9 +24,9 @@ import com.google.common.collect.ImmutableMap;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.functions.GenericIterableFactory;
|
||||
|
||||
public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
public class FMLControlledNamespacedRegistry<I> extends RegistryNamespacedDefaultedByKey {
|
||||
private final Class<I> superType;
|
||||
private String optionalDefaultName;
|
||||
private Object optionalDefaultKey;
|
||||
private I optionalDefaultObject;
|
||||
private int maxId;
|
||||
private int minId;
|
||||
@@ -33,11 +37,12 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
private BiMap<String, I> persistentSubstitutions;
|
||||
private BiMap<String, I> activeSubstitutions = HashBiMap.create();
|
||||
|
||||
FMLControlledNamespacedRegistry(String optionalDefault, int maxIdValue, int minIdValue, Class<I> type, char discriminator)
|
||||
FMLControlledNamespacedRegistry(Object defaultKey, int maxIdValue, int minIdValue, Class<I> type, char discriminator)
|
||||
{
|
||||
super(defaultKey);
|
||||
this.superType = type;
|
||||
this.discriminator = discriminator;
|
||||
this.optionalDefaultName = optionalDefault;
|
||||
this.optionalDefaultKey = defaultKey;
|
||||
this.maxId = maxIdValue;
|
||||
this.minId = minIdValue;
|
||||
}
|
||||
@@ -47,24 +52,29 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
for (I obj : typeSafeIterable())
|
||||
{
|
||||
int id = getId(obj);
|
||||
String name = getNameForObject(obj);
|
||||
Object name = func_177774_c(obj);
|
||||
|
||||
// name lookup failed -> obj is not in the obj<->name map
|
||||
if (name == null) throw new IllegalStateException(String.format("Registry entry for %s %s, id %d, doesn't yield a name.", type, obj, id));
|
||||
|
||||
ResourceLocation loc = (name instanceof ResourceLocation) ? (ResourceLocation)name : null;
|
||||
String nameS = (name instanceof String) ? (String)name : (loc != null ? name.toString() : null);
|
||||
if (loc == null && nameS == null) throw new IllegalStateException(String.format("Registry entry for %s %s name is invalid, must be a String or ResourceLocation %s", type, obj, name));
|
||||
|
||||
// id lookup failed -> obj is not in the obj<->id map
|
||||
if (id < 0) throw new IllegalStateException(String.format("Registry entry for %s %s, name %s, doesn't yield an id.", type, obj, name));
|
||||
// id is too high
|
||||
if (id > maxId) throw new IllegalStateException(String.format("Registry entry for %s %s, name %s uses the too large id %d.", type, obj, name));
|
||||
// name lookup failed -> obj is not in the obj<->name map
|
||||
if (name == null) throw new IllegalStateException(String.format("Registry entry for %s %s, id %d, doesn't yield a name.", type, obj, id));
|
||||
// empty name
|
||||
if (name.isEmpty()) throw new IllegalStateException(String.format("Registry entry for %s %s, id %d, yields an empty name.", type, obj, id));
|
||||
if (name.toString().isEmpty()) throw new IllegalStateException(String.format("Registry entry for %s %s, id %d, yields an empty name.", type, obj, id));
|
||||
// non-prefixed name
|
||||
if (name.indexOf(':') == -1) throw new IllegalStateException(String.format("Registry entry for %s %s, id %d, has the non-prefixed name %s.", type, obj, id, name));
|
||||
if (name.toString().indexOf(':') == -1) throw new IllegalStateException(String.format("Registry entry for %s %s, id %d, has the non-prefixed name %s.", type, obj, id, name));
|
||||
// id -> obj lookup is inconsistent
|
||||
if (getRaw(id) != obj) throw new IllegalStateException(String.format("Registry entry for id %d, name %s, doesn't yield the expected %s %s.", id, name, type, obj));
|
||||
// name -> obj lookup is inconsistent
|
||||
if (!(activeSubstitutions.containsKey(name) || activeSubstitutions.containsValue(name)) && getRaw(name) != obj ) throw new IllegalStateException(String.format("Registry entry for name %s, id %d, doesn't yield the expected %s %s.", name, id, type, obj));
|
||||
if (!(activeSubstitutions.containsKey(name) || activeSubstitutions.containsValue(name)) && getRaw(nameS) != obj ) throw new IllegalStateException(String.format("Registry entry for name %s, id %d, doesn't yield the expected %s %s.", name, id, type, obj));
|
||||
// name -> id lookup is inconsistent
|
||||
if (!(activeSubstitutions.containsKey(name) || activeSubstitutions.containsValue(name)) && getId(name) != id) throw new IllegalStateException(String.format("Registry entry for name %s doesn't yield the expected id %d.", name, id));
|
||||
if (!(activeSubstitutions.containsKey(name) || activeSubstitutions.containsValue(name)) && getId(nameS) != id) throw new IllegalStateException(String.format("Registry entry for name %s doesn't yield the expected id %d.", name, id));
|
||||
// id isn't marked as unavailable
|
||||
if (!availabilityMap.get(id)) throw new IllegalStateException(String.format("Registry entry for %s %s, id %d, name %s, marked as empty.", type, obj, id, name));
|
||||
// entry is blocked, thus should be empty
|
||||
@@ -72,7 +82,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
|
||||
if (obj instanceof ItemBlock)
|
||||
{
|
||||
Block block = ((ItemBlock) obj).field_150939_a;
|
||||
Block block = ((ItemBlock) obj).blockInstance;
|
||||
|
||||
// verify matching block entry
|
||||
if (iBlockRegistry.getId(block) != id)
|
||||
@@ -90,7 +100,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
if (this.superType != registry.superType) throw new IllegalArgumentException("incompatible registry");
|
||||
|
||||
this.discriminator = registry.discriminator;
|
||||
this.optionalDefaultName = registry.optionalDefaultName;
|
||||
this.optionalDefaultKey = registry.optionalDefaultKey;
|
||||
this.maxId = registry.maxId;
|
||||
this.minId = registry.minId;
|
||||
this.aliases.clear();
|
||||
@@ -100,7 +110,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
|
||||
for (I thing : registry.typeSafeIterable())
|
||||
{
|
||||
addObjectRaw(registry.getId(thing), registry.getNameForObject(thing), thing);
|
||||
addObjectRaw(registry.getId(thing), registry.func_177774_c(thing), thing);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,9 +123,10 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void addObject(int id, String name, Object thing)
|
||||
public void func_177775_a(int id, Object name, Object thing)
|
||||
{
|
||||
GameData.getMain().register(thing, name, id);
|
||||
Validate.isInstanceOf(ResourceLocation.class, name);
|
||||
GameData.getMain().register(thing, name.toString(), id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,15 +138,15 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
@Deprecated
|
||||
public void putObject(Object objName, Object obj)
|
||||
{
|
||||
String name = (String) objName;
|
||||
String name = objName.toString();
|
||||
I thing = superType.cast(obj);
|
||||
|
||||
if (name == null) throw new NullPointerException("Can't use a null-name for the registry.");
|
||||
if (name.isEmpty()) throw new IllegalArgumentException("Can't use an empty name for the registry.");
|
||||
if (thing == null) throw new NullPointerException("Can't add null-object to the registry.");
|
||||
|
||||
name = ensureNamespaced(name);
|
||||
String existingName = getNameForObject(thing);
|
||||
name = new ResourceLocation(name).toString();
|
||||
Object existingName = func_177774_c(thing);
|
||||
|
||||
if (existingName == null)
|
||||
{
|
||||
@@ -148,7 +159,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
else
|
||||
{
|
||||
FMLLog.bigWarning("Ignoring putObject(%s, %s), adding alias to %s instead", name, thing, existingName);
|
||||
addAlias(name, existingName);
|
||||
addAlias(name, existingName.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,9 +172,11 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
* @return Registered object of the default object if it wasn't found-
|
||||
*/
|
||||
@Override
|
||||
public I getObject(String name)
|
||||
public I getObject(Object name)
|
||||
{
|
||||
I object = getRaw(name);
|
||||
I object = null;
|
||||
if (name instanceof ResourceLocation) object = getRaw((ResourceLocation)name);
|
||||
if (name instanceof String) object = getRaw((String)name);
|
||||
return object == null ? this.optionalDefaultObject : object;
|
||||
}
|
||||
|
||||
@@ -235,11 +248,22 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
*/
|
||||
public I getRaw(String name)
|
||||
{
|
||||
I ret = superType.cast(super.getObject(name));
|
||||
return getRaw(new ResourceLocation(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the object identified by the specified name.
|
||||
*
|
||||
* @param name Block/Item name.
|
||||
* @return Block/Item object or null if it wasn't found.
|
||||
*/
|
||||
private I getRaw(ResourceLocation loc)
|
||||
{
|
||||
I ret = superType.cast(super.getObject(loc));
|
||||
|
||||
if (ret == null) // no match, try aliases recursively
|
||||
{
|
||||
name = aliases.get(name);
|
||||
String name = aliases.get(loc.toString());
|
||||
|
||||
if (name != null) return getRaw(name);
|
||||
}
|
||||
@@ -256,7 +280,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
* @return true if a matching entry was found.
|
||||
*/
|
||||
@Override
|
||||
public boolean containsKey(String name)
|
||||
public boolean containsKey(Object name)
|
||||
{
|
||||
boolean ret = super.containsKey(name);
|
||||
|
||||
@@ -310,7 +334,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
{
|
||||
for (I thing : this.typeSafeIterable())
|
||||
{
|
||||
idMapping.put(discriminator+getNameForObject(thing), getId(thing));
|
||||
idMapping.put(discriminator+func_177774_c(thing).toString(), getId(thing));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,7 +358,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
if (name.isEmpty()) throw new IllegalArgumentException(String.format("Can't use an empty name for the registry, object %s.", thing));
|
||||
if (name.indexOf(':') == -1) throw new IllegalArgumentException(String.format("Can't add the name (%s) without a prefix, object %s", name, thing));
|
||||
if (thing == null) throw new NullPointerException(String.format("Can't add null-object to the registry, name %s.", name));
|
||||
if (name.equals(optionalDefaultName) && this.optionalDefaultObject == null)
|
||||
if (optionalDefaultKey != null && optionalDefaultKey.toString().equals(name) && this.optionalDefaultObject == null)
|
||||
{
|
||||
this.optionalDefaultObject = thing;
|
||||
}
|
||||
@@ -365,7 +389,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
{
|
||||
int foundId = getId(thing);
|
||||
Object otherThing = getRaw(foundId);
|
||||
throw new IllegalArgumentException(String.format("The object %s{%x} has been registered twice, using the names %s and %s. (Other object at this id is %s{%x})", thing, System.identityHashCode(thing), getNameForObject(thing), name, otherThing, System.identityHashCode(otherThing)));
|
||||
throw new IllegalArgumentException(String.format("The object %s{%x} has been registered twice, using the names %s and %s. (Other object at this id is %s{%x})", thing, System.identityHashCode(thing), func_177774_c(thing), name, otherThing, System.identityHashCode(otherThing)));
|
||||
}
|
||||
if (GameData.isFrozen(this))
|
||||
{
|
||||
@@ -376,7 +400,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
{
|
||||
thing = activeSubstitutions.get(name);
|
||||
}
|
||||
addObjectRaw(idToUse, name, thing);
|
||||
addObjectRaw(idToUse, new ResourceLocation(name), thing);
|
||||
|
||||
FMLLog.finer("Registry add: %s %d %s (req. id %d)", name, idToUse, thing, id);
|
||||
return idToUse;
|
||||
@@ -396,9 +420,9 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
{
|
||||
if (!registry.field_148758_b.containsKey(thing))
|
||||
{
|
||||
if (!registry.activeSubstitutions.containsKey(getNameForObject(thing)))
|
||||
if (!registry.activeSubstitutions.containsKey(func_177774_c(thing).toString()))
|
||||
{
|
||||
ret.put(getNameForObject(thing), getId(thing));
|
||||
ret.put(func_177774_c(thing).toString(), getId(thing));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -421,14 +445,14 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
for (int id : ids)
|
||||
{
|
||||
I thing = getRaw(id);
|
||||
FMLLog.finer("Registry: %s %d %s", getNameForObject(thing), id, thing);
|
||||
FMLLog.finer("Registry: %s %d %s", func_177774_c(thing), id, thing);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Version of addObject not using the API restricting overrides.
|
||||
*/
|
||||
private void addObjectRaw(int id, String name, I thing)
|
||||
private void addObjectRaw(int id, Object name, I thing)
|
||||
{
|
||||
if (name == null) throw new NullPointerException("The name to be added to the registry is null. This can only happen with a corrupted registry state. Reflection/ASM hackery? Registry bug?");
|
||||
if (thing == null) throw new NullPointerException("The object to be added to the registry is null. This can only happen with a corrupted registry state. Reflection/ASM hackery? Registry bug?");
|
||||
@@ -494,4 +518,11 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespaced {
|
||||
}
|
||||
return persistentSubstitutions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_177776_a()
|
||||
{
|
||||
if (this.optionalDefaultKey != null)
|
||||
Validate.notNull(this.optionalDefaultObject);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
@@ -221,7 +222,7 @@ public class GameData {
|
||||
static UniqueIdentifier getUniqueName(Block block)
|
||||
{
|
||||
if (block == null) return null;
|
||||
String name = getMain().iBlockRegistry.getNameForObject(block);
|
||||
Object name = getMain().iBlockRegistry.func_177774_c(block);
|
||||
UniqueIdentifier ui = new UniqueIdentifier(name);
|
||||
if (customItemStacks.contains(ui.modId, ui.name))
|
||||
{
|
||||
@@ -234,7 +235,7 @@ public class GameData {
|
||||
static UniqueIdentifier getUniqueName(Item item)
|
||||
{
|
||||
if (item == null) return null;
|
||||
String name = getMain().iItemRegistry.getNameForObject(item);
|
||||
Object name = getMain().iItemRegistry.func_177774_c(item);
|
||||
UniqueIdentifier ui = new UniqueIdentifier(name);
|
||||
if (customItemStacks.contains(ui.modId, ui.name))
|
||||
{
|
||||
@@ -260,7 +261,6 @@ public class GameData {
|
||||
for (Entry<String, Integer> entry : dataList.entrySet())
|
||||
{
|
||||
String itemName = entry.getKey();
|
||||
@SuppressWarnings("unused")
|
||||
String realName = itemName.substring(1);
|
||||
|
||||
if (itemName.charAt(0) == '\u0001') // is a block
|
||||
@@ -608,7 +608,7 @@ public class GameData {
|
||||
if (remap.type == Type.BLOCK)
|
||||
{
|
||||
currId = getMain().iBlockRegistry.getId((Block) remap.getTarget());
|
||||
newName = getMain().iBlockRegistry.getNameForObject(remap.getTarget());
|
||||
newName = getMain().iBlockRegistry.func_177774_c(remap.getTarget()).toString();
|
||||
FMLLog.fine("The Block %s is being remapped to %s.", remap.name, newName);
|
||||
|
||||
newId = gameData.registerBlock((Block) remap.getTarget(), newName, remap.id);
|
||||
@@ -617,7 +617,7 @@ public class GameData {
|
||||
else
|
||||
{
|
||||
currId = getMain().iItemRegistry.getId((Item) remap.getTarget());
|
||||
newName = getMain().iItemRegistry.getNameForObject(remap.getTarget());
|
||||
newName = getMain().iItemRegistry.func_177774_c(remap.getTarget()).toString();
|
||||
FMLLog.fine("The Item %s is being remapped to %s.", remap.name, newName);
|
||||
|
||||
newId = gameData.registerItem((Item) remap.getTarget(), newName, remap.id);
|
||||
@@ -752,7 +752,7 @@ public class GameData {
|
||||
|
||||
private GameData()
|
||||
{
|
||||
iBlockRegistry = new FMLControlledNamespacedRegistry<Block>("minecraft:air", MAX_BLOCK_ID, MIN_BLOCK_ID, Block.class,'\u0001');
|
||||
iBlockRegistry = new FMLControlledNamespacedRegistry<Block>(new ResourceLocation("minecraft:air"), MAX_BLOCK_ID, MIN_BLOCK_ID, Block.class,'\u0001');
|
||||
iItemRegistry = new FMLControlledNamespacedRegistry<Item>(null, MAX_ITEM_ID, MIN_ITEM_ID, Item.class,'\u0002');
|
||||
availabilityMap = new BitSet(MAX_ITEM_ID + 1);
|
||||
blockedIds = new HashSet<Integer>();
|
||||
@@ -806,7 +806,7 @@ public class GameData {
|
||||
{
|
||||
if (item instanceof ItemBlock) // ItemBlock, adjust id and clear the slot already occupied by the corresponding block
|
||||
{
|
||||
Block block = ((ItemBlock) item).field_150939_a;
|
||||
Block block = ((ItemBlock) item).blockInstance;
|
||||
if (idHint != -1 && getMain().blockSubstitutions.containsKey(name))
|
||||
{
|
||||
block = getMain().blockSubstitutions.get(name);
|
||||
@@ -865,7 +865,7 @@ public class GameData {
|
||||
|
||||
for (Item item : iItemRegistry.typeSafeIterable()) // find matching ItemBlock
|
||||
{
|
||||
if (item instanceof ItemBlock && ((ItemBlock) item).field_150939_a == block)
|
||||
if (item instanceof ItemBlock && ((ItemBlock) item).blockInstance == block)
|
||||
{
|
||||
itemBlock = (ItemBlock) item;
|
||||
break;
|
||||
@@ -967,8 +967,8 @@ public class GameData {
|
||||
|
||||
private void verifyItemBlockName(ItemBlock item)
|
||||
{
|
||||
String blockName = iBlockRegistry.getNameForObject(item.field_150939_a);
|
||||
String itemName = iItemRegistry.getNameForObject(item);
|
||||
Object blockName = iBlockRegistry.func_177774_c(item.blockInstance);
|
||||
Object itemName = iItemRegistry.func_177774_c(item);
|
||||
|
||||
if (blockName != null && !blockName.equals(itemName))
|
||||
{
|
||||
|
||||
@@ -33,6 +33,7 @@ import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
|
||||
@@ -257,17 +258,17 @@ public class GameRegistry
|
||||
|
||||
public static void addSmelting(Block input, ItemStack output, float xp)
|
||||
{
|
||||
FurnaceRecipes.smelting().func_151393_a(input, output, xp);
|
||||
FurnaceRecipes.instance().addSmeltingRecipeForBlock(input, output, xp);
|
||||
}
|
||||
|
||||
public static void addSmelting(Item input, ItemStack output, float xp)
|
||||
{
|
||||
FurnaceRecipes.smelting().func_151396_a(input, output, xp);
|
||||
FurnaceRecipes.instance().addSmelting(input, output, xp);
|
||||
}
|
||||
|
||||
public static void addSmelting(ItemStack input, ItemStack output, float xp)
|
||||
{
|
||||
FurnaceRecipes.smelting().func_151394_a(input, output, xp);
|
||||
FurnaceRecipes.instance().addSmeltingRecipe(input, output, xp);
|
||||
}
|
||||
|
||||
public static void registerTileEntity(Class<? extends TileEntity> tileEntityClass, String id)
|
||||
@@ -385,6 +386,25 @@ public class GameRegistry
|
||||
this.name = parts[1];
|
||||
}
|
||||
|
||||
public UniqueIdentifier(Object obj)
|
||||
{
|
||||
if (obj instanceof String)
|
||||
{
|
||||
String[] parts = ((String)obj).split(":");
|
||||
this.modId = parts[0];
|
||||
this.name = parts[1];
|
||||
}
|
||||
else if (obj instanceof ResourceLocation)
|
||||
{
|
||||
this.modId = ((ResourceLocation)obj).getResourceDomain();
|
||||
this.name = ((ResourceLocation)obj).getResourcePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("UniqueIdentifier must be a String or ResourceLocation, was " + obj.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
|
||||
@@ -46,8 +46,9 @@ class ObjectHolderRef {
|
||||
}
|
||||
else
|
||||
{
|
||||
this.injectedObject = isBlock ? GameData.getBlockRegistry().getNameForObject(existing) :
|
||||
isItem ? GameData.getItemRegistry().getNameForObject(existing) : null;
|
||||
Object tmp = isBlock ? GameData.getBlockRegistry().func_177774_c(existing) :
|
||||
isItem ? GameData.getItemRegistry().func_177774_c(existing) : null;
|
||||
this.injectedObject = tmp != null ? tmp.toString() : null;
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
package cpw.mods.fml.common.registry;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -19,8 +21,16 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.passive.EntityVillager.*;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
@@ -45,12 +55,16 @@ public class VillagerRegistry
|
||||
{
|
||||
private static final VillagerRegistry INSTANCE = new VillagerRegistry();
|
||||
|
||||
private Multimap<Integer, IVillageTradeHandler> tradeHandlers = ArrayListMultimap.create();
|
||||
private Map<Class<?>, IVillageCreationHandler> villageCreationHandlers = Maps.newHashMap();
|
||||
private List<Integer> newVillagerIds = Lists.newArrayList();
|
||||
@SideOnly(Side.CLIENT)
|
||||
private Map<Integer, ResourceLocation> newVillagers;
|
||||
|
||||
private VillagerRegistry()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow access to the {@link net.minecraft.world.gen.structure.StructureVillagePieces} array controlling new village
|
||||
* creation so you can insert your own new village pieces
|
||||
@@ -83,29 +97,11 @@ public class VillagerRegistry
|
||||
* @param p1
|
||||
* @param p2
|
||||
* @param p3
|
||||
* @param p4
|
||||
* @param facing
|
||||
* @param p5
|
||||
*/
|
||||
Object buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, @SuppressWarnings("rawtypes") List pieces, Random random, int p1,
|
||||
int p2, int p3, int p4, int p5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow access to the {@link MerchantRecipeList} for a villager type for manipulation
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public interface IVillageTradeHandler
|
||||
{
|
||||
/**
|
||||
* Called to allow changing the content of the {@link MerchantRecipeList} for the villager
|
||||
* supplied during creation
|
||||
*
|
||||
* @param villager
|
||||
* @param recipeList
|
||||
*/
|
||||
void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random);
|
||||
int p2, int p3, EnumFacing facing, int p5);
|
||||
}
|
||||
|
||||
public static VillagerRegistry instance()
|
||||
@@ -152,17 +148,6 @@ public class VillagerRegistry
|
||||
villageCreationHandlers.put(handler.getComponentClass(), handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new villager trading handler for the specified villager type
|
||||
*
|
||||
* @param villagerId
|
||||
* @param handler
|
||||
*/
|
||||
public void registerVillageTradeHandler(int villagerId, IVillageTradeHandler handler)
|
||||
{
|
||||
tradeHandlers.put(villagerId, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to setup new villager types
|
||||
*
|
||||
@@ -188,21 +173,6 @@ public class VillagerRegistry
|
||||
{
|
||||
return Collections.unmodifiableCollection(instance().newVillagerIds);
|
||||
}
|
||||
/**
|
||||
* Callback to handle trade setup for villagers
|
||||
*
|
||||
* @param recipeList
|
||||
* @param villager
|
||||
* @param villagerType
|
||||
* @param random
|
||||
*/
|
||||
public static void manageVillagerTrades(MerchantRecipeList recipeList, EntityVillager villager, int villagerType, Random random)
|
||||
{
|
||||
for (IVillageTradeHandler handler : instance().tradeHandlers.get(villagerType))
|
||||
{
|
||||
handler.manipulateTradesForVillager(villager, recipeList, random);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addExtraVillageComponents(@SuppressWarnings("rawtypes") ArrayList components, Random random, int i)
|
||||
{
|
||||
@@ -215,36 +185,311 @@ public class VillagerRegistry
|
||||
}
|
||||
|
||||
public static Object getVillageComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, @SuppressWarnings("rawtypes") List pieces, Random random,
|
||||
int p1, int p2, int p3, int p4, int p5)
|
||||
int p1, int p2, int p3, EnumFacing facing, int p5)
|
||||
{
|
||||
return instance().villageCreationHandlers.get(villagePiece.villagePieceClass).buildComponent(villagePiece, startPiece, pieces, random, p1, p2, p3, p4, p5);
|
||||
return instance().villageCreationHandlers.get(villagePiece.villagePieceClass).buildComponent(villagePiece, startPiece, pieces, random, p1, p2, p3, facing, p5);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void addEmeraldBuyRecipe(EntityVillager villager, MerchantRecipeList list, Random random, Item item, float chance, int min, int max)
|
||||
public void register(VillagerProfession prof)
|
||||
{
|
||||
//blah
|
||||
}
|
||||
|
||||
private boolean hasInit = false;
|
||||
private List<VillagerProfession> professions = Lists.newArrayList();
|
||||
|
||||
//This field is moved from EntityVillager over to here.
|
||||
//It is nasty I know but it's vanilla.
|
||||
private static final ITradeList[][][][] vanillaTrades =
|
||||
{
|
||||
if (min > 0 && max > 0)
|
||||
{
|
||||
EntityVillager.villagersSellingList.put(item, new Tuple(min, max));
|
||||
}
|
||||
EntityVillager.func_146091_a(list, item, random, chance);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void addEmeraldSellRecipe(EntityVillager villager, MerchantRecipeList list, Random random, Item item, float chance, int min, int max)
|
||||
{
|
||||
if (min > 0 && max > 0)
|
||||
{
|
||||
{
|
||||
new EmeraldForItems(Items.wheat, new PriceInfo(18, 22)),
|
||||
new EmeraldForItems(Items.potato, new PriceInfo(15, 19)),
|
||||
new EmeraldForItems(Items.carrot, new PriceInfo(15, 19)),
|
||||
new ListItemForEmeralds(Items.bread, new PriceInfo(-4, -2))
|
||||
},
|
||||
{
|
||||
new EmeraldForItems(Item.getItemFromBlock(Blocks.pumpkin), new PriceInfo(8, 13)),
|
||||
new ListItemForEmeralds(Items.pumpkin_pie, new PriceInfo(-3, -2))
|
||||
},
|
||||
{
|
||||
new EmeraldForItems(Item.getItemFromBlock(Blocks.melon_block), new PriceInfo(7, 12)),
|
||||
new ListItemForEmeralds(Items.apple, new PriceInfo(-5, -7))
|
||||
},
|
||||
{
|
||||
new ListItemForEmeralds(Items.cookie, new PriceInfo(-6, -10)),
|
||||
new ListItemForEmeralds(Items.cake, new PriceInfo(1, 1))
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
new EmeraldForItems(Items.string, new PriceInfo(15, 20)),
|
||||
new EmeraldForItems(Items.coal, new PriceInfo(16, 24)),
|
||||
new ItemAndEmeraldToItem(Items.fish, new PriceInfo(6, 6), Items.field_179566_aV, new PriceInfo(6, 6))
|
||||
},
|
||||
{
|
||||
new ListEnchantedItemForEmeralds(Items.fishing_rod, new PriceInfo(7, 8))
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
new EmeraldForItems(Item.getItemFromBlock(Blocks.wool), new PriceInfo(16, 22)),
|
||||
new ListItemForEmeralds(Items.shears, new PriceInfo(3, 4))
|
||||
},
|
||||
{
|
||||
new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 0), new PriceInfo(1, 2)),
|
||||
new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 1), new PriceInfo(1, 2)),
|
||||
new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 2), new PriceInfo(1, 2)),
|
||||
new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 3), new PriceInfo(1, 2)),
|
||||
new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 4), new PriceInfo(1, 2)),
|
||||
new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 5), new PriceInfo(1, 2)),
|
||||
new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 6), new PriceInfo(1, 2)),
|
||||
new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 7), new PriceInfo(1, 2)),
|
||||
new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 8), new PriceInfo(1, 2)),
|
||||
new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 9), new PriceInfo(1, 2)),
|
||||
new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 10), new PriceInfo(1, 2)),
|
||||
new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 11), new PriceInfo(1, 2)),
|
||||
new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 12), new PriceInfo(1, 2)),
|
||||
new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 13), new PriceInfo(1, 2)),
|
||||
new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 14), new PriceInfo(1, 2)),
|
||||
new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 15), new PriceInfo(1, 2))
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
new EmeraldForItems(Items.string, new PriceInfo(15, 20)),
|
||||
new ListItemForEmeralds(Items.arrow, new PriceInfo(-12, -8))
|
||||
},
|
||||
{
|
||||
new ListItemForEmeralds(Items.bow, new PriceInfo(2, 3)),
|
||||
new ItemAndEmeraldToItem(Item.getItemFromBlock(Blocks.gravel), new PriceInfo(10, 10), Items.flint, new PriceInfo(6, 10))
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
EntityVillager.blacksmithSellingList.put(item, new Tuple(min, max));
|
||||
{
|
||||
{
|
||||
new EmeraldForItems(Items.paper, new PriceInfo(24, 36)),
|
||||
new ListEnchantedBookForEmeralds()
|
||||
},
|
||||
{
|
||||
new EmeraldForItems(Items.book, new PriceInfo(8, 10)),
|
||||
new ListItemForEmeralds(Items.compass, new PriceInfo(10, 12)),
|
||||
new ListItemForEmeralds(Item.getItemFromBlock(Blocks.bookshelf), new PriceInfo(3, 4))
|
||||
},
|
||||
{
|
||||
new EmeraldForItems(Items.written_book, new PriceInfo(2, 2)),
|
||||
new ListItemForEmeralds(Items.clock, new PriceInfo(10, 12)),
|
||||
new ListItemForEmeralds(Item.getItemFromBlock(Blocks.glass), new PriceInfo(-5, -3))
|
||||
},
|
||||
{
|
||||
new ListEnchantedBookForEmeralds()
|
||||
},
|
||||
{
|
||||
new ListEnchantedBookForEmeralds()
|
||||
},
|
||||
{
|
||||
new ListItemForEmeralds(Items.name_tag, new PriceInfo(20, 22))
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
{
|
||||
new EmeraldForItems(Items.rotten_flesh, new PriceInfo(36, 40)),
|
||||
new EmeraldForItems(Items.gold_ingot, new PriceInfo(8, 10))
|
||||
},
|
||||
{
|
||||
new ListItemForEmeralds(Items.redstone, new PriceInfo(-4, -1)),
|
||||
new ListItemForEmeralds(new ItemStack(Items.dye, 1, EnumDyeColor.BLUE.func_176767_b()),
|
||||
new PriceInfo(-2, -1))
|
||||
},
|
||||
{
|
||||
new ListItemForEmeralds(Items.ender_eye, new PriceInfo(7, 11)),
|
||||
new ListItemForEmeralds(Item.getItemFromBlock(Blocks.glowstone), new PriceInfo(-3, -1))
|
||||
},
|
||||
{
|
||||
new ListItemForEmeralds(Items.experience_bottle, new PriceInfo(3, 11))
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
{
|
||||
new EmeraldForItems(Items.coal, new PriceInfo(16, 24)),
|
||||
new ListItemForEmeralds(Items.iron_helmet, new PriceInfo(4, 6))
|
||||
},
|
||||
{
|
||||
new EmeraldForItems(Items.iron_ingot, new PriceInfo(7, 9)),
|
||||
new ListItemForEmeralds(Items.iron_chestplate, new PriceInfo(10, 14))
|
||||
},
|
||||
{
|
||||
new EmeraldForItems(Items.diamond, new PriceInfo(3, 4)),
|
||||
new ListEnchantedItemForEmeralds(Items.diamond_chestplate, new PriceInfo(16, 19))
|
||||
},
|
||||
{
|
||||
new ListItemForEmeralds(Items.chainmail_boots, new PriceInfo(5, 7)),
|
||||
new ListItemForEmeralds(Items.chainmail_leggings, new PriceInfo(9, 11)),
|
||||
new ListItemForEmeralds(Items.chainmail_helmet, new PriceInfo(5, 7)),
|
||||
new ListItemForEmeralds(Items.chainmail_chestplate, new PriceInfo(11, 15))
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
new EmeraldForItems(Items.coal, new PriceInfo(16, 24)),
|
||||
new ListItemForEmeralds(Items.iron_axe, new PriceInfo(6, 8))
|
||||
},
|
||||
{
|
||||
new EmeraldForItems(Items.iron_ingot, new PriceInfo(7, 9)),
|
||||
new ListEnchantedItemForEmeralds(Items.iron_sword, new PriceInfo(9, 10))
|
||||
},
|
||||
{
|
||||
new EmeraldForItems(Items.diamond, new PriceInfo(3, 4)),
|
||||
new ListEnchantedItemForEmeralds(Items.diamond_sword, new PriceInfo(12, 15)),
|
||||
new ListEnchantedItemForEmeralds(Items.diamond_axe, new PriceInfo(9, 12))
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
new EmeraldForItems(Items.coal, new PriceInfo(16, 24)),
|
||||
new ListEnchantedItemForEmeralds(Items.iron_shovel, new PriceInfo(5, 7))
|
||||
},
|
||||
{
|
||||
new EmeraldForItems(Items.iron_ingot, new PriceInfo(7, 9)),
|
||||
new ListEnchantedItemForEmeralds(Items.iron_pickaxe, new PriceInfo(9, 11))
|
||||
},
|
||||
{
|
||||
new EmeraldForItems(Items.diamond, new PriceInfo(3, 4)),
|
||||
new ListEnchantedItemForEmeralds(Items.diamond_pickaxe, new PriceInfo(12, 15))
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
{
|
||||
new EmeraldForItems(Items.porkchop, new PriceInfo(14, 18)),
|
||||
new EmeraldForItems(Items.chicken, new PriceInfo(14, 18))
|
||||
},
|
||||
{
|
||||
new EmeraldForItems(Items.coal, new PriceInfo(16, 24)),
|
||||
new ListItemForEmeralds(Items.cooked_porkchop, new PriceInfo(-7, -5)),
|
||||
new ListItemForEmeralds(Items.cooked_chicken, new PriceInfo(-8, -6))
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
new EmeraldForItems(Items.leather, new PriceInfo(9, 12)),
|
||||
new ListItemForEmeralds(Items.leather_leggings, new PriceInfo(2, 4))
|
||||
},
|
||||
{
|
||||
new ListEnchantedItemForEmeralds(Items.leather_chestplate, new PriceInfo(7, 12))
|
||||
},
|
||||
{
|
||||
new ListItemForEmeralds(Items.saddle, new PriceInfo(8, 10))
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void init()
|
||||
{
|
||||
if (hasInit)
|
||||
return;
|
||||
|
||||
VillagerProfession prof = new VillagerProfession("minecraft:farmer", "minecraft:textures/entity/villager/farmer.png");
|
||||
{
|
||||
register(prof);
|
||||
(new VillagerCareer(prof, "farmer" )).init(vanillaTrades[0][0]);
|
||||
(new VillagerCareer(prof, "fisherman" )).init(vanillaTrades[0][1]);
|
||||
(new VillagerCareer(prof, "shepherd" )).init(vanillaTrades[0][2]);
|
||||
(new VillagerCareer(prof, "fletcher" )).init(vanillaTrades[0][3]);
|
||||
}
|
||||
prof = new VillagerProfession("minecraft:librarian", "minecraft:textures/entity/villager/librarian.png");
|
||||
{
|
||||
register(prof);
|
||||
(new VillagerCareer(prof, "librarian")).init(vanillaTrades[1][0]);
|
||||
}
|
||||
prof = new VillagerProfession("minecraft:priest", "minecraft:textures/entity/villager/priest.png");
|
||||
{
|
||||
register(prof);
|
||||
(new VillagerCareer(prof, "cleric")).init(vanillaTrades[2][0]);
|
||||
}
|
||||
prof = new VillagerProfession("minecraft:smith", "minecraft:textures/entity/villager/smith.png");
|
||||
{
|
||||
register(prof);
|
||||
(new VillagerCareer(prof, "armor" )).init(vanillaTrades[3][0]);
|
||||
(new VillagerCareer(prof, "weapon")).init(vanillaTrades[3][1]);
|
||||
(new VillagerCareer(prof, "tool" )).init(vanillaTrades[3][2]);
|
||||
}
|
||||
prof = new VillagerProfession("minecraft:butcher", "minecraft:textures/entity/villager/butcher.png");
|
||||
{
|
||||
register(prof);
|
||||
(new VillagerCareer(prof, "butcher")).init(vanillaTrades[4][0]);
|
||||
(new VillagerCareer(prof, "leather")).init(vanillaTrades[4][1]);
|
||||
}
|
||||
EntityVillager.func_146089_b(list, item, random, chance);
|
||||
}
|
||||
|
||||
public static void applyRandomTrade(EntityVillager villager, Random rand)
|
||||
public static class VillagerProfession
|
||||
{
|
||||
int extra = instance().newVillagerIds.size();
|
||||
int trade = rand.nextInt(5 + extra);
|
||||
villager.setProfession(trade < 5 ? trade : instance().newVillagerIds.get(trade - 5));
|
||||
private ResourceLocation name;
|
||||
private ResourceLocation texture;
|
||||
private List<VillagerCareer> careers = Lists.newArrayList();
|
||||
|
||||
public VillagerProfession(String name, String texture)
|
||||
{
|
||||
this.name = new ResourceLocation(name);
|
||||
this.texture = new ResourceLocation(texture);
|
||||
}
|
||||
|
||||
private void register(VillagerCareer career)
|
||||
{
|
||||
Validate.isTrue(!careers.contains(career), "Attempted to register career that is already registered.");
|
||||
Validate.isTrue(career.profession == this, "Attempted to register career for the wrong profession.");
|
||||
career.id = careers.size();
|
||||
careers.add(career);
|
||||
}
|
||||
}
|
||||
|
||||
public static class VillagerCareer
|
||||
{
|
||||
private VillagerProfession profession;
|
||||
private String name;
|
||||
private int id;
|
||||
public VillagerCareer(VillagerProfession parent, String name)
|
||||
{
|
||||
this.profession = parent;
|
||||
this.name = name;
|
||||
parent.register(this);
|
||||
}
|
||||
|
||||
private VillagerCareer init(EntityVillager.ITradeList[][] traids)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof VillagerCareer)) return false;
|
||||
VillagerCareer oc = (VillagerCareer)o;
|
||||
return name.equals(oc.name) && profession == oc.profession;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook called when spawning a Villager, sets it's profession to a random registered profession.
|
||||
*
|
||||
* @param entity The new entity
|
||||
* @param rand The world's RNG
|
||||
*/
|
||||
public static void setRandomProfession(EntityVillager entity, Random rand)
|
||||
{
|
||||
//TODO: Grab id range from internal registry
|
||||
entity.setProfession(rand.nextInt(5));
|
||||
}
|
||||
|
||||
//TODO: Figure out a good generic system for this. Put on hold for Patches.
|
||||
}
|
||||
@@ -489,7 +489,6 @@ public class CoreModManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static void sortCoreMods()
|
||||
{
|
||||
TopologicalSort.DirectedGraph<FMLPluginWrapper> sortGraph = new TopologicalSort.DirectedGraph<FMLPluginWrapper>();
|
||||
|
||||
@@ -25,7 +25,6 @@ public class ReflectionHelper
|
||||
public static class UnableToFindMethodException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@SuppressWarnings("unused")
|
||||
private String[] methodNames;
|
||||
|
||||
public UnableToFindMethodException(String[] methodNames, Exception failed)
|
||||
@@ -39,7 +38,6 @@ public class ReflectionHelper
|
||||
public static class UnableToFindClassException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@SuppressWarnings("unused")
|
||||
private String[] classNames;
|
||||
|
||||
public UnableToFindClassException(String[] classNames, Exception err)
|
||||
@@ -53,7 +51,6 @@ public class ReflectionHelper
|
||||
public static class UnableToAccessFieldException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@SuppressWarnings("unused")
|
||||
private String[] fieldNameList;
|
||||
|
||||
public UnableToAccessFieldException(String[] fieldNames, Exception e)
|
||||
@@ -66,7 +63,6 @@ public class ReflectionHelper
|
||||
public static class UnableToFindFieldException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@SuppressWarnings("unused")
|
||||
private String[] fieldNameList;
|
||||
public UnableToFindFieldException(String[] fieldNameList, Exception e)
|
||||
{
|
||||
|
||||
@@ -242,11 +242,6 @@ public class FMLServerHandler implements IFMLSidedHandler
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public void waitForPlayClient()
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set<String> channelSet, String channel, Side side)
|
||||
@@ -259,7 +254,7 @@ public class FMLServerHandler implements IFMLSidedHandler
|
||||
{
|
||||
return DedicatedServer.allowPlayerLogins;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void allowLogins() {
|
||||
DedicatedServer.allowPlayerLogins = true;
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package net.minecraft.src;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
/**
|
||||
*
|
||||
* A static hook library for optifine and other basemod editing code to access FML functions
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class FMLRenderAccessLibrary
|
||||
{
|
||||
public static Logger getLogger()
|
||||
{
|
||||
Logger l = LogManager.getLogger("FMLRenderAccessLibrary");
|
||||
return l;
|
||||
}
|
||||
|
||||
public static void log(Level level, String message)
|
||||
{
|
||||
FMLLog.log("FMLRenderAccessLibrary", level, message);
|
||||
}
|
||||
|
||||
public static void log(Level level, String message, Throwable throwable)
|
||||
{
|
||||
FMLLog.log(level, throwable, message);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelId)
|
||||
{
|
||||
return RenderingRegistry.instance().renderWorldBlock(renderer, world, x, y, z, block, modelId);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void renderInventoryBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
|
||||
{
|
||||
RenderingRegistry.instance().renderInventoryBlock(renderer, block, metadata, modelID);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static boolean renderItemAsFull3DBlock(int modelId)
|
||||
{
|
||||
return RenderingRegistry.instance().renderItemAsFull3DBlock(modelId);
|
||||
}
|
||||
|
||||
// public static void doTextureCopy(Texture atlas, Texture source, int targetX, int targetY)
|
||||
// {
|
||||
// TextureFXManager.instance().getHelper().doTextureCopy(atlas, source, targetX, targetY);
|
||||
// }
|
||||
}
|
||||
@@ -80,3 +80,6 @@ fml.configgui.tooltip.undoAll=Undo All Changes. If the Apply globally checkbox i
|
||||
fml.configgui.tooltip.undoChanges=Undo Changes
|
||||
fml.configgui.tooltip.default=[default: %s]
|
||||
fml.configgui.tooltip.defaultNumeric=[range: %s ~ %s, default: %s]
|
||||
|
||||
fml.menu.mods=Mods
|
||||
fml.menu.modoptions=Mod Options...
|
||||
@@ -9,16 +9,6 @@ public net.minecraft.entity.EntityList field_75626_c #classToNameMap
|
||||
public net.minecraft.entity.EntityList field_75623_d #idToClassMap
|
||||
## RenderManager
|
||||
public net.minecraft.client.renderer.entity.RenderManager field_78729_o #renderers
|
||||
## RenderBlocks - everything
|
||||
public net.minecraft.client.renderer.RenderBlocks * # all fields
|
||||
public net.minecraft.client.renderer.RenderBlocks *() # all methods
|
||||
##RenderPlayer
|
||||
##public-f bht.h #FD:RenderPlayer/field_77110_j #armorlist # -- MISSING MAPPING
|
||||
##RenderBiped
|
||||
public-f net.minecraft.client.renderer.entity.RenderBiped field_82424_k #armorlist
|
||||
##StringTranslate
|
||||
##public bp.b #FD:StringTranslate/field_74815_b # -- MISSING MAPPING
|
||||
##public bp.e #FD:StringTranslate/field_74813_d # -- MISSING MAPPING
|
||||
## TileEntityRendererDispatcher
|
||||
public net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher field_147559_m
|
||||
## CraftingManager - make the add recipe methods public
|
||||
@@ -26,53 +16,22 @@ public net.minecraft.item.crafting.CraftingManager func_92103_a(Lnet.minecraft.i
|
||||
public net.minecraft.item.crafting.CraftingManager func_77596_b(Lnet.minecraft.item.ItemStack;[Ljava/lang/Object;)V
|
||||
## WeightedRandomItem
|
||||
public net.minecraft.util.WeightedRandom$Item field_76292_a #probability
|
||||
## ItemStack
|
||||
##public+f tv.c #FD:ItemStack/field_77993_c #itemId
|
||||
## StatBase
|
||||
#public ku.a #FD:StatBase/field_75978_a #statName
|
||||
## NetLoginHandler
|
||||
#public jy.a(Ljy;Z)Z #MD:NetLoginHandler/func_72531_a #'complete connection'
|
||||
#public jy.g #FD:NetLoginHandler/field_72543_h #userName
|
||||
## EntityPlayerMP getNextWindowId
|
||||
public net.minecraft.entity.player.EntityPlayerMP func_71117_bO()V
|
||||
public net.minecraft.entity.player.EntityPlayerMP field_71139_cq
|
||||
## EntityAITaskEntry
|
||||
public net.minecraft.entity.ai.EntityAITasks$EntityAITaskEntry
|
||||
## EntityAITasks
|
||||
#public pt.a #FD:EntityAITasks/field_75782_a #taskList
|
||||
## BlockChest
|
||||
#public ank.m(Labw;III)Z #MD:BlockChest/func_72292_n #isOcelotBlockingChest
|
||||
## EntityLiving
|
||||
##public ng.aU #FD:EntityLiving/field_70736_aM #carryoverDamage # -- MISSING MAPPING
|
||||
public net.minecraft.entity.EntityLiving field_70714_bg #tasks
|
||||
public net.minecraft.entity.EntityLiving field_70715_bh #targetTasks
|
||||
##public ng.bG #FD:EntityLiving/field_70703_bu #isJumping # -- MISSING MAPPING
|
||||
## EntityAIOcelotSit
|
||||
#protected qg.a(Labw;III)Z #MD:EntityAIOcelotSit/func_75398_a #nearestSittableBlock
|
||||
#protected qg.f()Z #MD:EntityAIOcelotSit/func_75399_f #isblocksittable
|
||||
## CallableMinecraftVersion - sanity check the MC version
|
||||
#public c #CL:CallableMinecraftVersion
|
||||
#public c.<init>(Lb;)V #MD:CallableMinecraftVersion/<init>(Lnet/minecraft/src/CrashReport;) #constructor
|
||||
## EntityAnimal
|
||||
#public rp.bp #FD:EntityAnimal/field_70881_d #inLove
|
||||
## WorldType
|
||||
#public acg.<init>(ILjava/lang/String;)V #MD:WorldType/<init>(ILjava/lang/String;)
|
||||
#public acg.<init>(ILjava/lang/String;I)V #MD:WorldType/<init>(ILjava/lang/String;I)
|
||||
## ComponentVillage
|
||||
#public ajm #CL:ComponentVillage
|
||||
## StructureStart
|
||||
#public aiv.a #FD:StructureStart/field_75075_a
|
||||
## EntityVillager - minmax lists
|
||||
public net.minecraft.entity.passive.EntityVillager func_146091_a(Lnet/minecraft/village/MerchantRecipeList;Lnet/minecraft/item/Item;Ljava/util/Random;F)V # buy
|
||||
public net.minecraft.entity.passive.EntityVillager func_146089_b(Lnet/minecraft/village/MerchantRecipeList;Lnet/minecraft/item/Item;Ljava/util/Random;F)V # sell
|
||||
public net.minecraft.entity.passive.EntityVillager field_70958_bB
|
||||
public net.minecraft.entity.passive.EntityVillager field_70960_bC
|
||||
## GuiButtonMerchant
|
||||
#public axx #CL:GuiButtonMerchant
|
||||
# GuiScreen
|
||||
public net.minecraft.client.gui.GuiScreen field_146297_k # minecraft instance - public because gui's outside access it
|
||||
# Minecraft
|
||||
#public atv.D #FD:Minecraft/field_71425_J #running
|
||||
public net.minecraft.client.Minecraft field_71446_o # textureManager
|
||||
## ItemBlock
|
||||
public net.minecraft.item.ItemBlock field_150939_a
|
||||
@@ -84,7 +43,6 @@ public net.minecraft.world.storage.SaveFormatOld field_75808_a # savesDirectory
|
||||
protected net.minecraft.util.ObjectIntIdentityMap field_148749_a # internal map
|
||||
protected net.minecraft.util.ObjectIntIdentityMap field_148748_b # internal index list
|
||||
protected-f net.minecraft.util.RegistryNamespaced field_148759_a # identitymap
|
||||
protected net.minecraft.util.RegistryNamespaced func_148755_c(Ljava/lang/String;)Ljava/lang/String; # prefix if necessary
|
||||
|
||||
# GuiButton
|
||||
public net.minecraft.client.gui.GuiButton field_146120_f # width - needed for config GUI stuff
|
||||
@@ -102,4 +60,13 @@ public net.minecraft.client.gui.GuiSlot field_148153_b # top - needed for config
|
||||
public net.minecraft.client.gui.GuiSlot field_148154_c # bottom - needed for config GUI stuff
|
||||
public net.minecraft.client.gui.GuiSlot field_148155_a # width - needed for config GUI stuff
|
||||
public net.minecraft.client.gui.GuiSlot field_148158_l # height - needed for config GUI stuff
|
||||
public net.minecraft.client.gui.GuiSlot field_148160_j # headerPadding - needed for config GUI stuff
|
||||
public net.minecraft.client.gui.GuiSlot field_148160_j # headerPadding - needed for config GUI stuff
|
||||
|
||||
# Villager Traid Classes
|
||||
public net.minecraft.entity.passive.EntityVillager$EmeraldForItems
|
||||
public net.minecraft.entity.passive.EntityVillager$ITradeList
|
||||
public net.minecraft.entity.passive.EntityVillager$ItemAndEmeraldToItem
|
||||
public net.minecraft.entity.passive.EntityVillager$ListEnchantedBookForEmeralds
|
||||
public net.minecraft.entity.passive.EntityVillager$ListEnchantedItemForEmeralds
|
||||
public net.minecraft.entity.passive.EntityVillager$ListItemForEmeralds
|
||||
public net.minecraft.entity.passive.EntityVillager$PriceInfo
|
||||
Reference in new issue
Block a user