diff --git a/src/main/java/binnie/botany/craftgui/ControlColourDisplay.java b/src/main/java/binnie/botany/craftgui/ControlColourDisplay.java index aa3582ea..5854c491 100644 --- a/src/main/java/binnie/botany/craftgui/ControlColourDisplay.java +++ b/src/main/java/binnie/botany/craftgui/ControlColourDisplay.java @@ -12,8 +12,8 @@ import binnie.craftgui.core.Tooltip; public class ControlColourDisplay extends Control implements IControlValue, ITooltip { IFlowerColour value; - public ControlColourDisplay(final IWidget parent, final float x, final float y) { - super(parent, x, y, 16.0f, 16.0f); + public ControlColourDisplay(final IWidget parent, final int x, final int y) { + super(parent, x, y, 16, 16); this.addAttribute(Attribute.MouseOver); } @@ -28,7 +28,7 @@ public class ControlColourDisplay extends Control implements IControlValue { } public ControlColourMixBox(final IWidget parent, final int x, final int y, final int width, final int height, final Type type) { - super(parent, x, y, width, height, 12.0f); + super(parent, x, y, width, height, 12); this.type = type; } diff --git a/src/main/java/binnie/botany/craftgui/ControlColourMixItem.java b/src/main/java/binnie/botany/craftgui/ControlColourMixItem.java index e2afd2e8..31ee95ba 100644 --- a/src/main/java/binnie/botany/craftgui/ControlColourMixItem.java +++ b/src/main/java/binnie/botany/craftgui/ControlColourMixItem.java @@ -15,9 +15,9 @@ public class ControlColourMixItem extends ControlOption { public ControlColourMixItem(final ControlList controlList, final IColourMix option, final int y) { super(controlList, option, y); - this.itemWidget1 = new ControlColourDisplay(this, 4.0f, 4.0f); - this.itemWidget2 = new ControlColourDisplay(this, 44.0f, 4.0f); - this.itemWidget3 = new ControlColourDisplay(this, 104.0f, 4.0f); + this.itemWidget1 = new ControlColourDisplay(this, 4, 4); + this.itemWidget2 = new ControlColourDisplay(this, 44, 4); + this.itemWidget3 = new ControlColourDisplay(this, 104, 4); this.addSymbol = new ControlColourMixSymbol(this, 24, 4, 0); this.arrowSymbol = new ControlColourMixSymbol(this, 64, 4, 1); final BreedingSystem system = ((WindowAbstractDatabase) this.getSuperParent()).getBreedingSystem(); diff --git a/src/main/java/binnie/botany/craftgui/ControlColourMixSymbol.java b/src/main/java/binnie/botany/craftgui/ControlColourMixSymbol.java index b68e21b3..25ba3b13 100644 --- a/src/main/java/binnie/botany/craftgui/ControlColourMixSymbol.java +++ b/src/main/java/binnie/botany/craftgui/ControlColourMixSymbol.java @@ -19,8 +19,8 @@ public class ControlColourMixSymbol extends Control implements ITooltip { int type; @Override - public void onRenderBackground() { - super.onRenderBackground(); + public void onRenderBackground(int guiWidth, int guiHeight) { + super.onRenderBackground(guiWidth, guiHeight); if (this.type == 0) { CraftGUI.render.texture(ControlColourMixSymbol.MutationPlus, IPoint.ZERO); } else { @@ -29,7 +29,7 @@ public class ControlColourMixSymbol extends Control implements ITooltip { } protected ControlColourMixSymbol(final IWidget parent, final int x, final int y, final int type) { - super(parent, x, y, 16 + type * 16, 16.0f); + super(parent, x, y, 16 + type * 16, 16); this.value = null; this.type = type; this.addAttribute(Attribute.MouseOver); diff --git a/src/main/java/binnie/botany/craftgui/ControlColourOption.java b/src/main/java/binnie/botany/craftgui/ControlColourOption.java index cceba5f6..f2430208 100644 --- a/src/main/java/binnie/botany/craftgui/ControlColourOption.java +++ b/src/main/java/binnie/botany/craftgui/ControlColourOption.java @@ -14,15 +14,15 @@ public class ControlColourOption extends ControlTextOption { public ControlColourOption(final ControlList controlList, final IFlowerColour option, final int y) { super(controlList, option, option.getColourName(), y); - this.setSize(new IPoint(this.getSize().x(), 20.0f)); - (this.controlBee = new ControlColourDisplay(this, 2.0f, 2.0f)).setValue(option); + this.setSize(new IPoint(this.getSize().x(), 20)); + (this.controlBee = new ControlColourDisplay(this, 2, 2)).setValue(option); this.addAttribute(Attribute.MouseOver); - CraftGUIUtil.moveWidget(this.textWidget, new IPoint(22.0f, 0.0f)); - this.textWidget.setSize(this.textWidget.getSize().sub(new IPoint(24.0f, 0.0f))); + CraftGUIUtil.moveWidget(this.textWidget, new IPoint(22, 0)); + this.textWidget.setSize(this.textWidget.getSize().sub(new IPoint(24, 0))); final int th = (int) CraftGUI.render.textHeight(this.textWidget.getValue(), this.textWidget.getSize().x()); final int height = Math.max(20, th + 6); this.setSize(new IPoint(this.size().x(), height)); this.textWidget.setSize(new IPoint(this.textWidget.getSize().x(), height)); - this.boxPosition = new IPoint(2.0f, (height - 18) / 2); + this.boxPosition = new IPoint(2, (height - 18) / 2); } } diff --git a/src/main/java/binnie/botany/craftgui/PageColourMix.java b/src/main/java/binnie/botany/craftgui/PageColourMix.java index b5144cda..d37f2d17 100644 --- a/src/main/java/binnie/botany/craftgui/PageColourMix.java +++ b/src/main/java/binnie/botany/craftgui/PageColourMix.java @@ -18,7 +18,7 @@ public class PageColourMix extends PageAbstract { public PageColourMix(final IWidget parent, final DatabaseTab tab) { super(parent, tab); - this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8.0f, "Further Mixes"); + this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8, "Further Mixes"); this.pageSpeciesFurther_List = new ControlColourMixBox(this, 4, 20, 136, 152, ControlColourMixBox.Type.Further); } diff --git a/src/main/java/binnie/botany/craftgui/PageColourMixResultant.java b/src/main/java/binnie/botany/craftgui/PageColourMixResultant.java index e9334a4a..2f289286 100644 --- a/src/main/java/binnie/botany/craftgui/PageColourMixResultant.java +++ b/src/main/java/binnie/botany/craftgui/PageColourMixResultant.java @@ -18,7 +18,7 @@ public class PageColourMixResultant extends PageAbstract { public PageColourMixResultant(final IWidget parent, final DatabaseTab tab) { super(parent, tab); - this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8.0f, "Resultant Mixes"); + this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8, "Resultant Mixes"); this.pageSpeciesFurther_List = new ControlColourMixBox(this, 4, 20, 136, 152, ControlColourMixBox.Type.Resultant); } diff --git a/src/main/java/binnie/botany/craftgui/PageSpeciesFlowerGenome.java b/src/main/java/binnie/botany/craftgui/PageSpeciesFlowerGenome.java index 360fca28..2488397d 100644 --- a/src/main/java/binnie/botany/craftgui/PageSpeciesFlowerGenome.java +++ b/src/main/java/binnie/botany/craftgui/PageSpeciesFlowerGenome.java @@ -42,32 +42,32 @@ public class PageSpeciesFlowerGenome extends PageSpecies { final IAlleleFlowerSpecies treeSpecies = genome.getPrimary(); final int w = 144; final int h = 176; - new ControlText(this, new IArea(0.0f, 4.0f, w, 16.0f), "Genome", TextJustification.MiddleCenter); - final ControlScrollableContent scrollable = new ControlScrollableContent(this, 4.0f, 20.0f, w - 8, h - 8 - 16, 12.0f); - final Control contents = new Control(scrollable, 0.0f, 0.0f, w - 8 - 12, h - 8 - 16); + new ControlText(this, new IArea(0, 4, w, 16), "Genome", TextJustification.MiddleCenter); + final ControlScrollableContent scrollable = new ControlScrollableContent(this, 4, 20, w - 8, h - 8 - 16, 12); + final Control contents = new Control(scrollable, 0, 0, w - 8 - 12, h - 8 - 16); final int tw = w - 8 - 12; final int w2 = 55; final int w3 = tw - 50; int y = 0; final int th = 14; final int th2 = 18; - new ControlText(contents, new IArea(0.0f, y, w2, th), "Temp. : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y, w2, th), "Temp. : ", TextJustification.MiddleRight); new ControlText(contents, new IArea(w2, y, w3, th), treeSpecies.getTemperature().getName(), TextJustification.MiddleLeft); y += th; - new ControlText(contents, new IArea(0.0f, y, w2, th), "Moist. : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y, w2, th), "Moist. : ", TextJustification.MiddleRight); new ControlText(contents, new IArea(w2, y, w3, th), Binnie.LANGUAGE.localise(treeSpecies.getMoisture()), TextJustification.MiddleLeft); y += th; - new ControlText(contents, new IArea(0.0f, y, w2, th), "pH. : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y, w2, th), "pH. : ", TextJustification.MiddleRight); new ControlText(contents, new IArea(w2, y, w3, th), Binnie.LANGUAGE.localise(treeSpecies.getPH()), TextJustification.MiddleLeft); y += th; - new ControlText(contents, new IArea(0.0f, y, w2, th), "Fertility : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y, w2, th), "Fertility : ", TextJustification.MiddleRight); new ControlText(contents, new IArea(w2, y, w3, th), genome.getFertility() + "x", TextJustification.MiddleLeft); y += th; final float lifespan = genome.getLifespan() * 68.27f / genome.getAgeChance() / 24000.0f; - new ControlText(contents, new IArea(0.0f, y, w2, th), "Lifespan : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y, w2, th), "Lifespan : ", TextJustification.MiddleRight); new ControlText(contents, new IArea(w2, y, w3, th), "" + String.format("%.2f", lifespan) + " days", TextJustification.MiddleLeft); y += th; - new ControlText(contents, new IArea(0.0f, y, w2, th), "Nectar : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y, w2, th), "Nectar : ", TextJustification.MiddleRight); new ControlText(contents, new IArea(w2, y, w3, th), genome.getActiveAllele(EnumFlowerChromosome.SAPPINESS).getName(), TextJustification.MiddleLeft); y += th; int x = w2; @@ -86,7 +86,7 @@ public class PageSpeciesFlowerGenome extends PageSpecies { } } final int numOfLines = 1 + (tot - 1) / 3; - new ControlText(contents, new IArea(0.0f, y - (numOfLines - 1) * 18, w2, 4 + 18 * numOfLines), "Varieties : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y - (numOfLines - 1) * 18, w2, 4 + 18 * numOfLines), "Varieties : ", TextJustification.MiddleRight); y += th; contents.setSize(new IPoint(contents.size().x(), y)); scrollable.setScrollableContent(contents); diff --git a/src/main/java/binnie/botany/craftgui/WindowBotanistDatabase.java b/src/main/java/binnie/botany/craftgui/WindowBotanistDatabase.java index c9be1d24..6e449a5f 100644 --- a/src/main/java/binnie/botany/craftgui/WindowBotanistDatabase.java +++ b/src/main/java/binnie/botany/craftgui/WindowBotanistDatabase.java @@ -30,7 +30,7 @@ public class WindowBotanistDatabase extends WindowAbstractDatabase { ControlListBox selectionBoxColors; public WindowBotanistDatabase(final EntityPlayer player, final Side side, final boolean nei) { - super(player, side, nei, Binnie.GENETICS.flowerBreedingSystem, 130.0f); + super(player, side, nei, Binnie.GENETICS.flowerBreedingSystem, 130); } public static Window create(final EntityPlayer player, final Side side, final boolean nei) { @@ -49,7 +49,7 @@ public class WindowBotanistDatabase extends WindowAbstractDatabase { this.createMode(FlowerMode.Colour, new ModeWidgets(FlowerMode.Colour, this) { @Override public void createListBox(final IArea area) { - this.listBox = new ControlListBox(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0f) { + this.listBox = new ControlListBox(this.modePage, area.x(), area.y(), area.w(), area.h(), 12) { @Override public IWidget createOption(final IFlowerColour value, final int y) { return new ControlColourOption(this.getContent(), value, y); diff --git a/src/main/java/binnie/core/block/TileEntityMetadata.java b/src/main/java/binnie/core/block/TileEntityMetadata.java index 99c7361c..767f83a2 100644 --- a/src/main/java/binnie/core/block/TileEntityMetadata.java +++ b/src/main/java/binnie/core/block/TileEntityMetadata.java @@ -1,8 +1,10 @@ package binnie.core.block; import binnie.core.network.packet.PacketMetadata; +import com.google.common.base.Preconditions; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; @@ -83,9 +85,11 @@ public class TileEntityMetadata extends TileEntity { } public static ItemStack getItemStack(final Block block, final int damage) { - final ItemStack item = new ItemStack(block, 1, 0); - setItemDamage(item, damage); - return item; + final Item item = Item.getItemFromBlock(block); + Preconditions.checkNotNull(item, "Could not get item for block %s", block); + final ItemStack itemStack = new ItemStack(item, 1, 0); + setItemDamage(itemStack, damage); + return itemStack; } public static void setItemDamage(final ItemStack item, final int i) { diff --git a/src/main/java/binnie/core/machines/inventory/SlotValidator.java b/src/main/java/binnie/core/machines/inventory/SlotValidator.java index d9a51cce..d23c995b 100644 --- a/src/main/java/binnie/core/machines/inventory/SlotValidator.java +++ b/src/main/java/binnie/core/machines/inventory/SlotValidator.java @@ -5,17 +5,22 @@ import forestry.api.genetics.AlleleManager; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.item.ItemStack; +import javax.annotation.Nullable; + public abstract class SlotValidator extends Validator { public static ValidatorIcon IconBee; public static ValidatorIcon IconFrame; public static ValidatorIcon IconCircuit; public static ValidatorIcon IconBlock; + + @Nullable private ValidatorIcon icon; - public SlotValidator(final ValidatorIcon icon) { + public SlotValidator(@Nullable final ValidatorIcon icon) { this.icon = icon; } + @Nullable public TextureAtlasSprite getIcon(final boolean input) { return (this.icon == null) ? null : BinnieCore.proxy.getTextureAtlasSprite(this.icon.getIcon(input).getResourceLocation()); } diff --git a/src/main/java/binnie/core/machines/storage/ControlColourSelector.java b/src/main/java/binnie/core/machines/storage/ControlColourSelector.java index 800f5fa5..561438ed 100644 --- a/src/main/java/binnie/core/machines/storage/ControlColourSelector.java +++ b/src/main/java/binnie/core/machines/storage/ControlColourSelector.java @@ -12,7 +12,7 @@ import binnie.craftgui.minecraft.EnumColor; class ControlColourSelector extends Control implements ITooltip, IControlValue { private EnumColor value; - public ControlColourSelector(final IWidget parent, final float x, final float y, final float w, final float h, final EnumColor value) { + public ControlColourSelector(final IWidget parent, final int x, final int y, final int w, final int h, final EnumColor value) { super(parent, x, y, w, h); this.setValue(value); this.addAttribute(Attribute.MouseOver); @@ -35,8 +35,8 @@ class ControlColourSelector extends Control implements ITooltip, IControlValue tab = new ControlTabBar(controlCompartment, 0.0f, 0.0f, 24.0f, compartmentPageHeight, Position.Left) { + final ControlTabBar tab = new ControlTabBar(controlCompartment, 0, 0, 24, compartmentPageHeight, Position.Left) { @Override - public ControlTab createTab(final float x, final float y, final float w, final float h, final Integer value) { + public ControlTab createTab(final int x, final int y, final int w, final int h, final Integer value) { return new ControlTabIcon(this, x, y, w, h, value) { @Override public ItemStack getItemStack() { @@ -142,7 +142,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh } }.setOrigin(EventHandler.Origin.DirectChild, tab)); x += 24; - final ControlPages compartmentPages = new ControlPages<>(controlCompartment, 24.0f, 0.0f, compartmentPageWidth, compartmentPageHeight); + final ControlPages compartmentPages = new ControlPages<>(controlCompartment, 24, 0, compartmentPageWidth, compartmentPageHeight); final ControlPage[] page = new ControlPage[inv.getTabNumber()]; for (int p = 0; p < inv.getTabNumber(); ++p) { page[p] = new ControlPage(compartmentPages, p); @@ -151,9 +151,9 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh int i = 0; for (int p2 = 0; p2 < inv.getTabNumber(); ++p2) { final ControlPage thisPage = page[p2]; - final Panel panel = new Panel(thisPage, 0.0f, 0.0f, thisPage.w(), thisPage.h(), MinecraftGUI.PanelType.Black) { + final Panel panel = new Panel(thisPage, 0, 0, thisPage.w(), thisPage.h(), MinecraftGUI.PanelType.Black) { @Override - public void onRenderForeground() { + public void onRenderForeground(int guiWidth, int guiHeight) { final Texture iTexture = CraftGUI.render.getTexture(CraftGUITexture.TabOutline); CraftGUI.render.colour(WindowCompartment.this.getTab(WindowCompartment.this.panels.get(this)).getColor().getColour()); CraftGUI.render.texture(iTexture, this.getArea().inset(3)); @@ -168,9 +168,9 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh } x += compartmentPageWidth; if (tabs2.length > 0) { - final ControlTabBar tab2 = new ControlTabBar(controlCompartment, 24 + compartmentPageWidth, 0.0f, 24.0f, compartmentPageHeight, Position.Right) { + final ControlTabBar tab2 = new ControlTabBar(controlCompartment, 24 + compartmentPageWidth, 0, 24, compartmentPageHeight, Position.Right) { @Override - public ControlTab createTab(final float x, final float y, final float w, final float h, final Integer value) { + public ControlTab createTab(final int x, final int y, final int w, final int h, final Integer value) { return new ControlTabIcon(this, x, y, w, h, value) { @Override public ItemStack getItemStack() { @@ -212,20 +212,20 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh } x += 16; this.setSize(new IPoint(Math.max(32 + compartmentWidth, 252), this.h())); - controlCompartment.setPosition(new IPoint((this.w() - controlCompartment.w()) / 2.0f, controlCompartment.y())); + controlCompartment.setPosition(new IPoint((this.w() - controlCompartment.w()) / 2, controlCompartment.y())); final ControlPlayerInventory invent = new ControlPlayerInventory(this, true); - final ControlSlide slide = new ControlSlide(this, 0.0f, 134.0f, 136.0f, 92.0f, Position.Left); + final ControlSlide slide = new ControlSlide(this, 0, 134, 136, 92, Position.Left); slide.setLabel("Tab Properties"); slide.setSlide(false); slide.addHelp("Tab Properties"); slide.addHelp("The label, colour and icon of the Tab can be altered here. Clicking on the icon with a held item will change it."); - final Panel tabPropertyPanel = new Panel(slide, 16.0f, 8.0f, 112.0f, 76.0f, MinecraftGUI.PanelType.Gray); + final Panel tabPropertyPanel = new Panel(slide, 16, 8, 112, 76, MinecraftGUI.PanelType.Gray); int y2 = 4; - new ControlText(tabPropertyPanel, new IPoint(4.0f, y2), "Tab Name:"); + new ControlText(tabPropertyPanel, new IPoint(4, y2), "Tab Name:"); final Panel parent = tabPropertyPanel; - final float x2 = 4.0f; + final int x2 = 4; y2 += 12; - (this.tabName = new ControlTextEdit(parent, x2, y2, 104.0f, 12.0f)).addSelfEventHandler(new EventTextEdit.Handler() { + (this.tabName = new ControlTextEdit(parent, x2, y2, 104, 12)).addSelfEventHandler(new EventTextEdit.Handler() { @Override public void onEvent(final EventTextEdit event) { final CompartmentTab tab = WindowCompartment.this.getCurrentTab(); @@ -236,8 +236,8 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh } }.setOrigin(EventHandler.Origin.Self, this.tabName)); y2 += 20; - new ControlText(tabPropertyPanel, new IPoint(4.0f, y2), "Tab Icon: "); - (this.tabIcon = new ControlItemDisplay(tabPropertyPanel, 58.0f, y2 - 4)).setItemStack(new ItemStack(Items.PAPER)); + new ControlText(tabPropertyPanel, new IPoint(4, y2), "Tab Icon: "); + (this.tabIcon = new ControlItemDisplay(tabPropertyPanel, 58, y2 - 4)).setItemStack(new ItemStack(Items.PAPER)); this.tabIcon.addAttribute(Attribute.MouseOver); this.tabIcon.addSelfEventHandler(new EventMouse.Down.Handler() { @Override @@ -254,13 +254,13 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh WindowCompartment.this.sendClientAction("comp-change-tab", nbt); } }); - this.tabColour = new ControlColourSelector(tabPropertyPanel, 82.0f, y2 - 4, 16.0f, 16.0f, EnumColor.White); + this.tabColour = new ControlColourSelector(tabPropertyPanel, 82, y2 - 4, 16, 16, EnumColor.White); this.tabIcon.addHelp("Icon for Current Tab"); this.tabIcon.addHelp("Click here with an item to change"); y2 += 20; - new ControlText(tabPropertyPanel, new IPoint(4.0f, y2), "Colour: "); + new ControlText(tabPropertyPanel, new IPoint(4, y2), "Colour: "); final int cw = 8; - final Panel panelColour = new Panel(tabPropertyPanel, 40.0f, y2 - 4, cw * 8 + 2, cw * 2 + 1, MinecraftGUI.PanelType.Gray); + final Panel panelColour = new Panel(tabPropertyPanel, 40, y2 - 4, cw * 8 + 2, cw * 2 + 1, MinecraftGUI.PanelType.Gray); for (int cc = 0; cc < 16; ++cc) { final ControlColourSelector color = new ControlColourSelector(panelColour, 1 + cw * (cc % 8), 1 + cw * (cc / 8), cw, cw, EnumColor.values()[cc]); color.addSelfEventHandler(new EventMouse.Down.Handler() { @@ -277,16 +277,16 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh color.addHelp("Select a colour to highlight the current tab"); } y2 += 20; - final ControlButton searchButton = new ControlButton(controlCompartment, compartmentWidth - 24 - 64 - 8, compartmentPageHeight, 64.0f, 16.0f, "Search") { + final ControlButton searchButton = new ControlButton(controlCompartment, compartmentWidth - 24 - 64 - 8, compartmentPageHeight, 64, 16, "Search") { @Override protected void onMouseClick(final EventMouse.Down event) { WindowCompartment.this.createSearchDialog(); } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { final Object texture = this.isMouseOver() ? CraftGUITexture.TabHighlighted : CraftGUITexture.Tab; - CraftGUI.render.texture(CraftGUI.render.getTexture(texture).crop(Position.Bottom, 8.0f), this.getArea()); + CraftGUI.render.texture(CraftGUI.render.getTexture(texture).crop(Position.Bottom, 8), this.getArea()); } }; searchButton.addHelp("Search Button"); @@ -294,7 +294,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh } public void createSearchDialog() { - new Dialog(this, 252.0f, 192.0f) { + new Dialog(this, 252, 192) { Control slotGrid; String textSearch = ""; boolean sortByName = false; @@ -307,16 +307,16 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh @Override public void initialise() { - final ControlScrollableContent scroll = new ControlScrollableContent(this, 124.0f, 16.0f, 116.0f, 92.0f, 6.0f) { + final ControlScrollableContent scroll = new ControlScrollableContent(this, 124, 16, 116, 92, 6) { @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.colour(11184810); - CraftGUI.render.texture(CraftGUITexture.Outline, this.getArea().inset(new IBorder(0.0f, 6.0f, 0.0f, 0.0f))); + CraftGUI.render.texture(CraftGUITexture.Outline, this.getArea().inset(new IBorder(0, 6, 0, 0))); } }; - scroll.setScrollableContent(this.slotGrid = new Control(scroll, 1.0f, 1.0f, 108.0f, 18.0f)); + scroll.setScrollableContent(this.slotGrid = new Control(scroll, 1, 1, 108, 18)); new ControlPlayerInventory(this, true); - new ControlTextEdit(this, 16.0f, 16.0f, 100.0f, 14.0f).addEventHandler(new EventTextEdit.Handler() { + new ControlTextEdit(this, 16, 16, 100, 14).addEventHandler(new EventTextEdit.Handler() { @Override public void onEvent(final EventTextEdit event) { textSearch = event.value; @@ -325,21 +325,21 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh }); this.includeItems = true; this.includeBlocks = true; - new ControlCheckbox(this, 16.0f, 40.0f, 100.0f, "Sort A-Z", this.sortByName) { + new ControlCheckbox(this, 16, 40, 100, "Sort A-Z", this.sortByName) { @Override protected void onValueChanged(final boolean value) { sortByName = value; updateSearch(); } }; - new ControlCheckbox(this, 16.0f, 64.0f, 100.0f, "Include Items", this.includeItems) { + new ControlCheckbox(this, 16, 64, 100, "Include Items", this.includeItems) { @Override protected void onValueChanged(final boolean value) { includeItems = value; updateSearch(); } }; - new ControlCheckbox(this, 16.0f, 88.0f, 100.0f, "Include Blocks", this.includeBlocks) { + new ControlCheckbox(this, 16, 88, 100, "Include Blocks", this.includeBlocks) { @Override protected void onValueChanged(final boolean value) { includeBlocks = value; diff --git a/src/main/java/binnie/craftgui/binniecore/WindowFieldKit.java b/src/main/java/binnie/craftgui/binniecore/WindowFieldKit.java index e62c760f..1532ca56 100644 --- a/src/main/java/binnie/craftgui/binniecore/WindowFieldKit.java +++ b/src/main/java/binnie/craftgui/binniecore/WindowFieldKit.java @@ -45,10 +45,10 @@ import java.util.Map; import java.util.Random; public class WindowFieldKit extends Window { - private float glassOffsetX; - private float glassOffsetY; - private float glassVX; - private float glassVY; + private int glassOffsetX; + private int glassOffsetY; + private int glassVX; + private int glassVY; private Random glassRand; private Control GlassControl; private ControlChromosome chromo; @@ -59,13 +59,13 @@ public class WindowFieldKit extends Window { private ItemStack prev; public WindowFieldKit(final EntityPlayer player, final IInventory inventory, final Side side) { - super(280.0f, 230.0f, player, inventory, side); - this.glassOffsetX = 0.0f; - this.glassOffsetY = 0.0f; - this.glassVX = 0.0f; - this.glassVY = 0.0f; + super(280, 230, player, inventory, side); + this.glassOffsetX = 0; + this.glassOffsetY = 0; + this.glassVX = 0; + this.glassVY = 0; this.glassRand = new Random(); - this.analyseProgress = 1.0f; + this.analyseProgress = 1; this.isAnalysing = false; this.info = new HashMap<>(); this.prev = null; @@ -115,13 +115,13 @@ public class WindowFieldKit extends Window { this.getWindowInventory().createSlot(1); this.setupValidators(); new ControlPlayerInventory(this); - final IPoint handGlass = new IPoint(16.0f, 32.0f); + final IPoint handGlass = new IPoint(16, 32); this.GlassControl = new ControlImage(this, handGlass.x(), handGlass.y(), new StandardTexture(0, 160, 96, 96, ExtraBeeTexture.GUIPunnett)); - new ControlSlot(this, handGlass.x() + 54.0f, handGlass.y() + 26.0f).assign(InventoryType.Window, 0); - new ControlSlot(this, 208.0f, 8.0f).assign(InventoryType.Window, 1); - (this.text = new ControlText(this, new IPoint(232.0f, 13.0f), "Paper")).setColour(2236962); - (this.text = new ControlText(this, new IArea(0.0f, 120.0f, this.w(), 24.0f), "", TextJustification.MiddleCenter)).setColour(2236962); - this.chromo = new ControlChromosome(this, 150.0f, 24.0f); + new ControlSlot(this, handGlass.x() + 54, handGlass.y() + 26).assign(InventoryType.Window, 0); + new ControlSlot(this, 208, 8).assign(InventoryType.Window, 1); + (this.text = new ControlText(this, new IPoint(232, 13), "Paper")).setColour(2236962); + (this.text = new ControlText(this, new IArea(0, 120, this.w(), 24), "", TextJustification.MiddleCenter)).setColour(2236962); + this.chromo = new ControlChromosome(this, 150, 24); this.addEventHandler(new EventValueChanged.Handler() { @Override public void onEvent(final EventValueChanged event) { @@ -151,9 +151,9 @@ public class WindowFieldKit extends Window { super.onUpdateClient(); if (this.isAnalysing) { this.analyseProgress += 0.01f; - if (this.analyseProgress >= 1.0f) { + if (this.analyseProgress >= 1) { this.isAnalysing = false; - this.analyseProgress = 1.0f; + this.analyseProgress = 1; final ItemStack stack = this.getWindowInventory().getStackInSlot(0); if (stack != null) { this.sendClientAction("analyse", new NBTTagCompound()); @@ -164,9 +164,9 @@ public class WindowFieldKit extends Window { this.glassVX += this.glassRand.nextFloat() - 0.5f - this.glassOffsetX * 0.2f; this.glassVY += this.glassRand.nextFloat() - 0.5f - this.glassOffsetY * 0.2f; this.glassOffsetX += this.glassVX; - this.glassOffsetX *= 1.0f - this.analyseProgress; + this.glassOffsetX *= 1 - this.analyseProgress; this.glassOffsetY += this.glassVY; - this.glassOffsetY *= 1.0f - this.analyseProgress; + this.glassOffsetY *= 1 - this.analyseProgress; this.GlassControl.setOffset(new IPoint(this.glassOffsetX, this.glassOffsetY)); } @@ -221,7 +221,7 @@ public class WindowFieldKit extends Window { if (this.getWindowInventory().getStackInSlot(1) == null) { this.text.setValue("No Paper!"); this.isAnalysing = false; - this.analyseProgress = 1.0f; + this.analyseProgress = 1; } else { this.startAnalysing(); this.chromo.setRoot(null); @@ -231,14 +231,14 @@ public class WindowFieldKit extends Window { } } else if (item != null) { this.isAnalysing = false; - this.analyseProgress = 1.0f; + this.analyseProgress = 1; this.refreshSpecies(); if (this.damageKit()) { return; } } else { this.isAnalysing = false; - this.analyseProgress = 1.0f; + this.analyseProgress = 1; this.chromo.setRoot(null); } } @@ -249,12 +249,12 @@ public class WindowFieldKit extends Window { } private void startAnalysing() { - this.glassVX = 0.0f; - this.glassVY = 0.0f; - this.glassOffsetX = 0.0f; - this.glassOffsetY = 0.0f; + this.glassVX = 0; + this.glassVY = 0; + this.glassOffsetX = 0; + this.glassOffsetY = 0; this.isAnalysing = true; - this.analyseProgress = 0.0f; + this.analyseProgress = 0; } @Override diff --git a/src/main/java/binnie/craftgui/binniecore/WindowGenesis.java b/src/main/java/binnie/craftgui/binniecore/WindowGenesis.java index 1c8acd0e..b8b06ee1 100644 --- a/src/main/java/binnie/craftgui/binniecore/WindowGenesis.java +++ b/src/main/java/binnie/craftgui/binniecore/WindowGenesis.java @@ -47,7 +47,7 @@ public class WindowGenesis extends Window { private Panel panelPickup; public WindowGenesis(final EntityPlayer player, final IInventory inventory, final Side side) { - super(342.0f, 228.0f, player, inventory, side); + super(342, 228, player, inventory, side); } @Override @@ -64,9 +64,9 @@ public class WindowGenesis extends Window { public void initialiseClient() { new ControlPlayerInventory(this); this.setTitle("Genesis"); - final ControlTabBar tabSystems = new ControlTabBar(this, 8.0f, 28.0f, 23.0f, 100.0f, Position.Left) { + final ControlTabBar tabSystems = new ControlTabBar(this, 8, 28, 23, 100, Position.Left) { @Override - public ControlTab createTab(final float x, final float y, final float w, final float h, final BreedingSystem value) { + public ControlTab createTab(final int x, final int y, final int w, final int h, final BreedingSystem value) { return new ControlTabIcon(this, x, y, w, h, value) { @Override public ItemStack getItemStack() { @@ -95,17 +95,17 @@ public class WindowGenesis extends Window { tabSystems.setValues(Binnie.GENETICS.getActiveSystems()); this.root = Binnie.GENETICS.getActiveSystems().iterator().next().getSpeciesRoot(); this.template = this.root.getDefaultTemplate(); - final IArea one = new IArea(32.0f, 28.0f, 170.0f, 100.0f); - final IArea two = new IArea(214.0f, 28.0f, 100.0f, 100.0f); + final IArea one = new IArea(32, 28, 170, 100); + final IArea two = new IArea(214, 28, 100, 100); new Panel(this, one.outset(1), MinecraftGUI.PanelType.Black); new Panel(this, two.outset(1), MinecraftGUI.PanelType.Black); - this.geneList = new ControlListBox(this, one.x(), one.y(), one.w(), one.h(), 10.0f) { + this.geneList = new ControlListBox(this, one.x(), one.y(), one.w(), one.h(), 10) { @Override public IWidget createOption(final Gene value, final int y) { return new ControlGenesisOption(this.getContent(), value, y); } }; - this.geneOptions = new ControlListBox(this, two.x(), two.y(), two.w(), two.h(), 10.0f) { + this.geneOptions = new ControlListBox(this, two.x(), two.y(), two.w(), two.h(), 10) { @Override public IWidget createOption(final Gene value, final int y) { return new ControlTextOption<>(this.getContent(), value, y); @@ -146,7 +146,7 @@ public class WindowGenesis extends Window { WindowGenesis.this.refreshTemplate(chromo); } }.setOrigin(EventHandler.Origin.Self, this.geneOptions)); - this.panelPickup = new Panel(this, 16.0f, 140.0f, 60.0f, 42.0f, MinecraftGUI.PanelType.Black); + this.panelPickup = new Panel(this, 16, 140, 60, 42, MinecraftGUI.PanelType.Black); this.refreshTemplate(null); } diff --git a/src/main/java/binnie/craftgui/controls/ControlCheckbox.java b/src/main/java/binnie/craftgui/controls/ControlCheckbox.java index f3e310d9..51299fda 100644 --- a/src/main/java/binnie/craftgui/controls/ControlCheckbox.java +++ b/src/main/java/binnie/craftgui/controls/ControlCheckbox.java @@ -17,16 +17,16 @@ public class ControlCheckbox extends Control implements IControlValue { boolean value; String text; - public ControlCheckbox(final IWidget parent, final float x, final float y, final boolean bool) { - this(parent, x, y, 0.0f, "", bool); + public ControlCheckbox(final IWidget parent, final int x, final int y, final boolean bool) { + this(parent, x, y, 0, "", bool); } - public ControlCheckbox(final IWidget parent, final float x, final float y, final float w, final String text, final boolean bool) { - super(parent, x, y, (w > 16.0f) ? w : 16.0f, 16.0f); + public ControlCheckbox(final IWidget parent, final int x, final int y, final int w, final String text, final boolean bool) { + super(parent, x, y, (w > 16) ? w : 16, 16); this.text = text; this.value = bool; - if (w > 16.0f) { - new ControlText(this, new IArea(16.0f, 1.0f, w - 16.0f, 16.0f), text, TextJustification.MiddleCenter).setColour(4473924); + if (w > 16) { + new ControlText(this, new IArea(16, 1, w - 16, 16), text, TextJustification.MiddleCenter).setColour(4473924); } this.addAttribute(Attribute.MouseOver); this.addEventHandler(new EventMouse.Down.Handler() { @@ -57,7 +57,7 @@ public class ControlCheckbox extends Control implements IControlValue { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { Object texture = this.getValue() ? CraftGUITexture.CheckboxChecked : CraftGUITexture.Checkbox; if (this.isMouseOver()) { texture = (this.getValue() ? CraftGUITexture.CheckboxCheckedHighlighted : CraftGUITexture.CheckboxHighlighted); diff --git a/src/main/java/binnie/craftgui/controls/ControlText.java b/src/main/java/binnie/craftgui/controls/ControlText.java index b650a85f..4a955afb 100644 --- a/src/main/java/binnie/craftgui/controls/ControlText.java +++ b/src/main/java/binnie/craftgui/controls/ControlText.java @@ -13,7 +13,7 @@ public class ControlText extends Control implements IControlValue { private TextJustification align; public ControlText(final IWidget parent, final IPoint pos, final String text) { - this(parent, new IArea(pos, new IPoint(500.0f, 0.0f)), text, TextJustification.TopLeft); + this(parent, new IArea(pos, new IPoint(500, 0)), text, TextJustification.TopLeft); } public ControlText(final IWidget parent, final String text, final TextJustification align) { @@ -27,7 +27,7 @@ public class ControlText extends Control implements IControlValue { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.text(this.getArea(), this.align, this.text, this.getColour()); } diff --git a/src/main/java/binnie/craftgui/controls/ControlTextCentered.java b/src/main/java/binnie/craftgui/controls/ControlTextCentered.java index 63ae7e86..33fa56de 100644 --- a/src/main/java/binnie/craftgui/controls/ControlTextCentered.java +++ b/src/main/java/binnie/craftgui/controls/ControlTextCentered.java @@ -6,7 +6,7 @@ import binnie.craftgui.core.geometry.IPoint; import binnie.craftgui.core.geometry.TextJustification; public class ControlTextCentered extends ControlText { - public ControlTextCentered(final IWidget parent, final float y, final String text) { - super(parent, new IArea(new IPoint(0.0f, y), new IPoint(parent.size().x(), 0.0f)), text, TextJustification.TopCenter); + public ControlTextCentered(final IWidget parent, final int y, final String text) { + super(parent, new IArea(new IPoint(0, y), new IPoint(parent.size().x(), 0)), text, TextJustification.TopCenter); } } diff --git a/src/main/java/binnie/craftgui/controls/ControlTextEdit.java b/src/main/java/binnie/craftgui/controls/ControlTextEdit.java index 69f77867..e4e3d997 100644 --- a/src/main/java/binnie/craftgui/controls/ControlTextEdit.java +++ b/src/main/java/binnie/craftgui/controls/ControlTextEdit.java @@ -17,7 +17,7 @@ public class ControlTextEdit extends Control implements IControlValue { GuiTextField field; private String cachedValue; - public ControlTextEdit(final IWidget parent, final float x, final float y, final float width, final float height) { + public ControlTextEdit(final IWidget parent, final int x, final int y, final int width, final int height) { super(parent, x, y, width, height); this.cachedValue = ""; this.field = new GuiTextField(0, this.getWindow().getGui().getFontRenderer(), 0, 0, 10, 10); @@ -77,7 +77,7 @@ public class ControlTextEdit extends Control implements IControlValue { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.texture(CraftGUITexture.Slot, this.getArea()); this.renderTextField(); } diff --git a/src/main/java/binnie/craftgui/controls/button/ControlButton.java b/src/main/java/binnie/craftgui/controls/button/ControlButton.java index 0fa30c78..0ffd2f4f 100644 --- a/src/main/java/binnie/craftgui/controls/button/ControlButton.java +++ b/src/main/java/binnie/craftgui/controls/button/ControlButton.java @@ -15,7 +15,7 @@ public class ControlButton extends Control { private ControlText textWidget; private String text; - public ControlButton(final IWidget parent, final float x, final float y, final float width, final float height) { + public ControlButton(final IWidget parent, final int x, final int y, final int width, final int height) { super(parent, x, y, width, height); this.addAttribute(Attribute.MouseOver); this.addEventHandler(new EventMouse.Down.Handler() { @@ -30,7 +30,7 @@ public class ControlButton extends Control { protected void onMouseClick(final EventMouse.Down event) { } - public ControlButton(final IWidget parent, final float x, final float y, final float width, final float height, final String text) { + public ControlButton(final IWidget parent, final int x, final int y, final int width, final int height, final String text) { this(parent, x, y, width, height); this.text = text; this.textWidget = new ControlText(this, this.getArea(), text, TextJustification.MiddleCenter); @@ -48,7 +48,7 @@ public class ControlButton extends Control { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { Object texture = CraftGUITexture.ButtonDisabled; if (this.isMouseOver()) { texture = CraftGUITexture.ButtonHighlighted; diff --git a/src/main/java/binnie/craftgui/controls/button/ControlEnumButton.java b/src/main/java/binnie/craftgui/controls/button/ControlEnumButton.java index 9e444abd..d150cf12 100644 --- a/src/main/java/binnie/craftgui/controls/button/ControlEnumButton.java +++ b/src/main/java/binnie/craftgui/controls/button/ControlEnumButton.java @@ -39,7 +39,7 @@ public class ControlEnumButton extends ControlButton implements IControlValue } } - public ControlEnumButton(final IWidget parent, final float x, final float y, final float width, final float height, final T[] values) { + public ControlEnumButton(final IWidget parent, final int x, final int y, final int width, final int height, final T[] values) { super(parent, x, y, width, height, ""); this.enumConstants = new ArrayList<>(); Collections.addAll(this.enumConstants, values); diff --git a/src/main/java/binnie/craftgui/controls/core/Control.java b/src/main/java/binnie/craftgui/controls/core/Control.java index f26a1f4a..870785e8 100644 --- a/src/main/java/binnie/craftgui/controls/core/Control.java +++ b/src/main/java/binnie/craftgui/controls/core/Control.java @@ -18,7 +18,7 @@ public class Control extends Widget implements ITooltipHelp, ITooltip { List tooltipStrings; public int extraLevel; - public Control(final IWidget parent, final float x, final float y, final float w, final float h) { + public Control(final IWidget parent, final int x, final int y, final int w, final int h) { super(parent); this.helpStrings = new ArrayList<>(); this.tooltipStrings = new ArrayList<>(); diff --git a/src/main/java/binnie/craftgui/controls/listbox/ControlList.java b/src/main/java/binnie/craftgui/controls/listbox/ControlList.java index 51667f8e..7675caa1 100644 --- a/src/main/java/binnie/craftgui/controls/listbox/ControlList.java +++ b/src/main/java/binnie/craftgui/controls/listbox/ControlList.java @@ -19,7 +19,7 @@ public class ControlList extends Control implements IControlValue { boolean creating; IValidator validator; - protected ControlList(final ControlListBox parent, final float x, final float y, final float w, final float h) { + protected ControlList(final ControlListBox parent, final int x, final int y, final int w, final int h) { super(parent, x, y, w, h); this.value = null; this.allOptions = new LinkedHashMap<>(); @@ -67,7 +67,7 @@ public class ControlList extends Control implements IControlValue { if (this.isValidOption(entry.getValue())) { entry.getValue().show(); this.optionWidgets.put(entry.getKey(), entry.getValue()); - entry.getValue().setPosition(new IPoint(0.0f, height)); + entry.getValue().setPosition(new IPoint(0, height)); height += (int) entry.getValue().getSize().y(); } else { entry.getValue().hide(); diff --git a/src/main/java/binnie/craftgui/controls/listbox/ControlListBox.java b/src/main/java/binnie/craftgui/controls/listbox/ControlListBox.java index f274d06a..8a236d34 100644 --- a/src/main/java/binnie/craftgui/controls/listbox/ControlListBox.java +++ b/src/main/java/binnie/craftgui/controls/listbox/ControlListBox.java @@ -9,13 +9,13 @@ import binnie.craftgui.events.EventKey; import java.util.Collection; public class ControlListBox extends ControlScrollableContent> implements IControlValue { - public ControlListBox(final IWidget parent, final float x, final float y, final float w, final float h, final float scrollBarSize) { + public ControlListBox(final IWidget parent, final int x, final int y, final int w, final int h, final int scrollBarSize) { super(parent, x, y, w, h, scrollBarSize); } @Override public void initialise() { - this.setScrollableContent(new ControlList<>(this, 1.0f, 1.0f, this.w() - 2.0f - this.scrollBarSize, this.h() - 2.0f)); + this.setScrollableContent(new ControlList<>(this, 1, 1, this.w() - 2 - this.scrollBarSize, this.h() - 2)); this.addEventHandler(new EventKey.Down.Handler() { @Override public void onEvent(final EventKey.Down event) { diff --git a/src/main/java/binnie/craftgui/controls/listbox/ControlOption.java b/src/main/java/binnie/craftgui/controls/listbox/ControlOption.java index 8f93e7f7..1376766b 100644 --- a/src/main/java/binnie/craftgui/controls/listbox/ControlOption.java +++ b/src/main/java/binnie/craftgui/controls/listbox/ControlOption.java @@ -27,7 +27,7 @@ public class ControlOption extends Control implements IControlValue { } public ControlOption(final ControlList controlList, final T option, final int height) { - super(controlList, 0.0f, height, controlList.getSize().x(), 20.0f); + super(controlList, 0, height, controlList.getSize().x(), 20); this.value = option; if (this.value != null) { this.addAttribute(Attribute.MouseOver); @@ -55,7 +55,7 @@ public class ControlOption extends Control implements IControlValue { } @Override - public void onRenderForeground() { + public void onRenderForeground(int guiWidth, int guiHeight) { if (this.isCurrentSelection()) { CraftGUI.render.texture(CraftGUITexture.Outline, this.getArea()); } diff --git a/src/main/java/binnie/craftgui/controls/page/ControlPage.java b/src/main/java/binnie/craftgui/controls/page/ControlPage.java index b0219094..b0f430c8 100644 --- a/src/main/java/binnie/craftgui/controls/page/ControlPage.java +++ b/src/main/java/binnie/craftgui/controls/page/ControlPage.java @@ -8,10 +8,10 @@ public class ControlPage extends Control implements IControlValue { T value; public ControlPage(final IWidget parent, final T value) { - this(parent, 0.0f, 0.0f, parent.w(), parent.h(), value); + this(parent, 0, 0, parent.w(), parent.h(), value); } - public ControlPage(final IWidget parent, final float x, final float y, final float w, final float h, final T value) { + public ControlPage(final IWidget parent, final int x, final int y, final int w, final int h, final T value) { super(parent, x, y, w, h); this.setValue(value); if (parent instanceof IControlValue && ((IControlValue) parent).getValue() == null) { diff --git a/src/main/java/binnie/craftgui/controls/page/ControlPages.java b/src/main/java/binnie/craftgui/controls/page/ControlPages.java index 2e2b57e1..5a78daa5 100644 --- a/src/main/java/binnie/craftgui/controls/page/ControlPages.java +++ b/src/main/java/binnie/craftgui/controls/page/ControlPages.java @@ -18,7 +18,7 @@ public class ControlPages extends Control implements IControlValues, ICont return child != null && this.value == ((IControlValue) child).getValue(); } - public ControlPages(final IWidget parent, final float x, final float y, final float w, final float h) { + public ControlPages(final IWidget parent, final int x, final int y, final int w, final int h) { super(parent, x, y, w, h); this.value = null; } diff --git a/src/main/java/binnie/craftgui/controls/scroll/ControlScroll.java b/src/main/java/binnie/craftgui/controls/scroll/ControlScroll.java index b50e750b..01adbacf 100644 --- a/src/main/java/binnie/craftgui/controls/scroll/ControlScroll.java +++ b/src/main/java/binnie/craftgui/controls/scroll/ControlScroll.java @@ -6,7 +6,7 @@ import binnie.craftgui.core.IWidget; public class ControlScroll extends Control { private IControlScrollable scrollWidget; - public ControlScroll(final IWidget parent, final float x, final float y, final float width, final float height, final IControlScrollable scrollWidget) { + public ControlScroll(final IWidget parent, final int x, final int y, final int width, final int height, final IControlScrollable scrollWidget) { super(parent, x, y, width, height); this.scrollWidget = scrollWidget; new ControlScrollBar(this); diff --git a/src/main/java/binnie/craftgui/controls/scroll/ControlScrollBar.java b/src/main/java/binnie/craftgui/controls/scroll/ControlScrollBar.java index deb9568b..12f63903 100644 --- a/src/main/java/binnie/craftgui/controls/scroll/ControlScrollBar.java +++ b/src/main/java/binnie/craftgui/controls/scroll/ControlScrollBar.java @@ -12,10 +12,10 @@ public class ControlScrollBar extends Control { protected final IControlScrollable scrollable; public ControlScrollBar(final ControlScroll parent) { - this(parent, 0.0f, 0.0f, parent.getSize().x(), parent.getSize().y(), parent.getScrollableWidget()); + this(parent, 0, 0, parent.getSize().x(), parent.getSize().y(), parent.getScrollableWidget()); } - public ControlScrollBar(final IWidget parent, final float x, final float y, final float w, final float h, final IControlScrollable scrollable2) { + public ControlScrollBar(final IWidget parent, final int x, final int y, final int w, final int h, final IControlScrollable scrollable2) { super(parent, x, y, w, h); this.scrollable = scrollable2; this.addAttribute(Attribute.MouseOver); @@ -53,21 +53,21 @@ public class ControlScrollBar extends Control { return this.scrollable.getPercentageShown() < 0.99f; } - public float getBarHeight() { - return this.h() * this.scrollable.getPercentageShown(); + public int getBarHeight() { + return Math.round(this.h() * this.scrollable.getPercentageShown()); } protected IArea getRenderArea() { - float height = this.getBarHeight(); - if (height < 6.0f) { - height = 6.0f; + int height = this.getBarHeight(); + if (height < 6) { + height = 6; } - final float yOffset = ((int) this.h() - (int) this.getBarHeight()) * this.scrollable.getPercentageIndex(); - return new IArea(0.0f, yOffset, this.getSize().x(), height); + final int yOffset = Math.round((this.h() - this.getBarHeight()) * this.scrollable.getPercentageIndex()); + return new IArea(0, yOffset, this.getSize().x(), height); } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { final IArea renderArea = this.getRenderArea(); Object texture = CraftGUITexture.ScrollDisabled; if (this.isMouseOver()) { diff --git a/src/main/java/binnie/craftgui/controls/scroll/ControlScrollableContent.java b/src/main/java/binnie/craftgui/controls/scroll/ControlScrollableContent.java index fe354484..75ecf090 100644 --- a/src/main/java/binnie/craftgui/controls/scroll/ControlScrollableContent.java +++ b/src/main/java/binnie/craftgui/controls/scroll/ControlScrollableContent.java @@ -9,20 +9,20 @@ import binnie.craftgui.events.EventWidget; public class ControlScrollableContent extends Control implements IControlScrollable { protected T controlChild; - protected float scrollBarSize; + protected int scrollBarSize; float percentageIndex; - public ControlScrollableContent(final IWidget parent, final float x, final float y, final float w, final float h, final float scrollBarSize) { + public ControlScrollableContent(final IWidget parent, final int x, final int y, final int w, final int h, final int scrollBarSize) { super(parent, x, y, w, h); - this.percentageIndex = 0.0f; - if (scrollBarSize != 0.0f) { - new ControlScroll(this, this.getSize().x() - scrollBarSize, 0.0f, scrollBarSize, this.getSize().y(), this); + this.percentageIndex = 0; + if (scrollBarSize != 0) { + new ControlScroll(this, this.getSize().x() - scrollBarSize, 0, scrollBarSize, this.getSize().y(), this); } this.addEventHandler(new EventMouse.Wheel.Handler() { @Override public void onEvent(final EventMouse.Wheel event) { - if (ControlScrollableContent.this.getRelativeMousePosition().x() > 0.0f && ControlScrollableContent.this.getRelativeMousePosition().y() > 0.0f && ControlScrollableContent.this.getRelativeMousePosition().x() < ControlScrollableContent.this.getSize().x() && ControlScrollableContent.this.getRelativeMousePosition().y() < ControlScrollableContent.this.getSize().y()) { - if (ControlScrollableContent.this.getMovementRange() == 0.0f) { + if (ControlScrollableContent.this.getRelativeMousePosition().x() > 0 && ControlScrollableContent.this.getRelativeMousePosition().y() > 0 && ControlScrollableContent.this.getRelativeMousePosition().x() < ControlScrollableContent.this.getSize().x() && ControlScrollableContent.this.getRelativeMousePosition().y() < ControlScrollableContent.this.getSize().y()) { + if (ControlScrollableContent.this.getMovementRange() == 0) { return; } final float percentageMove = 0.8f / ControlScrollableContent.this.getMovementRange(); @@ -39,14 +39,14 @@ public class ControlScrollableContent extends Control impleme return; } - child.setCroppedZone(this, new IArea(1.0F, 1.0F, getSize().x() - 2.0F - this.scrollBarSize, getSize().y() - 2.0F)); + child.setCroppedZone(this, new IArea(1, 1, getSize().x() - 2 - this.scrollBarSize, getSize().y() - 2)); child.addSelfEventHandler(new EventWidget.ChangeSize.Handler() { @Override public void onEvent(final EventWidget.ChangeSize event) { - ControlScrollableContent.this.controlChild.setOffset(new IPoint(0.0f, -ControlScrollableContent.this.percentageIndex * ControlScrollableContent.this.getMovementRange())); - if (ControlScrollableContent.this.getMovementRange() == 0.0f) { - ControlScrollableContent.this.percentageIndex = 0.0f; + ControlScrollableContent.this.controlChild.setOffset(new IPoint(0, Math.round(-ControlScrollableContent.this.percentageIndex * ControlScrollableContent.this.getMovementRange()))); + if (ControlScrollableContent.this.getMovementRange() == 0) { + ControlScrollableContent.this.percentageIndex = 0; } } }); @@ -58,11 +58,11 @@ public class ControlScrollableContent extends Control impleme @Override public float getPercentageShown() { - if (this.controlChild == null || this.controlChild.getSize().y() == 0.0f) { - return 1.0f; + if (this.controlChild == null || this.controlChild.getSize().y() == 0) { + return 1; } final float shown = this.getSize().y() / this.controlChild.getSize().y(); - return Math.min(shown, 1.0f); + return Math.min(shown, 1); } @Override @@ -76,15 +76,15 @@ public class ControlScrollableContent extends Control impleme return; } this.percentageIndex += percentage; - if (this.percentageIndex > 1.0f) { - this.percentageIndex = 1.0f; - } else if (this.percentageIndex < 0.0f) { - this.percentageIndex = 0.0f; + if (this.percentageIndex > 1) { + this.percentageIndex = 1; + } else if (this.percentageIndex < 0) { + this.percentageIndex = 0; } - if (this.getMovementRange() == 0.0f) { - this.percentageIndex = 0.0f; + if (this.getMovementRange() == 0) { + this.percentageIndex = 0; } - this.controlChild.setOffset(new IPoint(0.0f, -this.percentageIndex * this.getMovementRange())); + this.controlChild.setOffset(new IPoint(0, Math.round(-this.percentageIndex * this.getMovementRange()))); } @Override @@ -95,10 +95,10 @@ public class ControlScrollableContent extends Control impleme @Override public float getMovementRange() { if (this.controlChild == null) { - return 0.0f; + return 0; } final float range = this.controlChild.getSize().y() - this.getSize().y(); - return Math.max(range, 0.0f); + return Math.max(range, 0); } @Override @@ -111,13 +111,13 @@ public class ControlScrollableContent extends Control impleme maxY /= totalY; final float shownPercentage = this.getPercentageShown(); final float percentageIndex = this.getPercentageIndex(); - final float minPercent = (1.0f - shownPercentage) * percentageIndex; + final float minPercent = (1 - shownPercentage) * percentageIndex; final float maxPercent = minPercent + shownPercentage; if (maxY > maxPercent) { - this.setPercentageIndex((maxY - shownPercentage) / (1.0f - shownPercentage)); + this.setPercentageIndex((maxY - shownPercentage) / (1 - shownPercentage)); } if (minY < minPercent) { - this.setPercentageIndex(minY / (1.0f - shownPercentage)); + this.setPercentageIndex(minY / (1 - shownPercentage)); } } } diff --git a/src/main/java/binnie/craftgui/controls/tab/ControlTab.java b/src/main/java/binnie/craftgui/controls/tab/ControlTab.java index a3e742ad..e6e9ae48 100644 --- a/src/main/java/binnie/craftgui/controls/tab/ControlTab.java +++ b/src/main/java/binnie/craftgui/controls/tab/ControlTab.java @@ -20,7 +20,7 @@ public class ControlTab extends Control implements ITooltip, IControlValue private ControlTabBar tabBar; protected T value; - public ControlTab(final ControlTabBar parent, final float x, final float y, final float w, final float h, final T value) { + public ControlTab(final ControlTabBar parent, final int x, final int y, final int w, final int h, final T value) { super(parent, x, y, w, h); this.setValue(value); this.tabBar = parent; @@ -67,7 +67,7 @@ public class ControlTab extends Control implements ITooltip, IControlValue } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { Object texture = CraftGUITexture.TabDisabled; if (this.isMouseOver()) { texture = CraftGUITexture.TabHighlighted; @@ -76,7 +76,7 @@ public class ControlTab extends Control implements ITooltip, IControlValue } final Texture lTexture = CraftGUI.render.getTexture(texture); final Position position = this.getTabPosition(); - Texture iTexture = lTexture.crop(position, 8.0f); + Texture iTexture = lTexture.crop(position, 8); final IArea area = this.getArea(); if (texture == CraftGUITexture.TabDisabled) { if (position == Position.Top || position == Position.Left) { @@ -97,7 +97,7 @@ public class ControlTab extends Control implements ITooltip, IControlValue } if (icon.hasOutline()) { iTexture = CraftGUI.render.getTexture(CraftGUITexture.TabOutline); - iTexture = iTexture.crop(position, 8.0f); + iTexture = iTexture.crop(position, 8); CraftGUI.render.colour(icon.getOutlineColour()); CraftGUI.render.texture(iTexture, area.inset(2)); } diff --git a/src/main/java/binnie/craftgui/controls/tab/ControlTabBar.java b/src/main/java/binnie/craftgui/controls/tab/ControlTabBar.java index b5538b35..bf405bc1 100644 --- a/src/main/java/binnie/craftgui/controls/tab/ControlTabBar.java +++ b/src/main/java/binnie/craftgui/controls/tab/ControlTabBar.java @@ -13,7 +13,7 @@ public class ControlTabBar extends Control implements IControlValue { T value; Position position; - public ControlTabBar(final IWidget parent, final float x, final float y, final float width, final float height, final Position position) { + public ControlTabBar(final IWidget parent, final int x, final int y, final int width, final int height, final Position position) { super(parent, x, y, width, height); this.position = position; this.addEventHandler(new EventValueChanged.Handler() { @@ -37,9 +37,9 @@ public class ControlTabBar extends Control implements IControlValue { int j = 0; for (final T value : values) { if (this.position == Position.Top || this.position == Position.Bottom) { - final IWidget tab = this.createTab(j * tabDimension, 0.0f, tabDimension, this.getSize().y(), value); + final IWidget tab = this.createTab(j * tabDimension, 0, tabDimension, this.getSize().y(), value); } else { - final IWidget tab = this.createTab(0.0f, j * tabDimension, this.getSize().x(), tabDimension, value); + final IWidget tab = this.createTab(0, j * tabDimension, this.getSize().x(), tabDimension, value); } ++j; } @@ -48,7 +48,7 @@ public class ControlTabBar extends Control implements IControlValue { } } - public ControlTab createTab(final float x, final float y, final float w, final float h, final T value) { + public ControlTab createTab(final int x, final int y, final int w, final int h, final T value) { return new ControlTab<>(this, x, y, w, h, value); } diff --git a/src/main/java/binnie/craftgui/core/CraftGUI.java b/src/main/java/binnie/craftgui/core/CraftGUI.java index 3247d97b..03d8b47f 100644 --- a/src/main/java/binnie/craftgui/core/CraftGUI.java +++ b/src/main/java/binnie/craftgui/core/CraftGUI.java @@ -5,5 +5,5 @@ import binnie.craftgui.resource.minecraft.CraftGUIResourceManager; public class CraftGUI { public static CraftGUIResourceManager resourceManager; - public static Renderer render; + public static final Renderer render = new Renderer(); } diff --git a/src/main/java/binnie/craftgui/core/IWidget.java b/src/main/java/binnie/craftgui/core/IWidget.java index b82629af..c1653c27 100644 --- a/src/main/java/binnie/craftgui/core/IWidget.java +++ b/src/main/java/binnie/craftgui/core/IWidget.java @@ -52,7 +52,7 @@ public interface IWidget { int getColour(); - void render(); + void render(int guiWidth, int guiHeight); void updateClient(); @@ -126,13 +126,13 @@ public interface IWidget { boolean contains(final IPoint p0); - float x(); + int x(); - float y(); + int y(); - float w(); + int w(); - float h(); + int h(); - void onRender(final RenderStage p0); + void onRender(final RenderStage stage, int guiWidth, int guiHeight); } diff --git a/src/main/java/binnie/craftgui/core/TopLevelWidget.java b/src/main/java/binnie/craftgui/core/TopLevelWidget.java index f7e2e57e..fe4d653a 100644 --- a/src/main/java/binnie/craftgui/core/TopLevelWidget.java +++ b/src/main/java/binnie/craftgui/core/TopLevelWidget.java @@ -24,7 +24,7 @@ public abstract class TopLevelWidget extends Widget implements ITopLevelWidget { this.mousedOverWidget = null; this.draggedWidget = null; this.focusedWidget = null; - this.mousePosition = new IPoint(0.0f, 0.0f); + this.mousePosition = IPoint.ZERO; this.dragStart = IPoint.ZERO; this.addEventHandler(new EventMouse.Down.Handler() { @Override diff --git a/src/main/java/binnie/craftgui/core/Widget.java b/src/main/java/binnie/craftgui/core/Widget.java index 46f35114..cd7ec8c1 100644 --- a/src/main/java/binnie/craftgui/core/Widget.java +++ b/src/main/java/binnie/craftgui/core/Widget.java @@ -30,9 +30,9 @@ public class Widget implements IWidget { this.parent = null; this.subWidgets = new ArrayList<>(); this.attributes = new ArrayList<>(); - this.position = new IPoint(0.0f, 0.0f); - this.size = new IPoint(0.0f, 0.0f); - this.offset = new IPoint(0.0f, 0.0f); + this.position = IPoint.ZERO; + this.size = IPoint.ZERO; + this.offset = IPoint.ZERO; this.cropped = false; this.colour = 16777215; this.globalEventHandlers = new ArrayList<>(); @@ -269,19 +269,19 @@ public class Widget implements IWidget { } @Override - public final void render() { + public final void render(int guiWidth, int guiHeight) { if (this.isVisible()) { - CraftGUI.render.preRender(this); - this.onRender(RenderStage.PreChildren); + CraftGUI.render.preRender(this, guiWidth, guiHeight); + this.onRender(RenderStage.PreChildren, guiWidth, guiHeight); for (final IWidget widget : this.getWidgets()) { - widget.render(); + widget.render(guiWidth, guiHeight); } for (final IWidget widget : this.getWidgets()) { - CraftGUI.render.preRender(widget); - widget.onRender(RenderStage.PostSiblings); + CraftGUI.render.preRender(widget, guiWidth, guiHeight); + widget.onRender(RenderStage.PostSiblings, guiWidth, guiHeight); CraftGUI.render.postRender(widget); } - this.onRender(RenderStage.PostChildren); + this.onRender(RenderStage.PostChildren, guiWidth, guiHeight); CraftGUI.render.postRender(this); } } @@ -402,22 +402,22 @@ public class Widget implements IWidget { } @Override - public void onRender(final RenderStage stage) { + public void onRender(final RenderStage stage, int guiWidth, int guiHeight) { if (stage == RenderStage.PreChildren) { - this.onRenderBackground(); + this.onRenderBackground(guiWidth, guiHeight); } if (stage == RenderStage.PostChildren) { - this.onRenderForeground(); + this.onRenderForeground(guiWidth, guiHeight); } if (stage == RenderStage.PostSiblings) { this.onRenderOverlay(); } } - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { } - public void onRenderForeground() { + public void onRenderForeground(int guiWidth, int guiHeight) { } public void onRenderOverlay() { @@ -480,22 +480,22 @@ public class Widget implements IWidget { } @Override - public float x() { + public int x() { return this.pos().x(); } @Override - public float y() { + public int y() { return this.pos().y(); } @Override - public float w() { + public int w() { return this.size().x(); } @Override - public float h() { + public int h() { return this.size().y(); } diff --git a/src/main/java/binnie/craftgui/core/geometry/CraftGUIUtil.java b/src/main/java/binnie/craftgui/core/geometry/CraftGUIUtil.java index ade6ebf3..39f19e0a 100644 --- a/src/main/java/binnie/craftgui/core/geometry/CraftGUIUtil.java +++ b/src/main/java/binnie/craftgui/core/geometry/CraftGUIUtil.java @@ -3,6 +3,20 @@ package binnie.craftgui.core.geometry; import binnie.craftgui.controls.core.IControlValue; import binnie.craftgui.core.IWidget; import binnie.craftgui.events.EventValueChanged; +import com.google.common.base.Preconditions; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.VertexBuffer; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.client.config.GuiUtils; +import org.lwjgl.opengl.GL11; + +import javax.annotation.Nonnull; public class CraftGUIUtil { public static void alignToWidget(final IWidget target, final IWidget relativeTo) { @@ -15,34 +29,34 @@ public class CraftGUIUtil { target.setPosition(target.getPosition().add(movement)); } - public static void horizontalGrid(final float px, final float py, final IWidget... widgets) { - horizontalGrid(px, py, TextJustification.MiddleCenter, 0.0f, widgets); + public static void horizontalGrid(final int px, final int py, final IWidget... widgets) { + horizontalGrid(px, py, TextJustification.MiddleCenter, 0, widgets); } - public static void horizontalGrid(final float px, final float py, final TextJustification just, final float spacing, final IWidget... widgets) { - float x = 0.0f; - float h = 0.0f; + public static void horizontalGrid(final int px, final int py, final TextJustification just, final int spacing, final IWidget... widgets) { + int x = 0; + int h = 0; for (final IWidget widget : widgets) { h = Math.max(h, widget.getSize().y()); } for (final IWidget widget : widgets) { - widget.setPosition(new IPoint(px + x, py + (h - widget.getSize().y()) * just.yOffset)); + widget.setPosition(new IPoint(px + x, py + Math.round((h - widget.getSize().y()) * just.getYOffset()))); x += widget.getSize().x() + spacing; } } - public static void verticalGrid(final float px, final float py, final IWidget... widgets) { - horizontalGrid(px, py, TextJustification.MiddleCenter, 0.0f, widgets); + public static void verticalGrid(final int px, final int py, final IWidget... widgets) { + horizontalGrid(px, py, TextJustification.MiddleCenter, 0, widgets); } - public static void verticalGrid(final float px, final float py, final TextJustification just, final float spacing, final IWidget... widgets) { - float y = 0.0f; - float w = 0.0f; + public static void verticalGrid(final int px, final int py, final TextJustification just, final int spacing, final IWidget... widgets) { + int y = 0; + int w = 0; for (final IWidget widget : widgets) { w = Math.max(w, widget.getSize().x()); } for (final IWidget widget : widgets) { - widget.setPosition(new IPoint(px + (w - widget.getSize().x()) * just.xOffset, py + y)); + widget.setPosition(new IPoint(px + Math.round((w - widget.getSize().x()) * just.getXOffset()), py + y)); y += widget.getSize().y() + spacing; } } @@ -61,4 +75,131 @@ public class CraftGUIUtil { } }); } + + public static void renderTexturePadded(final IArea area, final IArea texture, final IBorder padding) { + int borderLeft = padding.l(); + int borderRight = padding.r(); + int borderTop = padding.t(); + int borderBottom = padding.b(); + final int posX = area.pos().x(); + final int posY = area.pos().y(); + final int width = area.size().x(); + final int height = area.size().y(); + final int textWidth = texture.w(); + final int textHeight = texture.h(); + final int u = texture.x(); + final int v = texture.y(); + if (borderTop + borderBottom > height) { + borderTop = height / 2; + borderBottom = height / 2; + } + if (borderLeft + borderRight > width) { + borderLeft = width / 2; + borderRight = width / 2; + } + final IPoint origin = area.pos(); + GuiUtils.drawTexturedModalRect(posX, posY, u, v, borderLeft, borderTop, 0); + GuiUtils.drawTexturedModalRect(posX + width - borderRight, posY, u + textWidth - borderRight, v, borderRight, borderTop, 0); + GuiUtils.drawTexturedModalRect(posX, posY + height - borderBottom, u, v + textHeight - borderBottom, borderLeft, borderBottom, 0); + GuiUtils.drawTexturedModalRect(posX + width - borderRight, posY + height - borderBottom, u + textWidth - borderRight, v + textHeight - borderBottom, borderRight, borderBottom, 0); + int texturingWidth; + for (int currentXPos = borderLeft; currentXPos < width - borderRight; currentXPos += texturingWidth) { + final int distanceXRemaining = width - borderRight - currentXPos; + texturingWidth = textWidth - borderLeft - borderRight; + if (texturingWidth > distanceXRemaining) { + texturingWidth = distanceXRemaining; + } + if (texturingWidth <= 0) { + break; + } + GuiUtils.drawTexturedModalRect(posX + currentXPos, posY, u + borderLeft, v, texturingWidth, borderTop, 0); + GuiUtils.drawTexturedModalRect(posX + currentXPos, posY + height - borderBottom, u + borderLeft, v + textHeight - borderBottom, texturingWidth, borderBottom, 0); + int texturingHeight; + for (int currentYPos = borderTop; currentYPos < height - borderBottom; currentYPos += texturingHeight) { + final int distanceYRemaining = height - borderBottom - currentYPos; + texturingHeight = textHeight - borderTop - borderBottom; + if (texturingHeight > distanceYRemaining) { + texturingHeight = distanceYRemaining; + } + if (texturingHeight <= 0) { + break; + } + GuiUtils.drawTexturedModalRect(posX + currentXPos, posY + currentYPos, u + borderLeft, v + borderTop, texturingWidth, texturingHeight, 0); + } + } + int texturingHeight2; + for (int currentYPos2 = borderTop; currentYPos2 < height - borderBottom; currentYPos2 += texturingHeight2) { + final int distanceYRemaining2 = height - borderBottom - currentYPos2; + texturingHeight2 = textHeight - borderTop - borderBottom; + if (texturingHeight2 > distanceYRemaining2) { + texturingHeight2 = distanceYRemaining2; + } + if (texturingHeight2 <= 0) { + break; + } + GuiUtils.drawTexturedModalRect(posX, posY + currentYPos2, u, v + borderTop, borderLeft, texturingHeight2, 0); + GuiUtils.drawTexturedModalRect(posX + width - borderRight, posY + currentYPos2, u + textWidth - borderRight, v + borderTop, borderRight, texturingHeight2, 0); + } + } + + public static void drawRect(float left, float top, float right, float bottom, final int color) { + GuiUtils.drawGradientRect(0, (int) left, (int) top, (int) right, (int) bottom, color, color); + } + + public static void renderItem(final IPoint pos, final ItemStack itemStack) { + renderItem(pos, itemStack, false); + } + + public static void renderItem(final IPoint pos, final ItemStack itemStack, final boolean rotating) { + Preconditions.checkNotNull(itemStack); + Minecraft minecraft = Minecraft.getMinecraft(); + RenderHelper.enableGUIStandardItemLighting(); + FontRenderer font = getFontRenderer(minecraft, itemStack); + + if (rotating) { + GlStateManager.pushMatrix(); + final float phase = Minecraft.getSystemTime() / 20; + GL11.glTranslatef(8, 8, 0); + GL11.glRotatef(phase, 0, -0.866f, 0.5f); + GL11.glTranslatef(-8, -8, -67.1f); + } + + minecraft.getRenderItem().renderItemAndEffectIntoGUI(null, itemStack, pos.x(), pos.y()); + minecraft.getRenderItem().renderItemOverlayIntoGUI(font, itemStack, pos.x(), pos.y(), null); + + if (rotating) { + GlStateManager.popMatrix(); + } + + GlStateManager.disableBlend(); + RenderHelper.disableStandardItemLighting(); + } + + @Nonnull + private static FontRenderer getFontRenderer(Minecraft minecraft, ItemStack ingredient) { + FontRenderer fontRenderer = ingredient.getItem().getFontRenderer(ingredient); + if (fontRenderer == null) { + fontRenderer = minecraft.fontRendererObj; + } + return fontRenderer; + } + + public static void drawTexture(double xCoord, double yCoord, TextureAtlasSprite textureSprite, int maskTop, int maskRight, double zLevel) { + double uMin = textureSprite.getMinU(); + double uMax = textureSprite.getMaxU(); + double vMin = textureSprite.getMinV(); + double vMax = textureSprite.getMaxV(); + uMax = uMax - maskRight / 16.0 * (uMax - uMin); + vMax = vMax - maskTop / 16.0 * (vMax - vMin); + + Tessellator tessellator = Tessellator.getInstance(); + VertexBuffer vertexBuffer = tessellator.getBuffer(); + vertexBuffer.begin(7, DefaultVertexFormats.POSITION_TEX); + vertexBuffer.pos(xCoord, yCoord + 16, zLevel).tex(uMin, vMax).endVertex(); + vertexBuffer.pos(xCoord + 16 - maskRight, yCoord + 16, zLevel).tex(uMax, vMax).endVertex(); + vertexBuffer.pos(xCoord + 16 - maskRight, yCoord + maskTop, zLevel).tex(uMax, vMin).endVertex(); + vertexBuffer.pos(xCoord, yCoord + maskTop, zLevel).tex(uMin, vMin).endVertex(); + tessellator.draw(); + } + } diff --git a/src/main/java/binnie/craftgui/core/geometry/IArea.java b/src/main/java/binnie/craftgui/core/geometry/IArea.java index d38c9ba1..9f28db76 100644 --- a/src/main/java/binnie/craftgui/core/geometry/IArea.java +++ b/src/main/java/binnie/craftgui/core/geometry/IArea.java @@ -12,19 +12,19 @@ public class IArea { this(pos.x(), pos.y(), size.x(), size.y()); } - public IArea(final float xywh) { + public IArea(final int xywh) { this(xywh, xywh, xywh, xywh); } - public IArea(final float xy, final float wh) { + public IArea(final int xy, final int wh) { this(xy, xy, wh, wh); } - public IArea(final float x, final float y, final float wh) { + public IArea(final int x, final int y, final int wh) { this(x, y, wh, wh); } - public IArea(final float x, final float y, final float w, final float h) { + public IArea(final int x, final int y, final int w, final int h) { this.setPosition(new IPoint(x, y)); this.setSize(new IPoint(w, h)); } @@ -57,36 +57,36 @@ public class IArea { return position.x() >= this.pos().x() && position.y() >= this.pos.y() && position.x() <= this.pos().x() + this.size().x() && position.y() <= this.pos().y() + this.size().y(); } - public float x() { + public int x() { return this.pos().x(); } - public float y() { + public int y() { return this.pos().y(); } - public float w() { + public int w() { return this.size().x(); } - public float h() { + public int h() { return this.size().y(); } - public float x(final float n) { - return this.pos.x(n); + public void x(final int n) { + this.pos = new IPoint(n, this.pos.y()); } - public float y(final float n) { - return this.pos.y(n); + public void y(final int n) { + this.pos = new IPoint(this.pos.x(), n); } - public float w(final float n) { - return this.size.x(n); + public void w(final int n) { + this.size = new IPoint(n, this.size.y()); } - public float h(final float n) { - return this.size.y(n); + public void h(final int n) { + this.size = new IPoint(this.size.x(), n); } public IArea inset(final IBorder border) { @@ -110,7 +110,7 @@ public class IArea { return this.w() + "x" + this.h() + "@" + this.x() + "," + this.y(); } - public IArea shift(final float dx, final float f) { + public IArea shift(final int dx, final int f) { return new IArea(this.x() + dx, this.y() + f, this.w(), this.h()); } } diff --git a/src/main/java/binnie/craftgui/core/geometry/IBorder.java b/src/main/java/binnie/craftgui/core/geometry/IBorder.java index 16e2212a..16dd857c 100644 --- a/src/main/java/binnie/craftgui/core/geometry/IBorder.java +++ b/src/main/java/binnie/craftgui/core/geometry/IBorder.java @@ -1,68 +1,68 @@ package binnie.craftgui.core.geometry; public class IBorder { - public static final IBorder ZERO = new IBorder(0.0f); - float t; - float b; - float l; - float r; + public static final IBorder ZERO = new IBorder(0); + int t; + int b; + int l; + int r; - public IBorder(final float pad) { + public IBorder(final int pad) { this(pad, pad, pad, pad); } - public IBorder(final float tb, final float rl) { + public IBorder(final int tb, final int rl) { this(tb, rl, tb, rl); } - public IBorder(final float t, final float rl, final float b) { + public IBorder(final int t, final int rl, final int b) { this(t, rl, b, rl); } - public IBorder(final float t, final float r, final float b, final float l) { + public IBorder(final int t, final int r, final int b, final int l) { this.t = t; this.b = b; this.l = l; this.r = r; } - public IBorder(final Position edge, final float n) { - this((edge == Position.Top) ? n : 0.0f, (edge == Position.Right) ? n : 0.0f, (edge == Position.Bottom) ? n : 0.0f, (edge == Position.Left) ? n : 0.0f); + public IBorder(final Position edge, final int n) { + this((edge == Position.Top) ? n : 0, (edge == Position.Right) ? n : 0, (edge == Position.Bottom) ? n : 0, (edge == Position.Left) ? n : 0); } public IBorder(final IBorder padding) { this(padding.t(), padding.r(), padding.b(), padding.l()); } - public float t() { + public int t() { return this.t; } - public float b() { + public int b() { return this.b; } - public float l() { + public int l() { return this.l; } - public float r() { + public int r() { return this.r; } - public float t(final float n) { + public int t(final int n) { return this.t = n; } - public float b(final float n) { + public int b(final int n) { return this.b = n; } - public float l(final float n) { + public int l(final int n) { return this.l = n; } - public float r(final float n) { + public int r(final int n) { return this.r = n; } diff --git a/src/main/java/binnie/craftgui/core/geometry/IPoint.java b/src/main/java/binnie/craftgui/core/geometry/IPoint.java index 8c36229a..b1c740f1 100644 --- a/src/main/java/binnie/craftgui/core/geometry/IPoint.java +++ b/src/main/java/binnie/craftgui/core/geometry/IPoint.java @@ -1,20 +1,16 @@ package binnie.craftgui.core.geometry; public class IPoint { - public static final IPoint ZERO = new IPoint(0.0f, 0.0f); - float x; - float y; + public static final IPoint ZERO = new IPoint(0, 0); + private final int x; + private final int y; - public IPoint(final float x, final float y) { - this.x = 0.0f; - this.y = 0.0f; + public IPoint(final int x, final int y) { this.x = x; this.y = y; } public IPoint(final IPoint o) { - this.x = 0.0f; - this.y = 0.0f; this.x = o.x(); this.y = o.y(); } @@ -35,7 +31,7 @@ public class IPoint { return add(this, other); } - public IPoint add(final float dx, final float dy) { + public IPoint add(final int dx, final int dy) { return add(this, new IPoint(dx, dy)); } @@ -43,27 +39,14 @@ public class IPoint { return new IPoint(this); } - public float x() { + public int x() { return this.x; } - public float y() { + public int y() { return this.y; } - public void xy(final float x, final float y) { - this.x(x); - this.y(y); - } - - public float x(final float x) { - return this.x = x; - } - - public float y(final float y) { - return this.y = y; - } - public boolean equals(final IPoint other) { return this.x() == other.x() && this.y() == other.y(); } diff --git a/src/main/java/binnie/craftgui/core/geometry/TextJustification.java b/src/main/java/binnie/craftgui/core/geometry/TextJustification.java index a83bf6e2..444ff97e 100644 --- a/src/main/java/binnie/craftgui/core/geometry/TextJustification.java +++ b/src/main/java/binnie/craftgui/core/geometry/TextJustification.java @@ -11,8 +11,8 @@ public enum TextJustification { BottomCenter(0.5f, 1.0f), BottomRight(1.0f, 1.0f); - float xOffset; - float yOffset; + private final float xOffset; + private final float yOffset; TextJustification(final float xOffset, final float yOffset) { this.xOffset = xOffset; diff --git a/src/main/java/binnie/craftgui/core/renderer/Renderer.java b/src/main/java/binnie/craftgui/core/renderer/Renderer.java index 5b0725eb..56c82bff 100644 --- a/src/main/java/binnie/craftgui/core/renderer/Renderer.java +++ b/src/main/java/binnie/craftgui/core/renderer/Renderer.java @@ -2,58 +2,53 @@ package binnie.craftgui.core.renderer; import binnie.core.BinnieCore; import binnie.craftgui.core.IWidget; +import binnie.craftgui.core.geometry.CraftGUIUtil; import binnie.craftgui.core.geometry.IArea; import binnie.craftgui.core.geometry.IPoint; import binnie.craftgui.core.geometry.Position; import binnie.craftgui.core.geometry.TextJustification; -import binnie.craftgui.minecraft.GuiCraftGUI; import binnie.craftgui.resource.IStyleSheet; import binnie.craftgui.resource.Texture; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; - +import net.minecraftforge.fml.client.config.GuiUtils; import org.lwjgl.opengl.GL11; import java.util.List; public class Renderer { - GuiCraftGUI gui; - int currentColour; - Texture currentTexture; - IStyleSheet stylesheet; + private IStyleSheet stylesheet; - public Renderer(final GuiCraftGUI gui) { - this.currentColour = 16777215; - this.gui = gui; - } - - public final void preRender(final IWidget widget) { - GL11.glPushMatrix(); - GL11.glTranslatef(widget.getPosition().x(), widget.getPosition().y(), 0.0f); + public final void preRender(final IWidget widget, int guiWidth, int guiHeight) { + GlStateManager.pushMatrix(); + GlStateManager.translate(widget.getPosition().x(), widget.getPosition().y(), 0.0f); this.colour(widget.getColour()); if (widget.isCroppedWidet()) { final IWidget cropRelative = (widget.getCropWidget() != null) ? widget.getCropWidget() : widget; final IPoint pos = cropRelative.getAbsolutePosition(); final IArea cropZone = widget.getCroppedZone(); - GL11.glEnable(3089); - this.limitArea(new IArea(pos.add(cropZone.pos()), cropZone.size())); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + this.limitArea(new IArea(pos.add(cropZone.pos()), cropZone.size()), guiWidth, guiHeight); } - GL11.glDisable(2929); + GlStateManager.disableDepth(); } public final void postRender(final IWidget widget) { if (widget.isCroppedWidet()) { - GL11.glDisable(3089); + GL11.glDisable(GL11.GL_SCISSOR_TEST); } - GL11.glEnable(2929); - GL11.glPopMatrix(); + GlStateManager.enableDepth(); + GlStateManager.popMatrix(); } public void colour(final int hex) { - this.currentColour = hex; int a = (hex & 0xFF000000) >> 24; final int r = (hex & 0xFF0000) >> 16; final int g = (hex & 0xFF00) >> 8; @@ -62,10 +57,9 @@ public class Renderer { a += 256; } if (a > 0 && a != 255) { - GL11.glColor4f(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f); - GL11.glEnable(3042); + GlStateManager.color(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f); } else { - GL11.glColor3f(r / 255.0f, g / 255.0f, b / 255.0f); + GlStateManager.color(r / 255.0f, g / 255.0f, b / 255.0f); } } @@ -77,10 +71,9 @@ public class Renderer { } public void setTexture(final Texture texture) { - if (texture != this.currentTexture && texture != null) { + if (texture != null) { BinnieCore.proxy.bindTexture(texture.getFilename()); } - this.colour(this.currentColour); } public void texture(final Object texture, final IPoint position) { @@ -94,7 +87,7 @@ public class Renderer { this.setTexture(texture); final IPoint point = position.sub(new IPoint(texture.getBorder().l(), texture.getBorder().t())); final IArea textureArea = texture.getArea().outset(texture.getBorder()); - this.gui.renderTexture(point, textureArea); + GuiUtils.drawTexturedModalRect(point.x(), point.y(), textureArea.pos().x(), textureArea.pos().y(), textureArea.size().x(), textureArea.size().y(), 0); } public void texture(final Object window, final IArea area) { @@ -109,9 +102,10 @@ public class Renderer { final IArea textureArea = texture.getArea().outset(texture.getBorder()); final IArea targetArea = area.outset(texture.getBorder()); if (textureArea.w() == targetArea.w() && textureArea.h() == targetArea.h()) { - this.gui.renderTexture(targetArea.pos(), textureArea); + final IPoint position = targetArea.pos(); + GuiUtils.drawTexturedModalRect(position.x(), position.y(), textureArea.pos().x(), textureArea.pos().y(), textureArea.size().x(), textureArea.size().y(), 0); } else { - this.gui.renderTexturePadded(targetArea, textureArea, texture.getTotalPadding()); + CraftGUIUtil.renderTexturePadded(targetArea, textureArea, texture.getTotalPadding()); } } @@ -120,15 +114,17 @@ public class Renderer { } public int textWidth(final String text) { - return this.gui.getFontRenderer().getStringWidth(text); + FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj; + return fontRendererObj.getStringWidth(text); } public int textHeight() { - return (this.gui.getFontRenderer() == null) ? 0 : this.gui.getFontRenderer().FONT_HEIGHT; + FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj; + return (fontRendererObj == null) ? 0 : fontRendererObj.FONT_HEIGHT; } public void text(final IPoint pos, final String text, final int colour) { - this.text(new IArea(pos, new IPoint(500.0f, 500.0f)), TextJustification.TopLeft, text, colour); + this.text(new IArea(pos, new IPoint(500, 500)), TextJustification.TopLeft, text, colour); } public void text(final IArea area, final TextJustification justification, final String text, final int colour) { @@ -136,7 +132,8 @@ public class Renderer { if (area.size().x() <= 0.0f) { return; } - final List wrappedStrings = this.gui.getFontRenderer().listFormattedStringToWidth(text, (int) area.size().x()); + FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj; + final List wrappedStrings = fontRendererObj.listFormattedStringToWidth(text, area.size().x()); final float totalHeight = wrappedStrings.size() * this.textHeight(); float posY = area.pos().y(); if (area.size().y() > totalHeight) { @@ -146,56 +143,97 @@ public class Renderer { final float stringWidth = this.textWidth(string); float posX = area.size().x() - stringWidth; posX *= justification.getXOffset(); - GL11.glDisable(2929); - this.gui.getFontRenderer().drawString(string, (int) (pos.x() + posX), (int) posY, colour); + GlStateManager.disableDepth(); + fontRendererObj.drawString(string, (int) (pos.x() + posX), (int) posY, colour); posY += this.textHeight(); } - GL11.glColor3f(1.0f, 1.0f, 1.0f); + GlStateManager.color(1.0f, 1.0f, 1.0f); } public void solid(final IArea area, final int colour) { - this.gui.drawRect(area.pos().x(), area.pos().y(), area.pos().x() + area.size().x(), area.pos().y() + area.size().y(), 0xFF000000 | colour); + CraftGUIUtil.drawRect(area.pos().x(), area.pos().y(), area.pos().x() + area.size().x(), area.pos().y() + area.size().y(), 0xFF000000 | colour); } - public void solidAlpha(final IArea area, final int c1) { - this.gui.drawGradientArea(area.pos().x(), area.pos().y(), area.pos().x() + area.size().x(), area.pos().y() + area.size().y(), c1, c1); + public void solidAlpha(final IArea area, final int color) { + CraftGUIUtil.drawRect(area.pos().x(), area.pos().y(), area.pos().x() + area.size().x(), area.pos().y() + area.size().y(), color); } - public void gradientRect(final IArea area, final int c1, final int c2) { - this.gui.drawGradientArea(area.pos().x(), area.pos().y(), area.pos().x() + area.size().x(), area.pos().y() + area.size().y(), c1, c2); - } - - public void item(final IPoint pos, final ItemStack item) { - this.gui.renderItem(pos, item, false); - } - - public void item(final IPoint pos, final ItemStack item, final boolean rotating) { - this.gui.renderItem(pos, item, rotating); + public void gradientRect(final IArea area, final int startColor, final int endColor) { + GuiUtils.drawGradientRect(0, area.pos().x(), area.pos().y(), area.pos().x() + area.size().x(), area.pos().y() + area.size().y(), startColor, endColor); } public void sprite(final IPoint pos, final TextureAtlasSprite icon) { - this.gui.renderSprite(pos, icon, TextureMap.LOCATION_BLOCKS_TEXTURE); + if (icon != null) { + BinnieCore.proxy.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + CraftGUIUtil.drawTexture(pos.x(), pos.y(), icon, 0, 0, 0); + } } public void fluid(IPoint pos, FluidStack fluid){ - this.gui.renderFluid(fluid, pos); + GlStateManager.enableBlend(); + GlStateManager.enableAlpha(); + + Minecraft minecraft = Minecraft.getMinecraft(); + if (fluid != null) { + Fluid fluid1 = fluid.getFluid(); + if (fluid1 != null) { + TextureAtlasSprite fluidStillSprite = getStillFluidSprite(minecraft, fluid1); + + int fluidColor = fluid1.getColor(fluid); + + minecraft.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + colour(fluidColor); + CraftGUIUtil.drawTexture(pos.x(), pos.y(), fluidStillSprite, 0, 0, 100); + } + } + + GlStateManager.color(1, 1, 1, 1); + GlStateManager.disableAlpha(); + GlStateManager.disableBlend(); } - public void limitArea(final IArea area) { - this.gui.limitArea(area); + private static TextureAtlasSprite getStillFluidSprite(Minecraft minecraft, Fluid fluid) { + TextureMap textureMapBlocks = minecraft.getTextureMapBlocks(); + ResourceLocation fluidStill = fluid.getStill(); + TextureAtlasSprite fluidStillSprite = null; + if (fluidStill != null) { + fluidStillSprite = textureMapBlocks.getTextureExtry(fluidStill.toString()); + } + if (fluidStillSprite == null) { + fluidStillSprite = textureMapBlocks.getMissingSprite(); + } + return fluidStillSprite; } - public float textHeight(final String text, final float width) { - return this.gui.getFontRenderer().listFormattedStringToWidth(text, (int) width).size() * this.textHeight(); - } - - public void texturePercentage(final Texture texture, final IArea area, final Position direction, final float percentage) { - final float dist = (direction == Position.Top || direction == Position.Bottom) ? (percentage * texture.h()) : (percentage * texture.w()); - final float dim = (direction == Position.Top || direction == Position.Bottom) ? texture.h() : texture.w(); + public void limitArea(final IArea area, int guiWidth, int guiHeight) { float x = area.pos().x(); float y = area.pos().y(); float w = area.size().x(); float h = area.size().y(); + y = guiHeight - (y + h); + Minecraft minecraft = Minecraft.getMinecraft(); + final float scaleX = guiWidth / (float) minecraft.displayWidth; + final float scaleY = guiHeight / (float) minecraft.displayHeight; + x += 0.0f; + y += 0.0f; + w += 0.0f; + h += 0.0f; + GL11.glScissor((int) (x / scaleX), (int) (y / scaleY), (int) (w / scaleX), (int) (h / scaleY)); + } + + public int textHeight(final String text, final int width) { + Minecraft minecraft = Minecraft.getMinecraft(); + FontRenderer fontRenderer = minecraft.fontRendererObj; + return fontRenderer.listFormattedStringToWidth(text, width).size() * this.textHeight(); + } + + public void texturePercentage(final Texture texture, final IArea area, final Position direction, final float percentage) { + final int dist = (direction == Position.Top || direction == Position.Bottom) ? Math.round(percentage * texture.h()) : Math.round(percentage * texture.w()); + final int dim = (direction == Position.Top || direction == Position.Bottom) ? texture.h() : texture.w(); + int x = area.pos().x(); + int y = area.pos().y(); + int w = area.size().x(); + int h = area.size().y(); switch (direction) { case Top: { h *= percentage; diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/ControlBlockIconDisplay.java b/src/main/java/binnie/craftgui/extratrees/dictionary/ControlBlockIconDisplay.java index 27727352..abefc06f 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/ControlBlockIconDisplay.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/ControlBlockIconDisplay.java @@ -9,13 +9,13 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite; public class ControlBlockIconDisplay extends Control { TextureAtlasSprite icon; - public ControlBlockIconDisplay(final IWidget parent, final float x, final float y, final TextureAtlasSprite icon) { - super(parent, x, y, 18.0f, 18.0f); + public ControlBlockIconDisplay(final IWidget parent, final int x, final int y, final TextureAtlasSprite icon) { + super(parent, x, y, 18, 18); this.icon = icon; } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.sprite(IPoint.ZERO, this.icon); } } diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/ControlBreweryProgress.java b/src/main/java/binnie/craftgui/extratrees/dictionary/ControlBreweryProgress.java index 5992963b..a30791c5 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/ControlBreweryProgress.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/ControlBreweryProgress.java @@ -5,6 +5,7 @@ import binnie.core.util.ItemStackSet; import binnie.craftgui.core.Attribute; import binnie.craftgui.core.CraftGUI; import binnie.craftgui.core.IWidget; +import binnie.craftgui.core.geometry.CraftGUIUtil; import binnie.craftgui.core.geometry.IArea; import binnie.craftgui.core.geometry.IPoint; import binnie.craftgui.minecraft.Window; @@ -24,34 +25,34 @@ public class ControlBreweryProgress extends ControlProgressBase { static Texture BreweryOverlay = new StandardTexture(34, 69, 34, 39, ExtraTreeTexture.Gui); @Override - public void onRenderBackground() { - CraftGUI.render.texture(ControlBreweryProgress.Brewery, new IPoint(0.0f, 0.0f)); + public void onRenderBackground(int guiWidth, int guiHeight) { + CraftGUI.render.texture(ControlBreweryProgress.Brewery, IPoint.ZERO); final BreweryLogic logic = Machine.getInterface(BreweryLogic.class, Window.get(this).getInventory()); if (logic == null || logic.currentCrafting == null || logic.currentCrafting.inputFluid == null) { return; } final int fermentedHeight = (int) (32.0f * logic.getProgress() / 100.0f); - CraftGUI.render.limitArea(new IArea(new IPoint(1.0f, 6.0f).add(this.getAbsolutePosition()), new IPoint(32.0f, 32 - fermentedHeight))); - GL11.glEnable(3089); - CraftGUI.render.fluid(new IPoint(1.0f, 6.0f), logic.currentCrafting.inputFluid); - CraftGUI.render.fluid(new IPoint(17.0f, 6.0f), logic.currentCrafting.inputFluid); - CraftGUI.render.fluid(new IPoint(1.0f, 22.0f), logic.currentCrafting.inputFluid); - CraftGUI.render.fluid(new IPoint(17.0f, 22.0f), logic.currentCrafting.inputFluid); - GL11.glDisable(3089); - CraftGUI.render.limitArea(new IArea(new IPoint(1.0f, 38 - fermentedHeight).add(this.getAbsolutePosition()), new IPoint(32.0f, fermentedHeight))); - GL11.glEnable(3089); - CraftGUI.render.fluid(new IPoint(1.0f, 6.0f), BreweryRecipes.getOutput(logic.currentCrafting)); - CraftGUI.render.fluid(new IPoint(17.0f, 6.0f), BreweryRecipes.getOutput(logic.currentCrafting)); - CraftGUI.render.fluid(new IPoint(1.0f, 22.0f), BreweryRecipes.getOutput(logic.currentCrafting)); - CraftGUI.render.fluid(new IPoint(17.0f, 22.0f), BreweryRecipes.getOutput(logic.currentCrafting)); - GL11.glDisable(3089); + CraftGUI.render.limitArea(new IArea(new IPoint(1, 6).add(this.getAbsolutePosition()), new IPoint(32, 32 - fermentedHeight)), guiWidth, guiHeight); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + CraftGUI.render.fluid(new IPoint(1, 6), logic.currentCrafting.inputFluid); + CraftGUI.render.fluid(new IPoint(17, 6), logic.currentCrafting.inputFluid); + CraftGUI.render.fluid(new IPoint(1, 22), logic.currentCrafting.inputFluid); + CraftGUI.render.fluid(new IPoint(17, 22), logic.currentCrafting.inputFluid); + GL11.glDisable(GL11.GL_SCISSOR_TEST); + CraftGUI.render.limitArea(new IArea(new IPoint(1, 38 - fermentedHeight).add(this.getAbsolutePosition()), new IPoint(32, fermentedHeight)), guiWidth, guiHeight); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + CraftGUI.render.fluid(new IPoint(1, 6), BreweryRecipes.getOutput(logic.currentCrafting)); + CraftGUI.render.fluid(new IPoint(17, 6), BreweryRecipes.getOutput(logic.currentCrafting)); + CraftGUI.render.fluid(new IPoint(1, 22), BreweryRecipes.getOutput(logic.currentCrafting)); + CraftGUI.render.fluid(new IPoint(17, 22), BreweryRecipes.getOutput(logic.currentCrafting)); + GL11.glDisable(GL11.GL_SCISSOR_TEST); final ItemStackSet stacks = new ItemStackSet(); Collections.addAll(stacks, logic.currentCrafting.inputGrains); stacks.add(logic.currentCrafting.ingredient); int x = 1; int y = 6; for (final ItemStack stack : stacks) { - CraftGUI.render.item(new IPoint(x, y), stack); + CraftGUIUtil.renderItem(new IPoint(x, y), stack); x += 16; if (x > 18) { x = 1; @@ -61,11 +62,11 @@ public class ControlBreweryProgress extends ControlProgressBase { } @Override - public void onRenderForeground() { + public void onRenderForeground(int guiWidth, int guiHeight) { } - protected ControlBreweryProgress(final IWidget parent, final float x, final float y) { - super(parent, x, y, 34.0f, 39.0f); + protected ControlBreweryProgress(final IWidget parent, final int x, final int y) { + super(parent, x, y, 34, 39); this.addAttribute(Attribute.MouseOver); } diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/ControlDistilleryProgress.java b/src/main/java/binnie/craftgui/extratrees/dictionary/ControlDistilleryProgress.java index a152a798..5f2180c4 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/ControlDistilleryProgress.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/ControlDistilleryProgress.java @@ -23,9 +23,9 @@ public class ControlDistilleryProgress extends ControlProgressBase { public static final Texture OUTPUT = new StandardTexture(68, 66, 17, 7, ExtraTreeTexture.Gui); @Override - public void onRenderBackground() { - CraftGUI.render.texture(DISTILLERY_BASE, new IPoint(0.0f, 0.0f)); - CraftGUI.render.texturePercentage(LIQUID_FLOW, new IArea(18.0f, 0.0f, 38.0f, 66.0f), Position.Left, this.progress); + public void onRenderBackground(int guiWidth, int guiHeight) { + CraftGUI.render.texture(DISTILLERY_BASE, IPoint.ZERO); + CraftGUI.render.texturePercentage(LIQUID_FLOW, new IArea(18, 0, 38, 66), Position.Left, this.progress); final DistilleryLogic component = Machine.getInterface(DistilleryLogic.class, Window.get(this).getInventory()); FluidStack stack = null; if (component != null) { @@ -33,32 +33,32 @@ public class ControlDistilleryProgress extends ControlProgressBase { } if (stack != null) { for (int y = 0; y < 4; ++y) { - CraftGUI.render.fluid(new IPoint(1.0f, 1 + y * 16), stack); + CraftGUI.render.fluid(new IPoint(1, 1 + y * 16), stack); } } } @Override - public void onRenderForeground() { + public void onRenderForeground(int guiWidth, int guiHeight) { DistilleryLogic distilleryLogic = Machine.getInterface(DistilleryLogic.class, Window.get(this).getInventory()); if (distilleryLogic != null) { final int level = distilleryLogic.level; - CraftGUI.render.texture(OUTPUT, new IPoint(47.0f, 14 + level * 15)); - CraftGUI.render.texture(DISTILLERY_OVERLAY, new IPoint(0.0f, 0.0f)); + CraftGUI.render.texture(OUTPUT, new IPoint(47, 14 + level * 15)); + CraftGUI.render.texture(DISTILLERY_OVERLAY, IPoint.ZERO); } } - protected ControlDistilleryProgress(final IWidget parent, final float x, final float y) { - super(parent, x, y, 58.0f, 66.0f); + protected ControlDistilleryProgress(final IWidget parent, final int x, final int y) { + super(parent, x, y, 58, 66); this.addSelfEventHandler(new EventMouse.Down.Handler() { @Override public void onEvent(final EventMouse.Down event) { int distillationLevel = -1; - if (new IArea(45.0f, 8.0f, 19.0f, 11.0f).contains(ControlDistilleryProgress.this.getRelativeMousePosition())) { + if (new IArea(45, 8, 19, 11).contains(ControlDistilleryProgress.this.getRelativeMousePosition())) { distillationLevel = 0; - } else if (new IArea(45.0f, 23.0f, 19.0f, 11.0f).contains(ControlDistilleryProgress.this.getRelativeMousePosition())) { + } else if (new IArea(45, 23, 19, 11).contains(ControlDistilleryProgress.this.getRelativeMousePosition())) { distillationLevel = 1; - } else if (new IArea(45.0f, 38.0f, 19.0f, 11.0f).contains(ControlDistilleryProgress.this.getRelativeMousePosition())) { + } else if (new IArea(45, 38, 19, 11).contains(ControlDistilleryProgress.this.getRelativeMousePosition())) { distillationLevel = 2; } if (distillationLevel >= 0) { diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/ControlFruitPressProgress.java b/src/main/java/binnie/craftgui/extratrees/dictionary/ControlFruitPressProgress.java index 833485d9..14d588fb 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/ControlFruitPressProgress.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/ControlFruitPressProgress.java @@ -3,6 +3,7 @@ package binnie.craftgui.extratrees.dictionary; import binnie.craftgui.core.Attribute; import binnie.craftgui.core.CraftGUI; import binnie.craftgui.core.IWidget; +import binnie.craftgui.core.geometry.CraftGUIUtil; import binnie.craftgui.core.geometry.IPoint; import binnie.craftgui.events.EventMouse; import binnie.craftgui.minecraft.Window; @@ -10,8 +11,8 @@ import binnie.craftgui.minecraft.control.ControlProgressBase; import binnie.craftgui.resource.Texture; import binnie.craftgui.resource.minecraft.StandardTexture; import binnie.extratrees.core.ExtraTreeTexture; -import binnie.extratrees.machines.fruitpress.FruitPressRecipes; import binnie.extratrees.machines.fruitpress.FruitPressMachine; +import binnie.extratrees.machines.fruitpress.FruitPressRecipes; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -22,8 +23,8 @@ public class ControlFruitPressProgress extends ControlProgressBase { static Texture PressSlot = new StandardTexture(9, 52, 34, 17, ExtraTreeTexture.Gui); @Override - public void onRenderBackground() { - CraftGUI.render.texture(ControlFruitPressProgress.PressSlot, new IPoint(3.0f, 52.0f)); + public void onRenderBackground(int guiWidth, int guiHeight) { + CraftGUI.render.texture(ControlFruitPressProgress.PressSlot, new IPoint(3, 52)); Slot slotFromInventory = Window.get(this).getContainer().getSlotFromInventory(Window.get(this).getInventory(), FruitPressMachine.SLOT_CURRENT); if (slotFromInventory == null) { return; @@ -33,17 +34,17 @@ public class ControlFruitPressProgress extends ControlProgressBase { return; } FluidStack fluid = FruitPressRecipes.getOutput(input); - CraftGUI.render.fluid(new IPoint(4.0f, 52.0f), fluid); - CraftGUI.render.item(new IPoint(4.0f, 52.0f), input); + CraftGUI.render.fluid(new IPoint(4, 52), fluid); + CraftGUIUtil.renderItem(new IPoint(4, 52), input); } @Override - public void onRenderForeground() { - CraftGUI.render.texture(ControlFruitPressProgress.PressTexture, new IPoint(0.0f, 16.0f * this.progress)); + public void onRenderForeground(int guiWidth, int guiHeight) { + CraftGUI.render.texture(ControlFruitPressProgress.PressTexture, new IPoint(0, Math.round(16 * this.progress))); } - protected ControlFruitPressProgress(final IWidget parent, final float x, final float y) { - super(parent, x, y, 37.0f, 69.0f); + protected ControlFruitPressProgress(final IWidget parent, final int x, final int y) { + super(parent, x, y, 37, 69); this.addAttribute(Attribute.MouseOver); this.addSelfEventHandler(new EventMouse.Down.Handler() { @Override diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/ControlLumbermillProgress.java b/src/main/java/binnie/craftgui/extratrees/dictionary/ControlLumbermillProgress.java index 741603bb..b447a150 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/ControlLumbermillProgress.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/ControlLumbermillProgress.java @@ -29,15 +29,15 @@ public class ControlLumbermillProgress extends ControlProgressBase { super.onUpdateClient(); if (this.oldProgress != this.progress) { this.oldProgress = this.progress; - this.animation += 5.0f; + this.animation += 5; } } @Override - public void onRenderForeground() { + public void onRenderForeground(int guiWidth, int guiHeight) { GL11.glDisable(2896); - final int sawX = (int) (63.0f * this.progress); - CraftGUI.render.texture(ControlLumbermillProgress.Saw, new IPoint(sawX, -8.0f + 6.0f * (float) Math.sin(this.animation))); + final int sawX = (int) (63 * this.progress); + CraftGUI.render.texture(ControlLumbermillProgress.Saw, new IPoint(sawX, -8 + Math.round(6 * (float) Math.sin(this.animation)))); final ItemStack item = Window.get(this).getInventory().getStackInSlot(LumbermillMachine.SLOT_LOG); if (item == null) { return; @@ -53,7 +53,7 @@ public class ControlLumbermillProgress extends ControlProgressBase { //TODO RENDERING //final IIcon icon = block.getIcon(2, item.getItemDamage()); for (int i = 0; i < 4; ++i) { - //CraftGUI.Render.iconBlock(new IPoint(1 + i * 16, 1.0f), icon); + //CraftGUI.Render.iconBlock(new IPoint(1 + i * 16, 1), icon); } final ItemStack result = LumbermillRecipes.getPlankProduct(item); if (result == null) { @@ -69,21 +69,21 @@ public class ControlLumbermillProgress extends ControlProgressBase { //final IIcon icon2 = block2.getIcon(2, result.getItemDamage()); final IPoint size = this.getSize(); final IPoint pos = this.getAbsolutePosition(); - CraftGUI.render.limitArea(new IArea(pos.add(new IPoint(0.0f, 0.0f)), new IPoint(this.progress * 64.0f + 2.0f, 18.0f))); + CraftGUI.render.limitArea(new IArea(pos.add(IPoint.ZERO), new IPoint(Math.round(this.progress * 64) + 2, 18)), guiWidth, guiHeight); GL11.glEnable(3089); for (int j = 0; j < 4; ++j) { //TODO RENDERING - //CraftGUI.Render.iconBlock(new IPoint(1 + j * 16, 1.0f), icon2); + //CraftGUI.Render.iconBlock(new IPoint(1 + j * 16, 1), icon2); } GL11.glDisable(3089); - CraftGUI.render.texture(ControlLumbermillProgress.Saw2, new IPoint(sawX + 2, -8.0f + 6.0f * (float) Math.sin(this.animation))); + CraftGUI.render.texture(ControlLumbermillProgress.Saw2, new IPoint(sawX + 2, -8 + Math.round(6 * (float) Math.sin(this.animation)))); } - protected ControlLumbermillProgress(final IWidget parent, final float x, final float y) { - super(parent, x, y, 66.0f, 18.0f); - this.oldProgress = 0.0f; - this.animation = 0.0f; - new Panel(this, 0.0f, 0.0f, 66.0f, 18.0f, MinecraftGUI.PanelType.Black); + protected ControlLumbermillProgress(final IWidget parent, final int x, final int y) { + super(parent, x, y, 66, 18); + this.oldProgress = 0; + this.animation = 0; + new Panel(this, 0, 0, 66, 18, MinecraftGUI.PanelType.Black); } } diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/ControlTileSelect.java b/src/main/java/binnie/craftgui/extratrees/dictionary/ControlTileSelect.java index 0064d544..f31db43c 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/ControlTileSelect.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/ControlTileSelect.java @@ -12,6 +12,7 @@ import binnie.craftgui.core.CraftGUI; import binnie.craftgui.core.ITooltip; import binnie.craftgui.core.IWidget; import binnie.craftgui.core.Tooltip; +import binnie.craftgui.core.geometry.CraftGUIUtil; import binnie.craftgui.core.geometry.IPoint; import binnie.craftgui.events.EventMouse; import binnie.craftgui.minecraft.Window; @@ -34,8 +35,8 @@ public class ControlTileSelect extends Control implements IControlValue IDesign value; float shownHeight; - protected ControlTileSelect(final IWidget parent, final float x, final float y) { - super(parent, x, y, 102.0f, 20 * (CarpentryManager.carpentryInterface.getSortedDesigns().size() / 4) + 22); + protected ControlTileSelect(final IWidget parent, final int x, final int y) { + super(parent, x, y, 102, 20 * (CarpentryManager.carpentryInterface.getSortedDesigns().size() / 4) + 22); this.value = EnumDesign.Blank; this.shownHeight = 92.0f; this.refresh(""); @@ -122,8 +123,8 @@ public class ControlTileSelect extends Control implements IControlValue public static class ControlTile extends Control implements IControlValue, ITooltip { IDesign value; - protected ControlTile(final IWidget parent, final float x, final float y, final IDesign value) { - super(parent, x, y, 18.0f, 18.0f); + protected ControlTile(final IWidget parent, final int x, final int y, final IDesign value) { + super(parent, x, y, 18, 18); this.setValue(value); this.addAttribute(Attribute.MouseOver); this.addSelfEventHandler(new EventMouse.Down.Handler() { @@ -152,14 +153,14 @@ public class ControlTileSelect extends Control implements IControlValue } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.texture(CraftGUITexture.Slot, IPoint.ZERO); } @Override - public void onRenderForeground() { + public void onRenderForeground(int guiWidth, int guiHeight) { final ItemStack image = ((WindowWoodworker) this.getSuperParent()).getDesignerType().getDisplayStack(this.getValue()); - CraftGUI.render.item(new IPoint(1.0f, 1.0f), image); + CraftGUIUtil.renderItem(new IPoint(1, 1), image); if (((IControlValue) this.getParent()).getValue() != this.getValue()) { if (Window.get(this).getMousedOverWidget() == this) { CraftGUI.render.gradientRect(this.getArea().inset(1), 1157627903, 1157627903); diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/DialogBreweryRecipe.java b/src/main/java/binnie/craftgui/extratrees/dictionary/DialogBreweryRecipe.java index e48e598b..2ad3f7e1 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/DialogBreweryRecipe.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/DialogBreweryRecipe.java @@ -4,7 +4,7 @@ import binnie.craftgui.core.IWidget; import binnie.craftgui.minecraft.Dialog; public class DialogBreweryRecipe extends Dialog { - public DialogBreweryRecipe(final IWidget parent, final float w, final float h) { + public DialogBreweryRecipe(final IWidget parent, final int w, final int h) { super(parent, w, h); } diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/PageFruit.java b/src/main/java/binnie/craftgui/extratrees/dictionary/PageFruit.java index ff5c05ff..bae6aded 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/PageFruit.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/PageFruit.java @@ -28,8 +28,8 @@ public class PageFruit extends PageAbstract { public void onValueChanged(final ItemStack species) { this.deleteAllChildren(); final WindowAbstractDatabase database = Window.get(this); - new ControlText(this, new IArea(0.0f, 0.0f, this.size().x(), 24.0f), ExtraTrees.proxy.localise("gui.database.tab.fruit." + (this.treesThatBearFruit ? "natural" : "potential")), TextJustification.MiddleCenter); + new ControlText(this, new IArea(0, 0, this.size().x(), 24), ExtraTrees.proxy.localise("gui.database.tab.fruit." + (this.treesThatBearFruit ? "natural" : "potential")), TextJustification.MiddleCenter); final Collection trees = this.treesThatBearFruit ? ((TreeBreedingSystem) database.getBreedingSystem()).getTreesThatBearFruit(species, database.isNEI(), database.getWorld(), database.getUsername()) : ((TreeBreedingSystem) database.getBreedingSystem()).getTreesThatCanBearFruit(species, database.isNEI(), database.getWorld(), database.getUsername()); - new ControlSpeciesBox(this, 4.0f, 24.0f, this.size().x() - 8.0f, this.size().y() - 4.0f - 24.0f).setOptions(trees); + new ControlSpeciesBox(this, 4, 24, this.size().x() - 8, this.size().y() - 4 - 24).setOptions(trees); } } diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/PagePlanksOverview.java b/src/main/java/binnie/craftgui/extratrees/dictionary/PagePlanksOverview.java index 2997daa8..e9e246bb 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/PagePlanksOverview.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/PagePlanksOverview.java @@ -28,8 +28,8 @@ public class PagePlanksOverview extends PageAbstract { public void onValueChanged(final ItemStack species) { this.deleteAllChildren(); final WindowAbstractDatabase database = Window.get(this); - new ControlText(this, new IArea(0.0f, 0.0f, this.size().x(), 24.0f), species.getDisplayName(), TextJustification.MiddleCenter); - new ControlText(this, new IArea(12.0f, 24.0f, this.size().x() - 24.0f, 24.0f), ExtraTrees.proxy.localise("gui.database.planks.use"), TextJustification.MiddleLeft); + new ControlText(this, new IArea(0, 0, this.size().x(), 24), species.getDisplayName(), TextJustification.MiddleCenter); + new ControlText(this, new IArea(12, 24, this.size().x() - 24, 24), ExtraTrees.proxy.localise("gui.database.planks.use"), TextJustification.MiddleLeft); final IPlankType type = WoodManager.get(species); int x = 12; if (type != null) { @@ -37,20 +37,20 @@ public class PagePlanksOverview extends PageAbstract { final ItemStack gate = WoodManager.getGate(type); final ItemStack door = WoodManager.getDoor(type, DoorType.Standard); if (fence != null) { - new ControlItemDisplay(this, x, 48.0f).setItemStack(fence); + new ControlItemDisplay(this, x, 48).setItemStack(fence); x += 22; } if (gate != null) { - new ControlItemDisplay(this, x, 48.0f).setItemStack(gate); + new ControlItemDisplay(this, x, 48).setItemStack(gate); x += 22; } if (door != null) { - new ControlItemDisplay(this, x, 48.0f).setItemStack(door); + new ControlItemDisplay(this, x, 48).setItemStack(door); x += 22; } } - final ControlText controlDescription = new ControlText(this, new IArea(8.0f, 84.0f, this.getSize().x() - 16.0f, 0.0f), "", TextJustification.MiddleCenter); - final ControlText controlSignature = new ControlText(this, new IArea(8.0f, 84.0f, this.getSize().x() - 16.0f, 0.0f), "", TextJustification.BottomRight); + final ControlText controlDescription = new ControlText(this, new IArea(8, 84, this.getSize().x() - 16, 0), "", TextJustification.MiddleCenter); + final ControlText controlSignature = new ControlText(this, new IArea(8, 84, this.getSize().x() - 16, 0), "", TextJustification.BottomRight); String desc = ""; if (type != null) { desc = type.getDescription(); @@ -71,7 +71,7 @@ public class PagePlanksOverview extends PageAbstract { } controlDescription.setValue(descBody + "§r"); controlSignature.setValue(descSig + "§r"); - final float descHeight = CraftGUI.render.textHeight(controlDescription.getValue(), controlDescription.getSize().x()); - controlSignature.setPosition(new IPoint(controlSignature.pos().x(), controlDescription.getPosition().y() + descHeight + 10.0f)); + final int descHeight = CraftGUI.render.textHeight(controlDescription.getValue(), controlDescription.getSize().x()); + controlSignature.setPosition(new IPoint(controlSignature.pos().x(), controlDescription.getPosition().y() + descHeight + 10)); } } diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/PagePlanksTrees.java b/src/main/java/binnie/craftgui/extratrees/dictionary/PagePlanksTrees.java index 7f91cd81..2d9d63f1 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/PagePlanksTrees.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/PagePlanksTrees.java @@ -24,8 +24,8 @@ public class PagePlanksTrees extends PageAbstract { public void onValueChanged(final ItemStack species) { this.deleteAllChildren(); final WindowAbstractDatabase database = Window.get(this); - new ControlText(this, new IArea(0.0f, 0.0f, this.size().x(), 24.0f), species.getDisplayName(), TextJustification.MiddleCenter); + new ControlText(this, new IArea(0, 0, this.size().x(), 24), species.getDisplayName(), TextJustification.MiddleCenter); final Collection trees = ((TreeBreedingSystem) database.getBreedingSystem()).getTreesThatMakePlanks(species, database.isNEI(), database.getWorld(), database.getUsername()); - new ControlSpeciesBox(this, 4.0f, 24.0f, this.size().x() - 8.0f, this.size().y() - 4.0f - 24.0f).setOptions(trees); + new ControlSpeciesBox(this, 4, 24, this.size().x() - 8, this.size().y() - 4 - 24).setOptions(trees); } } diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/PageSpeciesImage.java b/src/main/java/binnie/craftgui/extratrees/dictionary/PageSpeciesImage.java index db9df931..3c92ad5a 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/PageSpeciesImage.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/PageSpeciesImage.java @@ -15,10 +15,10 @@ public class PageSpeciesImage extends PageSpecies { public PageSpeciesImage(final IWidget parent, final DatabaseTab tab) { super(parent, tab); - new Panel(this, 7.0f, 25.0f, 130.0f, 120.0f, MinecraftGUI.PanelType.Gray); - this.display = new ControlDatabaseIndividualDisplay(this, 12.0f, 25.0f, 120.0f); + new Panel(this, 7, 25, 130, 120, MinecraftGUI.PanelType.Gray); + this.display = new ControlDatabaseIndividualDisplay(this, 12, 25, 120); this.display.hastooltip = false; - new ControlTextCentered(this, 8.0f, this.getValue().toString()); + new ControlTextCentered(this, 8, this.getValue().toString()); } @Override diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/PageSpeciesTreeGenome.java b/src/main/java/binnie/craftgui/extratrees/dictionary/PageSpeciesTreeGenome.java index dacfa9ad..d5d01d39 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/PageSpeciesTreeGenome.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/PageSpeciesTreeGenome.java @@ -48,9 +48,9 @@ public class PageSpeciesTreeGenome extends PageSpecies { final ItemStack log = treeSpecies.getWoodProvider().getWoodStack(); final int w = 144; final int h = 176; - new ControlText(this, new IArea(0.0f, 4.0f, w, 16.0f), this.getValue().toString(), TextJustification.MiddleCenter); - final ControlScrollableContent scrollable = new ControlScrollableContent(this, 4.0f, 20.0f, w - 8, h - 8 - 16, 12.0f); - final Control contents = new Control(scrollable, 0.0f, 0.0f, w - 8 - 12, h - 8 - 16); + new ControlText(this, new IArea(0, 4, w, 16), this.getValue().toString(), TextJustification.MiddleCenter); + final ControlScrollableContent scrollable = new ControlScrollableContent(this, 4, 20, w - 8, h - 8 - 16, 12); + final Control contents = new Control(scrollable, 0, 0, w - 8 - 12, h - 8 - 16); final int tw = w - 8 - 12; final int w2 = 65; final int w3 = tw - 50; @@ -58,10 +58,10 @@ public class PageSpeciesTreeGenome extends PageSpecies { final int th = 14; final int th2 = 18; final BreedingSystem syst = Binnie.GENETICS.treeBreedingSystem; - new ControlText(contents, new IArea(0.0f, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.PLANT) + " : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.PLANT) + " : ", TextJustification.MiddleRight); new ControlText(contents, new IArea(w2, y, w3, th), treeSpecies.getPlantType().toString(), TextJustification.MiddleLeft); y += th; - new ControlText(contents, new IArea(0.0f, y, w2, th), BinnieCore.proxy.localise("gui.temperature.short") + " : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y, w2, th), BinnieCore.proxy.localise("gui.temperature.short") + " : ", TextJustification.MiddleRight); new ControlText(contents, new IArea(w2, y, w3, th), treeSpecies.getTemperature().getName(), TextJustification.MiddleLeft); y += th; //TODO RENDERING @@ -76,7 +76,7 @@ public class PageSpeciesTreeGenome extends PageSpecies { ex.printStackTrace(); } //if (leaf != null) { - //new ControlText(contents, new IArea(0.0f, y, w2, th2), ExtraTrees.proxy.localise("gui.database.leaves") + " : ", TextJustification.MiddleRight); + //new ControlText(contents, new IArea(0, y, w2, th2), ExtraTrees.proxy.localise("gui.database.leaves") + " : ", TextJustification.MiddleRight); //TODO RENDERING //new ControlBlockIconDisplay(contents, w2, y, leaf).setColour(treeSpecies.getLeafColour(false)); //if (fruit != null && !treeSpecies.getUID().equals("forestry.treeOak")) { @@ -88,19 +88,19 @@ public class PageSpeciesTreeGenome extends PageSpecies { // final ItemStack log = (genome.getFruitProvider().getProducts().length // > 0) ? genome.getFruitProvider().getProducts()[0] : null; if (log != null) { - new ControlText(contents, new IArea(0.0f, y, w2, th2), ExtraTrees.proxy.localise("gui.database.log") + " : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y, w2, th2), ExtraTrees.proxy.localise("gui.database.log") + " : ", TextJustification.MiddleRight); final ControlItemDisplay display = new ControlItemDisplay(contents, w2, y); display.setItemStack(log); display.setTooltip(); y += th2; } - new ControlText(contents, new IArea(0.0f, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.GROWTH) + " : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.GROWTH) + " : ", TextJustification.MiddleRight); //new ControlText(contents, new IArea(w2, y, w3, th), genome.getGrowthProvider().getDescription(), TextJustification.MiddleLeft); y += th; - new ControlText(contents, new IArea(0.0f, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.HEIGHT) + " : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.HEIGHT) + " : ", TextJustification.MiddleRight); new ControlText(contents, new IArea(w2, y, w3, th), genome.getHeight() + "x", TextJustification.MiddleLeft); y += th; - new ControlText(contents, new IArea(0.0f, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.FERTILITY) + " : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.FERTILITY) + " : ", TextJustification.MiddleRight); new ControlText(contents, new IArea(w2, y, w3, th), genome.getFertility() + "x", TextJustification.MiddleLeft); y += th; final List fruits = new ArrayList<>(); @@ -108,7 +108,7 @@ public class PageSpeciesTreeGenome extends PageSpecies { fruits.add(stack); } if (!fruits.isEmpty()) { - new ControlText(contents, new IArea(0.0f, y, w2, th2), syst.getChromosomeShortName(EnumTreeChromosome.FRUITS) + " : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y, w2, th2), syst.getChromosomeShortName(EnumTreeChromosome.FRUITS) + " : ", TextJustification.MiddleRight); for (final ItemStack fruitw : fruits) { final ControlItemDisplay display2 = new ControlItemDisplay(contents, w2, y); display2.setItemStack(fruitw); @@ -116,16 +116,16 @@ public class PageSpeciesTreeGenome extends PageSpecies { y += th2; } } - new ControlText(contents, new IArea(0.0f, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.YIELD) + " : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.YIELD) + " : ", TextJustification.MiddleRight); new ControlText(contents, new IArea(w2, y, w3, th), genome.getYield() + "x", TextJustification.MiddleLeft); y += th; - new ControlText(contents, new IArea(0.0f, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.SAPPINESS) + " : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.SAPPINESS) + " : ", TextJustification.MiddleRight); new ControlText(contents, new IArea(w2, y, w3, th), genome.getSappiness() + "x", TextJustification.MiddleLeft); y += th; - new ControlText(contents, new IArea(0.0f, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.MATURATION) + " : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.MATURATION) + " : ", TextJustification.MiddleRight); new ControlText(contents, new IArea(w2, y, w3, th), genome.getMaturationTime() + "x", TextJustification.MiddleLeft); y += th; - new ControlText(contents, new IArea(0.0f, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.GIRTH) + " : ", TextJustification.MiddleRight); + new ControlText(contents, new IArea(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.GIRTH) + " : ", TextJustification.MiddleRight); new ControlText(contents, new IArea(w2, y, w3, th), genome.getGirth() + "x" + genome.getGirth(), TextJustification.MiddleLeft); y += th; contents.setSize(new IPoint(contents.size().x(), y)); diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/PageWood.java b/src/main/java/binnie/craftgui/extratrees/dictionary/PageWood.java index c34c2604..70be70b1 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/PageWood.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/PageWood.java @@ -24,8 +24,8 @@ public class PageWood extends PageAbstract { public void onValueChanged(final ItemStack species) { this.deleteAllChildren(); final WindowAbstractDatabase database = Window.get(this); - new ControlText(this, new IArea(0.0f, 0.0f, this.size().x(), 24.0f), this.getValue().toString(), TextJustification.MiddleCenter); + new ControlText(this, new IArea(0, 0, this.size().x(), 24), this.getValue().toString(), TextJustification.MiddleCenter); final Collection trees = ((TreeBreedingSystem) database.getBreedingSystem()).getTreesThatHaveWood(species, database.isNEI(), database.getWorld(), database.getUsername()); - new ControlSpeciesBox(this, 4.0f, 24.0f, this.size().x() - 8.0f, this.size().y() - 4.0f - 24.0f).setOptions(trees); + new ControlSpeciesBox(this, 4, 24, this.size().x() - 8, this.size().y() - 4 - 24).setOptions(trees); } } diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/WindowArboristDatabase.java b/src/main/java/binnie/craftgui/extratrees/dictionary/WindowArboristDatabase.java index a93dad4b..61a6e4f4 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/WindowArboristDatabase.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/WindowArboristDatabase.java @@ -29,7 +29,7 @@ public class WindowArboristDatabase extends WindowAbstractDatabase { ControlListBox selectionBoxPlanks; public WindowArboristDatabase(final EntityPlayer player, final Side side, final boolean nei) { - super(player, side, nei, Binnie.GENETICS.treeBreedingSystem, 120.0f); + super(player, side, nei, Binnie.GENETICS.treeBreedingSystem, 120); } public static Window create(final EntityPlayer player, final Side side, final boolean nei) { @@ -49,7 +49,7 @@ public class WindowArboristDatabase extends WindowAbstractDatabase { this.createMode(TreeMode.Fruit, new ModeWidgets(TreeMode.Fruit, this) { @Override public void createListBox(final IArea area) { - (this.listBox = new ControlListBox(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0f) { + (this.listBox = new ControlListBox(this.modePage, area.x(), area.y(), area.w(), area.h(), 12) { @Override public IWidget createOption(final ItemStack value, final int y) { return new ControlItemStackOption(this.getContent(), value, y); @@ -60,7 +60,7 @@ public class WindowArboristDatabase extends WindowAbstractDatabase { this.createMode(TreeMode.Wood, new ModeWidgets(TreeMode.Wood, this) { @Override public void createListBox(final IArea area) { - (this.listBox = new ControlListBox(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0f) { + (this.listBox = new ControlListBox(this.modePage, area.x(), area.y(), area.w(), area.h(), 12) { @Override public IWidget createOption(final ItemStack value, final int y) { return new ControlItemStackOption(this.getContent(), value, y); @@ -71,7 +71,7 @@ public class WindowArboristDatabase extends WindowAbstractDatabase { this.createMode(TreeMode.Planks, new ModeWidgets(TreeMode.Planks, this) { @Override public void createListBox(final IArea area) { - this.listBox = new ControlListBox(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0f) { + this.listBox = new ControlListBox(this.modePage, area.x(), area.y(), area.w(), area.h(), 12) { @Override public IWidget createOption(final ItemStack value, final int y) { return new ControlItemStackOption(this.getContent(), value, y); diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/WindowBrewery.java b/src/main/java/binnie/craftgui/extratrees/dictionary/WindowBrewery.java index 03af8e75..4a834a9f 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/WindowBrewery.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/WindowBrewery.java @@ -18,7 +18,7 @@ import net.minecraftforge.fml.relauncher.Side; public class WindowBrewery extends Window { public WindowBrewery(final EntityPlayer player, final IInventory inventory, final Side side) { - super(228.0f, 218.0f, player, inventory, side); + super(228, 218, player, inventory, side); } @Override @@ -35,15 +35,15 @@ public class WindowBrewery extends Window { public void initialiseClient() { this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName()); new ControlSlotArray(this, 42, 32, 1, 3).create(BreweryMachine.SLOT_RECIPE_GRAINS); - new ControlSlot(this, 16.0f, 41.0f).assign(BreweryMachine.SLOT_RECIPE_INPUT); - new ControlSlot(this, 105.0f, 77.0f).assign(BreweryMachine.SLOT_YEAST); + new ControlSlot(this, 16, 41).assign(BreweryMachine.SLOT_RECIPE_INPUT); + new ControlSlot(this, 105, 77).assign(BreweryMachine.SLOT_YEAST); new ControlLiquidTank(this, 76, 32).setTankID(BreweryMachine.TANK_INPUT); new ControlLiquidTank(this, 162, 32).setTankID(BreweryMachine.TANK_OUTPUT); new ControlEnergyBar(this, 196, 32, 16, 60, Position.Bottom); - new ControlBreweryProgress(this, 110.0f, 32.0f); - new ControlSlotArray(this, (int) (this.getSize().x() / 2.0f - 81.0f), 104, 9, 1).create(BreweryMachine.SLOTS_INVENTORY); + new ControlBreweryProgress(this, 110, 32); + new ControlSlotArray(this, this.getSize().x() / 2 - 81, 104, 9, 1).create(BreweryMachine.SLOTS_INVENTORY); new ControlPlayerInventory(this); - new ControlErrorState(this, 133.0f, 79.0f); + new ControlErrorState(this, 133, 79); } public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) { diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/WindowDistillery.java b/src/main/java/binnie/craftgui/extratrees/dictionary/WindowDistillery.java index 69849d58..a4094d66 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/WindowDistillery.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/WindowDistillery.java @@ -16,7 +16,7 @@ import net.minecraftforge.fml.relauncher.Side; public class WindowDistillery extends Window { public WindowDistillery(final EntityPlayer player, final IInventory inventory, final Side side) { - super(224.0f, 192.0f, player, inventory, side); + super(224, 192, player, inventory, side); } @Override @@ -35,13 +35,13 @@ public class WindowDistillery extends Window { int x = 16; new ControlLiquidTank(this, x, 35).setTankID(DistilleryMachine.TANK_INPUT); x += 34; - new ControlDistilleryProgress(this, x, 32.0f); + new ControlDistilleryProgress(this, x, 32); x += 64; new ControlLiquidTank(this, x, 35).setTankID(DistilleryMachine.TANK_OUTPUT); x += 34; new ControlEnergyBar(this, x, 36, 60, 16, Position.Left); new ControlPlayerInventory(this); - new ControlErrorState(this, x + 21, 62.0f); + new ControlErrorState(this, x + 21, 62); } public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) { diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/WindowLepidopteristDatabase.java b/src/main/java/binnie/craftgui/extratrees/dictionary/WindowLepidopteristDatabase.java index c39662b8..a6150a45 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/WindowLepidopteristDatabase.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/WindowLepidopteristDatabase.java @@ -18,7 +18,7 @@ import net.minecraftforge.fml.relauncher.Side; public class WindowLepidopteristDatabase extends WindowAbstractDatabase { public WindowLepidopteristDatabase(final EntityPlayer player, final Side side, final boolean nei) { - super(player, side, nei, Binnie.GENETICS.mothBreedingSystem, 160.0f); + super(player, side, nei, Binnie.GENETICS.mothBreedingSystem, 160); } public static Window create(final EntityPlayer player, final Side side, final boolean nei) { diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/WindowLumbermill.java b/src/main/java/binnie/craftgui/extratrees/dictionary/WindowLumbermill.java index 1be7b321..1d3ea490 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/WindowLumbermill.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/WindowLumbermill.java @@ -17,7 +17,7 @@ import net.minecraftforge.fml.relauncher.Side; public class WindowLumbermill extends Window { public WindowLumbermill(final EntityPlayer player, final IInventory inventory, final Side side) { - super(220.0f, 192.0f, player, inventory, side); + super(220, 192, player, inventory, side); } @Override @@ -33,15 +33,15 @@ public class WindowLumbermill extends Window { @Override public void initialiseClient() { this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName()); - new ControlSlot(this, 42.0f, 43.0f).assign(LumbermillMachine.SLOT_LOG); - new ControlSlot(this, 148.0f, 43.0f).assign(LumbermillMachine.SLOT_PLANKS); - new ControlSlot(this, 172.0f, 28.0f).assign(LumbermillMachine.SLOT_BARK); - new ControlSlot(this, 172.0f, 58.0f).assign(LumbermillMachine.SLOT_SAWDUST); - new ControlLumbermillProgress(this, 70.0f, 43.0f); + new ControlSlot(this, 42, 43).assign(LumbermillMachine.SLOT_LOG); + new ControlSlot(this, 148, 43).assign(LumbermillMachine.SLOT_PLANKS); + new ControlSlot(this, 172, 28).assign(LumbermillMachine.SLOT_BARK); + new ControlSlot(this, 172, 58).assign(LumbermillMachine.SLOT_SAWDUST); + new ControlLumbermillProgress(this, 70, 43); new ControlLiquidTank(this, 16, 32); new ControlEnergyBar(this, 8, 112, 16, 60, Position.Bottom); new ControlPlayerInventory(this); - new ControlErrorState(this, 95.0f, 73.0f); + new ControlErrorState(this, 95, 73); } public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) { diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/WindowPress.java b/src/main/java/binnie/craftgui/extratrees/dictionary/WindowPress.java index 934a50cb..a9eff482 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/WindowPress.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/WindowPress.java @@ -21,7 +21,7 @@ import net.minecraftforge.fml.relauncher.Side; public class WindowPress extends Window { public WindowPress(final EntityPlayer player, final IInventory inventory, final Side side) { - super(194.0f, 192.0f, player, inventory, side); + super(194, 192, player, inventory, side); } @Override @@ -37,12 +37,12 @@ public class WindowPress extends Window { @Override public void initialiseClient() { this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName()); - new ControlSlot(this, 24.0f, 52.0f).assign(FruitPressMachine.SLOT_FRUIT); + new ControlSlot(this, 24, 52).assign(FruitPressMachine.SLOT_FRUIT); new ControlLiquidTank(this, 99, 32).setTankID(FruitPressMachine.TANK_OUTPUT); new ControlEnergyBar(this, 154, 32, 16, 60, Position.Bottom); new ControlPlayerInventory(this); - new ControlErrorState(this, 128.0f, 54.0f); - new ControlFruitPressProgress(this, 62.0f, 24.0f); + new ControlErrorState(this, 128, 54); + new ControlFruitPressProgress(this, 62, 24); ((Window) this.getSuperParent()).getContainer().getOrCreateSlot(InventoryType.Machine, FruitPressMachine.SLOT_CURRENT); } diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/WindowSetSquare.java b/src/main/java/binnie/craftgui/extratrees/dictionary/WindowSetSquare.java index 2aef587a..2ab679ed 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/WindowSetSquare.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/WindowSetSquare.java @@ -10,7 +10,7 @@ import net.minecraftforge.fml.relauncher.Side; public class WindowSetSquare extends Window { public WindowSetSquare(final EntityPlayer player, final IInventory inventory, final Side side) { - super(150.0f, 150.0f, player, inventory, side); + super(150, 150, player, inventory, side); } @Override diff --git a/src/main/java/binnie/craftgui/extratrees/dictionary/WindowWoodworker.java b/src/main/java/binnie/craftgui/extratrees/dictionary/WindowWoodworker.java index d93fa354..35da41cd 100644 --- a/src/main/java/binnie/craftgui/extratrees/dictionary/WindowWoodworker.java +++ b/src/main/java/binnie/craftgui/extratrees/dictionary/WindowWoodworker.java @@ -31,26 +31,26 @@ public class WindowWoodworker extends Window { @Override public void initialiseClient() { this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName()); - new ControlText(this, new IArea(190.0f, 36.0f, 114.0f, 10.0f), BinnieCore.proxy.localise("gui.design"), TextJustification.TopCenter).setColour(4473924); - new Panel(this, 188.0f, 48.0f, 118.0f, 126.0f, MinecraftGUI.PanelType.Gray); - this.textEdit = new ControlTextEdit(this, 188.0f, 178.0f, 118.0f, 12.0f); - final ControlScrollableContent scroll = new ControlScrollableContent(this, 190.0f, 50.0f, 114.0f, 122.0f, 12.0f); - scroll.setScrollableContent(this.tileSelect = new ControlTileSelect(scroll, 0.0f, 0.0f)); - new ControlPlayerInventory(this).setPosition(new IPoint(14.0f, 96.0f)); - new ControlErrorState(this, 76.0f, 65.0f); + new ControlText(this, new IArea(190, 36, 114, 10), BinnieCore.proxy.localise("gui.design"), TextJustification.TopCenter).setColour(4473924); + new Panel(this, 188, 48, 118, 126, MinecraftGUI.PanelType.Gray); + this.textEdit = new ControlTextEdit(this, 188, 178, 118, 12); + final ControlScrollableContent scroll = new ControlScrollableContent(this, 190, 50, 114, 122, 12); + scroll.setScrollableContent(this.tileSelect = new ControlTileSelect(scroll, 0, 0)); + new ControlPlayerInventory(this).setPosition(new IPoint(14, 96)); + new ControlErrorState(this, 76, 65); if (this.getInventory() != null) { - final ControlSlot slotWood1 = new ControlSlot(this, 22.0f, 34.0f); + final ControlSlot slotWood1 = new ControlSlot(this, 22, 34); slotWood1.assign(Designer.design1Slot); - final ControlSlot slotWood2 = new ControlSlot(this, 62.0f, 34.0f); + final ControlSlot slotWood2 = new ControlSlot(this, 62, 34); slotWood2.assign(Designer.design2Slot); - final ControlSlot slotBeeswax = new ControlSlot(this, 42.0f, 64.0f); + final ControlSlot slotBeeswax = new ControlSlot(this, 42, 64); slotBeeswax.assign(Designer.beeswaxSlot); final ControlRecipeSlot slotFinished = new ControlRecipeSlot(this, 112, 34); } } public WindowWoodworker(final EntityPlayer player, final IInventory inventory, final Side side) { - super(320.0f, 216.0f, player, inventory, side); + super(320, 216, player, inventory, side); this.addEventHandler(new EventTextEdit.Handler() { @Override public void onEvent(final EventTextEdit event) { diff --git a/src/main/java/binnie/craftgui/extratrees/kitchen/ControlDropDownMenu.java b/src/main/java/binnie/craftgui/extratrees/kitchen/ControlDropDownMenu.java index 9cca0bdd..908d56f6 100644 --- a/src/main/java/binnie/craftgui/extratrees/kitchen/ControlDropDownMenu.java +++ b/src/main/java/binnie/craftgui/extratrees/kitchen/ControlDropDownMenu.java @@ -8,8 +8,8 @@ import binnie.craftgui.window.Panel; public class ControlDropDownMenu extends Panel { public boolean stayOpenOnChildClick; - public ControlDropDownMenu(final IWidget parent, final float x, final float y, final float width, final float height) { - super(parent, x, y, width, 2.0f, MinecraftGUI.PanelType.Gray); + public ControlDropDownMenu(final IWidget parent, final int x, final int y, final int width, final int height) { + super(parent, x, y, width, 2, MinecraftGUI.PanelType.Gray); this.stayOpenOnChildClick = false; this.addAttribute(Attribute.CanFocus); } diff --git a/src/main/java/binnie/craftgui/extratrees/kitchen/ControlDropdownButton.java b/src/main/java/binnie/craftgui/extratrees/kitchen/ControlDropdownButton.java index f2aeb3f0..f49607c6 100644 --- a/src/main/java/binnie/craftgui/extratrees/kitchen/ControlDropdownButton.java +++ b/src/main/java/binnie/craftgui/extratrees/kitchen/ControlDropdownButton.java @@ -6,7 +6,7 @@ import binnie.craftgui.events.EventMouse; import binnie.craftgui.minecraft.Window; public abstract class ControlDropdownButton extends ControlButton { - public ControlDropdownButton(final IWidget parent, final float x, final float y, final float width, final float height, final String text) { + public ControlDropdownButton(final IWidget parent, final int x, final int y, final int width, final int height, final String text) { super(parent, x, y, width, height, text); this.addSelfEventHandler(new EventMouse.Down.Handler() { @Override diff --git a/src/main/java/binnie/craftgui/extratrees/kitchen/ControlFluidDisplay.java b/src/main/java/binnie/craftgui/extratrees/kitchen/ControlFluidDisplay.java index c544de67..3a481758 100644 --- a/src/main/java/binnie/craftgui/extratrees/kitchen/ControlFluidDisplay.java +++ b/src/main/java/binnie/craftgui/extratrees/kitchen/ControlFluidDisplay.java @@ -24,31 +24,31 @@ public class ControlFluidDisplay extends Control implements ITooltip { this.addAttribute(Attribute.MouseOver); } - public ControlFluidDisplay(final IWidget parent, final float f, final float y) { - this(parent, f, y, 16.0f); + public ControlFluidDisplay(final IWidget parent, final int x, final int y) { + this(parent, x, y, 16); } - public ControlFluidDisplay(final IWidget parent, final float f, final float y, final FluidStack stack, final boolean tooltip) { - this(parent, f, y, 16.0f); + public ControlFluidDisplay(final IWidget parent, final int x, final int y, final FluidStack stack, final boolean tooltip) { + this(parent, x, y, 16); this.setItemStack(stack); if (tooltip) { this.setTooltip(); } } - public ControlFluidDisplay(final IWidget parent, final float x, final float y, final float size) { + public ControlFluidDisplay(final IWidget parent, final int x, final int y, final int size) { super(parent, x, y, size, size); this.itemStack = null; this.hastooltip = false; } @Override - public void onRenderForeground() { + public void onRenderForeground(int guiWidth, int guiHeight) { if (this.itemStack == null) { return; } final IPoint relativeToWindow = this.getAbsolutePosition().sub(this.getSuperParent().getPosition()); - if (relativeToWindow.x() > Window.get(this).getSize().x() + 100.0f || relativeToWindow.y() > Window.get(this).getSize().y() + 100.0f) { + if (relativeToWindow.x() > Window.get(this).getSize().x() + 100 || relativeToWindow.y() > Window.get(this).getSize().y() + 100) { return; } if (this.itemStack != null) { @@ -62,7 +62,7 @@ public class ControlFluidDisplay extends Control implements ITooltip { GL11.glColor4f(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f); GL11.glEnable(3042); GL11.glBlendFunc(770, 771); - if (this.getSize().x() != 16.0f) { + if (this.getSize().x() != 16) { GL11.glPushMatrix(); final float scale = this.getSize().x() / 16.0f; GL11.glScalef(scale, scale, 1.0f); diff --git a/src/main/java/binnie/craftgui/extratrees/kitchen/ControlSlotFluid.java b/src/main/java/binnie/craftgui/extratrees/kitchen/ControlSlotFluid.java index 1aee4711..4a01103e 100644 --- a/src/main/java/binnie/craftgui/extratrees/kitchen/ControlSlotFluid.java +++ b/src/main/java/binnie/craftgui/extratrees/kitchen/ControlSlotFluid.java @@ -23,24 +23,24 @@ public class ControlSlotFluid extends Control implements ITooltip { public ControlSlotFluid(final IWidget parent, final int x, final int y, final int size, final FluidStack fluid) { super(parent, x, y, size, size); this.addAttribute(Attribute.MouseOver); - this.itemDisplay = new ControlFluidDisplay(this, 1.0f, 1.0f, size - 2); + this.itemDisplay = new ControlFluidDisplay(this, 1, 1, size - 2); this.fluidStack = fluid; this.addSelfEventHandler(new EventWidget.ChangeSize.Handler() { @Override public void onEvent(final EventWidget.ChangeSize event) { if (ControlSlotFluid.this.itemDisplay != null) { - ControlSlotFluid.this.itemDisplay.setSize(ControlSlotFluid.this.getSize().sub(new IPoint(2.0f, 2.0f))); + ControlSlotFluid.this.itemDisplay.setSize(ControlSlotFluid.this.getSize().sub(new IPoint(2, 2))); } } }); } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { final int size = (int) this.getSize().x(); CraftGUI.render.texture(CraftGUITexture.Slot, this.getArea()); if (this.getSuperParent().getMousedOverWidget() == this) { - CraftGUI.render.gradientRect(new IArea(new IPoint(1.0f, 1.0f), this.getArea().size().sub(new IPoint(2.0f, 2.0f))), -2130706433, -2130706433); + CraftGUI.render.gradientRect(new IArea(new IPoint(1, 1), this.getArea().size().sub(new IPoint(2, 2))), -2130706433, -2130706433); } } diff --git a/src/main/java/binnie/craftgui/extratrees/kitchen/ControlTankSlot.java b/src/main/java/binnie/craftgui/extratrees/kitchen/ControlTankSlot.java index fca687ec..950d414a 100644 --- a/src/main/java/binnie/craftgui/extratrees/kitchen/ControlTankSlot.java +++ b/src/main/java/binnie/craftgui/extratrees/kitchen/ControlTankSlot.java @@ -28,13 +28,13 @@ public class ControlTankSlot extends ControlSlotFluid { @Override public void onUpdateClient() { this.fluidStack = Window.get(this).getContainer().getTankInfo(this.tankID).liquid; - final int height = (int) (16.0f * (((this.fluidStack == null) ? 0 : this.fluidStack.amount) / 1000.0f)); - this.itemDisplay.setCroppedZone(this.itemDisplay, new IArea(0.0f, 16 - height, 16.0f, 16.0f)); + final int height = 16 * (((this.fluidStack == null) ? 0 : this.fluidStack.amount) / 1000); + this.itemDisplay.setCroppedZone(this.itemDisplay, new IArea(0, 16 - height, 16, 16)); super.onUpdateClient(); } @Override - public void onRenderBackground() { - super.onRenderBackground(); + public void onRenderBackground(int guiWidth, int guiHeight) { + super.onRenderBackground(guiWidth, guiHeight); } } diff --git a/src/main/java/binnie/craftgui/extratrees/kitchen/WindowBottleRack.java b/src/main/java/binnie/craftgui/extratrees/kitchen/WindowBottleRack.java index 04c91a0f..59f3a55e 100644 --- a/src/main/java/binnie/craftgui/extratrees/kitchen/WindowBottleRack.java +++ b/src/main/java/binnie/craftgui/extratrees/kitchen/WindowBottleRack.java @@ -11,7 +11,7 @@ import net.minecraftforge.fml.relauncher.Side; public class WindowBottleRack extends Window { public WindowBottleRack(final EntityPlayer player, final IInventory inventory, final Side side) { - super(248.0f, 180.0f, player, inventory, side); + super(248, 180, player, inventory, side); } public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) { diff --git a/src/main/java/binnie/craftgui/genetics/machine/ControlGene.java b/src/main/java/binnie/craftgui/genetics/machine/ControlGene.java index 76edbfba..9340b3e3 100644 --- a/src/main/java/binnie/craftgui/genetics/machine/ControlGene.java +++ b/src/main/java/binnie/craftgui/genetics/machine/ControlGene.java @@ -40,8 +40,8 @@ public class ControlGene extends Control implements IControlValue, IToolt return stack != null && stack.stackSize == 1 && Engineering.isGeneAcceptor(stack) && Engineering.canAcceptGene(stack, this.getValue()); } - protected ControlGene(final IWidget parent, final float x, final float y) { - super(parent, x, y, 16.0f, 16.0f); + protected ControlGene(final IWidget parent, final int x, final int y) { + super(parent, x, y, 16, 16); this.addAttribute(Attribute.MouseOver); this.addSelfEventHandler(new EventMouse.Down.Handler() { @Override @@ -68,11 +68,11 @@ public class ControlGene extends Control implements IControlValue, IToolt } @Override - public void onRenderForeground() { + public void onRenderForeground(int guiWidth, int guiHeight) { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { if (this.isMouseOver() && this.canFill(Window.get(this).getHeldItemStack())) { CraftGUI.render.solid(this.getArea(), -1); CraftGUI.render.solid(this.getArea().inset(1), -12303292); diff --git a/src/main/java/binnie/craftgui/genetics/machine/ControlGeneScroll.java b/src/main/java/binnie/craftgui/genetics/machine/ControlGeneScroll.java index 33e2f2ae..95640cef 100644 --- a/src/main/java/binnie/craftgui/genetics/machine/ControlGeneScroll.java +++ b/src/main/java/binnie/craftgui/genetics/machine/ControlGeneScroll.java @@ -21,7 +21,7 @@ public class ControlGeneScroll extends Control implements IControlValue -range / 2.0f && y < range / 2.0f) { final float percentView = (float) Math.sqrt(1.0f - Math.abs(2.0f * y / range)); final float offMovement = (this.h() - 2.0f * h) / 2.0f; @@ -40,10 +40,11 @@ public class ControlSplicerProgress extends ControlProgressBase { c2 += alpha; c3 += alpha; c4 += alpha; - CraftGUI.render.solidAlpha(new IArea(this.w() / 2.0f + y, offMovement * percentView, 4.0f, h / 2.0f), c1); - CraftGUI.render.solidAlpha(new IArea(this.w() / 2.0f + y, offMovement * percentView + 4.0f, 4.0f, h / 2.0f), (y < 0.0f) ? c2 : c3); - CraftGUI.render.solidAlpha(new IArea(this.w() / 2.0f + y, this.h() - offMovement * percentView - 8.0f, 4.0f, h / 2.0f), (y < 0.0f) ? c3 : c2); - CraftGUI.render.solidAlpha(new IArea(this.w() / 2.0f + y, this.h() - offMovement * percentView - 4.0f, 4.0f, h / 2.0f), c4); + int viewAmount = Math.round(offMovement * percentView); + CraftGUI.render.solidAlpha(new IArea(this.w() / 2 + y, viewAmount, 4, h / 2), c1); + CraftGUI.render.solidAlpha(new IArea(this.w() / 2 + y, viewAmount + 4, 4, h / 2), (y < 0) ? c2 : c3); + CraftGUI.render.solidAlpha(new IArea(this.w() / 2 + y, this.h() - viewAmount - 8, 4, h / 2), (y < 0) ? c3 : c2); + CraftGUI.render.solidAlpha(new IArea(this.w() / 2 + y, this.h() - viewAmount - 4, 4, h / 2), c4); } } } diff --git a/src/main/java/binnie/craftgui/genetics/machine/WindowAcclimatiser.java b/src/main/java/binnie/craftgui/genetics/machine/WindowAcclimatiser.java index 9e421486..990515a3 100644 --- a/src/main/java/binnie/craftgui/genetics/machine/WindowAcclimatiser.java +++ b/src/main/java/binnie/craftgui/genetics/machine/WindowAcclimatiser.java @@ -40,7 +40,7 @@ public class WindowAcclimatiser extends WindowMachine { x += 72; new ControlSlotArray(this, x, y, 2, 2).create(Acclimatiser.SLOT_DRONE); new ControlEnergyBar(this, 21, 115, 16, 60, Position.Bottom); - new ControlErrorState(this, 181.0f, 83.0f); + new ControlErrorState(this, 181, 83); new ControlPlayerInventory(this); } diff --git a/src/main/java/binnie/craftgui/genetics/machine/WindowAnalyser.java b/src/main/java/binnie/craftgui/genetics/machine/WindowAnalyser.java index b3c410f8..3050fb9e 100644 --- a/src/main/java/binnie/craftgui/genetics/machine/WindowAnalyser.java +++ b/src/main/java/binnie/craftgui/genetics/machine/WindowAnalyser.java @@ -47,7 +47,7 @@ public class WindowAnalyser extends WindowMachine { x -= 28; new ControlIconDisplay(this, x + 36 + 2, y + 18, GUIIcon.ArrowRight.getIcon().getResourceLocation()); x += 56; - new Panel(this, x, y, 76.0f, 50.0f, MinecraftGUI.PanelType.Tinted); + new Panel(this, x, y, 76, 50, MinecraftGUI.PanelType.Tinted); new ControlProgress(this, x + 5, y + 5, WindowAnalyser.ProgressBase, WindowAnalyser.Progress, Position.Left); new ControlSlot(this, x + 38 - 9, y + 25 - 9).assign(6); new ControlIconDisplay(this, x + 76 + 2, y + 18, GUIIcon.ArrowRight.getIcon().getResourceLocation()); diff --git a/src/main/java/binnie/craftgui/genetics/machine/WindowGeneBank.java b/src/main/java/binnie/craftgui/genetics/machine/WindowGeneBank.java index 5f1de0c1..d9e649bc 100644 --- a/src/main/java/binnie/craftgui/genetics/machine/WindowGeneBank.java +++ b/src/main/java/binnie/craftgui/genetics/machine/WindowGeneBank.java @@ -92,21 +92,21 @@ public class WindowGeneBank extends WindowMachine { x += 124; boxX = x; final int geneBoxWidth = 120; - new Panel(this, boxX + 24, 32.0f, geneBoxWidth, 120.0f, MinecraftGUI.PanelType.Black); - new Panel(this, boxX + 24 + geneBoxWidth, 32.0f, 14.0f, 120.0f, MinecraftGUI.PanelType.Gray); - final ControlScrollableContent scroll = new ControlScrollableContent(this, boxX + 24 + 2, 34.0f, geneBoxWidth + 10, 116.0f, 12.0f); - final ControlTextEdit edit = new ControlTextEdit(this, boxX + 27 + geneBoxWidth - 70, 18.0f, 80.0f, 12.0f); + new Panel(this, boxX + 24, 32, geneBoxWidth, 120, MinecraftGUI.PanelType.Black); + new Panel(this, boxX + 24 + geneBoxWidth, 32, 14, 120, MinecraftGUI.PanelType.Gray); + final ControlScrollableContent scroll = new ControlScrollableContent(this, boxX + 24 + 2, 34, geneBoxWidth + 10, 116, 12); + final ControlTextEdit edit = new ControlTextEdit(this, boxX + 27 + geneBoxWidth - 70, 18, 80, 12); this.addEventHandler(new EventTextEdit.Handler() { @Override public void onEvent(final EventTextEdit event) { WindowGeneBank.this.genes.setFilter(event.getValue()); } }.setOrigin(EventHandler.Origin.Self, edit)); - scroll.setScrollableContent(this.genes = new ControlGeneScroll(scroll, 1.0f, 1.0f, geneBoxWidth, 116.0f)); + scroll.setScrollableContent(this.genes = new ControlGeneScroll(scroll, 1, 1, geneBoxWidth, 116)); this.genes.setGenes(Binnie.GENETICS.beeBreedingSystem); - final ControlTabBar tabBar = new ControlTabBar(this, boxX, 32.0f, 24.0f, 120.0f, Position.Left) { + final ControlTabBar tabBar = new ControlTabBar(this, boxX, 32, 24, 120, Position.Left) { @Override - public ControlTab createTab(final float x, final float y, final float w, final float h, final BreedingSystem value) { + public ControlTab createTab(final int x, final int y, final int w, final int h, final BreedingSystem value) { return new ControlTabIcon(this, x, y, w, h, value) { @Override public void getTooltip(final Tooltip tooltip) { @@ -132,10 +132,10 @@ public class WindowGeneBank extends WindowMachine { tabBar.setValues(Binnie.GENETICS.getActiveSystems()); tabBar.setValue(Binnie.GENETICS.beeBreedingSystem); boxX -= 8; - final ControlTabBar infoTabs = new ControlTabBar<>(this, boxX + 8, 160.0f, 16.0f, 50.0f, Position.Left); + final ControlTabBar infoTabs = new ControlTabBar<>(this, boxX + 8, 160, 16, 50, Position.Left); infoTabs.setValues(Arrays.asList("Stats", "Ranking")); infoTabs.setValue("Info"); - final Panel panelProject = new Panel(this, boxX + 24, 160.0f, geneBoxWidth + 20, 50.0f, MinecraftGUI.PanelType.Black); + final Panel panelProject = new Panel(this, boxX + 24, 160, geneBoxWidth + 20, 50, MinecraftGUI.PanelType.Black); int totalGenes = 0; int seqGenes = 0; for (final BreedingSystem system : Binnie.GENETICS.getActiveSystems()) { @@ -151,8 +151,8 @@ public class WindowGeneBank extends WindowMachine { } } } - new ControlText(panelProject, new IPoint(4.0f, 4.0f), "§nFull Genome Project"); - new ControlText(panelProject, new IPoint(4.0f, 18.0f), "§oSequenced §r" + seqGenes + "/" + totalGenes + " §oGenes"); + new ControlText(panelProject, new IPoint(4, 4), "§nFull Genome Project"); + new ControlText(panelProject, new IPoint(4, 18), "§oSequenced §r" + seqGenes + "/" + totalGenes + " §oGenes"); } @Override diff --git a/src/main/java/binnie/craftgui/genetics/machine/WindowGeneProject.java b/src/main/java/binnie/craftgui/genetics/machine/WindowGeneProject.java index dbe63339..e2abc28f 100644 --- a/src/main/java/binnie/craftgui/genetics/machine/WindowGeneProject.java +++ b/src/main/java/binnie/craftgui/genetics/machine/WindowGeneProject.java @@ -9,7 +9,7 @@ import net.minecraftforge.fml.relauncher.Side; public class WindowGeneProject extends Window { public WindowGeneProject(final EntityPlayer player, final IInventory inventory, final Side side) { - super(100.0f, 100.0f, player, inventory, side); + super(100, 100, player, inventory, side); } @Override diff --git a/src/main/java/binnie/craftgui/genetics/machine/WindowGenepool.java b/src/main/java/binnie/craftgui/genetics/machine/WindowGenepool.java index b9ac793a..5e3164f3 100644 --- a/src/main/java/binnie/craftgui/genetics/machine/WindowGenepool.java +++ b/src/main/java/binnie/craftgui/genetics/machine/WindowGenepool.java @@ -46,9 +46,9 @@ public class WindowGenepool extends WindowMachine { x += 130; new ControlLiquidTank(this, x, y).setTankID(0); new ControlEnergyBar(this, 21, 115, 16, 60, Position.Bottom); - new ControlSlot(this, 121.0f, 82.0f).assign(7); + new ControlSlot(this, 121, 82).assign(7); new ControlSlotCharge(this, 143, 82, 7).setColour(15722671); - new ControlErrorState(this, 181.0f, 83.0f); + new ControlErrorState(this, 181, 83); new ControlPlayerInventory(this); } diff --git a/src/main/java/binnie/craftgui/genetics/machine/WindowIncubator.java b/src/main/java/binnie/craftgui/genetics/machine/WindowIncubator.java index 5b479fbd..bc9c556d 100644 --- a/src/main/java/binnie/craftgui/genetics/machine/WindowIncubator.java +++ b/src/main/java/binnie/craftgui/genetics/machine/WindowIncubator.java @@ -49,7 +49,7 @@ public class WindowIncubator extends WindowMachine { new ControlLiquidTank(this, x, y).setTankID(1); x += 34; new ControlEnergyBar(this, x, y + 3, 16, 54, Position.Bottom); - new ControlErrorState(this, 91.0f, 82.0f); + new ControlErrorState(this, 91, 82); new ControlPlayerInventory(this); } diff --git a/src/main/java/binnie/craftgui/genetics/machine/WindowInoculator.java b/src/main/java/binnie/craftgui/genetics/machine/WindowInoculator.java index 5c5218e1..03250c9f 100644 --- a/src/main/java/binnie/craftgui/genetics/machine/WindowInoculator.java +++ b/src/main/java/binnie/craftgui/genetics/machine/WindowInoculator.java @@ -36,13 +36,23 @@ public class WindowInoculator extends WindowMachine { int x = 16; final int y = 32; new ControlLiquidTank(this, x, y + 18 + 16).setTankID(0); - CraftGUIUtil.horizontalGrid(x, y, new ControlSlotArray(this, 0, 0, 2, 1).create(Inoculator.SLOT_SERUM_RESERVE), new ControlIconDisplay(this, 0.0f, 0.0f, GUIIcon.ArrowRight.getIcon().getResourceLocation()), new ControlSlot(this, 0.0f, 0.0f).assign(0), new ControlIconDisplay(this, 0.0f, 0.0f, GUIIcon.ArrowRight.getIcon().getResourceLocation()), new ControlSlotArray(this, 0, 0, 2, 1).create(Inoculator.SLOT_SERUM_EXPENDED)); + CraftGUIUtil.horizontalGrid(x, y, + new ControlSlotArray(this, 0, 0, 2, 1).create(Inoculator.SLOT_SERUM_RESERVE), + new ControlIconDisplay(this, 0, 0, GUIIcon.ArrowRight.getIcon().getResourceLocation()), + new ControlSlot(this, 0, 0).assign(0), + new ControlIconDisplay(this, 0, 0, GUIIcon.ArrowRight.getIcon().getResourceLocation()), + new ControlSlotArray(this, 0, 0, 2, 1).create(Inoculator.SLOT_SERUM_EXPENDED) + ); x += 18; new ControlMachineProgress(this, x, y + 24, WindowInoculator.ProgressBase, WindowInoculator.Progress, Position.Left); new ControlEnergyBar(this, 91, 118, 60, 16, Position.Left); - new ControlErrorState(this, 161.0f, 118.0f); + new ControlErrorState(this, 161, 118); x += 142; - CraftGUIUtil.verticalGrid(x, y, TextJustification.MiddleLeft, 8.0f, new ControlSlotArray(this, x, y, 4, 1).create(Inoculator.SLOT_RESERVE), new ControlSlot(this, x, y + 18 + 8).assign(9), new ControlSlotArray(this, x, y + 18 + 8 + 18 + 8, 4, 1).create(Inoculator.SLOT_FINISHED)); + CraftGUIUtil.verticalGrid(x, y, TextJustification.MiddleLeft, 8, + new ControlSlotArray(this, x, y, 4, 1).create(Inoculator.SLOT_RESERVE), + new ControlSlot(this, x, y + 18 + 8).assign(9), + new ControlSlotArray(this, x, y + 18 + 8 + 18 + 8, 4, 1).create(Inoculator.SLOT_FINISHED) + ); new ControlIconDisplay(this, x + 18, y + 18 + 2, GUIIcon.ArrowUpLeft.getIcon().getResourceLocation()); new ControlIconDisplay(this, x + 18, y + 18 + 18, GUIIcon.ArrowLeftDown.getIcon().getResourceLocation()); new ControlPlayerInventory(this); diff --git a/src/main/java/binnie/craftgui/genetics/machine/WindowIsolator.java b/src/main/java/binnie/craftgui/genetics/machine/WindowIsolator.java index 46d36e37..c0f6aa84 100644 --- a/src/main/java/binnie/craftgui/genetics/machine/WindowIsolator.java +++ b/src/main/java/binnie/craftgui/genetics/machine/WindowIsolator.java @@ -54,7 +54,7 @@ public class WindowIsolator extends WindowMachine { x += 18; new ControlSlotArray(this, x, y + 3, 2, 3).create(Isolator.SLOT_FINISHED); new ControlEnergyBar(this, 260, 130, 16, 60, Position.Bottom); - new ControlErrorState(this, 153.0f, 81.0f); + new ControlErrorState(this, 153, 81); new ControlPlayerInventory(this); } diff --git a/src/main/java/binnie/craftgui/genetics/machine/WindowPolymeriser.java b/src/main/java/binnie/craftgui/genetics/machine/WindowPolymeriser.java index 17550ce8..49577eec 100644 --- a/src/main/java/binnie/craftgui/genetics/machine/WindowPolymeriser.java +++ b/src/main/java/binnie/craftgui/genetics/machine/WindowPolymeriser.java @@ -47,7 +47,7 @@ public class WindowPolymeriser extends WindowMachine { new ControlSlotCharge(this, x + 30 + 20, y + 18 + 8, 1).setColour(16766976); x += 138; new ControlSlotArray(this, x, y + 9, 2, 2).create(Polymeriser.SLOT_SERUM_FINISHED); - final ControlErrorState errorState = new ControlErrorState(this, 244.0f, 97.0f); + final ControlErrorState errorState = new ControlErrorState(this, 244, 97); new ControlPlayerInventory(this); } diff --git a/src/main/java/binnie/craftgui/genetics/machine/WindowSequencer.java b/src/main/java/binnie/craftgui/genetics/machine/WindowSequencer.java index 7b4575f5..2a57aedf 100644 --- a/src/main/java/binnie/craftgui/genetics/machine/WindowSequencer.java +++ b/src/main/java/binnie/craftgui/genetics/machine/WindowSequencer.java @@ -47,12 +47,18 @@ public class WindowSequencer extends WindowMachine { super.initialiseClient(); int x = 16; int y = 32; - CraftGUIUtil.horizontalGrid(x, y, TextJustification.MiddleCenter, 2.0f, new ControlSlotArray(this, 0, 0, 2, 2).create(Sequencer.SLOT_RESERVE), new ControlIconDisplay(this, 0.0f, 0.0f, GUIIcon.ArrowRight.getIcon().getResourceLocation()), new ControlSequencerProgress(this, 0, 0), new ControlIconDisplay(this, 0.0f, 0.0f, GUIIcon.ArrowRight.getIcon().getResourceLocation()), new ControlSlot(this, 0.0f, 0.0f).assign(6)); + CraftGUIUtil.horizontalGrid(x, y, TextJustification.MiddleCenter, 2, + new ControlSlotArray(this, 0, 0, 2, 2).create(Sequencer.SLOT_RESERVE), + new ControlIconDisplay(this, 0, 0, GUIIcon.ArrowRight.getIcon().getResourceLocation()), + new ControlSequencerProgress(this, 0, 0), + new ControlIconDisplay(this, 0, 0, GUIIcon.ArrowRight.getIcon().getResourceLocation()), + new ControlSlot(this, 0, 0).assign(6) + ); final ControlSlot slotTarget = new ControlSlot(this, x + 96, y + 16); slotTarget.assign(5); x = 34; y = 92; - this.slotText = new ControlText(this, new IArea(0.0f, y, this.w(), 12.0f), TextFormatting.DARK_GRAY + Genetics.proxy.localise("machine.machine.sequencer.texts.userless"), TextJustification.MiddleCenter); + this.slotText = new ControlText(this, new IArea(0, y, this.w(), 12), TextFormatting.DARK_GRAY + Genetics.proxy.localise("machine.machine.sequencer.texts.userless"), TextJustification.MiddleCenter); y += 20; final ControlSlot slotDye = new ControlSlot(this, x, y); slotDye.assign(0); diff --git a/src/main/java/binnie/craftgui/genetics/machine/WindowSplicer.java b/src/main/java/binnie/craftgui/genetics/machine/WindowSplicer.java index 6e4efd64..621e89b1 100644 --- a/src/main/java/binnie/craftgui/genetics/machine/WindowSplicer.java +++ b/src/main/java/binnie/craftgui/genetics/machine/WindowSplicer.java @@ -33,14 +33,24 @@ public class WindowSplicer extends WindowMachine { public void initialiseClient() { super.initialiseClient(); int x = 16; - new ControlSplicerProgress(this, 84.0f, 32.0f, this.w() - 172.0f, 102.0f); - CraftGUIUtil.horizontalGrid(x, 62.0f, new ControlSlotArray(this, 0, 0, 2, 1).create(Splicer.SLOT_SERUM_RESERVE), new ControlIconDisplay(this, 0.0f, 0.0f, GUIIcon.ArrowRight.getIcon().getResourceLocation()), new ControlSlot(this, 0.0f, 0.0f).assign(0)); + new ControlSplicerProgress(this, 84, 32, this.w() - 172, 102); + CraftGUIUtil.horizontalGrid(x, 62, + new ControlSlotArray(this, 0, 0, 2, 1).create(Splicer.SLOT_SERUM_RESERVE), + new ControlIconDisplay(this, 0, 0, GUIIcon.ArrowRight.getIcon().getResourceLocation()), + new ControlSlot(this, 0, 0).assign(0) + ); new ControlSlotArray(this, x + 12, 84, 2, 1).create(Splicer.SLOT_SERUM_EXPENDED); - new ControlIconDisplay(this, x + 12 + 36 + 4, 86.0f, GUIIcon.ArrowUpLeft.getIcon().getResourceLocation()); + new ControlIconDisplay(this, x + 12 + 36 + 4, 86, GUIIcon.ArrowUpLeft.getIcon().getResourceLocation()); new ControlEnergyBar(this, 196, 64, 60, 16, Position.Left); - new ControlErrorState(this, 218.0f, 86.0f); + new ControlErrorState(this, 218, 86); x += 142; - CraftGUIUtil.verticalGrid((this.w() - 72.0f) / 2.0f, 32.0f, TextJustification.MiddleCenter, 4.0f, new ControlSlotArray(this, 0, 0, 4, 1).create(Inoculator.SLOT_RESERVE), new ControlIconDisplay(this, 0.0f, 0.0f, GUIIcon.ArrowDown.getIcon().getResourceLocation()), new ControlSlot(this, 0.0f, 0.0f).assign(9), new ControlIconDisplay(this, 0.0f, 0.0f, GUIIcon.ArrowDown.getIcon().getResourceLocation()), new ControlSlotArray(this, 0, 0, 4, 1).create(Inoculator.SLOT_FINISHED)); + CraftGUIUtil.verticalGrid((this.w() - 72) / 2, 32, TextJustification.MiddleCenter, 4, + new ControlSlotArray(this, 0, 0, 4, 1).create(Inoculator.SLOT_RESERVE), + new ControlIconDisplay(this, 0, 0, GUIIcon.ArrowDown.getIcon().getResourceLocation()), + new ControlSlot(this, 0, 0).assign(9), + new ControlIconDisplay(this, 0, 0, GUIIcon.ArrowDown.getIcon().getResourceLocation()), + new ControlSlotArray(this, 0, 0, 4, 1).create(Inoculator.SLOT_FINISHED) + ); new ControlPlayerInventory(this); } diff --git a/src/main/java/binnie/craftgui/minecraft/Dialog.java b/src/main/java/binnie/craftgui/minecraft/Dialog.java index ed46e3f7..41474226 100644 --- a/src/main/java/binnie/craftgui/minecraft/Dialog.java +++ b/src/main/java/binnie/craftgui/minecraft/Dialog.java @@ -10,8 +10,8 @@ import binnie.craftgui.events.EventMouse; import binnie.craftgui.resource.minecraft.CraftGUITexture; public abstract class Dialog extends Control { - public Dialog(final IWidget parent, final float w, final float h) { - super(parent, (parent.w() - w) / 2.0f, (parent.h() - h) / 2.0f, w, h); + public Dialog(final IWidget parent, final int w, final int h) { + super(parent, (parent.w() - w) / 2, (parent.h() - h) / 2, w, h); this.addAttribute(Attribute.MouseOver); this.addAttribute(Attribute.AlwaysOnTop); this.addAttribute(Attribute.BlockTooltip); @@ -33,7 +33,7 @@ public abstract class Dialog extends Control { public abstract void onClose(); @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.gradientRect(this.getArea().outset(400), -1442840576, -1442840576); CraftGUI.render.texture(CraftGUITexture.Window, this.getArea()); CraftGUI.render.texture(CraftGUITexture.TabOutline, this.getArea().inset(4)); diff --git a/src/main/java/binnie/craftgui/minecraft/GuiCraftGUI.java b/src/main/java/binnie/craftgui/minecraft/GuiCraftGUI.java index b4492439..5c7b4cdd 100644 --- a/src/main/java/binnie/craftgui/minecraft/GuiCraftGUI.java +++ b/src/main/java/binnie/craftgui/minecraft/GuiCraftGUI.java @@ -1,11 +1,8 @@ package binnie.craftgui.minecraft; -import binnie.core.BinnieCore; -import binnie.craftgui.core.CraftGUI; import binnie.craftgui.core.IWidget; import binnie.craftgui.core.Tooltip; -import binnie.craftgui.core.geometry.IArea; -import binnie.craftgui.core.geometry.IBorder; +import binnie.craftgui.core.geometry.CraftGUIUtil; import binnie.craftgui.core.geometry.IPoint; import binnie.craftgui.events.EventKey; import binnie.craftgui.events.EventMouse; @@ -14,18 +11,11 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.VertexBuffer; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.JsonToNBT; import net.minecraft.nbt.NBTException; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.lwjgl.input.Keyboard; @@ -53,7 +43,7 @@ public class GuiCraftGUI extends GuiContainer { public GuiCraftGUI(final Window window) { super(window.getContainer()); - this.mousePos = new IPoint(0.0f, 0.0f); + this.mousePos = IPoint.ZERO; this.window = window; this.resize(window.getSize()); } @@ -87,7 +77,7 @@ public class GuiCraftGUI extends GuiContainer { GL11.glDisable(2929); this.zLevel = 10.0f; //GuiScreen.itemRender.zLevel = this.zLevel; - this.window.render(); + this.window.render(this.width, this.height); GL11.glPushMatrix(); @@ -96,7 +86,7 @@ public class GuiCraftGUI extends GuiContainer { final InventoryPlayer playerInventory = this.mc.thePlayer.inventory; this.draggedItem = playerInventory.getItemStack(); if (this.draggedItem != null) { - this.renderItem(new IPoint(mouseX - 8, mouseY - 8), this.draggedItem, 200, false); + CraftGUIUtil.renderItem(new IPoint(mouseX - 8, mouseY - 8), this.draggedItem, false); } RenderHelper.enableGUIStandardItemLighting(); GL11.glDisable(32826); @@ -188,7 +178,7 @@ public class GuiCraftGUI extends GuiContainer { GL11.glPushMatrix(); GL11.glTranslatef(i1, j1 - 1.5f, 0.0f); GL11.glScalef(0.6f, 0.6f, 1.0f); - this.renderItem(new IPoint(0.0f, 0.0f), stack, false); + CraftGUIUtil.renderItem(IPoint.ZERO, stack, false); GL11.glPopMatrix(); } catch (NBTException e) { e.printStackTrace(); @@ -271,191 +261,6 @@ public class GuiCraftGUI extends GuiContainer { this.window.onClose(); } - public void renderTexturedRect(final float x, final float y, final float u, final float v, final float w, final float h) { - this.drawTexturedModalRect((int) x, (int) y, (int) u, (int) v, (int) w, (int) h); - } - - public void renderTexture(final IPoint position, final IArea textureArea) { - this.drawTexturedModalRect((int) position.x(), (int) position.y(), (int) textureArea.pos().x(), (int) textureArea.pos().y(), (int) textureArea.size().x(), (int) textureArea.size().y()); - } - - private void renderTexturedRect(final IArea area, final IPoint uv) { - this.renderTexturedRect(area.pos().x(), area.pos().y(), uv.x(), uv.y(), area.size().x(), area.size().y()); - } - - public void renderTexturePadded(final IArea area, final IArea texture, final IBorder padding) { - int borderLeft = (int) padding.l(); - int borderRight = (int) padding.r(); - int borderTop = (int) padding.t(); - int borderBottom = (int) padding.b(); - final int posX = (int) area.pos().x(); - final int posY = (int) area.pos().y(); - final int width = (int) area.size().x(); - final int height = (int) area.size().y(); - final int textWidth = (int) texture.w(); - final int textHeight = (int) texture.h(); - final int u = (int) texture.x(); - final int v = (int) texture.y(); - if (borderTop + borderBottom > height) { - borderTop = height / 2; - borderBottom = height / 2; - } - if (borderLeft + borderRight > width) { - borderLeft = width / 2; - borderRight = width / 2; - } - final IPoint origin = area.pos(); - this.drawTexturedModalRect(posX, posY, u, v, borderLeft, borderTop); - this.drawTexturedModalRect(posX + width - borderRight, posY, u + textWidth - borderRight, v, borderRight, borderTop); - this.drawTexturedModalRect(posX, posY + height - borderBottom, u, v + textHeight - borderBottom, borderLeft, borderBottom); - this.drawTexturedModalRect(posX + width - borderRight, posY + height - borderBottom, u + textWidth - borderRight, v + textHeight - borderBottom, borderRight, borderBottom); - int texturingWidth; - for (int currentXPos = borderLeft; currentXPos < width - borderRight; currentXPos += texturingWidth) { - final int distanceXRemaining = width - borderRight - currentXPos; - texturingWidth = textWidth - borderLeft - borderRight; - if (texturingWidth > distanceXRemaining) { - texturingWidth = distanceXRemaining; - } - if (texturingWidth <= 0) { - break; - } - this.drawTexturedModalRect(posX + currentXPos, posY, u + borderLeft, v, texturingWidth, borderTop); - this.drawTexturedModalRect(posX + currentXPos, posY + height - borderBottom, u + borderLeft, v + textHeight - borderBottom, texturingWidth, borderBottom); - int texturingHeight; - for (int currentYPos = borderTop; currentYPos < height - borderBottom; currentYPos += texturingHeight) { - final int distanceYRemaining = height - borderBottom - currentYPos; - texturingHeight = textHeight - borderTop - borderBottom; - if (texturingHeight > distanceYRemaining) { - texturingHeight = distanceYRemaining; - } - if (texturingHeight <= 0) { - break; - } - this.drawTexturedModalRect(posX + currentXPos, posY + currentYPos, u + borderLeft, v + borderTop, texturingWidth, texturingHeight); - } - } - int texturingHeight2; - for (int currentYPos2 = borderTop; currentYPos2 < height - borderBottom; currentYPos2 += texturingHeight2) { - final int distanceYRemaining2 = height - borderBottom - currentYPos2; - texturingHeight2 = textHeight - borderTop - borderBottom; - if (texturingHeight2 > distanceYRemaining2) { - texturingHeight2 = distanceYRemaining2; - } - if (texturingHeight2 <= 0) { - break; - } - this.drawTexturedModalRect(posX, posY + currentYPos2, u, v + borderTop, borderLeft, texturingHeight2); - this.drawTexturedModalRect(posX + width - borderRight, posY + currentYPos2, u + textWidth - borderRight, v + borderTop, borderRight, texturingHeight2); - } - } - - public void drawGradientArea(final float p_73733_1_, final float p_73733_2_, final float p_73733_3_, final float p_73733_4_, final int p_73733_5_, final int p_73733_6_) { - final float f = (p_73733_5_ >> 24 & 0xFF) / 255.0f; - final float f2 = (p_73733_5_ >> 16 & 0xFF) / 255.0f; - final float f3 = (p_73733_5_ >> 8 & 0xFF) / 255.0f; - final float f4 = (p_73733_5_ & 0xFF) / 255.0f; - final float f5 = (p_73733_6_ >> 24 & 0xFF) / 255.0f; - final float f6 = (p_73733_6_ >> 16 & 0xFF) / 255.0f; - final float f7 = (p_73733_6_ >> 8 & 0xFF) / 255.0f; - final float f8 = (p_73733_6_ & 0xFF) / 255.0f; - GL11.glDisable(3553); - GL11.glEnable(3042); - GL11.glDisable(3008); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glShadeModel(7425); - final Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer vb = tessellator.getBuffer(); - vb.begin(7, DefaultVertexFormats.POSITION_COLOR); - vb.pos(p_73733_3_, p_73733_2_, this.zLevel).color(f2, f3, f4, f).endVertex(); - vb.pos(p_73733_1_, p_73733_2_, this.zLevel).color(f2, f3, f4, f).endVertex(); - vb.pos(p_73733_1_, p_73733_4_, this.zLevel).color(f6, f7, f8, f5).endVertex(); - vb.pos(p_73733_3_, p_73733_4_, this.zLevel).color(f6, f7, f8, f5).endVertex(); - tessellator.draw(); - GL11.glShadeModel(7424); - GL11.glDisable(3042); - GL11.glEnable(3008); - GL11.glEnable(3553); - } - - public void renderItem(final IPoint pos, final ItemStack item, final boolean rotating) { - this.renderItem(pos, item, (int) this.zLevel + 3, rotating); - } - - private void renderItem(final IPoint pos, final ItemStack item, final int zLevel, final boolean rotating) { - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f); - GL11.glPushMatrix(); - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(32826); - GL11.glEnable(2929); - FontRenderer font = item.getItem().getFontRenderer(item); - if (font == null) { - font = this.getFontRenderer(); - } - if (item != null) { - BinnieCore.proxy.getMinecraftInstance(); - final float phase = Minecraft.getSystemTime() / 20.0f; - GL11.glPushMatrix(); - if (rotating) { - GL11.glTranslatef(8.0f, 8.0f, 0.0f); - GL11.glRotatef(phase, 0.0f, -0.866f, 0.5f); - GL11.glTranslatef(-8.0f, -8.0f, -67.1f); - } - Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(item, (int) pos.x(), (int) pos.y()); - GL11.glPopMatrix(); - Minecraft.getMinecraft().getRenderItem().renderItemOverlayIntoGUI(font, item, (int) pos.x(), (int) pos.y(), null); - } - GL11.glClear(256); - GL11.glEnable(3042); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - RenderHelper.disableStandardItemLighting(); - CraftGUI.render.colour(-1); - GL11.glEnable(32826); - GL11.glPopMatrix(); - } - - public void renderFluid(FluidStack fluid, IPoint pos) { - final int hex = fluid.getFluid().getColor(fluid); - final int r = (hex & 0xFF0000) >> 16; - final int g = (hex & 0xFF00) >> 8; - final int b = hex & 0xFF; - TextureAtlasSprite icon = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(fluid.getFluid().getStill().toString()); - GL11.glColor4f(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f); - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - renderSprite(pos, icon, TextureMap.LOCATION_BLOCKS_TEXTURE); - GL11.glDisable(3042); - } - - public void renderSprite(final IPoint pos, final TextureAtlasSprite icon, final ResourceLocation map) { - if (icon == null) { - return; - } - GL11.glPushMatrix(); - GL11.glEnable(32826); - BinnieCore.proxy.bindTexture(map); - drawTexture((int) pos.x(), (int) pos.y(), icon, 0, 0, zLevel); - GL11.glEnable(32826); - GL11.glPopMatrix(); - } - - private static void drawTexture(double xCoord, double yCoord, TextureAtlasSprite textureSprite, int maskTop, int maskRight, double zLevel) { - double uMin = textureSprite.getMinU(); - double uMax = textureSprite.getMaxU(); - double vMin = textureSprite.getMinV(); - double vMax = textureSprite.getMaxV(); - uMax = uMax - maskRight / 16.0 * (uMax - uMin); - vMax = vMax - maskTop / 16.0 * (vMax - vMin); - - Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer vertexBuffer = tessellator.getBuffer(); - vertexBuffer.begin(7, DefaultVertexFormats.POSITION_TEX); - vertexBuffer.pos(xCoord, yCoord + 16, zLevel).tex(uMin, vMax).endVertex(); - vertexBuffer.pos(xCoord + 16 - maskRight, yCoord + 16, zLevel).tex(uMax, vMax).endVertex(); - vertexBuffer.pos(xCoord + 16 - maskRight, yCoord + maskTop, zLevel).tex(uMax, vMin).endVertex(); - vertexBuffer.pos(xCoord, yCoord + maskTop, zLevel).tex(uMin, vMin).endVertex(); - tessellator.draw(); - } - public boolean isHelpMode() { return Keyboard.isKeyDown(15); } @@ -472,56 +277,4 @@ public class GuiCraftGUI extends GuiContainer { this.window.setPosition(new IPoint(this.guiLeft, this.guiTop)); } - public void limitArea(final IArea area) { - float x = area.pos().x(); - float y = area.pos().y(); - float w = area.size().x(); - float h = area.size().y(); - y = this.height - (y + h); - final float k = this.xSize; - final float scaleX = this.width / (float) this.mc.displayWidth; - final float scaleY = this.height / (float) this.mc.displayHeight; - x += 0.0f; - y += 0.0f; - w += 0.0f; - h += 0.0f; - GL11.glScissor((int) (x / scaleX), (int) (y / scaleY), (int) (w / scaleX), (int) (h / scaleY)); - } - - public int getZLevel() { - return (int) this.zLevel; - } - - public void drawRect(float p_73734_0_, float p_73734_1_, float p_73734_2_, float p_73734_3_, final int p_73734_4_) { - if (p_73734_0_ < p_73734_2_) { - final float j1 = p_73734_0_; - p_73734_0_ = p_73734_2_; - p_73734_2_ = j1; - } - if (p_73734_1_ < p_73734_3_) { - final float j1 = p_73734_1_; - p_73734_1_ = p_73734_3_; - p_73734_3_ = j1; - } - final float f3 = (p_73734_4_ >> 24 & 0xFF) / 255.0f; - final float f4 = (p_73734_4_ >> 16 & 0xFF) / 255.0f; - final float f5 = (p_73734_4_ >> 8 & 0xFF) / 255.0f; - final float f6 = (p_73734_4_ & 0xFF) / 255.0f; - final Tessellator tessellator = Tessellator.getInstance(); - GL11.glEnable(3042); - GL11.glDisable(3553); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glColor4f(f4, f5, f6, f3); - - VertexBuffer vertexBuffer = tessellator.getBuffer(); - vertexBuffer.begin(7, DefaultVertexFormats.POSITION); - vertexBuffer.pos(p_73734_0_, p_73734_3_, 0.0).endVertex(); - vertexBuffer.pos(p_73734_2_, p_73734_3_, 0.0).endVertex(); - vertexBuffer.pos(p_73734_2_, p_73734_1_, 0.0).endVertex(); - vertexBuffer.pos(p_73734_0_, p_73734_1_, 0.0).endVertex(); - tessellator.draw(); - - GL11.glEnable(3553); - GL11.glDisable(3042); - } } diff --git a/src/main/java/binnie/craftgui/minecraft/Window.java b/src/main/java/binnie/craftgui/minecraft/Window.java index 95d9f963..b6d06f9c 100644 --- a/src/main/java/binnie/craftgui/minecraft/Window.java +++ b/src/main/java/binnie/craftgui/minecraft/Window.java @@ -20,7 +20,6 @@ import binnie.craftgui.core.IWidget; import binnie.craftgui.core.Tooltip; import binnie.craftgui.core.TopLevelWidget; import binnie.craftgui.core.geometry.IPoint; -import binnie.craftgui.core.renderer.Renderer; import binnie.craftgui.events.EventWidget; import binnie.craftgui.minecraft.control.ControlHelp; import binnie.craftgui.minecraft.control.ControlInfo; @@ -49,8 +48,8 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG private ContainerCraftGUI container; private WindowInventory windowInventory; private ControlText title; - protected float titleButtonLeft; - protected float titleButtonRight; + protected int titleButtonLeft; + protected int titleButtonRight; private StandardTexture bgText1; private StandardTexture bgText2; private boolean hasBeenInitialised; @@ -122,9 +121,9 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG return null; } - public Window(final float width, final float height, final EntityPlayer player, final IInventory inventory, final Side side) { - this.titleButtonLeft = 8.0f; - this.titleButtonRight = 8.0f; + public Window(final int width, final int height, final EntityPlayer player, final IInventory inventory, final Side side) { + this.titleButtonLeft = 8; + this.titleButtonRight = 8; this.bgText1 = null; this.bgText2 = null; this.hasBeenInitialised = false; @@ -141,13 +140,13 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG for (final EnumHighlighting h : EnumHighlighting.values()) { ControlSlot.highlighting.put(h, new ArrayList<>()); } - (CraftGUI.render = new Renderer(this.gui)).stylesheet(StyleSheetManager.getDefault()); - this.titleButtonLeft = -14.0f; + CraftGUI.render.stylesheet(StyleSheetManager.getDefault()); + this.titleButtonLeft = -14; if (this.showHelpButton()) { - new ControlHelp(this, this.titleButtonLeft += 22.0f, 8.0f); + new ControlHelp(this, this.titleButtonLeft += 22, 8); } if (this.showInfoButton() != null) { - new ControlInfo(this, this.titleButtonLeft += 22.0f, 8.0f, this.showInfoButton()); + new ControlInfo(this, this.titleButtonLeft += 22, 8, this.showInfoButton()); } this.addSelfEventHandler(new EventWidget.ChangeSize.Handler() { @Override @@ -163,7 +162,7 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG } public void setTitle(final String title) { - (this.title = new ControlTextCentered(this, 12.0f, title)).setColour(4210752); + (this.title = new ControlTextCentered(this, 12, title)).setColour(4210752); } @SideOnly(Side.CLIENT) @@ -184,7 +183,7 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG return; } this.bgText1 = new StandardTexture(0, 0, 256, 256, this.getBackgroundTextureFile(1)); - if (this.getSize().x() > 256.0f) { + if (this.getSize().x() > 256) { this.bgText2 = new StandardTexture(0, 0, 256, 256, this.getBackgroundTextureFile(2)); } if (!BinnieCore.proxy.checkTexture(this.bgText1.getTexture())) { @@ -201,13 +200,13 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.colour(16777215); if (this.getBackground1() != null) { CraftGUI.render.texture(this.getBackground1(), IPoint.ZERO); } if (this.getBackground2() != null) { - CraftGUI.render.texture(this.getBackground2(), new IPoint(256.0f, 0.0f)); + CraftGUI.render.texture(this.getBackground2(), new IPoint(256, 0)); } CraftGUI.render.colour(this.getColour()); CraftGUI.render.texture(CraftGUITexture.Window, this.getArea()); @@ -279,18 +278,18 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG @Override public void recieveGuiNBT(final Side side, final EntityPlayer player, final String name, final NBTTagCompound action) { if (side == Side.CLIENT && name.equals("username")) { - final float w = this.w(); - final float titleButtonRight = this.titleButtonRight + 16.0f; + final int w = this.w(); + final int titleButtonRight = this.titleButtonRight + 16; this.titleButtonRight = titleButtonRight; - final ControlUser controlUser = new ControlUser(this, w - titleButtonRight, 8.0f, action.getString("username")); - this.titleButtonRight += 6.0f; + final ControlUser controlUser = new ControlUser(this, w - titleButtonRight, 8, action.getString("username")); + this.titleButtonRight += 6; } if (side == Side.CLIENT && name.equals("power-system")) { - final float w2 = this.w(); - final float titleButtonRight2 = this.titleButtonRight + 16.0f; + final int w2 = this.w(); + final int titleButtonRight2 = this.titleButtonRight + 16; this.titleButtonRight = titleButtonRight2; - final ControlPowerSystem controlPowerSystem = new ControlPowerSystem(this, w2 - titleButtonRight2, 8.0f, PowerSystem.get(action.getByte("system"))); - this.titleButtonRight += 6.0f; + final ControlPowerSystem controlPowerSystem = new ControlPowerSystem(this, w2 - titleButtonRight2, 8, PowerSystem.get(action.getByte("system"))); + this.titleButtonRight += 6; } } diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlEnergyBar.java b/src/main/java/binnie/craftgui/minecraft/control/ControlEnergyBar.java index 7f93b503..a8f6bcb8 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlEnergyBar.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlEnergyBar.java @@ -16,6 +16,7 @@ import binnie.craftgui.core.geometry.Position; import binnie.craftgui.minecraft.MinecraftTooltip; import binnie.craftgui.minecraft.Window; import binnie.craftgui.resource.minecraft.CraftGUITexture; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.inventory.IInventory; import org.lwjgl.opengl.GL11; @@ -73,7 +74,7 @@ public class ControlEnergyBar extends Control implements ITooltip { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.texture(CraftGUITexture.EnergyBarBack, this.getArea()); final float percentage = this.getPercentage() / 100.0f; CraftGUI.render.colour(this.getColourFromPercentage(percentage)); @@ -81,13 +82,13 @@ public class ControlEnergyBar extends Control implements ITooltip { switch (this.direction) { case Top: case Bottom: { - final float height = area.size().y() * percentage; + final int height = Math.round(area.size().y() * percentage); area.setSize(new IPoint(area.size().x(), height)); break; } case Left: case Right: { - final float width = area.size().x() * percentage; + final int width = Math.round(area.size().x() * percentage); area.setSize(new IPoint(width, area.size().y())); break; } @@ -100,12 +101,12 @@ public class ControlEnergyBar extends Control implements ITooltip { CraftGUI.render.gradientRect(this.getArea().inset(1), c, c); } CraftGUI.render.texture(CraftGUITexture.EnergyBarGlow, area); - GL11.glColor3d(1.0, 1.0, 1.0); + GlStateManager.color(1, 1, 1, 1); CraftGUI.render.texture(CraftGUITexture.EnergyBarGlass, this.getArea()); } @Override - public void onRenderForeground() { + public void onRenderForeground(int guiWidth, int guiHeight) { if (this.isMouseOver() && Window.get(this).getGui().isHelpMode()) { final IArea area = this.getArea(); CraftGUI.render.colour(MinecraftTooltip.getOutline(Tooltip.Type.Help)); diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlErrorState.java b/src/main/java/binnie/craftgui/minecraft/control/ControlErrorState.java index 09b09c4f..ffe9d3b8 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlErrorState.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlErrorState.java @@ -19,7 +19,7 @@ public class ControlErrorState extends Control implements ITooltip { private int type; @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { Object texture = CraftGUITexture.StateWarning; if (this.errorState == null) { texture = CraftGUITexture.StateNone; @@ -27,7 +27,7 @@ public class ControlErrorState extends Control implements ITooltip { texture = CraftGUITexture.StateError; } CraftGUI.render.texture(texture, IPoint.ZERO); - super.onRenderBackground(); + super.onRenderBackground(guiWidth, guiHeight); } public ErrorState getError() { @@ -70,8 +70,8 @@ public class ControlErrorState extends Control implements ITooltip { } } - public ControlErrorState(final IWidget parent, final float x, final float y) { - super(parent, x, y, 16.0f, 16.0f); + public ControlErrorState(final IWidget parent, final int x, final int y) { + super(parent, x, y, 16, 16); this.type = 0; this.addAttribute(Attribute.MouseOver); } diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlHelp.java b/src/main/java/binnie/craftgui/minecraft/control/ControlHelp.java index bf2a66ea..462afb02 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlHelp.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlHelp.java @@ -9,13 +9,13 @@ import binnie.craftgui.core.Tooltip; import binnie.craftgui.resource.minecraft.CraftGUITexture; public class ControlHelp extends Control implements ITooltip { - public ControlHelp(final IWidget parent, final float x, final float y) { - super(parent, x, y, 16.0f, 16.0f); + public ControlHelp(final IWidget parent, final int x, final int y) { + super(parent, x, y, 16, 16); this.addAttribute(Attribute.MouseOver); } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.texture(CraftGUITexture.HelpButton, this.getArea()); } diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlIconDisplay.java b/src/main/java/binnie/craftgui/minecraft/control/ControlIconDisplay.java index 652b3e56..fa294572 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlIconDisplay.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlIconDisplay.java @@ -11,13 +11,13 @@ import net.minecraft.util.ResourceLocation; public class ControlIconDisplay extends Control { private TextureAtlasSprite icon; - public ControlIconDisplay(final IWidget parent, final float x, final float y, final ResourceLocation icon) { - super(parent, x, y, 16.0f, 16.0f); + public ControlIconDisplay(final IWidget parent, final int x, final int y, final ResourceLocation icon) { + super(parent, x, y, 16, 16); this.icon = BinnieCore.proxy.getTextureAtlasSprite(icon); } @Override - public void onRenderForeground() { + public void onRenderForeground(int guiWidth, int guiHeight) { CraftGUI.render.sprite(IPoint.ZERO, this.icon); } } diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlImage.java b/src/main/java/binnie/craftgui/minecraft/control/ControlImage.java index df3906a4..cceef1a1 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlImage.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlImage.java @@ -9,14 +9,14 @@ import binnie.craftgui.resource.Texture; public class ControlImage extends Control { private Object key; - public ControlImage(final IWidget parent, final float x, final float y, final Texture text) { + public ControlImage(final IWidget parent, final int x, final int y, final Texture text) { super(parent, x, y, text.w(), text.h()); this.key = null; this.key = text; } @Override - public void onRenderForeground() { + public void onRenderForeground(int guiWidth, int guiHeight) { CraftGUI.render.texture(this.key, IPoint.ZERO); } } diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlInfo.java b/src/main/java/binnie/craftgui/minecraft/control/ControlInfo.java index 04b67061..897d937f 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlInfo.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlInfo.java @@ -11,14 +11,14 @@ import binnie.craftgui.resource.minecraft.CraftGUITexture; public class ControlInfo extends Control implements ITooltip { private String info; - public ControlInfo(final IWidget parent, final float x, final float y, final String info) { - super(parent, x, y, 16.0f, 16.0f); + public ControlInfo(final IWidget parent, final int x, final int y, final String info) { + super(parent, x, y, 16, 16); this.addAttribute(Attribute.MouseOver); this.info = info; } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.texture(CraftGUITexture.InfoButton, this.getArea()); } diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlItemDisplay.java b/src/main/java/binnie/craftgui/minecraft/control/ControlItemDisplay.java index c6503dfb..9a700c4a 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlItemDisplay.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlItemDisplay.java @@ -1,17 +1,15 @@ package binnie.craftgui.minecraft.control; -import binnie.core.BinnieCore; import binnie.craftgui.controls.core.Control; import binnie.craftgui.core.Attribute; -import binnie.craftgui.core.CraftGUI; import binnie.craftgui.core.ITooltip; import binnie.craftgui.core.IWidget; import binnie.craftgui.core.Tooltip; +import binnie.craftgui.core.geometry.CraftGUIUtil; import binnie.craftgui.core.geometry.IPoint; import binnie.craftgui.minecraft.Window; -import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.item.ItemStack; -import org.lwjgl.opengl.GL11; public class ControlItemDisplay extends Control implements ITooltip { private ItemStack itemStack; @@ -23,19 +21,19 @@ public class ControlItemDisplay extends Control implements ITooltip { this.addAttribute(Attribute.MouseOver); } - public ControlItemDisplay(final IWidget parent, final float x, final float y) { - this(parent, x, y, 16.0f); + public ControlItemDisplay(final IWidget parent, final int x, final int y) { + this(parent, x, y, 16); } - public ControlItemDisplay(final IWidget parent, final float f, final float y, final ItemStack stack, final boolean tooltip) { - this(parent, f, y, 16.0f); + public ControlItemDisplay(final IWidget parent, final int f, final int y, final ItemStack stack, final boolean tooltip) { + this(parent, f, y, 16); this.setItemStack(stack); if (tooltip) { this.setTooltip(); } } - public ControlItemDisplay(final IWidget parent, final float x, final float y, final float size) { + public ControlItemDisplay(final IWidget parent, final int x, final int y, final int size) { super(parent, x, y, size, size); this.itemStack = null; this.hastooltip = false; @@ -43,25 +41,26 @@ public class ControlItemDisplay extends Control implements ITooltip { } @Override - public void onRenderBackground() { - final IPoint relativeToWindow = this.getAbsolutePosition().sub(this.getSuperParent().getPosition()); - if (relativeToWindow.x() > Window.get(this).getSize().x() + 100.0f || relativeToWindow.y() > Window.get(this).getSize().y() + 100.0f) { + public void onRenderBackground(int guiWidth, int guiHeight) { + if (this.itemStack == null) { return; } - if (this.itemStack != null) { - if (this.getSize().x() != 16.0f) { - GL11.glPushMatrix(); - final float scale = this.getSize().x() / 16.0f; - GL11.glScalef(scale, scale, 1.0f); - BinnieCore.proxy.getMinecraftInstance(); - final float phase = Minecraft.getSystemTime() / 20.0f; - CraftGUI.render.item(IPoint.ZERO, this.itemStack, this.rotating); - GL11.glPopMatrix(); - } else { - CraftGUI.render.item(IPoint.ZERO, this.itemStack, this.rotating); - } + final IPoint relativeToWindow = this.getAbsolutePosition().sub(this.getSuperParent().getPosition()); + if (relativeToWindow.x() > Window.get(this).getSize().x() + 100 || relativeToWindow.y() > Window.get(this).getSize().y() + 100) { + return; } + + if (this.getSize().x() != 16) { + GlStateManager.pushMatrix(); + final float scale = this.getSize().x() / 16.0f; + GlStateManager.scale(scale, scale, 1); + CraftGUIUtil.renderItem(IPoint.ZERO, this.itemStack, this.rotating); + GlStateManager.popMatrix(); + } else { + CraftGUIUtil.renderItem(IPoint.ZERO, this.itemStack, this.rotating); + } + GlStateManager.enableAlpha(); } public void setItemStack(final ItemStack itemStack) { diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlLiquidTank.java b/src/main/java/binnie/craftgui/minecraft/control/ControlLiquidTank.java index 6ab0f306..547fc619 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlLiquidTank.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlLiquidTank.java @@ -18,6 +18,7 @@ import binnie.craftgui.events.EventMouse; import binnie.craftgui.minecraft.MinecraftTooltip; import binnie.craftgui.minecraft.Window; import binnie.craftgui.resource.minecraft.CraftGUITexture; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.nbt.NBTTagCompound; @@ -37,7 +38,7 @@ public class ControlLiquidTank extends Control implements ITooltip { } public ControlLiquidTank(final IWidget parent, final int x, final int y, final boolean horizontal) { - super(parent, x, y, horizontal ? 60.0f : 18.0f, horizontal ? 18.0f : 60.0f); + super(parent, x, y, horizontal ? 60 : 18, horizontal ? 18 : 60); this.tankID = 0; this.horizontal = false; this.horizontal = horizontal; @@ -71,7 +72,7 @@ public class ControlLiquidTank extends Control implements ITooltip { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.texture(this.horizontal ? CraftGUITexture.HorizontalLiquidTank : CraftGUITexture.LiquidTank, IPoint.ZERO); if (this.isMouseOver() && Window.get(this).getGui().isHelpMode()) { final int c = -1442840576 + MinecraftTooltip.getOutline(Tooltip.Type.Help); @@ -87,42 +88,44 @@ public class ControlLiquidTank extends Control implements ITooltip { } } if (this.isTankValid()) { - final Object content = null; - final float height = this.horizontal ? 16.0f : 58.0f; - final int squaled = (int) (height * (this.getTank().getAmount() / this.getTank().getCapacity())); - final int yPos = (int) height + 1; + final int height = this.horizontal ? 16 : 58; + final int squaled = Math.round(height * (this.getTank().getAmount() / this.getTank().getCapacity())); + final int yPos = height + 1; final Fluid fluid = this.getTank().liquid.getFluid(); final int hex = fluid.getColor(this.getTank().liquid); final int r = (hex & 0xFF0000) >> 16; final int g = (hex & 0xFF00) >> 8; final int b = hex & 0xFF; - GL11.glColor4f(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f); - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - final IPoint pos = this.getAbsolutePosition(); - final IPoint offset = new IPoint(0.0f, height - squaled); - final IArea limited = this.getArea().inset(1); - if (this.horizontal) { - limited.setSize(new IPoint(limited.w() - 1.0f, limited.h())); - } - CraftGUI.render.limitArea(new IArea(limited.pos().add(pos).add(offset), limited.size().sub(offset))); - GL11.glEnable(3089); - - BinnieCore.proxy.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); - for (int y = 0; y < height; y += 16) { - for (int x = 0; x < (this.horizontal ? 58 : 16); x += 16) { - final TextureAtlasSprite icon = BinnieCore.proxy.getTextureAtlasSprite(fluid.getStill()); - CraftGUI.render.sprite(new IPoint(1 + x, 1 + y), icon); + GlStateManager.color(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f); + GlStateManager.enableBlend(); + { + GlStateManager.blendFunc(770, 771); + final IPoint pos = this.getAbsolutePosition(); + final IPoint offset = new IPoint(0, height - squaled); + final IArea limited = this.getArea().inset(1); + if (this.horizontal) { + limited.setSize(new IPoint(limited.w() - 1, limited.h())); } + CraftGUI.render.limitArea(new IArea(limited.pos().add(pos).add(offset), limited.size().sub(offset)), guiWidth, guiHeight); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + { + BinnieCore.proxy.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + for (int y = 0; y < height; y += 16) { + for (int x = 0; x < (this.horizontal ? 58 : 16); x += 16) { + final TextureAtlasSprite icon = BinnieCore.proxy.getTextureAtlasSprite(fluid.getStill()); + CraftGUI.render.sprite(new IPoint(1 + x, 1 + y), icon); + } + } + } + GL11.glDisable(GL11.GL_SCISSOR_TEST); } - - GL11.glDisable(3089); - GL11.glDisable(3042); + GlStateManager.disableBlend(); + GlStateManager.color(1, 1, 1, 1); } } @Override - public void onRenderForeground() { + public void onRenderForeground(int guiWidth, int guiHeight) { CraftGUI.render.texture(this.horizontal ? CraftGUITexture.HorizontalLiquidTankOverlay : CraftGUITexture.LiquidTankOverlay, IPoint.ZERO); if (this.isMouseOver() && Window.get(this).getGui().isHelpMode()) { final IArea area = this.getArea(); diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlPlayerInventory.java b/src/main/java/binnie/craftgui/minecraft/control/ControlPlayerInventory.java index 1f3ff807..803295f6 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlPlayerInventory.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlPlayerInventory.java @@ -13,7 +13,7 @@ public class ControlPlayerInventory extends Control { private List slots; public ControlPlayerInventory(final IWidget parent, final boolean wide) { - super(parent, (int) (parent.getSize().x() / 2.0f) - (wide ? 110 : 81), (int) parent.getSize().y() - (wide ? 54 : 76) - 12, wide ? 220 : 162, wide ? 54 : 76); + super(parent, (int) (parent.getSize().x() / 2) - (wide ? 110 : 81), (int) parent.getSize().y() - (wide ? 54 : 76) - 12, wide ? 220 : 162, wide ? 54 : 76); this.slots = new ArrayList<>(); for (int row = 0; row < 3; ++row) { for (int column = 0; column < 9; ++column) { @@ -28,7 +28,7 @@ public class ControlPlayerInventory extends Control { } } else { for (int i1 = 0; i1 < 9; ++i1) { - final ControlSlot slot2 = new ControlSlot(this, i1 * 18, 58.0f); + final ControlSlot slot2 = new ControlSlot(this, i1 * 18, 58); this.slots.add(slot2); } } @@ -40,7 +40,7 @@ public class ControlPlayerInventory extends Control { } public ControlPlayerInventory(final IWidget parent, final int x, final int y) { - super(parent, x, y, 54.0f, 220.0f); + super(parent, x, y, 54, 220); this.slots = new ArrayList<>(); for (int row = 0; row < 6; ++row) { for (int column = 0; column < 6; ++column) { diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlPowerSystem.java b/src/main/java/binnie/craftgui/minecraft/control/ControlPowerSystem.java index a7957610..4c92dc9d 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlPowerSystem.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlPowerSystem.java @@ -12,14 +12,14 @@ import binnie.craftgui.resource.minecraft.CraftGUITexture; public class ControlPowerSystem extends Control implements ITooltip { private PowerSystem system; - public ControlPowerSystem(final IWidget parent, final float x, final float y, final PowerSystem system) { - super(parent, x, y, 16.0f, 16.0f); + public ControlPowerSystem(final IWidget parent, final int x, final int y, final PowerSystem system) { + super(parent, x, y, 16, 16); this.addAttribute(Attribute.MouseOver); this.system = system; } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.texture(CraftGUITexture.PowerButton, this.getArea()); } diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlProgress.java b/src/main/java/binnie/craftgui/minecraft/control/ControlProgress.java index 43a1f6a3..70c00084 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlProgress.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlProgress.java @@ -11,7 +11,7 @@ public class ControlProgress extends ControlProgressBase { private Position direction; public ControlProgress(final IWidget parent, final int x, final int y, final Texture progressBlank, final Texture progressBar, final Position dir) { - super(parent, x, y, (progressBlank == null) ? 0.0f : progressBlank.w(), (progressBlank == null) ? 0.0f : progressBlank.h()); + super(parent, x, y, (progressBlank == null) ? 0 : progressBlank.w(), (progressBlank == null) ? 0 : progressBlank.h()); this.progressBlank = progressBlank; this.progressBar = progressBar; this.progress = 0.0f; @@ -19,7 +19,7 @@ public class ControlProgress extends ControlProgressBase { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.texture(this.progressBlank, this.getArea()); CraftGUI.render.texturePercentage(this.progressBar, this.getArea(), this.direction, this.progress); } diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlProgressBase.java b/src/main/java/binnie/craftgui/minecraft/control/ControlProgressBase.java index 6bf4d3f8..abafd40c 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlProgressBase.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlProgressBase.java @@ -12,7 +12,7 @@ import binnie.craftgui.minecraft.Window; public class ControlProgressBase extends Control { protected float progress; - public ControlProgressBase(final IWidget parent, final float x, final float y, final float w, final float h) { + public ControlProgressBase(final IWidget parent, final int x, final int y, final int w, final int h) { super(parent, x, y, w, h); this.progress = 0.0f; this.addAttribute(Attribute.MouseOver); diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlSlide.java b/src/main/java/binnie/craftgui/minecraft/control/ControlSlide.java index 24ad084f..64546b05 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlSlide.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlSlide.java @@ -20,7 +20,7 @@ public class ControlSlide extends Control { private Position anchor; private String label; - public ControlSlide(final IWidget parent, final float x, final float y, final float w, final float h, final Position anchor2) { + public ControlSlide(final IWidget parent, final int x, final int y, final int w, final int h, final Position anchor2) { super(parent, x, y, w, h); this.slideActive = true; this.label = null; @@ -28,29 +28,29 @@ public class ControlSlide extends Control { this.addAttribute(Attribute.BlockTooltip); this.expanded = new IArea(this.getPosition(), this.getSize()); this.anchor = anchor2.opposite(); - final float border = (this.anchor.x() != 0) ? (this.expanded.w() - 6.0f) : (this.expanded.h() - 6.0f); + final int border = (this.anchor.x() != 0) ? (this.expanded.w() - 6) : (this.expanded.h() - 6); this.shrunk = this.expanded.inset(new IBorder(this.anchor, border)); this.slideActive = false; } @Override - public void onRenderBackground() { - super.onRenderBackground(); + public void onRenderBackground(int guiWidth, int guiHeight) { + super.onRenderBackground(guiWidth, guiHeight); if (this.label != null) { - final float lw = CraftGUI.render.textWidth(this.label) + 16; - final float lh = CraftGUI.render.textHeight() + 16; + final int lw = CraftGUI.render.textWidth(this.label) + 16; + final int lh = CraftGUI.render.textHeight() + 16; final boolean hor = this.anchor.x() != 0; final IArea ar = this.isSlideActive() ? this.expanded : this.shrunk; - IArea tabArea = new IArea(hor ? (-lh / 2.0f) : (-lw / 2.0f), hor ? (-lw / 2.0f) : (-lh / 2.0f), hor ? lh : lw, hor ? lw : lh); - final IPoint shift = new IPoint(ar.w() * (1 - this.anchor.x()) / 2.0f, ar.h() * (1 - this.anchor.y()) / 2.0f); - tabArea = tabArea.shift(shift.x() - (-3.0f + lh / 2.0f) * this.anchor.x(), shift.y() - (-3.0f + lh / 2.0f) * this.anchor.y()); - Texture texture = CraftGUI.render.getTexture(this.isSlideActive() ? CraftGUITexture.Tab : CraftGUITexture.TabDisabled).crop(this.anchor.opposite(), 8.0f); + IArea tabArea = new IArea(hor ? (-lh / 2) : (-lw / 2), hor ? (-lw / 2) : (-lh / 2), hor ? lh : lw, hor ? lw : lh); + final IPoint shift = new IPoint(ar.w() * (1 - this.anchor.x()) / 2, ar.h() * (1 - this.anchor.y()) / 2); + tabArea = tabArea.shift(shift.x() - (-3 + lh / 2) * this.anchor.x(), shift.y() - (-3 + lh / 2) * this.anchor.y()); + Texture texture = CraftGUI.render.getTexture(this.isSlideActive() ? CraftGUITexture.Tab : CraftGUITexture.TabDisabled).crop(this.anchor.opposite(), 8); CraftGUI.render.texture(texture, tabArea); - texture = CraftGUI.render.getTexture(CraftGUITexture.TabOutline).crop(this.anchor.opposite(), 8.0f); + texture = CraftGUI.render.getTexture(CraftGUITexture.TabOutline).crop(this.anchor.opposite(), 8); CraftGUI.render.texture(texture, tabArea.inset(2)); - final IArea labelArea = new IArea(-lw / 2.0f, 0.0f, lw, lh); + final IArea labelArea = new IArea(-lw / 2, 0, lw, lh); GL11.glPushMatrix(); - GL11.glTranslatef(shift.x() + this.anchor.x() * 2.0f, shift.y() + this.anchor.y() * 2.0f, 0.0f); + GL11.glTranslatef(shift.x() + this.anchor.x() * 2, shift.y() + this.anchor.y() * 2, 0); if (this.anchor.x() != 0) { GL11.glRotatef(90.0f, 0.0f, 0.0f, this.anchor.x()); } @@ -62,7 +62,7 @@ public class ControlSlide extends Control { } CraftGUI.render.texture(CraftGUITexture.Window, this.getArea()); final Object slideTexture = (this.anchor == Position.Bottom) ? CraftGUITexture.SlideDown : ((this.anchor == Position.Top) ? CraftGUITexture.SlideUp : ((this.anchor == Position.Left) ? CraftGUITexture.SlideLeft : CraftGUITexture.SlideRight)); - CraftGUI.render.texture(slideTexture, new IPoint((this.anchor.x() + 1.0f) * this.w() / 2.0f - 8.0f, (this.anchor.y() + 1.0f) * this.h() / 2.0f - 8.0f)); + CraftGUI.render.texture(slideTexture, new IPoint((this.anchor.x() + 1) * this.w() / 2 - 8, (this.anchor.y() + 1) * this.h() / 2 - 8)); } public boolean isSlideActive() { @@ -79,7 +79,7 @@ public class ControlSlide extends Control { @Override public boolean isMouseOverWidget(final IPoint relativeMouse) { - return this.getArea().outset(this.isSlideActive() ? 16 : 8).outset(new IBorder(this.anchor.opposite(), 16.0f)).contains(relativeMouse); + return this.getArea().outset(this.isSlideActive() ? 16 : 8).outset(new IBorder(this.anchor.opposite(), 16)).contains(relativeMouse); } @Override diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlSlot.java b/src/main/java/binnie/craftgui/minecraft/control/ControlSlot.java index 6b62e81f..e527eb91 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlSlot.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlSlot.java @@ -16,6 +16,7 @@ import binnie.craftgui.minecraft.WindowInventory; import binnie.craftgui.resource.minecraft.CraftGUITexture; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.multiplayer.PlayerControllerMP; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ClickType; @@ -32,7 +33,7 @@ public class ControlSlot extends ControlSlotBase { public static boolean shiftClickActive = false; public Slot slot; - public ControlSlot(final IWidget parent, final float x, final float y) { + public ControlSlot(final IWidget parent, final int x, final int y) { super(parent, x, y); this.slot = null; this.addSelfEventHandler(new EventMouse.Down.Handler() { @@ -57,17 +58,21 @@ public class ControlSlot extends ControlSlotBase { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.texture(CraftGUITexture.Slot, IPoint.ZERO); if (this.slot == null) { return; } final InventorySlot islot = this.getInventorySlot(); - //TODO RENDERING - if (islot != null && islot.getValidator() != null) { - final TextureAtlasSprite icon = islot.getValidator().getIcon(!islot.getInputSides().isEmpty()); - if (icon != null) { - CraftGUI.render.sprite(new IPoint(1.0f, 1.0f), icon); + if (islot != null) { + SlotValidator validator = islot.getValidator(); + if (validator != null) { + final TextureAtlasSprite icon = validator.getIcon(!islot.getInputSides().isEmpty()); + if (icon != null) { + GlStateManager.enableBlend(); + CraftGUI.render.sprite(new IPoint(1, 1), icon); + GlStateManager.disableBlend(); + } } } boolean highlighted = false; @@ -80,13 +85,13 @@ public class ControlSlot extends ControlSlotBase { } highlighted = true; final int c = -1442840576 + Math.min(highlight.getKey().getColour(), 16777215); - CraftGUI.render.gradientRect(new IArea(1.0f, 1.0f, 16.0f, 16.0f), c, c); + CraftGUI.render.gradientRect(new IArea(1, 1, 16, 16), c, c); } if (!highlighted && this.getSuperParent().getMousedOverWidget() == this) { if (Window.get(this).getGui().getDraggedItem() != null && !this.slot.isItemValid(Window.get(this).getGui().getDraggedItem())) { - CraftGUI.render.gradientRect(new IArea(1.0f, 1.0f, 16.0f, 16.0f), -1426089575, -1426089575); + CraftGUI.render.gradientRect(new IArea(1, 1, 16, 16), -1426089575, -1426089575); } else { - CraftGUI.render.gradientRect(new IArea(1.0f, 1.0f, 16.0f, 16.0f), -2130706433, -2130706433); + CraftGUI.render.gradientRect(new IArea(1, 1, 16, 16), -2130706433, -2130706433); } } } diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlSlotBase.java b/src/main/java/binnie/craftgui/minecraft/control/ControlSlotBase.java index 2fb5f0a5..774c0283 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlSlotBase.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlSlotBase.java @@ -16,19 +16,19 @@ import net.minecraft.item.ItemStack; public abstract class ControlSlotBase extends Control implements ITooltip { private ControlItemDisplay itemDisplay; - public ControlSlotBase(final IWidget parent, final float x, final float y) { + public ControlSlotBase(final IWidget parent, final int x, final int y) { this(parent, x, y, 18); } - public ControlSlotBase(final IWidget parent, final float x, final float y, final int size) { + public ControlSlotBase(final IWidget parent, final int x, final int y, final int size) { super(parent, x, y, size, size); this.addAttribute(Attribute.MouseOver); - this.itemDisplay = new ControlItemDisplay(this, 1.0f, 1.0f, size - 2); + this.itemDisplay = new ControlItemDisplay(this, 1, 1, size - 2); this.addSelfEventHandler(new EventWidget.ChangeSize.Handler() { @Override public void onEvent(final EventWidget.ChangeSize event) { if (ControlSlotBase.this.itemDisplay != null) { - ControlSlotBase.this.itemDisplay.setSize(ControlSlotBase.this.getSize().sub(new IPoint(2.0f, 2.0f))); + ControlSlotBase.this.itemDisplay.setSize(ControlSlotBase.this.getSize().sub(new IPoint(2, 2))); } } }); @@ -39,11 +39,11 @@ public abstract class ControlSlotBase extends Control implements ITooltip { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { final int size = (int) this.getSize().x(); CraftGUI.render.texture(CraftGUITexture.Slot, this.getArea()); if (this.getSuperParent().getMousedOverWidget() == this) { - CraftGUI.render.gradientRect(new IArea(new IPoint(1.0f, 1.0f), this.getArea().size().sub(new IPoint(2.0f, 2.0f))), -2130706433, -2130706433); + CraftGUI.render.gradientRect(new IArea(new IPoint(1, 1), this.getArea().size().sub(new IPoint(2, 2))), -2130706433, -2130706433); } } diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlSlotCharge.java b/src/main/java/binnie/craftgui/minecraft/control/ControlSlotCharge.java index 1d4a2cd9..218ac926 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlSlotCharge.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlSlotCharge.java @@ -19,13 +19,13 @@ public class ControlSlotCharge extends Control { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.texture(CraftGUITexture.PanelBlack, this.getArea()); CraftGUI.render.texturePercentage(CraftGUI.render.getTexture(CraftGUITexture.SlotCharge), this.getArea().inset(1), Position.Bottom, this.getCharge()); } public ControlSlotCharge(final IWidget parent, final int x, final int y, final int slot) { - super(parent, x, y, 4.0f, 18.0f); + super(parent, x, y, 4, 18); this.slot = slot; } diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlTabIcon.java b/src/main/java/binnie/craftgui/minecraft/control/ControlTabIcon.java index 71e085ab..70724f17 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlTabIcon.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlTabIcon.java @@ -9,9 +9,9 @@ import net.minecraft.item.ItemStack; public class ControlTabIcon extends ControlTab { private ControlItemDisplay item; - public ControlTabIcon(final ControlTabBar parent, final float x, final float y, final float w, final float h, final T value) { + public ControlTabIcon(final ControlTabBar parent, final int x, final int y, final int w, final int h, final T value) { super(parent, x, y, w, h, value); - this.item = new ControlItemDisplay(this, -8.0f + w / 2.0f, -8.0f + h / 2.0f); + this.item = new ControlItemDisplay(this, -8 + w / 2, -8 + h / 2); this.item.hastooltip = false; } @@ -26,8 +26,8 @@ public class ControlTabIcon extends ControlTab { public void onUpdateClient() { super.onUpdateClient(); this.item.setItemStack(this.getItemStack()); - final float x = ((ControlTabBar) this.getParent()).getDirection().x(); - this.item.setOffset(new IPoint((this.isCurrentSelection() || this.isMouseOver()) ? 0.0f : (-4.0f * x), 0.0f)); + final int x = ((ControlTabBar) this.getParent()).getDirection().x(); + this.item.setOffset(new IPoint((this.isCurrentSelection() || this.isMouseOver()) ? 0 : (-4 * x), 0)); } public boolean hasOutline() { diff --git a/src/main/java/binnie/craftgui/minecraft/control/ControlUser.java b/src/main/java/binnie/craftgui/minecraft/control/ControlUser.java index 8204a5ae..0de5fa0e 100644 --- a/src/main/java/binnie/craftgui/minecraft/control/ControlUser.java +++ b/src/main/java/binnie/craftgui/minecraft/control/ControlUser.java @@ -14,8 +14,8 @@ public class ControlUser extends Control implements ITooltip { private String username; String team; - public ControlUser(final IWidget parent, final float x, final float y, final String username) { - super(parent, x, y, 16.0f, 16.0f); + public ControlUser(final IWidget parent, final int x, final int y, final String username) { + super(parent, x, y, 16, 16); this.username = ""; this.team = ""; this.addAttribute(Attribute.MouseOver); @@ -23,7 +23,7 @@ public class ControlUser extends Control implements ITooltip { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.texture(CraftGUITexture.UserButton, this.getArea()); } diff --git a/src/main/java/binnie/craftgui/minecraft/render/MinecraftTexture.java b/src/main/java/binnie/craftgui/minecraft/render/MinecraftTexture.java index 408e092c..cd21bd67 100644 --- a/src/main/java/binnie/craftgui/minecraft/render/MinecraftTexture.java +++ b/src/main/java/binnie/craftgui/minecraft/render/MinecraftTexture.java @@ -8,6 +8,6 @@ public class MinecraftTexture { IBinnieTexture texture; public MinecraftTexture() { - this.textureArea = new IArea(0.0f, 0.0f, 0.0f, 0.0f); + this.textureArea = new IArea(0, 0, 0, 0); } } diff --git a/src/main/java/binnie/craftgui/mod/database/ControlBranchBox.java b/src/main/java/binnie/craftgui/mod/database/ControlBranchBox.java index a48fb48e..291594a9 100644 --- a/src/main/java/binnie/craftgui/mod/database/ControlBranchBox.java +++ b/src/main/java/binnie/craftgui/mod/database/ControlBranchBox.java @@ -10,7 +10,7 @@ class ControlBranchBox extends ControlListBox { return new ControlBranchBoxOption(this.getContent(), value, y); } - public ControlBranchBox(final IWidget parent, final float x, final float y, final float width, final float height) { - super(parent, x, y, width, height, 12.0f); + public ControlBranchBox(final IWidget parent, final int x, final int y, final int width, final int height) { + super(parent, x, y, width, height, 12); } } diff --git a/src/main/java/binnie/craftgui/mod/database/ControlBreedingProgress.java b/src/main/java/binnie/craftgui/mod/database/ControlBreedingProgress.java index 02c72b5a..4bab8e0f 100644 --- a/src/main/java/binnie/craftgui/mod/database/ControlBreedingProgress.java +++ b/src/main/java/binnie/craftgui/mod/database/ControlBreedingProgress.java @@ -23,10 +23,10 @@ class ControlBreedingProgress extends Control { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.texture(CraftGUITexture.PanelBlack, this.getArea()); final IArea area = this.getArea().inset(1); - area.setSize(new IPoint(area.size().x() * this.percentage, area.size().y())); + area.setSize(new IPoint(Math.round(area.size().x() * this.percentage), area.size().y())); CraftGUI.render.colour(this.colour); CraftGUI.render.texture(ControlBreedingProgress.Progress, area); } diff --git a/src/main/java/binnie/craftgui/mod/database/ControlDatabaseIndividualDisplay.java b/src/main/java/binnie/craftgui/mod/database/ControlDatabaseIndividualDisplay.java index 7295e7ff..4cea45f0 100644 --- a/src/main/java/binnie/craftgui/mod/database/ControlDatabaseIndividualDisplay.java +++ b/src/main/java/binnie/craftgui/mod/database/ControlDatabaseIndividualDisplay.java @@ -39,11 +39,11 @@ public class ControlDatabaseIndividualDisplay extends ControlItemDisplay impleme this.addAttribute(Attribute.MouseOver); } - public ControlDatabaseIndividualDisplay(final IWidget parent, final float x, final float y) { - this(parent, x, y, 16.0f); + public ControlDatabaseIndividualDisplay(final IWidget parent, final int x, final int y) { + this(parent, x, y, 16); } - public ControlDatabaseIndividualDisplay(final IWidget parent, final float x, final float y, final float size) { + public ControlDatabaseIndividualDisplay(final IWidget parent, final int x, final int y, final int size) { super(parent, x, y, size); this.species = null; this.discovered = EnumDiscoveryState.Show; @@ -58,7 +58,7 @@ public class ControlDatabaseIndividualDisplay extends ControlItemDisplay impleme } @Override - public void onRenderForeground() { + public void onRenderForeground(int guiWidth, int guiHeight) { //TODO RENDERING // IIcon icon = null; diff --git a/src/main/java/binnie/craftgui/mod/database/ControlItemStackOption.java b/src/main/java/binnie/craftgui/mod/database/ControlItemStackOption.java index 7cfb6e7f..511c8936 100644 --- a/src/main/java/binnie/craftgui/mod/database/ControlItemStackOption.java +++ b/src/main/java/binnie/craftgui/mod/database/ControlItemStackOption.java @@ -14,11 +14,11 @@ public class ControlItemStackOption extends ControlTextOption { public ControlItemStackOption(final ControlList controlList, final ItemStack option, final int y) { super(controlList, option, option.getDisplayName(), y); - this.setSize(new IPoint(this.getSize().x(), 20.0f)); - (this.controlBee = new ControlItemDisplay(this, 2.0f, 2.0f)).setItemStack(option); + this.setSize(new IPoint(this.getSize().x(), 20)); + (this.controlBee = new ControlItemDisplay(this, 2, 2)).setItemStack(option); this.addAttribute(Attribute.MouseOver); - CraftGUIUtil.moveWidget(this.textWidget, new IPoint(22.0f, 0.0f)); - this.textWidget.setSize(this.textWidget.getSize().sub(new IPoint(24.0f, 0.0f))); + CraftGUIUtil.moveWidget(this.textWidget, new IPoint(22, 0)); + this.textWidget.setSize(this.textWidget.getSize().sub(new IPoint(24, 0))); final int th = (int) CraftGUI.render.textHeight(this.textWidget.getValue(), this.textWidget.getSize().x()); final int height = Math.max(20, th + 6); this.setSize(new IPoint(this.size().x(), height)); diff --git a/src/main/java/binnie/craftgui/mod/database/ControlMutationBox.java b/src/main/java/binnie/craftgui/mod/database/ControlMutationBox.java index 0e7329e5..b6902e87 100644 --- a/src/main/java/binnie/craftgui/mod/database/ControlMutationBox.java +++ b/src/main/java/binnie/craftgui/mod/database/ControlMutationBox.java @@ -20,7 +20,7 @@ class ControlMutationBox extends ControlListBox { } public ControlMutationBox(final IWidget parent, final int x, final int y, final int width, final int height, final Type type) { - super(parent, x, y, width, height, 12.0f); + super(parent, x, y, width, height, 12); this.species = null; this.type = type; } diff --git a/src/main/java/binnie/craftgui/mod/database/ControlMutationItem.java b/src/main/java/binnie/craftgui/mod/database/ControlMutationItem.java index 06be1e05..87b1c2eb 100644 --- a/src/main/java/binnie/craftgui/mod/database/ControlMutationItem.java +++ b/src/main/java/binnie/craftgui/mod/database/ControlMutationItem.java @@ -16,9 +16,9 @@ class ControlMutationItem extends ControlOption { public ControlMutationItem(final ControlList controlList, final IMutation option, final IAlleleSpecies species, final int y) { super(controlList, option, y); - this.itemWidget1 = new ControlDatabaseIndividualDisplay(this, 4.0f, 4.0f); - this.itemWidget2 = new ControlDatabaseIndividualDisplay(this, 44.0f, 4.0f); - this.itemWidget3 = new ControlDatabaseIndividualDisplay(this, 104.0f, 4.0f); + this.itemWidget1 = new ControlDatabaseIndividualDisplay(this, 4, 4); + this.itemWidget2 = new ControlDatabaseIndividualDisplay(this, 44, 4); + this.itemWidget3 = new ControlDatabaseIndividualDisplay(this, 104, 4); this.addSymbol = new ControlMutationSymbol(this, 24, 4, 0); this.arrowSymbol = new ControlMutationSymbol(this, 64, 4, 1); final boolean isNEI = ((WindowAbstractDatabase) this.getSuperParent()).isNEI(); diff --git a/src/main/java/binnie/craftgui/mod/database/ControlMutationSymbol.java b/src/main/java/binnie/craftgui/mod/database/ControlMutationSymbol.java index f3d0fe4c..ad391012 100644 --- a/src/main/java/binnie/craftgui/mod/database/ControlMutationSymbol.java +++ b/src/main/java/binnie/craftgui/mod/database/ControlMutationSymbol.java @@ -23,8 +23,8 @@ class ControlMutationSymbol extends Control implements ITooltip { private int type; @Override - public void onRenderBackground() { - super.onRenderBackground(); + public void onRenderBackground(int guiWidth, int guiHeight) { + super.onRenderBackground(guiWidth, guiHeight); if (this.type == 0) { CraftGUI.render.texture(ControlMutationSymbol.MutationPlus, IPoint.ZERO); } else { @@ -33,7 +33,7 @@ class ControlMutationSymbol extends Control implements ITooltip { } protected ControlMutationSymbol(final IWidget parent, final int x, final int y, final int type) { - super(parent, x, y, 16 + type * 16, 16.0f); + super(parent, x, y, 16 + type * 16, 16); this.value = null; this.type = type; this.addAttribute(Attribute.MouseOver); diff --git a/src/main/java/binnie/craftgui/mod/database/ControlSpeciesBox.java b/src/main/java/binnie/craftgui/mod/database/ControlSpeciesBox.java index 7260159b..6742a59b 100644 --- a/src/main/java/binnie/craftgui/mod/database/ControlSpeciesBox.java +++ b/src/main/java/binnie/craftgui/mod/database/ControlSpeciesBox.java @@ -20,8 +20,8 @@ public class ControlSpeciesBox extends ControlListBox { return new ControlSpeciexBoxOption(this.getContent(), value, y); } - public ControlSpeciesBox(final IWidget parent, final float x, final float y, final float width, final float height) { - super(parent, x, y, width, height, 12.0f); + public ControlSpeciesBox(final IWidget parent, final int x, final int y, final int width, final int height) { + super(parent, x, y, width, height, 12); this.branch = null; } diff --git a/src/main/java/binnie/craftgui/mod/database/ControlSpeciexBoxOption.java b/src/main/java/binnie/craftgui/mod/database/ControlSpeciexBoxOption.java index a9c8367e..44e64bac 100644 --- a/src/main/java/binnie/craftgui/mod/database/ControlSpeciexBoxOption.java +++ b/src/main/java/binnie/craftgui/mod/database/ControlSpeciexBoxOption.java @@ -13,8 +13,8 @@ class ControlSpeciexBoxOption extends ControlTextOption { public ControlSpeciexBoxOption(final ControlList controlList, final IAlleleSpecies option, final int y) { super(controlList, option, option.getName(), y); - this.setSize(new IPoint(this.getSize().x(), 20.0f)); - (this.controlBee = new ControlDatabaseIndividualDisplay(this, 2.0f, 2.0f)).setSpecies(this.getValue(), EnumDiscoveryState.Undetermined); + this.setSize(new IPoint(this.getSize().x(), 20)); + (this.controlBee = new ControlDatabaseIndividualDisplay(this, 2, 2)).setSpecies(this.getValue(), EnumDiscoveryState.Undetermined); if (this.controlBee.discovered == EnumDiscoveryState.Discovered) { this.controlBee.discovered = EnumDiscoveryState.Show; } @@ -22,8 +22,8 @@ class ControlSpeciexBoxOption extends ControlTextOption { if (this.controlBee.discovered == EnumDiscoveryState.Show) { this.addAttribute(Attribute.MouseOver); } - CraftGUIUtil.moveWidget(this.textWidget, new IPoint(22.0f, 0.0f)); - this.textWidget.setSize(this.textWidget.getSize().sub(new IPoint(24.0f, 0.0f))); + CraftGUIUtil.moveWidget(this.textWidget, new IPoint(22, 0)); + this.textWidget.setSize(this.textWidget.getSize().sub(new IPoint(24, 0))); final int th = (int) CraftGUI.render.textHeight(this.textWidget.getValue(), this.textWidget.getSize().x()); final int height = Math.max(20, th + 6); this.setSize(new IPoint(this.size().x(), height)); diff --git a/src/main/java/binnie/craftgui/mod/database/PageAbstract.java b/src/main/java/binnie/craftgui/mod/database/PageAbstract.java index 5591a3c9..7ea5401e 100644 --- a/src/main/java/binnie/craftgui/mod/database/PageAbstract.java +++ b/src/main/java/binnie/craftgui/mod/database/PageAbstract.java @@ -5,7 +5,7 @@ import binnie.craftgui.core.IWidget; public abstract class PageAbstract extends ControlPage { public PageAbstract(final IWidget parent, final DatabaseTab tab) { - super(parent, 0.0f, 0.0f, parent.getSize().x(), parent.getSize().y(), tab); + super(parent, 0, 0, parent.getSize().x(), parent.getSize().y(), tab); } public abstract void onValueChanged(final T p0); diff --git a/src/main/java/binnie/craftgui/mod/database/PageBranchOverview.java b/src/main/java/binnie/craftgui/mod/database/PageBranchOverview.java index 8feda4eb..7134e3b4 100644 --- a/src/main/java/binnie/craftgui/mod/database/PageBranchOverview.java +++ b/src/main/java/binnie/craftgui/mod/database/PageBranchOverview.java @@ -21,9 +21,9 @@ public class PageBranchOverview extends PageBranch { public PageBranchOverview(final IWidget parent, final DatabaseTab tab) { super(parent, tab); this.pageBranchOverview_branchDescription = new ArrayList<>(); - this.pageBranchOverview_branchName = new ControlTextCentered(this, 8.0f, ""); - this.pageBranchOverview_branchScientific = new ControlTextCentered(this, 32.0f, ""); - this.pageBranchOverview_branchAuthority = new ControlTextCentered(this, 44.0f, ""); + this.pageBranchOverview_branchName = new ControlTextCentered(this, 8, ""); + this.pageBranchOverview_branchScientific = new ControlTextCentered(this, 32, ""); + this.pageBranchOverview_branchAuthority = new ControlTextCentered(this, 44, ""); } @Override diff --git a/src/main/java/binnie/craftgui/mod/database/PageBranchSpecies.java b/src/main/java/binnie/craftgui/mod/database/PageBranchSpecies.java index 6982deb3..01897499 100644 --- a/src/main/java/binnie/craftgui/mod/database/PageBranchSpecies.java +++ b/src/main/java/binnie/craftgui/mod/database/PageBranchSpecies.java @@ -19,7 +19,7 @@ public class PageBranchSpecies extends PageBranch { public PageBranchSpecies(final IWidget parent, final DatabaseTab tab) { super(parent, tab); - this.pageBranchSpecies_title = new ControlTextCentered(this, 8.0f, Binnie.LANGUAGE.localise("binniecore.gui.database.species")); + this.pageBranchSpecies_title = new ControlTextCentered(this, 8, Binnie.LANGUAGE.localise("binniecore.gui.database.species")); this.addEventHandler(new EventValueChanged.Handler() { @Override public void onEvent(final EventValueChanged event) { @@ -28,7 +28,7 @@ public class PageBranchSpecies extends PageBranch { } } }); - this.pageBranchSpecies_speciesList = new ControlSpeciesBox(this, 4.0f, 20.0f, 136.0f, 152.0f); + this.pageBranchSpecies_speciesList = new ControlSpeciesBox(this, 4, 20, 136, 152); } @Override diff --git a/src/main/java/binnie/craftgui/mod/database/PageBreeder.java b/src/main/java/binnie/craftgui/mod/database/PageBreeder.java index 091f79bb..609c5223 100644 --- a/src/main/java/binnie/craftgui/mod/database/PageBreeder.java +++ b/src/main/java/binnie/craftgui/mod/database/PageBreeder.java @@ -13,7 +13,7 @@ public class PageBreeder extends ControlPage { private GameProfile player; public PageBreeder(final IWidget parent, final GameProfile player, final DatabaseTab tab) { - super(parent, 0.0f, 0.0f, parent.getSize().x(), parent.getSize().y(), tab); + super(parent, 0, 0, parent.getSize().x(), parent.getSize().y(), tab); this.player = player; this.onPageRefresh(); } @@ -24,15 +24,15 @@ public class PageBreeder extends ControlPage { } final BreedingSystem system = ((WindowAbstractDatabase) Window.get(this)).getBreedingSystem(); final String descriptor = system.getDescriptor(); - new ControlTextCentered(this, 8.0f, TextFormatting.UNDERLINE + system.getDescriptor() + " " + Binnie.LANGUAGE.localise("binniecore.gui.database.breeder.profile")); - new ControlTextCentered(this, 75.0f, "" + system.discoveredSpeciesCount + "/" + system.totalSpeciesCount + " " + Binnie.LANGUAGE.localise("binniecore.gui.database.species")); + new ControlTextCentered(this, 8, TextFormatting.UNDERLINE + system.getDescriptor() + " " + Binnie.LANGUAGE.localise("binniecore.gui.database.breeder.profile")); + new ControlTextCentered(this, 75, "" + system.discoveredSpeciesCount + "/" + system.totalSpeciesCount + " " + Binnie.LANGUAGE.localise("binniecore.gui.database.species")); new ControlBreedingProgress(this, 20, 87, 102, 14, system, system.discoveredSpeciesPercentage); - new ControlTextCentered(this, 115.0f, "" + system.discoveredBranchCount + "/" + system.totalBranchCount + " " + Binnie.LANGUAGE.localise("binniecore.gui.database.breeder.branches")); + new ControlTextCentered(this, 115, "" + system.discoveredBranchCount + "/" + system.totalBranchCount + " " + Binnie.LANGUAGE.localise("binniecore.gui.database.breeder.branches")); new ControlBreedingProgress(this, 20, 127, 102, 14, system, system.discoveredBranchPercentage); if (system.discoveredSecretCount > 0) { - new ControlTextCentered(this, 155.0f, "" + system.discoveredSecretCount + "/" + system.totalSecretCount + " " + Binnie.LANGUAGE.localise("binniecore.gui.database.breeder.species.secret")); + new ControlTextCentered(this, 155, "" + system.discoveredSecretCount + "/" + system.totalSecretCount + " " + Binnie.LANGUAGE.localise("binniecore.gui.database.breeder.species.secret")); } - new ControlTextCentered(this, 32.0f, this.player.getName()); - new ControlTextCentered(this, 44.0f, TextFormatting.ITALIC + system.getEpitome()); + new ControlTextCentered(this, 32, this.player.getName()); + new ControlTextCentered(this, 44, TextFormatting.ITALIC + system.getEpitome()); } } diff --git a/src/main/java/binnie/craftgui/mod/database/PageBreederStats.java b/src/main/java/binnie/craftgui/mod/database/PageBreederStats.java index d5689f84..6d10f224 100644 --- a/src/main/java/binnie/craftgui/mod/database/PageBreederStats.java +++ b/src/main/java/binnie/craftgui/mod/database/PageBreederStats.java @@ -12,9 +12,9 @@ public class PageBreederStats extends Control { String player; public PageBreederStats(final IWidget parent, final int w, final int h, final String player) { - super(parent, 0.0f, 0.0f, w, h); + super(parent, 0, 0, w, h); this.player = player; - final ControlText pageBranchOverview_branchName = new ControlTextCentered(this, 8.0f, TextFormatting.UNDERLINE + Binnie.LANGUAGE.localise("binniecore.gui.database.breeder.stats")); + final ControlText pageBranchOverview_branchName = new ControlTextCentered(this, 8, TextFormatting.UNDERLINE + Binnie.LANGUAGE.localise("binniecore.gui.database.breeder.stats")); final BreedingSystem system = ((WindowAbstractDatabase) this.getSuperParent()).getBreedingSystem(); } } diff --git a/src/main/java/binnie/craftgui/mod/database/PageSpeciesMutations.java b/src/main/java/binnie/craftgui/mod/database/PageSpeciesMutations.java index 78fb0520..eb882fc1 100644 --- a/src/main/java/binnie/craftgui/mod/database/PageSpeciesMutations.java +++ b/src/main/java/binnie/craftgui/mod/database/PageSpeciesMutations.java @@ -12,7 +12,7 @@ public class PageSpeciesMutations extends PageSpecies { public PageSpeciesMutations(final IWidget parent, final DatabaseTab tab) { super(parent, tab); - this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8.0f, Binnie.LANGUAGE.localise("binniecore.gui.database.mutations.further")); + this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8, Binnie.LANGUAGE.localise("binniecore.gui.database.mutations.further")); this.pageSpeciesFurther_List = new ControlMutationBox(this, 4, 20, 136, 152, ControlMutationBox.Type.Further); } diff --git a/src/main/java/binnie/craftgui/mod/database/PageSpeciesOverview.java b/src/main/java/binnie/craftgui/mod/database/PageSpeciesOverview.java index 0a0d2e1c..20fde80f 100644 --- a/src/main/java/binnie/craftgui/mod/database/PageSpeciesOverview.java +++ b/src/main/java/binnie/craftgui/mod/database/PageSpeciesOverview.java @@ -25,14 +25,14 @@ public class PageSpeciesOverview extends PageSpecies { public PageSpeciesOverview(final IWidget parent, final DatabaseTab tab) { super(parent, tab); - this.controlInd1 = new ControlDatabaseIndividualDisplay(this, 5.0f, 5.0f); - this.controlInd2 = new ControlDatabaseIndividualDisplay(this, 123.0f, 5.0f); - this.controlName = new ControlTextCentered(this, 8.0f, ""); - this.controlScientific = new ControlTextCentered(this, 32.0f, ""); - this.controlAuthority = new ControlTextCentered(this, 44.0f, ""); - this.controlComplexity = new ControlTextCentered(this, 68.0f, ""); - this.controlDescription = new ControlText(this, new IArea(8.0f, 84.0f, this.getSize().x() - 16.0f, 0.0f), "", TextJustification.MiddleCenter); - this.controlSignature = new ControlText(this, new IArea(8.0f, 84.0f, this.getSize().x() - 16.0f, 0.0f), "", TextJustification.BottomRight); + this.controlInd1 = new ControlDatabaseIndividualDisplay(this, 5, 5); + this.controlInd2 = new ControlDatabaseIndividualDisplay(this, 123, 5); + this.controlName = new ControlTextCentered(this, 8, ""); + this.controlScientific = new ControlTextCentered(this, 32, ""); + this.controlAuthority = new ControlTextCentered(this, 44, ""); + this.controlComplexity = new ControlTextCentered(this, 68, ""); + this.controlDescription = new ControlText(this, new IArea(8, 84, this.getSize().x() - 16, 0), "", TextJustification.MiddleCenter); + this.controlSignature = new ControlText(this, new IArea(8, 84, this.getSize().x() - 16, 0), "", TextJustification.BottomRight); } @Override @@ -62,7 +62,7 @@ public class PageSpeciesOverview extends PageSpecies { } this.controlDescription.setValue(descBody + TextFormatting.RESET); this.controlSignature.setValue(descSig); - final float descHeight = CraftGUI.render.textHeight(this.controlDescription.getValue(), this.controlDescription.getSize().x()); - this.controlSignature.setPosition(new IPoint(this.controlSignature.pos().x(), this.controlDescription.getPosition().y() + descHeight + 10.0f)); + final int descHeight = CraftGUI.render.textHeight(this.controlDescription.getValue(), this.controlDescription.getSize().x()); + this.controlSignature.setPosition(new IPoint(this.controlSignature.pos().x(), this.controlDescription.getPosition().y() + descHeight + 10)); } } diff --git a/src/main/java/binnie/craftgui/mod/database/PageSpeciesResultant.java b/src/main/java/binnie/craftgui/mod/database/PageSpeciesResultant.java index 52f8237d..092eaf27 100644 --- a/src/main/java/binnie/craftgui/mod/database/PageSpeciesResultant.java +++ b/src/main/java/binnie/craftgui/mod/database/PageSpeciesResultant.java @@ -12,7 +12,7 @@ public class PageSpeciesResultant extends PageSpecies { public PageSpeciesResultant(final IWidget parent, final DatabaseTab tab) { super(parent, tab); - this.pageSpeciesResultant_Title = new ControlTextCentered(this, 8.0f, Binnie.LANGUAGE.localise("binniecore.gui.database.mutations.resultant")); + this.pageSpeciesResultant_Title = new ControlTextCentered(this, 8, Binnie.LANGUAGE.localise("binniecore.gui.database.mutations.resultant")); this.pageSpeciesResultant_List = new ControlMutationBox(this, 4, 20, 136, 152, ControlMutationBox.Type.Resultant); } diff --git a/src/main/java/binnie/craftgui/mod/database/WindowAbstractDatabase.java b/src/main/java/binnie/craftgui/mod/database/WindowAbstractDatabase.java index 7a61a1cf..557f9cc1 100644 --- a/src/main/java/binnie/craftgui/mod/database/WindowAbstractDatabase.java +++ b/src/main/java/binnie/craftgui/mod/database/WindowAbstractDatabase.java @@ -35,12 +35,12 @@ import java.util.Map; import java.util.Objects; public abstract class WindowAbstractDatabase extends Window { - private float selectionBoxWidth; - private final float infoBoxWidth = 144.0f; - private final float infoBoxHeight = 176.0f; - private final float infoTabWidth = 16.0f; - private final float modeTabWidth = 22.0f; - private final float searchBoxHeight = 16.0f; + private int selectionBoxWidth; + private final int infoBoxWidth = 144; + private final int infoBoxHeight = 176; + private final int infoTabWidth = 16; + private final int modeTabWidth = 22; + private final int searchBoxHeight = 16; private Map modes; boolean isNEI; private BreedingSystem system; @@ -53,9 +53,9 @@ public abstract class WindowAbstractDatabase extends Window { this.modePages.setValue(mode); } - public WindowAbstractDatabase(final EntityPlayer player, final Side side, final boolean nei, final BreedingSystem system, final float wid) { - super(100.0f, 192.0f, player, null, side); - this.selectionBoxWidth = 95.0f; + public WindowAbstractDatabase(final EntityPlayer player, final Side side, final boolean nei, final BreedingSystem system, final int wid) { + super(100, 192, player, null, side); + this.selectionBoxWidth = 95; this.modes = new HashMap<>(); this.panelInformation = null; this.panelSearch = null; @@ -79,7 +79,7 @@ public abstract class WindowAbstractDatabase extends Window { } public WindowAbstractDatabase(final EntityPlayer player, final Side side, final boolean nei, final BreedingSystem system) { - this(player, side, nei, system, 95.0f); + this(player, side, nei, system, 95); } protected ModeWidgets createMode(final IDatabaseMode mode, final ModeWidgets widgets) { @@ -89,7 +89,7 @@ public abstract class WindowAbstractDatabase extends Window { @Override public void initialiseClient() { - this.setSize(new IPoint(176.0f + this.selectionBoxWidth + 22.0f + 8.0f, 208.0f)); + this.setSize(new IPoint(176 + this.selectionBoxWidth + 22 + 8, 208)); this.addEventHandler(new EventValueChanged.Handler() { @Override public void onEvent(final EventValueChanged event) { @@ -127,11 +127,11 @@ public abstract class WindowAbstractDatabase extends Window { } } }.setOrigin(EventHandler.Origin.DirectChild, this)); - new ControlHelp(this, 4.0f, 4.0f); - (this.panelInformation = new Panel(this, 24.0f, 24.0f, 144.0f, 176.0f, MinecraftGUI.PanelType.Black)).setColour(860416); - (this.panelSearch = new Panel(this, 176.0f, 24.0f, this.selectionBoxWidth, 160.0f, MinecraftGUI.PanelType.Black)).setColour(860416); - this.modePages = new ControlPages<>(this, 0.0f, 0.0f, this.getSize().x(), this.getSize().y()); - new ControlTextEdit(this, 176.0f, 184.0f, this.selectionBoxWidth, 16.0f); + new ControlHelp(this, 4, 4); + (this.panelInformation = new Panel(this, 24, 24, 144, 176, MinecraftGUI.PanelType.Black)).setColour(860416); + (this.panelSearch = new Panel(this, 176, 24, this.selectionBoxWidth, 160, MinecraftGUI.PanelType.Black)).setColour(860416); + this.modePages = new ControlPages<>(this, 0, 0, this.getSize().x(), this.getSize().y()); + new ControlTextEdit(this, 176, 184, this.selectionBoxWidth, 16); this.createMode(Mode.Species, new ModeWidgets(Mode.Species, this) { @Override public void createListBox(final IArea area) { @@ -152,13 +152,13 @@ public abstract class WindowAbstractDatabase extends Window { this.createMode(Mode.Breeder, new ModeWidgets(Mode.Breeder, this) { @Override public void createListBox(final IArea area) { - this.listBox = new ControlListBox(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0f); + this.listBox = new ControlListBox(this.modePage, area.x(), area.y(), area.w(), area.h(), 12); } }); this.addTabs(); - final ControlTabBar tab = new ControlTabBar(this, 176.0f + this.selectionBoxWidth, 24.0f, 22.0f, 176.0f, Position.Right) { + final ControlTabBar tab = new ControlTabBar(this, 176 + this.selectionBoxWidth, 24, 22, 176, Position.Right) { @Override - public ControlTab createTab(final float x, final float y, final float w, final float h, final IDatabaseMode value) { + public ControlTab createTab(final int x, final int y, final int w, final int h, final IDatabaseMode value) { return new ControlTab(this, x, y, w, h, value) { @Override public String getName() { @@ -171,7 +171,7 @@ public abstract class WindowAbstractDatabase extends Window { CraftGUIUtil.linkWidgets(tab, this.modePages); this.changeMode(Mode.Species); for (final IDatabaseMode mode : this.modes.keySet()) { - this.modes.get(mode).infoTabs = new ControlTabBar(this.modes.get(mode).modePage, 8.0f, 24.0f, 16.0f, 176.0f, Position.Left); + this.modes.get(mode).infoTabs = new ControlTabBar(this.modes.get(mode).modePage, 8, 24, 16, 176, Position.Left); this.modes.get(mode).infoTabs.setValues(this.modes.get(mode).infoPages.getValues()); CraftGUIUtil.linkWidgets(this.modes.get(mode).infoTabs, this.modes.get(mode).infoPages); } @@ -229,12 +229,12 @@ public abstract class WindowAbstractDatabase extends Window { public ModeWidgets(final IDatabaseMode mode, final WindowAbstractDatabase database) { this.database = database; - this.modePage = new ControlPage<>(database.modePages, 0.0f, 0.0f, database.getSize().x(), database.getSize().y(), mode); + this.modePage = new ControlPage<>(database.modePages, 0, 0, database.getSize().x(), database.getSize().y(), mode); final IArea listBoxArea = database.panelSearch.area().inset(2); this.createListBox(listBoxArea); CraftGUIUtil.alignToWidget(this.listBox, database.panelSearch); - CraftGUIUtil.moveWidget(this.listBox, new IPoint(2.0f, 2.0f)); - CraftGUIUtil.alignToWidget(this.infoPages = new ControlPages<>(this.modePage, 0.0f, 0.0f, 144.0f, 176.0f), database.panelInformation); + CraftGUIUtil.moveWidget(this.listBox, new IPoint(2, 2)); + CraftGUIUtil.alignToWidget(this.infoPages = new ControlPages<>(this.modePage, 0, 0, 144, 176), database.panelInformation); } public abstract void createListBox(final IArea p0); diff --git a/src/main/java/binnie/craftgui/resource/Texture.java b/src/main/java/binnie/craftgui/resource/Texture.java index dc2edb72..a75dbfd6 100644 --- a/src/main/java/binnie/craftgui/resource/Texture.java +++ b/src/main/java/binnie/craftgui/resource/Texture.java @@ -49,46 +49,46 @@ public class Texture { return this.padding.add(this.border); } - public float w() { + public int w() { return this.getArea().w(); } - public float h() { + public int h() { return this.getArea().h(); } - public float u() { + public int u() { return this.getArea().x(); } - public float v() { + public int v() { return this.getArea().y(); } - public Texture crop(final Position anchor, final float dist) { + public Texture crop(final Position anchor, final int dist) { return this.crop(new IBorder(anchor.opposite(), dist)); } public Texture crop(final IBorder crop) { final Texture copy = new Texture(this.area, this.padding, this.border, this.filename); - if (crop.b() > 0.0f) { - copy.border.b(0.0f); + if (crop.b() > 0) { + copy.border.b(0); copy.padding.b(copy.padding.b() - Math.min(crop.b(), copy.padding.b())); copy.area.h(copy.area.h() - crop.b()); } - if (crop.t() > 0.0f) { - copy.border.t(0.0f); + if (crop.t() > 0) { + copy.border.t(0); copy.padding.t(copy.padding.t() - Math.min(crop.t(), copy.padding.t())); copy.area.h(copy.area.h() - crop.t()); copy.area.y(copy.area.y() + crop.t()); } - if (crop.r() > 0.0f) { - copy.border.r(0.0f); + if (crop.r() > 0) { + copy.border.r(0); copy.padding.r(copy.padding.r() - Math.min(crop.r(), copy.padding.r())); copy.area.w(copy.area.w() - crop.r()); } - if (crop.l() > 0.0f) { - copy.border.l(0.0f); + if (crop.l() > 0) { + copy.border.l(0); copy.padding.l(copy.padding.l() - Math.min(crop.l(), copy.padding.l())); copy.area.w(copy.area.w() - crop.l()); copy.area.x(copy.area.x() + crop.l()); diff --git a/src/main/java/binnie/craftgui/resource/minecraft/CraftGUIResourceManager.java b/src/main/java/binnie/craftgui/resource/minecraft/CraftGUIResourceManager.java index 68d87790..e4446608 100644 --- a/src/main/java/binnie/craftgui/resource/minecraft/CraftGUIResourceManager.java +++ b/src/main/java/binnie/craftgui/resource/minecraft/CraftGUIResourceManager.java @@ -88,20 +88,20 @@ public class CraftGUIResourceManager implements IResourceManagerReloadListener { if (split.length < 1 || split.length > 4) { throw new RuntimeException("Parameter must have between one and four numbers"); } - final List f = new ArrayList<>(); + final List i = new ArrayList<>(); for (final String string : split) { - f.add(Float.parseFloat(string)); + i.add(Integer.parseInt(string)); } - if (f.size() == 1) { - return new IArea(f.get(0)); + if (i.size() == 1) { + return new IArea(i.get(0)); } - if (f.size() == 2) { - return new IArea(f.get(0), f.get(1)); + if (i.size() == 2) { + return new IArea(i.get(0), i.get(1)); } - if (f.size() == 3) { - return new IArea(f.get(0), f.get(1), f.get(2)); + if (i.size() == 3) { + return new IArea(i.get(0), i.get(1), i.get(2)); } - return new IArea(f.get(0), f.get(1), f.get(2), f.get(3)); + return new IArea(i.get(0), i.get(1), i.get(2), i.get(3)); } public IBorder getBorder(final String name) { @@ -109,20 +109,20 @@ public class CraftGUIResourceManager implements IResourceManagerReloadListener { if (split.length < 1 || split.length > 4) { throw new RuntimeException("Parameter must have between one and four numbers"); } - final List f = new ArrayList<>(); + final List i = new ArrayList<>(); for (final String string : split) { - f.add(Float.parseFloat(string)); + i.add(Integer.parseInt(string)); } - if (f.size() == 1) { - return new IBorder(f.get(0)); + if (i.size() == 1) { + return new IBorder(i.get(0)); } - if (f.size() == 2) { - return new IBorder(f.get(0), f.get(1)); + if (i.size() == 2) { + return new IBorder(i.get(0), i.get(1)); } - if (f.size() == 3) { - return new IBorder(f.get(0), f.get(1), f.get(2)); + if (i.size() == 3) { + return new IBorder(i.get(0), i.get(1), i.get(2)); } - return new IBorder(f.get(0), f.get(1), f.get(2), f.get(3)); + return new IBorder(i.get(0), i.get(1), i.get(2), i.get(3)); } public IBinnieTexture getTextureSheet(final String name) { diff --git a/src/main/java/binnie/craftgui/window/Panel.java b/src/main/java/binnie/craftgui/window/Panel.java index 0dd2e582..462edef2 100644 --- a/src/main/java/binnie/craftgui/window/Panel.java +++ b/src/main/java/binnie/craftgui/window/Panel.java @@ -10,7 +10,7 @@ import binnie.craftgui.resource.minecraft.CraftGUITexture; public class Panel extends Control { IPanelType type; - public Panel(final IWidget parent, final float x, final float y, final float width, final float height, final IPanelType type) { + public Panel(final IWidget parent, final int x, final int y, final int width, final int height, final IPanelType type) { super(parent, x, y, width, height); this.type = type; } @@ -24,7 +24,7 @@ public class Panel extends Control { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { final IPanelType panelType = this.getType(); if (panelType instanceof MinecraftGUI.PanelType) { switch ((MinecraftGUI.PanelType) panelType) { diff --git a/src/main/java/binnie/extrabees/gui/WindowAlvearyFrame.java b/src/main/java/binnie/extrabees/gui/WindowAlvearyFrame.java index d09e13da..e2554628 100644 --- a/src/main/java/binnie/extrabees/gui/WindowAlvearyFrame.java +++ b/src/main/java/binnie/extrabees/gui/WindowAlvearyFrame.java @@ -16,7 +16,7 @@ public class WindowAlvearyFrame extends Window { ControlPlayerInventory playerInventory; public WindowAlvearyFrame(final EntityPlayer player, final IInventory inventory, final Side side) { - super(176.0f, 144.0f, player, inventory, side); + super(176, 144, player, inventory, side); this.machine = ((TileEntityMachine) inventory).getMachine(); } @@ -31,7 +31,7 @@ public class WindowAlvearyFrame extends Window { public void initialiseClient() { this.setTitle("Frame Housing"); this.playerInventory = new ControlPlayerInventory(this); - final ControlSlot slot = new ControlSlot(this, 79.0f, 30.0f); + final ControlSlot slot = new ControlSlot(this, 79, 30); slot.assign(0); } diff --git a/src/main/java/binnie/extrabees/gui/WindowAlvearyHatchery.java b/src/main/java/binnie/extrabees/gui/WindowAlvearyHatchery.java index c540ff6b..b072a75b 100644 --- a/src/main/java/binnie/extrabees/gui/WindowAlvearyHatchery.java +++ b/src/main/java/binnie/extrabees/gui/WindowAlvearyHatchery.java @@ -17,7 +17,7 @@ public class WindowAlvearyHatchery extends Window { ControlPlayerInventory playerInventory; public WindowAlvearyHatchery(final EntityPlayer player, final IInventory inventory, final Side side) { - super(176.0f, 144.0f, player, inventory, side); + super(176, 144, player, inventory, side); this.machine = ((TileEntityMachine) inventory).getMachine(); } diff --git a/src/main/java/binnie/extrabees/gui/WindowAlvearyIndustrialFrame.java b/src/main/java/binnie/extrabees/gui/WindowAlvearyIndustrialFrame.java index 22fd0234..ba280268 100644 --- a/src/main/java/binnie/extrabees/gui/WindowAlvearyIndustrialFrame.java +++ b/src/main/java/binnie/extrabees/gui/WindowAlvearyIndustrialFrame.java @@ -16,7 +16,7 @@ public class WindowAlvearyIndustrialFrame extends Window { ControlPlayerInventory playerInventory; public WindowAlvearyIndustrialFrame(final EntityPlayer player, final IInventory inventory, final Side side) { - super(176.0f, 144.0f, player, inventory, side); + super(176, 144, player, inventory, side); this.machine = ((TileEntityMachine) inventory).getMachine(); } @@ -31,7 +31,7 @@ public class WindowAlvearyIndustrialFrame extends Window { public void initialiseClient() { this.setTitle("Industrial Frame Housing"); this.playerInventory = new ControlPlayerInventory(this); - final ControlSlot slot = new ControlSlot(this, 79.0f, 30.0f); + final ControlSlot slot = new ControlSlot(this, 79, 30); slot.assign(0); } diff --git a/src/main/java/binnie/extrabees/gui/WindowAlvearyMutator.java b/src/main/java/binnie/extrabees/gui/WindowAlvearyMutator.java index 68ff1b99..1bc64d87 100644 --- a/src/main/java/binnie/extrabees/gui/WindowAlvearyMutator.java +++ b/src/main/java/binnie/extrabees/gui/WindowAlvearyMutator.java @@ -22,7 +22,7 @@ public class WindowAlvearyMutator extends Window { ControlPlayerInventory playerInventory; public WindowAlvearyMutator(final EntityPlayer player, final IInventory inventory, final Side side) { - super(176.0f, 176.0f, player, inventory, side); + super(176, 176, player, inventory, side); this.machine = ((TileEntityMachine) inventory).getMachine(); } @@ -37,18 +37,18 @@ public class WindowAlvearyMutator extends Window { public void initialiseClient() { this.setTitle("Mutator"); this.playerInventory = new ControlPlayerInventory(this); - final ControlSlot slot = new ControlSlot(this, 79.0f, 30.0f); + final ControlSlot slot = new ControlSlot(this, 79, 30); slot.assign(0); - new ControlText(this, new IArea(0.0f, 52.0f, this.w(), 16.0f), "Possible Mutagens:", TextJustification.MiddleCenter).setColour(5592405); + new ControlText(this, new IArea(0, 52, this.w(), 16), "Possible Mutagens:", TextJustification.MiddleCenter).setColour(5592405); final int size = AlvearyMutator.getMutagens().size(); final int w = size * 18; if (size > 0) { - float x = (this.w() - w) / 2.0f; + int x = (this.w() - w) / 2; for (final ItemStack stack : AlvearyMutator.getMutagens()) { - final ControlItemDisplay display = new ControlItemDisplay(this, x, 66.0f); + final ControlItemDisplay display = new ControlItemDisplay(this, x, 66); display.setItemStack(stack); display.hastooltip = true; - x += 18.0f; + x += 18; } } } diff --git a/src/main/java/binnie/extrabees/gui/WindowAlvearyStimulator.java b/src/main/java/binnie/extrabees/gui/WindowAlvearyStimulator.java index 0fcb5b17..52ea5676 100644 --- a/src/main/java/binnie/extrabees/gui/WindowAlvearyStimulator.java +++ b/src/main/java/binnie/extrabees/gui/WindowAlvearyStimulator.java @@ -19,7 +19,7 @@ public class WindowAlvearyStimulator extends Window { ControlPlayerInventory playerInventory; public WindowAlvearyStimulator(final EntityPlayer player, final IInventory inventory, final Side side) { - super(176.0f, 144.0f, player, inventory, side); + super(176, 144, player, inventory, side); this.machine = ((TileEntityMachine) inventory).getMachine(); } @@ -34,7 +34,7 @@ public class WindowAlvearyStimulator extends Window { public void initialiseClient() { this.setTitle("Stimulator"); new ControlEnergyBar(this, 75, 29, 60, 16, Position.Left); - final ControlSlot slot = new ControlSlot(this, 41.0f, 28.0f); + final ControlSlot slot = new ControlSlot(this, 41, 28); slot.assign(AlvearyStimulator.slotCircuit); this.playerInventory = new ControlPlayerInventory(this); } diff --git a/src/main/java/binnie/extrabees/gui/database/ControlBiomes.java b/src/main/java/binnie/extrabees/gui/database/ControlBiomes.java index 036f773c..250dbf31 100644 --- a/src/main/java/binnie/extrabees/gui/database/ControlBiomes.java +++ b/src/main/java/binnie/extrabees/gui/database/ControlBiomes.java @@ -43,7 +43,7 @@ public class ControlBiomes extends Control implements ITooltip { } @Override - public void onRenderForeground() { + public void onRenderForeground(int guiWidth, int guiHeight) { for (int i = 0; i < this.tolerated.size(); ++i) { final int x = i % 8 * 16; final int y = i / 8 * 16; @@ -51,7 +51,7 @@ public class ControlBiomes extends Control implements ITooltip { //TODO FIND COLOR //CraftGUI.Render.colour(Biome.getBiome(i).color); } - CraftGUI.render.texture(CraftGUITexture.Button, new IArea(x, y, 16.0f, 16.0f)); + CraftGUI.render.texture(CraftGUITexture.Button, new IArea(x, y, 16, 16)); } } diff --git a/src/main/java/binnie/extrabees/gui/database/ControlClimateBar.java b/src/main/java/binnie/extrabees/gui/database/ControlClimateBar.java index 9ab3e43e..d06874f7 100644 --- a/src/main/java/binnie/extrabees/gui/database/ControlClimateBar.java +++ b/src/main/java/binnie/extrabees/gui/database/ControlClimateBar.java @@ -63,7 +63,7 @@ public class ControlClimateBar extends Control implements ITooltip { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.texture(CraftGUITexture.EnergyBarBack, this.getArea()); final int types = this.isHumidity ? 3 : 6; final int w = (int) ((this.getSize().x() - 2.0f) / types); @@ -76,7 +76,7 @@ public class ControlClimateBar extends Control implements ITooltip { } else { colour = this.tempColours[i]; } - CraftGUI.render.solid(new IArea(x + 1, 1.0f, w, this.getSize().y() - 2.0f), colour); + CraftGUI.render.solid(new IArea(x + 1, 1, w, this.getSize().y() - 2), colour); } } CraftGUI.render.texture(CraftGUITexture.EnergyBarGlass, this.getArea()); diff --git a/src/main/java/binnie/extrabees/gui/database/ControlProductsBox.java b/src/main/java/binnie/extrabees/gui/database/ControlProductsBox.java index 4b80fc1b..7b42b914 100644 --- a/src/main/java/binnie/extrabees/gui/database/ControlProductsBox.java +++ b/src/main/java/binnie/extrabees/gui/database/ControlProductsBox.java @@ -24,7 +24,7 @@ public class ControlProductsBox extends ControlListBox controlList, final ControlProductsBox.Product value, final int y) { super(controlList, value, y); - (this.item = new ControlItemDisplay(this, 4.0f, 4.0f)).setTooltip(); - final ControlText textWidget = new ControlTextCentered(this, 2.0f, ""); - CraftGUIUtil.moveWidget(textWidget, new IPoint(12.0f, 0.0f)); + (this.item = new ControlItemDisplay(this, 4, 4)).setTooltip(); + final ControlText textWidget = new ControlTextCentered(this, 2, ""); + CraftGUIUtil.moveWidget(textWidget, new IPoint(12, 0)); if (value != null) { this.item.setItemStack(value.item); - final float time = (int) (55000.0 / value.chance); - final float seconds = time / 20.0f; - final float minutes = seconds / 60.0f; - final float hours = minutes / 60.0f; + final int time = (int) (55000.0 / value.chance); + final int seconds = time / 20; + final int minutes = seconds / 60; + final int hours = minutes / 60; final DecimalFormat df = new DecimalFormat("#.0"); - if (hours > 1.0f) { + if (hours > 1) { textWidget.setValue("Every " + df.format(hours) + " hours"); - } else if (minutes > 1.0f) { + } else if (minutes > 1) { textWidget.setValue("Every " + df.format(minutes) + " min."); } else { textWidget.setValue("Every " + df.format(seconds) + " sec."); diff --git a/src/main/java/binnie/extrabees/gui/database/PageSpeciesClimate.java b/src/main/java/binnie/extrabees/gui/database/PageSpeciesClimate.java index 3bf23bc8..c8db0c54 100644 --- a/src/main/java/binnie/extrabees/gui/database/PageSpeciesClimate.java +++ b/src/main/java/binnie/extrabees/gui/database/PageSpeciesClimate.java @@ -14,10 +14,10 @@ public class PageSpeciesClimate extends PageSpecies { public PageSpeciesClimate(final IWidget parent, final DatabaseTab tab) { super(parent, tab); - new ControlTextCentered(this, 8.0f, "Climate"); + new ControlTextCentered(this, 8, "Climate"); this.tempBar = new ControlClimateBar(this, 8, 24, 128, 12); this.humidBar = new ControlClimateBar(this, 8, 42, 128, 12, true); - new ControlTextCentered(this, 70.0f, "Biomes"); + new ControlTextCentered(this, 70, "Biomes"); this.biomes = new ControlBiomes(this, 8, 90, 8, 4); } diff --git a/src/main/java/binnie/extrabees/gui/database/PageSpeciesGenome.java b/src/main/java/binnie/extrabees/gui/database/PageSpeciesGenome.java index d63bec61..5558c558 100644 --- a/src/main/java/binnie/extrabees/gui/database/PageSpeciesGenome.java +++ b/src/main/java/binnie/extrabees/gui/database/PageSpeciesGenome.java @@ -29,28 +29,28 @@ public class PageSpeciesGenome extends PageSpecies { public PageSpeciesGenome(final IWidget parent, final DatabaseTab tab) { super(parent, tab); - this.pageSpeciesGenome_Title = new ControlTextCentered(this, 8.0f, "Genome"); - new ControlText(this, new IArea(0.0f, 32.0f, 68.0f, 30.0f), "Speed:", TextJustification.TopRight); - new ControlText(this, new IArea(0.0f, 44.0f, 68.0f, 30.0f), "Lifespan:", TextJustification.TopRight); - new ControlText(this, new IArea(0.0f, 56.0f, 68.0f, 30.0f), "Fertility:", TextJustification.TopRight); - new ControlText(this, new IArea(0.0f, 68.0f, 68.0f, 30.0f), "Flowering:", TextJustification.TopRight); - new ControlText(this, new IArea(0.0f, 80.0f, 68.0f, 30.0f), "Territory:", TextJustification.TopRight); - new ControlText(this, new IArea(0.0f, 97.0f, 68.0f, 30.0f), "Behavior:", TextJustification.TopRight); - new ControlText(this, new IArea(0.0f, 109.0f, 68.0f, 30.0f), "Sunlight:", TextJustification.TopRight); - new ControlText(this, new IArea(0.0f, 121.0f, 68.0f, 30.0f), "Rain:", TextJustification.TopRight); - new ControlText(this, new IArea(0.0f, 138.0f, 68.0f, 30.0f), "Flower:", TextJustification.TopRight); - new ControlText(this, new IArea(0.0f, 155.0f, 68.0f, 30.0f), "Effect:", TextJustification.TopRight); + this.pageSpeciesGenome_Title = new ControlTextCentered(this, 8, "Genome"); + new ControlText(this, new IArea(0, 32, 68, 30), "Speed:", TextJustification.TopRight); + new ControlText(this, new IArea(0, 44, 68, 30), "Lifespan:", TextJustification.TopRight); + new ControlText(this, new IArea(0, 56, 68, 30), "Fertility:", TextJustification.TopRight); + new ControlText(this, new IArea(0, 68, 68, 30), "Flowering:", TextJustification.TopRight); + new ControlText(this, new IArea(0, 80, 68, 30), "Territory:", TextJustification.TopRight); + new ControlText(this, new IArea(0, 97, 68, 30), "Behavior:", TextJustification.TopRight); + new ControlText(this, new IArea(0, 109, 68, 30), "Sunlight:", TextJustification.TopRight); + new ControlText(this, new IArea(0, 121, 68, 30), "Rain:", TextJustification.TopRight); + new ControlText(this, new IArea(0, 138, 68, 30), "Flower:", TextJustification.TopRight); + new ControlText(this, new IArea(0, 155, 68, 30), "Effect:", TextJustification.TopRight); final int x = 72; - this.pageSpeciesGenome_SpeedText = new ControlText(this, new IArea(x, 32.0f, 72.0f, 30.0f), "", TextJustification.TopLeft); - this.pageSpeciesGenome_LifespanText = new ControlText(this, new IArea(x, 44.0f, 72.0f, 30.0f), "", TextJustification.TopLeft); - this.pageSpeciesGenome_FertilityText = new ControlText(this, new IArea(x, 56.0f, 72.0f, 30.0f), "", TextJustification.TopLeft); - this.pageSpeciesGenome_FloweringText = new ControlText(this, new IArea(x, 68.0f, 72.0f, 30.0f), "", TextJustification.TopLeft); - this.pageSpeciesGenome_TerritoryText = new ControlText(this, new IArea(x, 80.0f, 72.0f, 30.0f), "", TextJustification.TopLeft); - this.pageSpeciesGenome_NocturnalText = new ControlText(this, new IArea(x, 97.0f, 72.0f, 30.0f), "", TextJustification.TopLeft); - this.pageSpeciesGenome_CaveDwellingText = new ControlText(this, new IArea(x, 109.0f, 72.0f, 30.0f), "", TextJustification.TopLeft); - this.pageSpeciesGenome_TolerantFlyerText = new ControlText(this, new IArea(x, 121.0f, 72.0f, 30.0f), "", TextJustification.TopLeft); - this.pageSpeciesGenome_FlowerText = new ControlText(this, new IArea(x, 138.0f, 72.0f, 30.0f), "", TextJustification.TopLeft); - this.pageSpeciesGenome_EffectText = new ControlText(this, new IArea(x, 155.0f, 72.0f, 30.0f), "", TextJustification.TopLeft); + this.pageSpeciesGenome_SpeedText = new ControlText(this, new IArea(x, 32, 72, 30), "", TextJustification.TopLeft); + this.pageSpeciesGenome_LifespanText = new ControlText(this, new IArea(x, 44, 72, 30), "", TextJustification.TopLeft); + this.pageSpeciesGenome_FertilityText = new ControlText(this, new IArea(x, 56, 72, 30), "", TextJustification.TopLeft); + this.pageSpeciesGenome_FloweringText = new ControlText(this, new IArea(x, 68, 72, 30), "", TextJustification.TopLeft); + this.pageSpeciesGenome_TerritoryText = new ControlText(this, new IArea(x, 80, 72, 30), "", TextJustification.TopLeft); + this.pageSpeciesGenome_NocturnalText = new ControlText(this, new IArea(x, 97, 72, 30), "", TextJustification.TopLeft); + this.pageSpeciesGenome_CaveDwellingText = new ControlText(this, new IArea(x, 109, 72, 30), "", TextJustification.TopLeft); + this.pageSpeciesGenome_TolerantFlyerText = new ControlText(this, new IArea(x, 121, 72, 30), "", TextJustification.TopLeft); + this.pageSpeciesGenome_FlowerText = new ControlText(this, new IArea(x, 138, 72, 30), "", TextJustification.TopLeft); + this.pageSpeciesGenome_EffectText = new ControlText(this, new IArea(x, 155, 72, 30), "", TextJustification.TopLeft); } @Override diff --git a/src/main/java/binnie/extrabees/gui/database/PageSpeciesProducts.java b/src/main/java/binnie/extrabees/gui/database/PageSpeciesProducts.java index d0c9622f..b56cfa75 100644 --- a/src/main/java/binnie/extrabees/gui/database/PageSpeciesProducts.java +++ b/src/main/java/binnie/extrabees/gui/database/PageSpeciesProducts.java @@ -16,9 +16,9 @@ public class PageSpeciesProducts extends PageSpecies { public PageSpeciesProducts(final IWidget parent, final DatabaseTab tab) { super(parent, tab); - this.pageSpeciesProducts_Title = new ControlTextCentered(this, 8.0f, "Products"); + this.pageSpeciesProducts_Title = new ControlTextCentered(this, 8, "Products"); this.pageSpeciesProducts_Products = new ControlProductsBox(this, 4, 20, 136, 48, ControlProductsBox.Type.Products); - this.pageSpeciesProducts_Title2 = new ControlTextCentered(this, 68.0f, "Specialties"); + this.pageSpeciesProducts_Title2 = new ControlTextCentered(this, 68, "Specialties"); this.pageSpeciesProducts_Specialties = new ControlProductsBox(this, 4, 80, 136, 48, ControlProductsBox.Type.Specialties); } diff --git a/src/main/java/binnie/extrabees/gui/database/WindowApiaristDatabase.java b/src/main/java/binnie/extrabees/gui/database/WindowApiaristDatabase.java index 69f56965..fad7a6b2 100644 --- a/src/main/java/binnie/extrabees/gui/database/WindowApiaristDatabase.java +++ b/src/main/java/binnie/extrabees/gui/database/WindowApiaristDatabase.java @@ -32,7 +32,7 @@ public class WindowApiaristDatabase extends WindowAbstractDatabase { } public WindowApiaristDatabase(final EntityPlayer player, final Side side, final boolean nei) { - super(player, side, nei, Binnie.GENETICS.beeBreedingSystem, 110.0f); + super(player, side, nei, Binnie.GENETICS.beeBreedingSystem, 110); } public static Window create(final EntityPlayer player, final Side side, final boolean nei) { diff --git a/src/main/java/binnie/extrabees/gui/punnett/ControlChromosome.java b/src/main/java/binnie/extrabees/gui/punnett/ControlChromosome.java index 8f98386f..c3bc8001 100644 --- a/src/main/java/binnie/extrabees/gui/punnett/ControlChromosome.java +++ b/src/main/java/binnie/extrabees/gui/punnett/ControlChromosome.java @@ -12,8 +12,8 @@ import forestry.api.genetics.IChromosomeType; public class ControlChromosome extends Control implements IControlValue, ITooltip { IChromosomeType value; - protected ControlChromosome(final IWidget parent, final float x, final float y, final IChromosomeType type) { - super(parent, x, y, 16.0f, 16.0f); + protected ControlChromosome(final IWidget parent, final int x, final int y, final IChromosomeType type) { + super(parent, x, y, 16, 16); this.setValue(type); this.addAttribute(Attribute.MouseOver); } @@ -29,7 +29,7 @@ public class ControlChromosome extends Control implements IControlValue 1) ? 50 : 100; - new ControlIconDisplay(this, (this.w() - w) / 2.0f, y - ((sections == 1) ? 0 : 0), null) { + new ControlIconDisplay(this, (this.w() - w) / 2, y - ((sections == 1) ? 0 : 0), null) { @Override - public void onRenderForeground() { + public void onRenderForeground(int guiWidth, int guiHeight) { // GL11.glPushMatrix(); // final float scale = w / 16.0f; // final float dy = (sections > 1) ? 16.0f : 0.0f; // GL11.glScalef(scale, scale, 1.0f); // CraftGUI.Render.colour(ind.getGenome().getStemColor().getColor(false)); // if (sections > 1) { -// CraftGUI.Render.iconBlock(new IPoint(0.0f, 0.0f), ind.getGenome().getType().getStem(EnumFlowerStage.FLOWER, true, 1)); +// CraftGUI.Render.iconBlock(IPoint.ZERO, ind.getGenome().getType().getStem(EnumFlowerStage.FLOWER, true, 1)); // } -// CraftGUI.Render.iconBlock(new IPoint(0.0f, dy), ind.getGenome().getType().getStem(EnumFlowerStage.FLOWER, true, 0)); +// CraftGUI.Render.iconBlock(new IPoint(0, dy), ind.getGenome().getType().getStem(EnumFlowerStage.FLOWER, true, 0)); // CraftGUI.Render.colour(ind.getGenome().getPrimaryColor().getColor(false)); // if (sections > 1) { -// CraftGUI.Render.iconBlock(new IPoint(0.0f, 0.0f), ind.getGenome().getType().getPetalIcon(EnumFlowerStage.FLOWER, true, 1)); +// CraftGUI.Render.iconBlock(IPoint.ZERO, ind.getGenome().getType().getPetalIcon(EnumFlowerStage.FLOWER, true, 1)); // } -// CraftGUI.Render.iconBlock(new IPoint(0.0f, dy), ind.getGenome().getType().getPetalIcon(EnumFlowerStage.FLOWER, true, 0)); +// CraftGUI.Render.iconBlock(new IPoint(0, dy), ind.getGenome().getType().getPetalIcon(EnumFlowerStage.FLOWER, true, 0)); // CraftGUI.Render.colour(ind.getGenome().getSecondaryColor().getColor(false)); // if (sections > 1) { -// CraftGUI.Render.iconBlock(new IPoint(0.0f, 0.0f), ind.getGenome().getType().getVariantIcon(EnumFlowerStage.FLOWER, true, 1)); +// CraftGUI.Render.iconBlock(IPoint.ZERO, ind.getGenome().getType().getVariantIcon(EnumFlowerStage.FLOWER, true, 1)); // } -// CraftGUI.Render.iconBlock(new IPoint(0.0f, dy), ind.getGenome().getType().getVariantIcon(EnumFlowerStage.FLOWER, true, 0)); +// CraftGUI.Render.iconBlock(new IPoint(0, dy), ind.getGenome().getType().getVariantIcon(EnumFlowerStage.FLOWER, true, 0)); // GL11.glPopMatrix(); } }; diff --git a/src/main/java/binnie/genetics/gui/AnalystPageBehaviour.java b/src/main/java/binnie/genetics/gui/AnalystPageBehaviour.java index cbd815c1..4f91ec30 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageBehaviour.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageBehaviour.java @@ -30,16 +30,16 @@ public class AnalystPageBehaviour extends ControlAnalystPage { final int fertility = bee.getGenome().getFlowering(); new ControlTextCentered(this, y, "Pollinates nearby\n" + bee.getGenome().getFlowerProvider().getDescription()).setColour(this.getColour()); y += 20; - new ControlTextCentered(this, y, "§oEvery " + this.getTimeString(PluginApiculture.ticksPerBeeWorkCycle * 100.0f / fertility)).setColour(this.getColour()); + new ControlTextCentered(this, y, "§oEvery " + this.getTimeString(PluginApiculture.ticksPerBeeWorkCycle * 100 / fertility)).setColour(this.getColour()); y += 22; final IAlleleBeeEffect effect = bee.getGenome().getEffect(); final Vec3i t = bee.getGenome().getTerritory(); if (!effect.getUID().contains("None")) { final String effectDesc = BinnieCore.proxy.localiseOrBlank("allele." + effect.getUID() + ".desc"); final String loc = effectDesc.equals("") ? ("Effect: " + effect.getName()) : effectDesc; - new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 0.0f), loc, TextJustification.TopCenter).setColour(this.getColour()); - y += (int) (CraftGUI.render.textHeight(loc, this.w() - 8.0f) + 1.0f); - new ControlTextCentered(this, y, "§oWithin " + (int) (t.getX() / 2.0f) + " blocks").setColour(this.getColour()); + new ControlText(this, new IArea(4, y, this.w() - 8, 0), loc, TextJustification.TopCenter).setColour(this.getColour()); + y += (int) (CraftGUI.render.textHeight(loc, this.w() - 8) + 1); + new ControlTextCentered(this, y, "§oWithin " + (int) (t.getX() / 2) + " blocks").setColour(this.getColour()); y += 22; } new ControlTextCentered(this, y, "Territory: §o" + t.getX() + "x" + t.getY() + "x" + t.getZ()).setColour(this.getColour()); @@ -51,14 +51,14 @@ public class AnalystPageBehaviour extends ControlAnalystPage { y += 20; new ControlTextCentered(this, y, "Pollinates nearby\n" + bee2.getGenome().getFlowerProvider().getDescription()).setColour(this.getColour()); y += 20; - new ControlTextCentered(this, y, "§oEvery " + this.getTimeString(1500.0f)).setColour(this.getColour()); + new ControlTextCentered(this, y, "§oEvery " + this.getTimeString(1500)).setColour(this.getColour()); y += 22; final IAlleleButterflyEffect effect2 = bee2.getGenome().getEffect(); if (!effect2.getUID().contains("None")) { final String effectDesc2 = BinnieCore.proxy.localiseOrBlank("allele." + effect2.getUID() + ".desc"); final String loc2 = effectDesc2.equals("") ? ("Effect: " + effect2.getName()) : effectDesc2; - new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 0.0f), loc2, TextJustification.TopCenter).setColour(this.getColour()); - y += (int) (CraftGUI.render.textHeight(loc2, this.w() - 8.0f) + 1.0f); + new ControlText(this, new IArea(4, y, this.w() - 8, 0), loc2, TextJustification.TopCenter).setColour(this.getColour()); + y += (int) (CraftGUI.render.textHeight(loc2, this.w() - 8) + 1); y += 22; } } diff --git a/src/main/java/binnie/genetics/gui/AnalystPageBiology.java b/src/main/java/binnie/genetics/gui/AnalystPageBiology.java index 42ff21b5..35c0e83b 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageBiology.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageBiology.java @@ -100,7 +100,7 @@ public class AnalystPageBiology extends ControlAnalystPage { final int fertility = (int) (1.0f / tree.getGenome().getFertility()); new ControlTextCentered(this, y, "1 Sapling per §l" + fertility + "§r leave" + ((fertility > 1) ? "s" : "")).setColour(this.getColour()); y += 22; - final float butterflySpawn = 1365.3999f / (tree.getGenome().getSappiness() * tree.getGenome().getYield() * 0.5f); + final int butterflySpawn = Math.round(1365.3999f / (tree.getGenome().getSappiness() * tree.getGenome().getYield() * 0.5f)); new ControlTextCentered(this, y, "Butterfies spawn every\n" + this.getTimeString(butterflySpawn) + " per leaf").setColour(this.getColour()); y += 34; new ControlTextCentered(this, y, "Plant Types").setColour(this.getColour()); @@ -112,7 +112,7 @@ public class AnalystPageBiology extends ControlAnalystPage { } if (ind instanceof IFlower) { final IFlower flower = (IFlower) ind; - final float butterflySpawn2 = 1365.3999f / (flower.getGenome().getSappiness() * 0.2f); + final int butterflySpawn2 = Math.round(1365.3999f / (flower.getGenome().getSappiness() * 0.2f)); new ControlTextCentered(this, y, "Butterfies spawn every\n" + this.getTimeString(butterflySpawn2)).setColour(this.getColour()); y += 30; float CHANCE_DISPERSAL = 0.8f; diff --git a/src/main/java/binnie/genetics/gui/AnalystPageClimate.java b/src/main/java/binnie/genetics/gui/AnalystPageClimate.java index 9891059a..ec468b48 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageClimate.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageClimate.java @@ -48,17 +48,17 @@ public class AnalystPageClimate extends ControlAnalystPage { int y = 4; new ControlTextCentered(this, y, "§nClimate").setColour(this.getColour()); y += 16; - new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), "Temp. Tolerance", TextJustification.MiddleCenter).setColour(this.getColour()); + new ControlText(this, new IArea(4, y, this.w() - 8, 14), "Temp. Tolerance", TextJustification.MiddleCenter).setColour(this.getColour()); y += 12; - this.createTemperatureBar(this, (this.w() - 100.0f) / 2.0f, y, 100.0f, 10.0f, temp, tempTol); + this.createTemperatureBar(this, (this.w() - 100) / 2, y, 100, 10, temp, tempTol); y += 16; if (!(ind instanceof IFlower)) { - new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), "Humidity Tolerance", TextJustification.MiddleCenter).setColour(this.getColour()); + new ControlText(this, new IArea(4, y, this.w() - 8, 14), "Humidity Tolerance", TextJustification.MiddleCenter).setColour(this.getColour()); y += 12; - this.createHumidity(this, (this.w() - 100.0f) / 2.0f, y, 100.0f, 10.0f, humid, humidTol); + this.createHumidity(this, (this.w() - 100) / 2, y, 100, 10, humid, humidTol); y += 16; } - new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), "Biomes", TextJustification.MiddleCenter).setColour(this.getColour()); + new ControlText(this, new IArea(4, y, this.w() - 8, 14), "Biomes", TextJustification.MiddleCenter).setColour(this.getColour()); y += 12; final List biomes = new ArrayList<>(); for (final Biome biome : Biome.EXPLORATION_BIOMES_LIST) { //TODO check @@ -82,12 +82,12 @@ public class AnalystPageClimate extends ControlAnalystPage { } } } - final int maxBiomePerLine = (int) ((this.w() + 2.0f - 16.0f) / 18.0f); - final float biomeListX = (this.w() - (Math.min(maxBiomePerLine, biomes.size()) * 18 - 2)) / 2.0f; + final int maxBiomePerLine = (this.w() + 2 - 16) / 18; + final int biomeListX = (this.w() - (Math.min(maxBiomePerLine, biomes.size()) * 18 - 2)) / 2; int dx = 0; int dy = 0; for (final Biome biome2 : biomes) { - new ControlBiome(this, biomeListX + dx, y + dy, 16.0f, 16.0f, biome2); + new ControlBiome(this, biomeListX + dx, y + dy, 16, 16, biome2); dx += 18; if (dx >= 18 * maxBiomePerLine) { dx = 0; @@ -97,7 +97,7 @@ public class AnalystPageClimate extends ControlAnalystPage { this.setSize(new IPoint(this.w(), y + dy + 18 + 8)); } - protected void createTemperatureBar(final IWidget parent, final float x, final float y, final float w, final float h, final EnumTemperature value, final EnumTolerance tol) { + protected void createTemperatureBar(final IWidget parent, final int x, final int y, final int w, final int h, final EnumTemperature value, final EnumTolerance tol) { new ControlToleranceBar(parent, x, y, w, h, EnumTemperature.class) { @Override protected String getName(final EnumTemperature value) { @@ -111,7 +111,7 @@ public class AnalystPageClimate extends ControlAnalystPage { }.setValues(value, tol); } - protected void createHumidity(final IWidget parent, final float x, final float y, final float w, final float h, final EnumHumidity value, final EnumTolerance tol) { + protected void createHumidity(final IWidget parent, final int x, final int y, final int w, final int h, final EnumHumidity value, final EnumTolerance tol) { new ControlToleranceBar(parent, x, y, w, h, EnumHumidity.class) { @Override protected String getName(final EnumHumidity value) { diff --git a/src/main/java/binnie/genetics/gui/AnalystPageDatabase.java b/src/main/java/binnie/genetics/gui/AnalystPageDatabase.java index c9842b55..13538f1e 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageDatabase.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageDatabase.java @@ -46,7 +46,7 @@ public class AnalystPageDatabase extends ControlAnalystPage { int y = 4; new ControlTextCentered(this, y, "§nRegistry").setColour(this.getColour()); y += 16; - new ControlTextEdit(this, 20.0f, y, this.w() - 40.0f, 16.0f) { + new ControlTextEdit(this, 20, y, this.w() - 40, 16) { @Override public void onTextEdit(final String value) { final Collection options = new ArrayList<>(); @@ -66,7 +66,7 @@ public class AnalystPageDatabase extends ControlAnalystPage { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.colour(5592405); CraftGUI.render.texture(CraftGUITexture.TabSolid, this.getArea().inset(1)); CraftGUI.render.colour(AnalystPageDatabase.this.getColour()); @@ -75,7 +75,7 @@ public class AnalystPageDatabase extends ControlAnalystPage { } }; y += 22; - new Panel(this, 3.0f, y - 1, this.w() - 6.0f, this.h() - y - 8.0f + 2.0f, MinecraftGUI.PanelType.TabOutline).setColour(this.getColour()); + new Panel(this, 3, y - 1, this.w() - 6, this.h() - y - 8 + 2, MinecraftGUI.PanelType.TabOutline).setColour(this.getColour()); final boolean textView = false; final Collection options = this.getSpecies(system); for (final IAlleleSpecies species : options) { @@ -86,7 +86,7 @@ public class AnalystPageDatabase extends ControlAnalystPage { final String maturation = system.getAlleleName(EnumTreeChromosome.MATURATION, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.MATURATION)); } if (textView) { - this.scroll = new ControlListBox(this, 4.0f, y, this.w() - 8.0f, this.h() - y - 8.0f - 20.0f, 0.0f) { + this.scroll = new ControlListBox(this, 4, y, this.w() - 8, this.h() - y - 8 - 20, 0) { @Override public void initialise() { super.initialise(); @@ -95,22 +95,22 @@ public class AnalystPageDatabase extends ControlAnalystPage { @Override public IWidget createOption(final IAlleleSpecies v, final int y) { - return new Control(this.getContent(), 0.0f, y, this.w(), 12.0f) { + return new Control(this.getContent(), 0, y, this.w(), 12) { IAlleleSpecies value = v; @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.text(this.getArea(), TextJustification.MiddleCenter, this.value.getName(), 16777215); } }; } }; } else { - (this.scroll = new ControlScrollableContent(this, 4.0f, y, this.w() - 8.0f, this.h() - y - 8.0f, 0.0f)).setScrollableContent(this.getItemScrollList(system, options)); + (this.scroll = new ControlScrollableContent(this, 4, y, this.w() - 8, this.h() - y - 8, 0)).setScrollableContent(this.getItemScrollList(system, options)); } - new ControlScrollBar(this, this.scroll.x() + this.scroll.w() - 6.0f, this.scroll.y() + 3.0f, 3.0f, this.scroll.h() - 6.0f, this.scroll) { + new ControlScrollBar(this, this.scroll.x() + this.scroll.w() - 6, this.scroll.y() + 3, 3, this.scroll.h() - 6, this.scroll) { @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { if (!this.isEnabled()) { return; } @@ -121,11 +121,11 @@ public class AnalystPageDatabase extends ControlAnalystPage { } private IWidget getItemScrollList(final BreedingSystem system, final Collection options) { - return new Control(this.scroll, 0.0f, 0.0f, this.scroll.w(), this.scroll.h()) { + return new Control(this.scroll, 0, 0, this.scroll.w(), this.scroll.h()) { @Override public void initialise() { - final int maxBiomePerLine = (int) ((this.w() - 4.0f + 2.0f) / 18.0f); - final float biomeListX = -6.0f + (this.w() - (maxBiomePerLine * 18 - 2)) / 2.0f; + final int maxBiomePerLine = (this.w() - 4 + 2) / 18; + final int biomeListX = -6 + (this.w() - (maxBiomePerLine * 18 - 2)) / 2; int dx = 0; int dy = 0; for (final IAlleleSpecies species : options) { @@ -143,7 +143,7 @@ public class AnalystPageDatabase extends ControlAnalystPage { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { final WindowAnalyst window = (WindowAnalyst) AnalystPageDatabase.this.getSuperParent(); if (window.getIndividual() != null && window.getIndividual().getGenome().getPrimary() == species) { CraftGUI.render.colour(15658734); @@ -154,7 +154,7 @@ public class AnalystPageDatabase extends ControlAnalystPage { CraftGUI.render.colour(15658734); CraftGUI.render.texture(CraftGUITexture.TabSolid, this.getArea().outset(1)); } - super.onRenderBackground(); + super.onRenderBackground(guiWidth, guiHeight); } }; dx += 18; diff --git a/src/main/java/binnie/genetics/gui/AnalystPageDescription.java b/src/main/java/binnie/genetics/gui/AnalystPageDescription.java index fb2038d0..a2d0c770 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageDescription.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageDescription.java @@ -55,13 +55,13 @@ public class AnalystPageDescription extends ControlAnalystPage { y += (int) (3.0f + CraftGUI.render.textHeight("Discovered by §l" + authority + "§r", this.w())); new ControlTextCentered(this, y, "Genetic Complexity: " + species.getComplexity()).setColour(this.getColour()); y += 26; - final ControlText descText = new ControlText(this, new IArea(8.0f, y, this.w() - 16.0f, 0.0f), descBody + "§r", TextJustification.TopCenter); - final IWidget signatureText = new ControlText(this, new IArea(8.0f, y, this.w() - 16.0f, 0.0f), descSig + "§r", TextJustification.BottomRight); + final ControlText descText = new ControlText(this, new IArea(8, y, this.w() - 16, 0), descBody + "§r", TextJustification.TopCenter); + final IWidget signatureText = new ControlText(this, new IArea(8, y, this.w() - 16, 0), descSig + "§r", TextJustification.BottomRight); descText.setColour(this.getColour()); signatureText.setColour(this.getColour()); - final float descHeight = CraftGUI.render.textHeight(descText.getValue(), descText.getSize().x()); - signatureText.setPosition(new IPoint(signatureText.pos().x(), descText.getPosition().y() + descHeight + 10.0f)); - this.setSize(new IPoint(this.w(), 20.0f + signatureText.y())); + final int descHeight = CraftGUI.render.textHeight(descText.getValue(), descText.getSize().x()); + signatureText.setPosition(new IPoint(signatureText.pos().x(), descText.getPosition().y() + descHeight + 10)); + this.setSize(new IPoint(this.w(), 20 + signatureText.y())); } @Override diff --git a/src/main/java/binnie/genetics/gui/AnalystPageFruit.java b/src/main/java/binnie/genetics/gui/AnalystPageFruit.java index 6bd99ccf..e04180b2 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageFruit.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageFruit.java @@ -57,7 +57,7 @@ public class AnalystPageFruit extends AnalystPageProduce { final int w = products.size() * 18 - 2; final int i = 0; for (final ItemStack stack : products) { - final ControlItemDisplay d = new ControlItemDisplay(this, (this.w() - w) / 2.0f + 18 * i, y); + final ControlItemDisplay d = new ControlItemDisplay(this, (this.w() - w) / 2 + 18 * i, y); d.setTooltip(); d.setItemStack(stack); } @@ -69,7 +69,7 @@ public class AnalystPageFruit extends AnalystPageProduce { final int w = products.size() * 18 - 2; final int i = 0; for (final ItemStack stack : specialties) { - final ControlItemDisplay d = new ControlItemDisplay(this, (this.w() - w) / 2.0f + 18 * i, y); + final ControlItemDisplay d = new ControlItemDisplay(this, (this.w() - w) / 2 + 18 * i, y); d.setTooltip(); d.setItemStack(stack); } diff --git a/src/main/java/binnie/genetics/gui/AnalystPageGenome.java b/src/main/java/binnie/genetics/gui/AnalystPageGenome.java index 604c32ae..3f8d62b3 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageGenome.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageGenome.java @@ -29,26 +29,26 @@ public class AnalystPageGenome extends ControlAnalystPage { y += 16; final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(ind.getClass()); final BreedingSystem system = Binnie.GENETICS.getSystem(root); - final Control scaled = new Control(this, 0.0f, y, 0.0f, 0.0f) { + final Control scaled = new Control(this, 0, y, 0, 0) { @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { GL11.glPushMatrix(); GL11.glTranslatef(10.0f, -15.0f, 0.0f); GL11.glScalef(0.9f, 0.95f, 1.0f); } @Override - public void onRenderForeground() { + public void onRenderForeground(int guiWidth, int guiHeight) { GL11.glPopMatrix(); } }; for (final IChromosomeType chromo : system.getActiveKaryotype()) { final IAllele allele = active ? ind.getGenome().getActiveAllele(chromo) : ind.getGenome().getInactiveAllele(chromo); final String alleleName = system.getAlleleName(chromo, allele); - final float height = CraftGUI.render.textHeight(alleleName, this.w() / 2.0f - 2.0f); - new ControlText(scaled, new IArea(0.0f, y + (height - 9.0f) / 2.0f, this.w() / 2.0f - 2.0f, 0.0f), system.getChromosomeShortName(chromo) + " :", TextJustification.TopRight).setColour(this.getColour()); - new ControlText(scaled, new IArea(this.w() / 2.0f + 2.0f, y, this.w() / 2.0f - 2.0f, 0.0f), alleleName, TextJustification.TopLeft).setColour(this.getColour()); - y += (int) (3.0f + height); + final int height = CraftGUI.render.textHeight(alleleName, this.w() / 2 - 2); + new ControlText(scaled, new IArea(0, y + (height - 9) / 2, this.w() / 2 - 2, 0), system.getChromosomeShortName(chromo) + " :", TextJustification.TopRight).setColour(this.getColour()); + new ControlText(scaled, new IArea(this.w() / 2 + 2, y, this.w() / 2 - 2, 0), alleleName, TextJustification.TopLeft).setColour(this.getColour()); + y += 3 + height; } this.setSize(new IPoint(this.w(), y + 8)); } diff --git a/src/main/java/binnie/genetics/gui/AnalystPageGrowth.java b/src/main/java/binnie/genetics/gui/AnalystPageGrowth.java index f9c9d962..afc297a0 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageGrowth.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageGrowth.java @@ -22,7 +22,7 @@ public class AnalystPageGrowth extends ControlAnalystPage { final int mat = tree.getGenome().getMaturationTime(); new ControlTextCentered(this, y, "Saplings mature in").setColour(this.getColour()); y += 12; - new ControlTextCentered(this, y, "§l" + this.getTimeString(1373.3999f * mat)).setColour(this.getColour()); + new ControlTextCentered(this, y, "§l" + this.getTimeString(Math.round(1373.3999f * mat))).setColour(this.getColour()); y += 22; new ControlTextCentered(this, y, "§oHeight: " + Binnie.GENETICS.treeBreedingSystem.getAlleleName(EnumTreeChromosome.HEIGHT, ind.getGenome().getActiveAllele(EnumTreeChromosome.HEIGHT))).setColour(this.getColour()); y += 12; diff --git a/src/main/java/binnie/genetics/gui/AnalystPageKaryogram.java b/src/main/java/binnie/genetics/gui/AnalystPageKaryogram.java index 2bc0ef47..46a13469 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageKaryogram.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageKaryogram.java @@ -21,7 +21,7 @@ public class AnalystPageKaryogram extends ControlAnalystPage { final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(ind.getClass()); final BreedingSystem system = Binnie.GENETICS.getSystem(root); final int maxBiomePerLine = (int) ((this.w() + 4.0f - 16.0f) / 22.0f); - float karygramX = (this.w() - (Math.min(maxBiomePerLine, system.getActiveKaryotype().size()) * 18 - 4)) / 2.0f; + int karygramX = (this.w() - (Math.min(maxBiomePerLine, system.getActiveKaryotype().size()) * 18 - 4)) / 2; int dx = 0; int dy = 0; int rem = system.getActiveKaryotype().size(); diff --git a/src/main/java/binnie/genetics/gui/AnalystPageMutations.java b/src/main/java/binnie/genetics/gui/AnalystPageMutations.java index ebcea074..7814daf0 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageMutations.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageMutations.java @@ -9,6 +9,7 @@ import binnie.craftgui.controls.core.Control; import binnie.craftgui.core.Attribute; import binnie.craftgui.core.CraftGUI; import binnie.craftgui.core.IWidget; +import binnie.craftgui.core.geometry.CraftGUIUtil; import binnie.craftgui.core.geometry.IArea; import binnie.craftgui.core.geometry.IPoint; import binnie.craftgui.core.geometry.TextJustification; @@ -88,7 +89,7 @@ public class AnalystPageMutations extends ControlAnalystPage { } else if (hive != null) { new ControlTextCentered(this, y, "Natural Habitat").setColour(this.getColour()); y += 10; - final ControlItemDisplay display = new ControlItemDisplay(this, (this.w() - 16.0f) / 2.0f, y); + final ControlItemDisplay display = new ControlItemDisplay(this, (this.w() - 16) / 2, y); if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Steadfast.getAllele()) { display.addTooltip("Dungeon Chests"); } else { @@ -98,20 +99,20 @@ public class AnalystPageMutations extends ControlAnalystPage { y += 24; } } - float ox = (this.w() - 88.0f - 8.0f) / 2.0f; - float dx = 0.0f; + int ox = (this.w() - 88 - 8) / 2; + int dx = 0; if (!resultant.isEmpty()) { if (resultant.size() == 1) { - ox = (this.w() - 44.0f) / 2.0f; + ox = (this.w() - 44) / 2; } new ControlTextCentered(this, y, "Resultant Mutations").setColour(this.getColour()); y += 10; for (final IMutation mutation : resultant) { final float specificChance = this.getSpecificChance(ind, mutation, system); if (!isMaster && !this.isKnown(system, mutation)) { - new ControlUnknownMutation(this, ox + dx, y, 44.0f, 16.0f); + new ControlUnknownMutation(this, ox + dx, y, 44, 16); } else { - new Control(this, ox + dx, y, 44.0f, 16.0f) { + new Control(this, ox + dx, y, 44, 16) { @Override public void initialise() { final IAlleleSpecies species0 = mutation.getAllele0(); @@ -129,36 +130,36 @@ public class AnalystPageMutations extends ControlAnalystPage { } @Override - public void onRenderBackground() { - CraftGUI.render.item(new IPoint(0.0f, 0.0f), system.getDefaultMember(mutation.getAllele0().getUID())); - CraftGUI.render.item(new IPoint(28.0f, 0.0f), system.getDefaultMember(mutation.getAllele1().getUID())); + public void onRenderBackground(int guiWidth, int guiHeight) { + CraftGUIUtil.renderItem(IPoint.ZERO, system.getDefaultMember(mutation.getAllele0().getUID())); + CraftGUIUtil.renderItem(new IPoint(28, 0), system.getDefaultMember(mutation.getAllele1().getUID())); if (specificChance != mutation.getBaseChance()) { CraftGUI.render.colour(AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getColour()); - //CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconAdd0.getIcon()); + //CraftGUI.Render.iconItem(new IPoint(14, 0), ModuleItem.iconAdd0.getIcon()); CraftGUI.render.colour(AnalystPageMutations.this.getMutationColour(specificChance).getColour()); - //CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconAdd1.getIcon()); + //CraftGUI.Render.iconItem(new IPoint(14, 0), ModuleItem.iconAdd1.getIcon()); } else { CraftGUI.render.colour(AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getColour()); - //CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconAdd.getIcon()); + //CraftGUI.Render.iconItem(new IPoint(14, 0), ModuleItem.iconAdd.getIcon()); } } }; } - dx = 52.0f - dx; - if (dx == 0.0f || resultant.size() == 1) { + dx = 52 - dx; + if (dx == 0 || resultant.size() == 1) { y += 18; } } - if (dx != 0.0f && resultant.size() != 1) { + if (dx != 0 && resultant.size() != 1) { y += 18; } y += 10; } - ox = (this.w() - 88.0f - 8.0f) / 2.0f; - dx = 0.0f; + ox = (this.w() - 88 - 8) / 2; + dx = 0; if (!further.isEmpty()) { if (further.size() == 1) { - ox = (this.w() - 44.0f) / 2.0f; + ox = (this.w() - 44) / 2; } new ControlTextCentered(this, y, "Further Mutations").setColour(this.getColour()); y += 10; @@ -166,9 +167,9 @@ public class AnalystPageMutations extends ControlAnalystPage { final IAllele speciesComb = mutation.getPartner(speciesCurrent); final float specificChance2 = this.getSpecificChance(ind, mutation, system); if (!isMaster && !this.isKnown(system, mutation)) { - new ControlUnknownMutation(this, ox + dx, y, 44.0f, 16.0f); + new ControlUnknownMutation(this, ox + dx, y, 44, 16); } else { - new Control(this, ox + dx, y, 44.0f, 16.0f) { + new Control(this, ox + dx, y, 44, 16) { @Override public void initialise() { final IAlleleSpecies species0 = (IAlleleSpecies) speciesComb; @@ -187,28 +188,28 @@ public class AnalystPageMutations extends ControlAnalystPage { } @Override - public void onRenderBackground() { - CraftGUI.render.item(new IPoint(0.0f, 0.0f), system.getDefaultMember(speciesComb.getUID())); - CraftGUI.render.item(new IPoint(28.0f, 0.0f), system.getDefaultMember(mutation.getTemplate()[0].getUID())); + public void onRenderBackground(int guiWidth, int guiHeight) { + CraftGUIUtil.renderItem(IPoint.ZERO, system.getDefaultMember(speciesComb.getUID())); + CraftGUIUtil.renderItem(new IPoint(28, 0), system.getDefaultMember(mutation.getTemplate()[0].getUID())); CraftGUI.render.colour(AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getColour()); if (specificChance2 != mutation.getBaseChance()) { CraftGUI.render.colour(AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getColour()); - //CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconArrow0.getIcon()); + //CraftGUI.Render.iconItem(new IPoint(14, 0), ModuleItem.iconArrow0.getIcon()); CraftGUI.render.colour(AnalystPageMutations.this.getMutationColour(specificChance2).getColour()); - //CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconArrow1.getIcon()); + //CraftGUI.Render.iconItem(new IPoint(14, 0), ModuleItem.iconArrow1.getIcon()); } else { CraftGUI.render.colour(AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getColour()); - //CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconArrow.getIcon()); + //CraftGUI.Render.iconItem(new IPoint(14, 0), ModuleItem.iconArrow.getIcon()); } } }; } - dx = 52.0f - dx; - if (dx == 0.0f || further.size() == 1) { + dx = 52 - dx; + if (dx == 0 || further.size() == 1) { y += 18; } } - if (dx != 0.0f && further.size() != 1) { + if (dx != 0 && further.size() != 1) { y += 18; } } @@ -249,14 +250,14 @@ public class AnalystPageMutations extends ControlAnalystPage { } static class ControlUnknownMutation extends Control { - public ControlUnknownMutation(final IWidget parent, final float x, final float y, final float w, final float h) { + public ControlUnknownMutation(final IWidget parent, final int x, final int y, final int w, final int h) { super(parent, x, y, w, h); this.addAttribute(Attribute.MouseOver); this.addTooltip("Unknown Mutation"); } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.text(this.getArea(), TextJustification.MiddleCenter, "UNKNOWN", 11184810); } } diff --git a/src/main/java/binnie/genetics/gui/AnalystPageProduce.java b/src/main/java/binnie/genetics/gui/AnalystPageProduce.java index 8ff7f9f8..da8a4c94 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageProduce.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageProduce.java @@ -211,8 +211,8 @@ public abstract class AnalystPageProduce extends ControlAnalystPage { protected int getRefined(final String string, int y, final Collection products) { new ControlTextCentered(this, y, string).setColour(this.getColour()); y += 10; - final int maxBiomePerLine = (int) ((this.w() + 2.0f - 16.0f) / 18.0f); - final float biomeListX = (this.w() - (Math.min(maxBiomePerLine, products.size()) * 18 - 2)) / 2.0f; + final int maxBiomePerLine = (this.w() + 2 - 16) / 18; + final int biomeListX = (this.w() - (Math.min(maxBiomePerLine, products.size()) * 18 - 2)) / 2; int dx = 0; int dy = 0; for (final ItemStack soilStack : products) { diff --git a/src/main/java/binnie/genetics/gui/AnalystPageProducts.java b/src/main/java/binnie/genetics/gui/AnalystPageProducts.java index 3e213e00..cc71db10 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageProducts.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageProducts.java @@ -100,7 +100,7 @@ public class AnalystPageProducts extends AnalystPageProduce { } } final int maxBiomePerLine = (int) ((this.w() + 2.0f - 16.0f) / 18.0f); - final float biomeListX = (this.w() - (Math.min(maxBiomePerLine, allFluids.size() + refinedProducts.size()) * 18 - 2)) / 2.0f; + final int biomeListX = (this.w() - (Math.min(maxBiomePerLine, allFluids.size() + refinedProducts.size()) * 18 - 2)) / 2; int dx = 0; int dy = 0; for (final ItemStack soilStack : refinedProducts) { @@ -152,7 +152,7 @@ public class AnalystPageProducts extends AnalystPageProduce { } private void createProductEntry(final ItemStack key, final Float value, final int y, final float speed) { - final ControlItemDisplay item = new ControlItemDisplay(this, 16.0f, y) { + final ControlItemDisplay item = new ControlItemDisplay(this, 16, y) { @Override public void getTooltip(final Tooltip tooltip) { super.getTooltip(tooltip); @@ -179,9 +179,9 @@ public class AnalystPageProducts extends AnalystPageProduce { item.setTooltip(); final ControlText textWidget = new ControlTextCentered(this, y + 4, ""); textWidget.setColour(this.getColour()); - CraftGUIUtil.moveWidget(textWidget, new IPoint(12.0f, 0.0f)); + CraftGUIUtil.moveWidget(textWidget, new IPoint(12, 0)); item.setItemStack(key); - final float time = (int) (PluginApiculture.ticksPerBeeWorkCycle * 100.0 / (speed * value)); + final int time = (int) (PluginApiculture.ticksPerBeeWorkCycle * 100.0 / (speed * value)); textWidget.setValue(Genetics.proxy.localise("gui.analyst.products.every") + " " + this.getTimeString(time)); } diff --git a/src/main/java/binnie/genetics/gui/AnalystPageSoil.java b/src/main/java/binnie/genetics/gui/AnalystPageSoil.java index 13360805..70bba4b7 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageSoil.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageSoil.java @@ -32,15 +32,15 @@ public class AnalystPageSoil extends ControlAnalystPage { int y = 4; new ControlTextCentered(this, y, TextFormatting.UNDERLINE + getTitle()).setColour(this.getColour()); y += 16; - new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), Genetics.proxy.localise("gui.analyst.soil.tolerance.moisture"), TextJustification.MiddleCenter).setColour(this.getColour()); + new ControlText(this, new IArea(4, y, this.w() - 8, 14), Genetics.proxy.localise("gui.analyst.soil.tolerance.moisture"), TextJustification.MiddleCenter).setColour(this.getColour()); y += 12; - this.createMoisture(this, (this.w() - 100.0f) / 2.0f, y, 100.0f, 10.0f, moisture, moistureTol); + this.createMoisture(this, (this.w() - 100) / 2, y, 100, 10, moisture, moistureTol); y += 16; - new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), Genetics.proxy.localise("gui.analyst.soil.tolerance.ph"), TextJustification.MiddleCenter).setColour(this.getColour()); + new ControlText(this, new IArea(4, y, this.w() - 8, 14), Genetics.proxy.localise("gui.analyst.soil.tolerance.ph"), TextJustification.MiddleCenter).setColour(this.getColour()); y += 12; - this.createAcidity(this, (this.w() - 100.0f) / 2.0f, y, 100.0f, 10.0f, pH, pHTol); + this.createAcidity(this, (this.w() - 100) / 2, y, 100, 10, pH, pHTol); y += 16; - new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), Genetics.proxy.localise("gui.analyst.soil.recommended"), TextJustification.MiddleCenter).setColour(this.getColour()); + new ControlText(this, new IArea(4, y, this.w() - 8, 14), Genetics.proxy.localise("gui.analyst.soil.recommended"), TextJustification.MiddleCenter).setColour(this.getColour()); y += 12; EnumMoisture recomMoisture = EnumMoisture.Normal; final boolean canTolNormal = Tolerance.canTolerate(moisture, EnumMoisture.Normal, moistureTol); @@ -79,11 +79,11 @@ public class AnalystPageSoil extends ControlAnalystPage { } } final ItemStack stack = new ItemStack(Botany.soil, 1, BlockSoil.getMeta(recomPH, recomMoisture)); - final ControlItemDisplay recomSoil = new ControlItemDisplay(this, (this.w() - 24.0f) / 2.0f, y, 24.0f); + final ControlItemDisplay recomSoil = new ControlItemDisplay(this, (this.w() - 24) / 2, y, 24); recomSoil.setItemStack(stack); recomSoil.setTooltip(); y += 32; - new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), Genetics.proxy.localise("gui.analyst.soil.other"), TextJustification.MiddleCenter).setColour(this.getColour()); + new ControlText(this, new IArea(4, y, this.w() - 8, 14), Genetics.proxy.localise("gui.analyst.soil.other"), TextJustification.MiddleCenter).setColour(this.getColour()); y += 12; final List stacks = new ArrayList<>(); for (final EnumAcidity a : EnumSet.range(EnumAcidity.Acid, EnumAcidity.Alkaline)) { @@ -93,8 +93,8 @@ public class AnalystPageSoil extends ControlAnalystPage { } } } - final float soilListWidth = 17 * stacks.size() - 1; - final float soilListX = (this.w() - soilListWidth) / 2.0f; + final int soilListWidth = 17 * stacks.size() - 1; + final int soilListX = (this.w() - soilListWidth) / 2; int t = 0; for (final ItemStack soilStack : stacks) { final ControlItemDisplay display = new ControlItemDisplay(this, soilListX + 17 * t++, y); @@ -103,7 +103,7 @@ public class AnalystPageSoil extends ControlAnalystPage { } } - protected void createMoisture(final IWidget parent, final float x, final float y, final float w, final float h, final EnumMoisture value, final EnumTolerance tol) { + protected void createMoisture(final IWidget parent, final int x, final int y, final int w, final int h, final EnumMoisture value, final EnumTolerance tol) { new ControlToleranceBar(parent, x, y, w, h, EnumMoisture.class) { @Override protected String getName(final EnumMoisture value) { @@ -117,7 +117,7 @@ public class AnalystPageSoil extends ControlAnalystPage { }.setValues(value, tol); } - protected void createAcidity(final IWidget parent, final float x, final float y, final float w, final float h, final EnumAcidity value, final EnumTolerance tol) { + protected void createAcidity(final IWidget parent, final int x, final int y, final int w, final int h, final EnumAcidity value, final EnumTolerance tol) { new ControlToleranceBar(parent, x, y, w, h, EnumAcidity.class) { @Override protected String getName(final EnumAcidity value) { diff --git a/src/main/java/binnie/genetics/gui/AnalystPageSpecimen.java b/src/main/java/binnie/genetics/gui/AnalystPageSpecimen.java index 4d563d91..c2c8256d 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageSpecimen.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageSpecimen.java @@ -14,8 +14,8 @@ public class AnalystPageSpecimen extends ControlAnalystPage { int y = 4; new ControlTextCentered(this, y, TextFormatting.UNDERLINE + getTitle()).setColour(this.getColour()); y += 12; - final float w = (this.w() - 16.0f) * ind.getSize(); - new ControlIndividualDisplay(this, (this.w() - w) / 2.0f, y + (this.w() - w) / 2.0f, w, ind); + final int w = Math.round((this.w() - 16) * ind.getSize()); + new ControlIndividualDisplay(this, (this.w() - w) / 2, y + (this.w() - w) / 2, w, ind); } @Override diff --git a/src/main/java/binnie/genetics/gui/AnalystPageWood.java b/src/main/java/binnie/genetics/gui/AnalystPageWood.java index 2b9c092a..4eb96c35 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageWood.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageWood.java @@ -46,7 +46,7 @@ public class AnalystPageWood extends AnalystPageProduce { final int w = products.size() * 18 - 2; final int i = 0; for (final ItemStack stack : products) { - final ControlItemDisplay d = new ControlItemDisplay(this, (this.w() - w) / 2.0f + 18 * i, y); + final ControlItemDisplay d = new ControlItemDisplay(this, (this.w() - w) / 2 + 18 * i, y); d.setTooltip(); d.setItemStack(stack); } diff --git a/src/main/java/binnie/genetics/gui/ControlAnalystChromosome.java b/src/main/java/binnie/genetics/gui/ControlAnalystChromosome.java index 00698e1b..a47f6b27 100644 --- a/src/main/java/binnie/genetics/gui/ControlAnalystChromosome.java +++ b/src/main/java/binnie/genetics/gui/ControlAnalystChromosome.java @@ -24,8 +24,8 @@ public class ControlAnalystChromosome extends Control implements ITooltip { Texture Homozygous; Texture Heterozygous; - public ControlAnalystChromosome(final IWidget parent, final float x, final float y, final ISpeciesRoot root, final IChromosomeType type, final IAllele allele0, final IAllele allele1) { - super(parent, x, y, 16.0f, 22.0f); + public ControlAnalystChromosome(final IWidget parent, final int x, final int y, final ISpeciesRoot root, final IChromosomeType type, final IAllele allele0, final IAllele allele1) { + super(parent, x, y, 16, 22); this.Homozygous = new StandardTexture(0, 0, 16, 22, BinnieCoreTexture.GUIAnalyst); this.Heterozygous = new StandardTexture(16, 0, 16, 22, BinnieCoreTexture.GUIAnalyst); this.addAttribute(Attribute.MouseOver); @@ -40,8 +40,8 @@ public class ControlAnalystChromosome extends Control implements ITooltip { } @Override - public void onRenderBackground() { - super.onRenderBackground(); + public void onRenderBackground(int guiWidth, int guiHeight) { + super.onRenderBackground(guiWidth, guiHeight); CraftGUI.render.texture(this.isHomozygous() ? this.Homozygous : this.Heterozygous, IPoint.ZERO); } diff --git a/src/main/java/binnie/genetics/gui/ControlAnalystPage.java b/src/main/java/binnie/genetics/gui/ControlAnalystPage.java index dd452698..abd4ed05 100644 --- a/src/main/java/binnie/genetics/gui/ControlAnalystPage.java +++ b/src/main/java/binnie/genetics/gui/ControlAnalystPage.java @@ -13,20 +13,20 @@ public abstract class ControlAnalystPage extends Control { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { } public abstract String getTitle(); - protected String getTimeString(final float time) { - final float seconds = time / 20.0f; - final float minutes = seconds / 60.0f; - final float hours = minutes / 60.0f; + protected String getTimeString(final int time) { + final int seconds = time / 20; + final int minutes = seconds / 60; + final int hours = minutes / 60; final DecimalFormat df = new DecimalFormat("#.0"); - if (hours > 1.0f) { + if (hours > 1) { return df.format(hours) + " hours"; } - if (minutes > 1.0f) { + if (minutes > 1) { return df.format(minutes) + " min."; } return df.format(seconds) + " sec."; diff --git a/src/main/java/binnie/genetics/gui/ControlBiome.java b/src/main/java/binnie/genetics/gui/ControlBiome.java index 196875ef..98637c38 100644 --- a/src/main/java/binnie/genetics/gui/ControlBiome.java +++ b/src/main/java/binnie/genetics/gui/ControlBiome.java @@ -11,7 +11,7 @@ public class ControlBiome extends Control implements ITooltip { Biome biome; String iconCategory; - public ControlBiome(final IWidget parent, final float x, final float y, final float w, final float h, final Biome biome) { + public ControlBiome(final IWidget parent, final int x, final int y, final int w, final int h, final Biome biome) { super(parent, x, y, w, h); this.biome = null; this.iconCategory = "plains"; @@ -19,7 +19,7 @@ public class ControlBiome extends Control implements ITooltip { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.MOUNTAIN)) { this.iconCategory = "hills"; } diff --git a/src/main/java/binnie/genetics/gui/ControlChromoPicker.java b/src/main/java/binnie/genetics/gui/ControlChromoPicker.java index 7b0b391e..f8bc2562 100644 --- a/src/main/java/binnie/genetics/gui/ControlChromoPicker.java +++ b/src/main/java/binnie/genetics/gui/ControlChromoPicker.java @@ -20,8 +20,8 @@ public class ControlChromoPicker extends Control implements ITooltip { IChromosomeType type; ControlChromosome parent; - public ControlChromoPicker(final ControlChromosome parent, final float x, final float y, final IChromosomeType chromo) { - super(parent, x, y, 16.0f, 16.0f); + public ControlChromoPicker(final ControlChromosome parent, final int x, final int y, final IChromosomeType chromo) { + super(parent, x, y, 16, 16); this.Selected = new StandardTexture(160, 18, 16, 16, ExtraBeeTexture.GUIPunnett); this.Texture = new StandardTexture(160, 34, 16, 16, ExtraBeeTexture.GUIPunnett); this.type = chromo; @@ -42,8 +42,8 @@ public class ControlChromoPicker extends Control implements ITooltip { } @Override - public void onRenderBackground() { - super.onRenderBackground(); + public void onRenderBackground(int guiWidth, int guiHeight) { + super.onRenderBackground(guiWidth, guiHeight); final boolean selected = this.isMouseOver(); final Texture text = selected ? this.Selected : this.Texture; CraftGUI.render.texture(text, IPoint.ZERO); diff --git a/src/main/java/binnie/genetics/gui/ControlChromosome.java b/src/main/java/binnie/genetics/gui/ControlChromosome.java index 5f4591ed..559600f8 100644 --- a/src/main/java/binnie/genetics/gui/ControlChromosome.java +++ b/src/main/java/binnie/genetics/gui/ControlChromosome.java @@ -24,8 +24,8 @@ public class ControlChromosome extends Control implements IControlValue { } @Override - public void onRenderBackground() { - super.onRenderBackground(); - CraftGUI.render.text(new IArea(0.0f, 0.0f, 70.0f, 22.0f), TextJustification.MiddleCenter, this.getChromosomeName(), this.getColour()); - CraftGUI.render.text(new IArea(75.0f, 0.0f, 80.0f, 22.0f), TextJustification.MiddleCenter, this.getAlleleName(), this.getColour()); - CraftGUI.render.solid(new IArea(70.0f, 2.0f, 1.0f, 16.0f), -16777216 + this.getColour()); + public void onRenderBackground(int guiWidth, int guiHeight) { + super.onRenderBackground(guiWidth, guiHeight); + CraftGUI.render.text(new IArea(0, 0, 70, 22), TextJustification.MiddleCenter, this.getChromosomeName(), this.getColour()); + CraftGUI.render.text(new IArea(75, 0, 80, 22), TextJustification.MiddleCenter, this.getAlleleName(), this.getColour()); + CraftGUI.render.solid(new IArea(70, 2, 1, 16), -16777216 + this.getColour()); } } diff --git a/src/main/java/binnie/genetics/gui/ControlIndividualDisplay.java b/src/main/java/binnie/genetics/gui/ControlIndividualDisplay.java index 55687d72..56c93454 100644 --- a/src/main/java/binnie/genetics/gui/ControlIndividualDisplay.java +++ b/src/main/java/binnie/genetics/gui/ControlIndividualDisplay.java @@ -11,11 +11,11 @@ import forestry.api.genetics.IIndividual; import net.minecraft.item.ItemStack; public class ControlIndividualDisplay extends ControlItemDisplay implements ITooltip { - public ControlIndividualDisplay(final IWidget parent, final float x, final float y, final IIndividual ind) { - this(parent, x, y, 16.0f, ind); + public ControlIndividualDisplay(final IWidget parent, final int x, final int y, final IIndividual ind) { + this(parent, x, y, 16, ind); } - public ControlIndividualDisplay(final IWidget parent, final float x, final float y, final float size, final IIndividual ind) { + public ControlIndividualDisplay(final IWidget parent, final int x, final int y, final int size, final IIndividual ind) { super(parent, x, y, size); final BreedingSystem system = Binnie.GENETICS.getSystem(ind.getGenome().getSpeciesRoot()); this.setItemStack(system.getSpeciesRoot().getMemberStack(ind, system.getDefaultType())); diff --git a/src/main/java/binnie/genetics/gui/ControlToleranceBar.java b/src/main/java/binnie/genetics/gui/ControlToleranceBar.java index 9a9887c9..98a04f2d 100644 --- a/src/main/java/binnie/genetics/gui/ControlToleranceBar.java +++ b/src/main/java/binnie/genetics/gui/ControlToleranceBar.java @@ -20,7 +20,7 @@ public abstract class ControlToleranceBar> extends Control imp EnumSet tolerated; EnumSet fullSet; - public ControlToleranceBar(final IWidget parent, final float x, final float y, final float width, final float height, final Class clss) { + public ControlToleranceBar(final IWidget parent, final int x, final int y, final int width, final int height, final Class clss) { super(parent, x, y, width, height); this.addAttribute(Attribute.MouseOver); this.enumClass = clss; @@ -47,14 +47,14 @@ public abstract class ControlToleranceBar> extends Control imp protected abstract int getColour(final T p0); @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.gradientRect(this.getArea(), -1431655766, -1431655766); - final float w = this.getArea().w() / this.fullSet.size(); + final int w = this.getArea().w() / this.fullSet.size(); int t = 0; for (final T value : this.fullSet) { final int col = (this.tolerated.contains(value) ? -16777216 : 855638016) + this.getColour(value); - final IBorder inset = new IBorder(this.tolerated.contains(value) ? 1.0f : 3.0f); - CraftGUI.render.gradientRect(new IArea(w * t, 0.0f, w, this.h()).inset(inset), col, col); + final IBorder inset = new IBorder(this.tolerated.contains(value) ? 1 : 3); + CraftGUI.render.gradientRect(new IArea(w * t, 0, w, this.h()).inset(inset), col, col); ++t; } } diff --git a/src/main/java/binnie/genetics/gui/ControlTooltip.java b/src/main/java/binnie/genetics/gui/ControlTooltip.java index 8f2c32ef..26445ac2 100644 --- a/src/main/java/binnie/genetics/gui/ControlTooltip.java +++ b/src/main/java/binnie/genetics/gui/ControlTooltip.java @@ -6,7 +6,7 @@ import binnie.craftgui.core.IWidget; import binnie.craftgui.core.Tooltip; public class ControlTooltip extends Control implements ITooltip { - public ControlTooltip(final IWidget parent, final float x, final float y, final float w, final float h) { + public ControlTooltip(final IWidget parent, final int x, final int y, final int w, final int h) { super(parent, x, y, w, h); } diff --git a/src/main/java/binnie/genetics/gui/WindowAnalyst.java b/src/main/java/binnie/genetics/gui/WindowAnalyst.java index d66a485b..1fdff7ca 100644 --- a/src/main/java/binnie/genetics/gui/WindowAnalyst.java +++ b/src/main/java/binnie/genetics/gui/WindowAnalyst.java @@ -14,6 +14,7 @@ import binnie.craftgui.core.CraftGUI; import binnie.craftgui.core.IWidget; import binnie.craftgui.core.Tooltip; import binnie.craftgui.core.Widget; +import binnie.craftgui.core.geometry.CraftGUIUtil; import binnie.craftgui.core.geometry.IArea; import binnie.craftgui.core.geometry.IPoint; import binnie.craftgui.core.geometry.Position; @@ -68,7 +69,7 @@ public class WindowAnalyst extends Window { } public WindowAnalyst(final EntityPlayer player, final IInventory inventory, final Side side, final boolean database, final boolean master) { - super(312.0f, 230.0f, player, inventory, side); + super(312, 230, player, inventory, side); this.baseWidget = null; this.tabBar = null; this.analystPages = new ArrayList<>(); @@ -131,7 +132,7 @@ public class WindowAnalyst extends Window { final int y = 28; if (this.isDatabase) { for (final BreedingSystem syst : Binnie.GENETICS.getActiveSystems()) { - new Control(this, x, y, 20.0f, 20.0f) { + new Control(this, x, y, 20, 20) { @Override public void initialise() { this.addAttribute(Attribute.MouseOver); @@ -149,7 +150,7 @@ public class WindowAnalyst extends Window { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.colour(syst.getColour()); final int outset = (WindowAnalyst.this.getSystem() == syst) ? 1 : 0; CraftGUI.render.texture(CraftGUITexture.TabOutline, this.getArea().outset(outset)); @@ -157,7 +158,7 @@ public class WindowAnalyst extends Window { CraftGUI.render.colour(1140850688 + syst.getColour()); CraftGUI.render.texture(CraftGUITexture.TabSolid, this.getArea().outset(outset)); } - CraftGUI.render.item(new IPoint(2.0f, 2.0f), syst.getItemStackRepresentitive()); + CraftGUIUtil.renderItem(new IPoint(2, 2), syst.getItemStackRepresentitive()); } }; x += 22; @@ -169,21 +170,21 @@ public class WindowAnalyst extends Window { x += 26; this.setupValidators(); } - this.tabBar = new Control(this, x, 28.0f, this.w() - 16.0f - x, 20.0f); - this.analystPanel = new Panel(this, 16.0f, 54.0f, 280.0f, 164.0f, MinecraftGUI.PanelType.Outline) { + this.tabBar = new Control(this, x, 28, this.w() - 16 - x, 20); + this.analystPanel = new Panel(this, 16, 54, 280, 164, MinecraftGUI.PanelType.Outline) { @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.render.gradientRect(this.getArea(), 1157627903, 1728053247); - super.onRenderBackground(); + super.onRenderBackground(guiWidth, guiHeight); } @Override public void initialise() { this.setColour(4473924); - final float sectionWidth = (this.w() - 8.0f - 4.0f) / 2.0f; - WindowAnalyst.this.leftPage = new ControlScrollableContent(this, 3.0f, 3.0f, sectionWidth + 2.0f, this.h() - 8.0f + 2.0f, 0.0f) { + final int sectionWidth = (this.w() - 8 - 4) / 2; + WindowAnalyst.this.leftPage = new ControlScrollableContent(this, 3, 3, sectionWidth + 2, this.h() - 8 + 2, 0) { @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { if (this.getContent() == null) { return; } @@ -191,9 +192,9 @@ public class WindowAnalyst extends Window { CraftGUI.render.texture(CraftGUITexture.TabOutline, this.getArea()); } }; - new ControlScrollBar(this, sectionWidth + 2.0f - 3.0f, 6.0f, 3.0f, this.h() - 8.0f + 2.0f - 6.0f, WindowAnalyst.this.leftPage) { + new ControlScrollBar(this, sectionWidth + 2 - 3, 6, 3, this.h() - 8 + 2 - 6, WindowAnalyst.this.leftPage) { @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { if (!this.isEnabled()) { return; } @@ -204,9 +205,9 @@ public class WindowAnalyst extends Window { CraftGUI.render.solid(this.getRenderArea(), WindowAnalyst.this.leftPage.getContent().getColour()); } }; - WindowAnalyst.this.rightPage = new ControlScrollableContent(this, 3.0f + sectionWidth + 4.0f, 3.0f, sectionWidth + 2.0f, this.h() - 8.0f + 2.0f, 0.0f) { + WindowAnalyst.this.rightPage = new ControlScrollableContent(this, 3 + sectionWidth + 4, 3, sectionWidth + 2, this.h() - 8 + 2, 0) { @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { if (this.getContent() == null) { return; } @@ -214,9 +215,9 @@ public class WindowAnalyst extends Window { CraftGUI.render.texture(CraftGUITexture.TabOutline, this.getArea()); } }; - new ControlScrollBar(this, sectionWidth + 2.0f - 3.0f + sectionWidth + 4.0f, 6.0f, 3.0f, this.h() - 8.0f + 2.0f - 6.0f, WindowAnalyst.this.rightPage) { + new ControlScrollBar(this, sectionWidth + 2 - 3 + sectionWidth + 4, 6, 3, this.h() - 8 + 2 - 6, WindowAnalyst.this.rightPage) { @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { if (!this.isEnabled()) { return; } @@ -227,11 +228,11 @@ public class WindowAnalyst extends Window { CraftGUI.render.solid(this.getRenderArea(), WindowAnalyst.this.rightPage.getContent().getColour()); } }; - WindowAnalyst.this.analystPageSize = new IArea(1.0f, 1.0f, sectionWidth, this.h() - 8.0f); + WindowAnalyst.this.analystPageSize = new IArea(1, 1, sectionWidth, this.h() - 8); } }; if (!this.isDatabase) { - this.slideUpInv = new ControlSlide(this, (this.getSize().x() - 244.0f) / 2.0f, this.getSize().y() - 80.0f + 1.0f, 244.0f, 80.0f, Position.Bottom); + this.slideUpInv = new ControlSlide(this, (this.getSize().x() - 244) / 2, this.getSize().y() - 80 + 1, 244, 80, Position.Bottom); new ControlPlayerInventory(this.slideUpInv, true); this.slideUpInv.setSlide(false); } @@ -247,10 +248,10 @@ public class WindowAnalyst extends Window { } }); if (!this.isDatabase) { - this.analystNone = new Control(this.analystPanel, 0.0f, 0.0f, this.analystPanel.w(), this.analystPanel.h()) { + this.analystNone = new Control(this.analystPanel, 0, 0, this.analystPanel.w(), this.analystPanel.h()) { @Override public void initialise() { - new ControlTextCentered(this, 20.0f, "Add a bee, tree, flower or butterfly to the top left slot. DNA Dye is required if it has not been analysed yet. This dye can also convert vanilla items to breedable individuals.").setColour(4473924); + new ControlTextCentered(this, 20, "Add a bee, tree, flower or butterfly to the top left slot. DNA Dye is required if it has not been analysed yet. This dye can also convert vanilla items to breedable individuals.").setColour(4473924); new ControlPlayerInventory(this); } }; @@ -336,10 +337,10 @@ public class WindowAnalyst extends Window { this.analystPages.add(new AnalystPageMutations(this.analystPanel, this.analystPageSize, this.current, this.isMaster)); } this.tabBar.deleteAllChildren(); - final float width = this.tabBar.w() / this.analystPages.size(); - float x = 0.0f; + final int width = this.tabBar.w() / this.analystPages.size(); + int x = 0; for (final ControlAnalystPage page : this.analystPages) { - new ControlTooltip(this.tabBar, x, 0.0f, width, this.tabBar.h()) { + new ControlTooltip(this.tabBar, x, 0, width, this.tabBar.h()) { ControlAnalystPage value; @Override @@ -378,13 +379,13 @@ public class WindowAnalyst extends Window { } @Override - public void onRenderBackground() { + public void onRenderBackground(int guiWidth, int guiHeight) { final boolean active = this.value == WindowAnalyst.this.leftPage.getContent() || this.value == WindowAnalyst.this.rightPage.getContent(); CraftGUI.render.colour((active ? -16777216 : 1140850688) + this.value.getColour()); CraftGUI.render.texture(CraftGUITexture.TabSolid, this.getArea().inset(1)); CraftGUI.render.colour(this.value.getColour()); CraftGUI.render.texture(CraftGUITexture.TabOutline, this.getArea().inset(1)); - super.onRenderBackground(); + super.onRenderBackground(guiWidth, guiHeight); } }; x += width; @@ -414,8 +415,8 @@ public class WindowAnalyst extends Window { } final int newRightIndex = rightIndex + (right ? 1 : -1); final int newLeftIndex = this.lockedSearch ? 0 : (newRightIndex - 1); - float oldRightPercent = 0.0f; - float oldLeftPercent = 0.0f; + float oldRightPercent = 0; + float oldLeftPercent = 0; if (newLeftIndex == rightIndex) { oldRightPercent = this.rightPage.getPercentageIndex(); } @@ -427,10 +428,10 @@ public class WindowAnalyst extends Window { this.setPage(this.leftPage, this.analystPages.get(newLeftIndex)); this.setPage(this.rightPage, this.analystPages.get(newRightIndex)); this.analystPages.get(newLeftIndex).show(); - if (oldRightPercent != 0.0f) { + if (oldRightPercent != 0) { this.leftPage.setPercentageIndex(oldRightPercent); } - if (oldLeftPercent != 0.0f) { + if (oldLeftPercent != 0) { this.rightPage.setPercentageIndex(oldLeftPercent); } } @@ -444,8 +445,8 @@ public class WindowAnalyst extends Window { if (page != null) { page.show(); side.setScrollableContent(page); - side.setPercentageIndex(0.0f); - page.setPosition(side.pos().add(1.0f, 1.0f)); + side.setPercentageIndex(0); + page.setPosition(side.pos().add(1, 1)); } }