Fixed screens, except containerscreen. Fixed clientproxy and BlockRayTraceResult (cast if type = block).
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package nl.requios.effortlessbuilding;
|
package nl.requios.effortlessbuilding;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.inventory.container.Container;
|
||||||
|
import net.minecraft.inventory.container.ContainerType;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraftforge.event.RegistryEvent;
|
import net.minecraftforge.event.RegistryEvent;
|
||||||
@@ -18,8 +20,7 @@ public class ModEventHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
public static void registerItems(RegistryEvent.Register<Item> event) {
|
||||||
{
|
|
||||||
event.getRegistry().registerAll(EffortlessBuilding.ITEMS);
|
event.getRegistry().registerAll(EffortlessBuilding.ITEMS);
|
||||||
|
|
||||||
for (Block block : EffortlessBuilding.BLOCKS)
|
for (Block block : EffortlessBuilding.BLOCKS)
|
||||||
@@ -27,4 +28,10 @@ public class ModEventHandler {
|
|||||||
event.getRegistry().register(new BlockItem(block, new Item.Properties()).setRegistryName(block.getRegistryName()));
|
event.getRegistry().register(new BlockItem(block, new Item.Properties()).setRegistryName(block.getRegistryName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO 1.14 Gui
|
||||||
|
// @SubscribeEvent
|
||||||
|
// public static void registerContainerTypes(RegistryEvent.Register<ContainerType<?>> event) {
|
||||||
|
// event.getRegistry().register()
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ public class RandomizerBagContainer extends Container {
|
|||||||
HOTBAR_START = INV_END + 1, HOTBAR_END = HOTBAR_START + 8;
|
HOTBAR_START = INV_END + 1, HOTBAR_END = HOTBAR_START + 8;
|
||||||
|
|
||||||
public RandomizerBagContainer(PlayerInventory parInventoryPlayer, IItemHandler parIInventory) {
|
public RandomizerBagContainer(PlayerInventory parInventoryPlayer, IItemHandler parIInventory) {
|
||||||
|
//TODO 1.14 Gui
|
||||||
|
super(null, 0);
|
||||||
bagInventory = parIInventory;
|
bagInventory = parIInventory;
|
||||||
sizeInventory = bagInventory.getSlots();
|
sizeInventory = bagInventory.getSlots();
|
||||||
for (int i = 0; i < sizeInventory; ++i) {
|
for (int i = 0; i < sizeInventory; ++i) {
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package nl.requios.effortlessbuilding.gui;
|
|||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
@@ -18,7 +18,7 @@ public class RandomizerBagGuiContainer extends ContainerScreen {
|
|||||||
private final IItemHandler inventoryBag;
|
private final IItemHandler inventoryBag;
|
||||||
|
|
||||||
public RandomizerBagGuiContainer(PlayerInventory inventoryPlayer, IItemHandler inventoryBag) {
|
public RandomizerBagGuiContainer(PlayerInventory inventoryPlayer, IItemHandler inventoryBag) {
|
||||||
super(new RandomizerBagContainer(inventoryPlayer, inventoryBag));
|
super(new RandomizerBagContainer(inventoryPlayer, inventoryBag), inventoryPlayer, new TranslationTextComponent("effortlessbuilding.screen.randomizer_bag"));
|
||||||
this.inventoryPlayer = inventoryPlayer;
|
this.inventoryPlayer = inventoryPlayer;
|
||||||
this.inventoryBag = inventoryBag;
|
this.inventoryBag = inventoryBag;
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ public class RandomizerBagGuiContainer extends ContainerScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||||
drawDefaultBackground();
|
renderBackground();
|
||||||
super.render(mouseX, mouseY, partialTicks);
|
super.render(mouseX, mouseY, partialTicks);
|
||||||
this.renderHoveredToolTip(mouseX, mouseY);
|
this.renderHoveredToolTip(mouseX, mouseY);
|
||||||
}
|
}
|
||||||
@@ -45,6 +45,6 @@ public class RandomizerBagGuiContainer extends ContainerScreen {
|
|||||||
minecraft.getTextureManager().bindTexture(guiTextures);
|
minecraft.getTextureManager().bindTexture(guiTextures);
|
||||||
int marginHorizontal = (width - xSize) / 2;
|
int marginHorizontal = (width - xSize) / 2;
|
||||||
int marginVertical = (height - ySize) / 2;
|
int marginVertical = (height - ySize) / 2;
|
||||||
drawTexturedModalRect(marginHorizontal, marginVertical, 0, 0, xSize, ySize);
|
blit(marginHorizontal, marginVertical, 0, 0, xSize, ySize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ import net.minecraft.client.gui.screen.Screen;
|
|||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraft.world.IInteractionObject;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.fml.network.FMLPlayMessages;
|
import net.minecraftforge.fml.network.FMLPlayMessages;
|
||||||
@@ -19,8 +20,8 @@ import nl.requios.effortlessbuilding.EffortlessBuilding;
|
|||||||
import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
|
import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
TODO 1.14 GUI
|
|
||||||
public class RandomizerBagGuiHandler implements /*IGuiHandler, */IInteractionObject {
|
public class RandomizerBagGuiHandler implements INamedContainerProvider {
|
||||||
// @Nullable
|
// @Nullable
|
||||||
// @Override
|
// @Override
|
||||||
// public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
// public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
@@ -54,54 +55,40 @@ public class RandomizerBagGuiHandler implements /*IGuiHandler, */IInteractionObj
|
|||||||
// return null;
|
// return null;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
// @OnlyIn(Dist.CLIENT)
|
||||||
public static Screen openGui(FMLPlayMessages.OpenContainer openContainer) {
|
// public static Screen openGui(FMLPlayMessages.OpenContainer openContainer) {
|
||||||
if (openContainer.getId().equals(EffortlessBuilding.RANDOMIZER_BAG_GUI)) {
|
// if (openContainer.getId().equals(EffortlessBuilding.RANDOMIZER_BAG_GUI)) {
|
||||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
// ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||||
if (player.getHeldItem(Hand.MAIN_HAND).getItem() instanceof ItemRandomizerBag) {
|
// if (player.getHeldItem(Hand.MAIN_HAND).getItem() instanceof ItemRandomizerBag) {
|
||||||
IItemHandler itemHandler = player.getHeldItem(Hand.MAIN_HAND).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null);
|
// IItemHandler itemHandler = player.getHeldItem(Hand.MAIN_HAND).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null);
|
||||||
if (itemHandler != null) {
|
// if (itemHandler != null) {
|
||||||
return new RandomizerBagGuiContainer(player.inventory, itemHandler);
|
// return new RandomizerBagGuiContainer(player.inventory, itemHandler);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public Container createContainer(PlayerInventory inventory, PlayerEntity player) {
|
// public Container createContainer(PlayerInventory inventory, PlayerEntity player) {
|
||||||
if (player.getHeldItem(Hand.MAIN_HAND).getItem() instanceof ItemRandomizerBag) {
|
// if (player.getHeldItem(Hand.MAIN_HAND).getItem() instanceof ItemRandomizerBag) {
|
||||||
IItemHandler itemHandler = player.getHeldItem(Hand.MAIN_HAND).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null);
|
// IItemHandler itemHandler = player.getHeldItem(Hand.MAIN_HAND).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null);
|
||||||
if (itemHandler != null) {
|
// if (itemHandler != null) {
|
||||||
return new RandomizerBagContainer(inventory, itemHandler);
|
// return new RandomizerBagContainer(inventory, itemHandler);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getGuiID() {
|
|
||||||
return EffortlessBuilding.RANDOMIZER_BAG_GUI.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ITextComponent getName() {
|
|
||||||
return new StringTextComponent("Randomizer Bag");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasCustomName() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITextComponent getDisplayName() {
|
public ITextComponent getDisplayName() {
|
||||||
return new StringTextComponent("Randomizer Bag");
|
return new TranslationTextComponent("effortlessbuilding.screen.randomizer_bag");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO 1.14 GUI
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public ITextComponent getCustomName() {
|
public Container createMenu(int containerId, PlayerInventory playerInventory, PlayerEntity player) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ import com.mojang.blaze3d.platform.GlStateManager;
|
|||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
||||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||||
@@ -18,7 +20,6 @@ import com.google.common.base.Stopwatch;
|
|||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
@@ -41,6 +42,10 @@ public class RadialMenu extends Screen {
|
|||||||
public ActionEnum doAction = null;
|
public ActionEnum doAction = null;
|
||||||
public boolean actionUsed = false;
|
public boolean actionUsed = false;
|
||||||
|
|
||||||
|
public RadialMenu() {
|
||||||
|
super(new TranslationTextComponent("effortlessbuilding.screen.radial_menu"));
|
||||||
|
}
|
||||||
|
|
||||||
private float clampVis(final float f) {
|
private float clampVis(final float f) {
|
||||||
return Math.max( 0.0f, Math.min( 1.0f, f ) );
|
return Math.max( 0.0f, Math.min( 1.0f, f ) );
|
||||||
}
|
}
|
||||||
@@ -118,7 +123,7 @@ public class RadialMenu extends Screen {
|
|||||||
final int startColor = (int) ( visibility * 98 ) << 24;
|
final int startColor = (int) ( visibility * 98 ) << 24;
|
||||||
final int endColor = (int) ( visibility * 128 ) << 24;
|
final int endColor = (int) ( visibility * 128 ) << 24;
|
||||||
|
|
||||||
drawGradientRect(0, 0, width, height, startColor, endColor);
|
fillGradient(0, 0, width, height, startColor, endColor);
|
||||||
|
|
||||||
GlStateManager.disableTexture();
|
GlStateManager.disableTexture();
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
@@ -229,10 +234,10 @@ public class RadialMenu extends Screen {
|
|||||||
switchTo = menuRegion.mode;
|
switchTo = menuRegion.mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.pos(middleX + x1m1, middleY + y1m1, zLevel).color(r, g, b, a).endVertex();
|
buffer.pos(middleX + x1m1, middleY + y1m1, blitOffset).color(r, g, b, a).endVertex();
|
||||||
buffer.pos(middleX + x2m1, middleY + y2m1, zLevel).color(r, g, b, a).endVertex();
|
buffer.pos(middleX + x2m1, middleY + y2m1, blitOffset).color(r, g, b, a).endVertex();
|
||||||
buffer.pos(middleX + x2m2, middleY + y2m2, zLevel).color(r, g, b, a).endVertex();
|
buffer.pos(middleX + x2m2, middleY + y2m2, blitOffset).color(r, g, b, a).endVertex();
|
||||||
buffer.pos(middleX + x1m2, middleY + y1m2, zLevel).color(r, g, b, a).endVertex();
|
buffer.pos(middleX + x1m2, middleY + y1m2, blitOffset).color(r, g, b, a).endVertex();
|
||||||
|
|
||||||
currentMode++;
|
currentMode++;
|
||||||
}
|
}
|
||||||
@@ -268,10 +273,10 @@ public class RadialMenu extends Screen {
|
|||||||
doAction = btn.action;
|
doAction = btn.action;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.pos(middleX + btn.x1, middleY + btn.y1, zLevel).color(r, g, b, a).endVertex();
|
buffer.pos(middleX + btn.x1, middleY + btn.y1, blitOffset).color(r, g, b, a).endVertex();
|
||||||
buffer.pos(middleX + btn.x1, middleY + btn.y2, zLevel).color(r, g, b, a).endVertex();
|
buffer.pos(middleX + btn.x1, middleY + btn.y2, blitOffset).color(r, g, b, a).endVertex();
|
||||||
buffer.pos(middleX + btn.x2, middleY + btn.y2, zLevel).color(r, g, b, a).endVertex();
|
buffer.pos(middleX + btn.x2, middleY + btn.y2, blitOffset).color(r, g, b, a).endVertex();
|
||||||
buffer.pos(middleX + btn.x2, middleY + btn.y1, zLevel).color(r, g, b, a).endVertex();
|
buffer.pos(middleX + btn.x2, middleY + btn.y1, blitOffset).color(r, g, b, a).endVertex();
|
||||||
}
|
}
|
||||||
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
@@ -279,7 +284,7 @@ public class RadialMenu extends Screen {
|
|||||||
GlStateManager.shadeModel(GL11.GL_FLAT);
|
GlStateManager.shadeModel(GL11.GL_FLAT);
|
||||||
|
|
||||||
GlStateManager.translatef(0f, 0f, 5f);
|
GlStateManager.translatef(0f, 0f, 5f);
|
||||||
GlStateManager.enableTexture2D();
|
GlStateManager.enableTexture();
|
||||||
GlStateManager.color3f(1f, 1f, 1f);
|
GlStateManager.color3f(1f, 1f, 1f);
|
||||||
GlStateManager.disableBlend();
|
GlStateManager.disableBlend();
|
||||||
GlStateManager.enableAlphaTest();
|
GlStateManager.enableAlphaTest();
|
||||||
@@ -308,10 +313,10 @@ public class RadialMenu extends Screen {
|
|||||||
final double v1 = 0;
|
final double v1 = 0;
|
||||||
final double v2 = 16;
|
final double v2 = 16;
|
||||||
|
|
||||||
buffer.pos(middleX + x1, middleY + y1, zLevel).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex();
|
buffer.pos(middleX + x1, middleY + y1, blitOffset).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex();
|
||||||
buffer.pos(middleX + x1, middleY + y2, zLevel).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex();
|
buffer.pos(middleX + x1, middleY + y2, blitOffset).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex();
|
||||||
buffer.pos(middleX + x2, middleY + y2, zLevel).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex();
|
buffer.pos(middleX + x2, middleY + y2, blitOffset).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex();
|
||||||
buffer.pos(middleX + x2, middleY + y1, zLevel).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex();
|
buffer.pos(middleX + x2, middleY + y1, blitOffset).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draw action icons
|
//Draw action icons
|
||||||
@@ -334,10 +339,10 @@ public class RadialMenu extends Screen {
|
|||||||
final double btny1 = btnmiddleY - 8;
|
final double btny1 = btnmiddleY - 8;
|
||||||
final double btny2 = btnmiddleY + 8;
|
final double btny2 = btnmiddleY + 8;
|
||||||
|
|
||||||
buffer.pos(middleX + btnx1, middleY + btny1, zLevel).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex();
|
buffer.pos(middleX + btnx1, middleY + btny1, blitOffset).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex();
|
||||||
buffer.pos(middleX + btnx1, middleY + btny2, zLevel).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex();
|
buffer.pos(middleX + btnx1, middleY + btny2, blitOffset).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex();
|
||||||
buffer.pos(middleX + btnx2, middleY + btny2, zLevel).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex();
|
buffer.pos(middleX + btnx2, middleY + btny2, blitOffset).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex();
|
||||||
buffer.pos(middleX + btnx2, middleY + btny1, zLevel).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex();
|
buffer.pos(middleX + btnx2, middleY + btny1, blitOffset).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex();
|
||||||
}
|
}
|
||||||
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
@@ -385,22 +390,22 @@ public class RadialMenu extends Screen {
|
|||||||
|
|
||||||
//Add keybind in brackets
|
//Add keybind in brackets
|
||||||
if (button.action == ActionEnum.UNDO) {
|
if (button.action == ActionEnum.UNDO) {
|
||||||
keybind = ClientProxy.keyBindings[4].getKey().getName();
|
keybind = ClientProxy.keyBindings[4].getLocalizedName();
|
||||||
}
|
}
|
||||||
if (button.action == ActionEnum.REDO) {
|
if (button.action == ActionEnum.REDO) {
|
||||||
keybind = ClientProxy.keyBindings[5].getKey().getName();
|
keybind = ClientProxy.keyBindings[5].getLocalizedName();
|
||||||
}
|
}
|
||||||
if (button.action == ActionEnum.REPLACE) {
|
if (button.action == ActionEnum.REPLACE) {
|
||||||
keybind = ClientProxy.keyBindings[1].getKey().getName();
|
keybind = ClientProxy.keyBindings[1].getLocalizedName();
|
||||||
}
|
}
|
||||||
if (button.action == ActionEnum.OPEN_MODIFIER_SETTINGS) {
|
if (button.action == ActionEnum.OPEN_MODIFIER_SETTINGS) {
|
||||||
keybind = ClientProxy.keyBindings[0].getKey().getName();
|
keybind = ClientProxy.keyBindings[0].getLocalizedName();
|
||||||
}
|
}
|
||||||
if (currentBuildMode.options.length > 0) {
|
if (currentBuildMode.options.length > 0) {
|
||||||
//Add (ctrl) to first two actions of first option
|
//Add (ctrl) to first two actions of first option
|
||||||
if (button.action == currentBuildMode.options[0].actions[0]
|
if (button.action == currentBuildMode.options[0].actions[0]
|
||||||
|| button.action == currentBuildMode.options[0].actions[1]) {
|
|| button.action == currentBuildMode.options[0].actions[1]) {
|
||||||
keybind = ClientProxy.keyBindings[6].getKey().getName();
|
keybind = ClientProxy.keyBindings[6].getLocalizedName();
|
||||||
if (keybind.equals("Left Control")) keybind = "Ctrl";
|
if (keybind.equals("Left Control")) keybind = "Ctrl";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
||||||
|
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import net.minecraft.client.gui.widget.Widget;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
@@ -31,8 +32,8 @@ public class ArraySettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int initGui(int id, List<Button> buttons) {
|
public void init(List<Widget> buttons) {
|
||||||
id = super.initGui(id, buttons);
|
super.init(buttons);
|
||||||
|
|
||||||
int y = top;
|
int y = top;
|
||||||
buttonArrayEnabled = new GuiCheckBox(left - 15 + 8, y, "", false) {
|
buttonArrayEnabled = new GuiCheckBox(left - 15 + 8, y, "", false) {
|
||||||
@@ -45,23 +46,23 @@ public class ArraySettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
buttons.add(buttonArrayEnabled);
|
buttons.add(buttonArrayEnabled);
|
||||||
|
|
||||||
y = top + 20;
|
y = top + 20;
|
||||||
textArrayOffsetX = new GuiNumberField(id++, id++, id++, font, buttons, left + 70, y, 50, 18);
|
textArrayOffsetX = new GuiNumberField(font, buttons, left + 70, y, 50, 18);
|
||||||
textArrayOffsetX.setNumber(0);
|
textArrayOffsetX.setNumber(0);
|
||||||
textArrayOffsetX.setTooltip("How much each copy is shifted.");
|
textArrayOffsetX.setTooltip("How much each copy is shifted.");
|
||||||
arrayNumberFieldList.add(textArrayOffsetX);
|
arrayNumberFieldList.add(textArrayOffsetX);
|
||||||
|
|
||||||
textArrayOffsetY = new GuiNumberField(id++, id++, id++, font, buttons, left + 140, y, 50, 18);
|
textArrayOffsetY = new GuiNumberField(font, buttons, left + 140, y, 50, 18);
|
||||||
textArrayOffsetY.setNumber(0);
|
textArrayOffsetY.setNumber(0);
|
||||||
textArrayOffsetY.setTooltip("How much each copy is shifted.");
|
textArrayOffsetY.setTooltip("How much each copy is shifted.");
|
||||||
arrayNumberFieldList.add(textArrayOffsetY);
|
arrayNumberFieldList.add(textArrayOffsetY);
|
||||||
|
|
||||||
textArrayOffsetZ = new GuiNumberField(id++, id++, id++, font, buttons, left + 210, y, 50, 18);
|
textArrayOffsetZ = new GuiNumberField(font, buttons, left + 210, y, 50, 18);
|
||||||
textArrayOffsetZ.setNumber(0);
|
textArrayOffsetZ.setNumber(0);
|
||||||
textArrayOffsetZ.setTooltip("How much each copy is shifted.");
|
textArrayOffsetZ.setTooltip("How much each copy is shifted.");
|
||||||
arrayNumberFieldList.add(textArrayOffsetZ);
|
arrayNumberFieldList.add(textArrayOffsetZ);
|
||||||
|
|
||||||
y = top + 50;
|
y = top + 50;
|
||||||
textArrayCount = new GuiNumberField(id++, id++, id++, font, buttons, left + 55, y, 50, 18);
|
textArrayCount = new GuiNumberField(font, buttons, left + 55, y, 50, 18);
|
||||||
textArrayCount.setNumber(5);
|
textArrayCount.setNumber(5);
|
||||||
textArrayCount.setTooltip("How many copies should be made.");
|
textArrayCount.setTooltip("How many copies should be made.");
|
||||||
arrayNumberFieldList.add(textArrayCount);
|
arrayNumberFieldList.add(textArrayCount);
|
||||||
@@ -77,8 +78,6 @@ public class ArraySettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setCollapsed(!buttonArrayEnabled.isChecked());
|
setCollapsed(!buttonArrayEnabled.isChecked());
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateScreen() {
|
public void updateScreen() {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.widget.Widget;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
@@ -41,8 +42,8 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int initGui(int id, List<Button> buttonList) {
|
public void init(List<Widget> buttonList) {
|
||||||
id = super.initGui(id, buttonList);
|
super.init(buttonList);
|
||||||
|
|
||||||
int y = top - 2;
|
int y = top - 2;
|
||||||
buttonMirrorEnabled = new GuiCheckBox(left - 15 + 8, y, "", false) {
|
buttonMirrorEnabled = new GuiCheckBox(left - 15 + 8, y, "", false) {
|
||||||
@@ -55,18 +56,18 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
buttonList.add(buttonMirrorEnabled);
|
buttonList.add(buttonMirrorEnabled);
|
||||||
|
|
||||||
y = top + 18;
|
y = top + 18;
|
||||||
textMirrorPosX = new GuiNumberField(id++, id++, id++, font, buttonList, left + 58, y, 62, 18);
|
textMirrorPosX = new GuiNumberField(font, buttonList, left + 58, y, 62, 18);
|
||||||
textMirrorPosX.setNumber(0);
|
textMirrorPosX.setNumber(0);
|
||||||
textMirrorPosX.setTooltip(
|
textMirrorPosX.setTooltip(
|
||||||
Arrays.asList("The position of the mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
Arrays.asList("The position of the mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
||||||
mirrorNumberFieldList.add(textMirrorPosX);
|
mirrorNumberFieldList.add(textMirrorPosX);
|
||||||
|
|
||||||
textMirrorPosY = new GuiNumberField(id++, id++, id++, font, buttonList, left + 138, y, 62, 18);
|
textMirrorPosY = new GuiNumberField(font, buttonList, left + 138, y, 62, 18);
|
||||||
textMirrorPosY.setNumber(64);
|
textMirrorPosY.setNumber(64);
|
||||||
textMirrorPosY.setTooltip(Arrays.asList("The position of the mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
textMirrorPosY.setTooltip(Arrays.asList("The position of the mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
||||||
mirrorNumberFieldList.add(textMirrorPosY);
|
mirrorNumberFieldList.add(textMirrorPosY);
|
||||||
|
|
||||||
textMirrorPosZ = new GuiNumberField(id++, id++, id++, font, buttonList, left + 218, y, 62, 18);
|
textMirrorPosZ = new GuiNumberField(font, buttonList, left + 218, y, 62, 18);
|
||||||
textMirrorPosZ.setNumber(0);
|
textMirrorPosZ.setNumber(0);
|
||||||
textMirrorPosZ.setTooltip(Arrays.asList("The position of the mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
textMirrorPosZ.setTooltip(Arrays.asList("The position of the mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
||||||
mirrorNumberFieldList.add(textMirrorPosZ);
|
mirrorNumberFieldList.add(textMirrorPosZ);
|
||||||
@@ -82,7 +83,7 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
mirrorButtonList.add(buttonMirrorZ);
|
mirrorButtonList.add(buttonMirrorZ);
|
||||||
|
|
||||||
y = top + 47;
|
y = top + 47;
|
||||||
textMirrorRadius = new GuiNumberField(id++, id++, id++, font, buttonList, left + 218, y, 62, 18);
|
textMirrorRadius = new GuiNumberField(font, buttonList, left + 218, y, 62, 18);
|
||||||
textMirrorRadius.setNumber(50);
|
textMirrorRadius.setNumber(50);
|
||||||
//TODO change to diameter (remove /2)
|
//TODO change to diameter (remove /2)
|
||||||
textMirrorRadius.setTooltip(Arrays.asList("How far the mirror reaches in any direction.",
|
textMirrorRadius.setTooltip(Arrays.asList("How far the mirror reaches in any direction.",
|
||||||
@@ -91,62 +92,46 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
mirrorNumberFieldList.add(textMirrorRadius);
|
mirrorNumberFieldList.add(textMirrorRadius);
|
||||||
|
|
||||||
y = top + 72;
|
y = top + 72;
|
||||||
buttonCurrentPosition = new GuiIconButton(id++, left + 5, y, 0, 0, BUILDING_ICONS) {
|
buttonCurrentPosition = new GuiIconButton(left + 5, y, 0, 0, BUILDING_ICONS, button -> {
|
||||||
@Override
|
Vec3d pos = new Vec3d(Math.floor(mc.player.posX) + 0.5, Math.floor(mc.player.posY) + 0.5, Math.floor(mc.player.posZ) + 0.5);
|
||||||
public void onClick(double mouseX, double mouseY) {
|
textMirrorPosX.setNumber(pos.x);
|
||||||
super.onClick(mouseX, mouseY);
|
textMirrorPosY.setNumber(pos.y);
|
||||||
Vec3d pos = new Vec3d(Math.floor(mc.player.posX) + 0.5, Math.floor(mc.player.posY) + 0.5, Math.floor(mc.player.posZ) + 0.5);
|
textMirrorPosZ.setNumber(pos.z);
|
||||||
textMirrorPosX.setNumber(pos.x);
|
});
|
||||||
textMirrorPosY.setNumber(pos.y);
|
|
||||||
textMirrorPosZ.setNumber(pos.z);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
buttonCurrentPosition.setTooltip("Set mirror position to current player position");
|
buttonCurrentPosition.setTooltip("Set mirror position to current player position");
|
||||||
mirrorIconButtonList.add(buttonCurrentPosition);
|
mirrorIconButtonList.add(buttonCurrentPosition);
|
||||||
|
|
||||||
buttonToggleOdd = new GuiIconButton(id++, left + 35, y, 0, 20, BUILDING_ICONS) {
|
buttonToggleOdd = new GuiIconButton(left + 35, y, 0, 20, BUILDING_ICONS, button -> {
|
||||||
@Override
|
toggleOdd = !toggleOdd;
|
||||||
public void onClick(double mouseX, double mouseY) {
|
buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
||||||
super.onClick(mouseX, mouseY);
|
if (toggleOdd) {
|
||||||
toggleOdd = !toggleOdd;
|
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to corner of block", "for even numbered builds"));
|
||||||
buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
textMirrorPosX.setNumber(textMirrorPosX.getNumber() + 0.5);
|
||||||
if (toggleOdd) {
|
textMirrorPosY.setNumber(textMirrorPosY.getNumber() + 0.5);
|
||||||
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to corner of block", "for even numbered builds"));
|
textMirrorPosZ.setNumber(textMirrorPosZ.getNumber() + 0.5);
|
||||||
textMirrorPosX.setNumber(textMirrorPosX.getNumber() + 0.5);
|
} else {
|
||||||
textMirrorPosY.setNumber(textMirrorPosY.getNumber() + 0.5);
|
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to middle of block", "for odd numbered builds"));
|
||||||
textMirrorPosZ.setNumber(textMirrorPosZ.getNumber() + 0.5);
|
textMirrorPosX.setNumber(Math.floor(textMirrorPosX.getNumber()));
|
||||||
} else {
|
textMirrorPosY.setNumber(Math.floor(textMirrorPosY.getNumber()));
|
||||||
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to middle of block", "for odd numbered builds"));
|
textMirrorPosZ.setNumber(Math.floor(textMirrorPosZ.getNumber()));
|
||||||
textMirrorPosX.setNumber(Math.floor(textMirrorPosX.getNumber()));
|
|
||||||
textMirrorPosY.setNumber(Math.floor(textMirrorPosY.getNumber()));
|
|
||||||
textMirrorPosZ.setNumber(Math.floor(textMirrorPosZ.getNumber()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to middle of block", "for odd numbered builds"));
|
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to middle of block", "for odd numbered builds"));
|
||||||
mirrorIconButtonList.add(buttonToggleOdd);
|
mirrorIconButtonList.add(buttonToggleOdd);
|
||||||
|
|
||||||
buttonDrawLines = new GuiIconButton(id++, left + 65, y, 0, 40, BUILDING_ICONS) {
|
buttonDrawLines = new GuiIconButton(left + 65, y, 0, 40, BUILDING_ICONS, button -> {
|
||||||
@Override
|
drawLines = !drawLines;
|
||||||
public void onClick(double mouseX, double mouseY) {
|
buttonDrawLines.setUseAlternateIcon(drawLines);
|
||||||
super.onClick(mouseX, mouseY);
|
buttonDrawLines.setTooltip(drawLines ? "Hide lines" : "Show lines");
|
||||||
drawLines = !drawLines;
|
});
|
||||||
buttonDrawLines.setUseAlternateIcon(drawLines);
|
|
||||||
buttonDrawLines.setTooltip(drawLines ? "Hide lines" : "Show lines");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
buttonDrawLines.setTooltip("Show lines");
|
buttonDrawLines.setTooltip("Show lines");
|
||||||
mirrorIconButtonList.add(buttonDrawLines);
|
mirrorIconButtonList.add(buttonDrawLines);
|
||||||
|
|
||||||
buttonDrawPlanes = new GuiIconButton(id++, left + 95, y, 0, 60, BUILDING_ICONS) {
|
buttonDrawPlanes = new GuiIconButton(left + 95, y, 0, 60, BUILDING_ICONS, button -> {
|
||||||
@Override
|
drawPlanes = !drawPlanes;
|
||||||
public void onClick(double mouseX, double mouseY) {
|
buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
||||||
super.onClick(mouseX, mouseY);
|
buttonDrawPlanes.setTooltip(drawPlanes ? "Hide area" : "Show area");
|
||||||
drawPlanes = !drawPlanes;
|
});
|
||||||
buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
|
||||||
buttonDrawPlanes.setTooltip(drawPlanes ? "Hide area" : "Show area");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
buttonDrawPlanes.setTooltip("Show area");
|
buttonDrawPlanes.setTooltip("Show area");
|
||||||
mirrorIconButtonList.add(buttonDrawPlanes);
|
mirrorIconButtonList.add(buttonDrawPlanes);
|
||||||
|
|
||||||
@@ -181,8 +166,6 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
buttonList.addAll(mirrorIconButtonList);
|
buttonList.addAll(mirrorIconButtonList);
|
||||||
|
|
||||||
setCollapsed(!buttonMirrorEnabled.isChecked());
|
setCollapsed(!buttonMirrorEnabled.isChecked());
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package nl.requios.effortlessbuilding.gui.buildmodifier;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
@@ -25,11 +27,13 @@ public class ModifierSettingsGui extends Screen {
|
|||||||
private ArraySettingsGui arraySettingsGui;
|
private ArraySettingsGui arraySettingsGui;
|
||||||
private RadialMirrorSettingsGui radialMirrorSettingsGui;
|
private RadialMirrorSettingsGui radialMirrorSettingsGui;
|
||||||
|
|
||||||
|
public ModifierSettingsGui() {
|
||||||
|
super(new TranslationTextComponent("effortlessbuilding.screen.modifier_settings"));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//Create buttons and labels and add them to buttonList/labelList
|
//Create buttons and labels and add them to buttonList/labelList
|
||||||
public void initGui() {
|
protected void init() {
|
||||||
int id = 0;
|
|
||||||
|
|
||||||
scrollPane = new GuiScrollPane(this, font, 8, height - 30);
|
scrollPane = new GuiScrollPane(this, font, 8, height - 30);
|
||||||
|
|
||||||
mirrorSettingsGui = new MirrorSettingsGui(scrollPane);
|
mirrorSettingsGui = new MirrorSettingsGui(scrollPane);
|
||||||
@@ -41,19 +45,14 @@ public class ModifierSettingsGui extends Screen {
|
|||||||
radialMirrorSettingsGui = new RadialMirrorSettingsGui(scrollPane);
|
radialMirrorSettingsGui = new RadialMirrorSettingsGui(scrollPane);
|
||||||
scrollPane.AddListEntry(radialMirrorSettingsGui);
|
scrollPane.AddListEntry(radialMirrorSettingsGui);
|
||||||
|
|
||||||
id = scrollPane.initGui(id, buttons);
|
scrollPane.init(buttons);
|
||||||
|
|
||||||
//Close button
|
//Close button
|
||||||
int y = height - 26;
|
int y = height - 26;
|
||||||
buttonClose = new Button(width / 2 - 100, y, "Close") {
|
buttonClose = new Button(width / 2 - 100, y, 200, 20, "Close", (button) -> {
|
||||||
@Override
|
Minecraft.getInstance().player.closeScreen();
|
||||||
public void onClick(double mouseX, double mouseY) {
|
});
|
||||||
super.onClick(mouseX, mouseY);
|
|
||||||
Minecraft.getInstance().player.closeScreen();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
buttons.add(buttonClose);
|
buttons.add(buttonClose);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -68,9 +67,9 @@ public class ModifierSettingsGui extends Screen {
|
|||||||
//Set colors using GL11, use the fontObj field to display text
|
//Set colors using GL11, use the fontObj field to display text
|
||||||
//Use drawTexturedModalRect() to transfers areas of a texture resource to the screen
|
//Use drawTexturedModalRect() to transfers areas of a texture resource to the screen
|
||||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||||
this.drawDefaultBackground();
|
this.renderBackground();
|
||||||
|
|
||||||
scrollPane.drawScreen(mouseX, mouseY, partialTicks);
|
scrollPane.render(mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
buttonClose.render(mouseX, mouseY, partialTicks);
|
buttonClose.render(mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
@@ -83,7 +82,7 @@ public class ModifierSettingsGui extends Screen {
|
|||||||
super.charTyped(typedChar, keyCode);
|
super.charTyped(typedChar, keyCode);
|
||||||
scrollPane.charTyped(typedChar, keyCode);
|
scrollPane.charTyped(typedChar, keyCode);
|
||||||
if (keyCode == ClientProxy.keyBindings[0].getKey().getKeyCode()) {
|
if (keyCode == ClientProxy.keyBindings[0].getKey().getKeyCode()) {
|
||||||
mc.player.closeScreen();
|
minecraft.player.closeScreen();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -115,7 +114,7 @@ public class ModifierSettingsGui extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGuiClosed() {
|
public void onClose() {
|
||||||
scrollPane.onGuiClosed();
|
scrollPane.onGuiClosed();
|
||||||
|
|
||||||
//save everything
|
//save everything
|
||||||
@@ -123,17 +122,17 @@ public class ModifierSettingsGui extends Screen {
|
|||||||
Array.ArraySettings a = arraySettingsGui.getArraySettings();
|
Array.ArraySettings a = arraySettingsGui.getArraySettings();
|
||||||
RadialMirror.RadialMirrorSettings r = radialMirrorSettingsGui.getRadialMirrorSettings();
|
RadialMirror.RadialMirrorSettings r = radialMirrorSettingsGui.getRadialMirrorSettings();
|
||||||
|
|
||||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(mc.player);
|
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(minecraft.player);
|
||||||
if (modifierSettings == null) modifierSettings = new ModifierSettingsManager.ModifierSettings();
|
if (modifierSettings == null) modifierSettings = new ModifierSettingsManager.ModifierSettings();
|
||||||
modifierSettings.setMirrorSettings(m);
|
modifierSettings.setMirrorSettings(m);
|
||||||
modifierSettings.setArraySettings(a);
|
modifierSettings.setArraySettings(a);
|
||||||
modifierSettings.setRadialMirrorSettings(r);
|
modifierSettings.setRadialMirrorSettings(r);
|
||||||
|
|
||||||
//Sanitize
|
//Sanitize
|
||||||
String error = ModifierSettingsManager.sanitize(modifierSettings, mc.player);
|
String error = ModifierSettingsManager.sanitize(modifierSettings, minecraft.player);
|
||||||
if (!error.isEmpty()) EffortlessBuilding.log(mc.player, error);
|
if (!error.isEmpty()) EffortlessBuilding.log(minecraft.player, error);
|
||||||
|
|
||||||
ModifierSettingsManager.setModifierSettings(mc.player, modifierSettings);
|
ModifierSettingsManager.setModifierSettings(minecraft.player, modifierSettings);
|
||||||
|
|
||||||
//Send to server
|
//Send to server
|
||||||
PacketHandler.INSTANCE.sendToServer(new ModifierSettingsMessage(modifierSettings));
|
PacketHandler.INSTANCE.sendToServer(new ModifierSettingsMessage(modifierSettings));
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.widget.Widget;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
@@ -41,8 +42,8 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int initGui(int id, List<Button> buttonList) {
|
public void init(List<Widget> buttonList) {
|
||||||
id = super.initGui(id, buttonList);
|
super.init(buttonList);
|
||||||
|
|
||||||
int y = top - 2;
|
int y = top - 2;
|
||||||
buttonRadialMirrorEnabled = new GuiCheckBox(left - 15 + 8, y, "", false) {
|
buttonRadialMirrorEnabled = new GuiCheckBox(left - 15 + 8, y, "", false) {
|
||||||
@@ -55,29 +56,29 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
buttonList.add(buttonRadialMirrorEnabled);
|
buttonList.add(buttonRadialMirrorEnabled);
|
||||||
|
|
||||||
y = top + 18;
|
y = top + 18;
|
||||||
textRadialMirrorPosX = new GuiNumberField(id++, id++, id++, font, buttonList, left + 58, y, 62, 18);
|
textRadialMirrorPosX = new GuiNumberField(font, buttonList, left + 58, y, 62, 18);
|
||||||
textRadialMirrorPosX.setNumber(0);
|
textRadialMirrorPosX.setNumber(0);
|
||||||
textRadialMirrorPosX.setTooltip(
|
textRadialMirrorPosX.setTooltip(
|
||||||
Arrays.asList("The position of the radial mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
Arrays.asList("The position of the radial mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
||||||
radialMirrorNumberFieldList.add(textRadialMirrorPosX);
|
radialMirrorNumberFieldList.add(textRadialMirrorPosX);
|
||||||
|
|
||||||
textRadialMirrorPosY = new GuiNumberField(id++, id++, id++, font, buttonList, left + 138, y, 62, 18);
|
textRadialMirrorPosY = new GuiNumberField(font, buttonList, left + 138, y, 62, 18);
|
||||||
textRadialMirrorPosY.setNumber(64);
|
textRadialMirrorPosY.setNumber(64);
|
||||||
textRadialMirrorPosY.setTooltip(Arrays.asList("The position of the radial mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
textRadialMirrorPosY.setTooltip(Arrays.asList("The position of the radial mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
||||||
radialMirrorNumberFieldList.add(textRadialMirrorPosY);
|
radialMirrorNumberFieldList.add(textRadialMirrorPosY);
|
||||||
|
|
||||||
textRadialMirrorPosZ = new GuiNumberField(id++, id++, id++, font, buttonList, left + 218, y, 62, 18);
|
textRadialMirrorPosZ = new GuiNumberField(font, buttonList, left + 218, y, 62, 18);
|
||||||
textRadialMirrorPosZ.setNumber(0);
|
textRadialMirrorPosZ.setNumber(0);
|
||||||
textRadialMirrorPosZ.setTooltip(Arrays.asList("The position of the radial mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
textRadialMirrorPosZ.setTooltip(Arrays.asList("The position of the radial mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
||||||
radialMirrorNumberFieldList.add(textRadialMirrorPosZ);
|
radialMirrorNumberFieldList.add(textRadialMirrorPosZ);
|
||||||
|
|
||||||
y = top + 47;
|
y = top + 47;
|
||||||
textRadialMirrorSlices = new GuiNumberField(id++, id++, id++, font, buttonList, left + 55, y, 50, 18);
|
textRadialMirrorSlices = new GuiNumberField(font, buttonList, left + 55, y, 50, 18);
|
||||||
textRadialMirrorSlices.setNumber(4);
|
textRadialMirrorSlices.setNumber(4);
|
||||||
textRadialMirrorSlices.setTooltip(Arrays.asList("The number of repeating slices.", TextFormatting.GRAY + "Minimally 2."));
|
textRadialMirrorSlices.setTooltip(Arrays.asList("The number of repeating slices.", TextFormatting.GRAY + "Minimally 2."));
|
||||||
radialMirrorNumberFieldList.add(textRadialMirrorSlices);
|
radialMirrorNumberFieldList.add(textRadialMirrorSlices);
|
||||||
|
|
||||||
textRadialMirrorRadius = new GuiNumberField(id++, id++, id++, font, buttonList, left + 218, y, 62, 18);
|
textRadialMirrorRadius = new GuiNumberField(font, buttonList, left + 218, y, 62, 18);
|
||||||
textRadialMirrorRadius.setNumber(50);
|
textRadialMirrorRadius.setNumber(50);
|
||||||
//TODO change to diameter (remove /2)
|
//TODO change to diameter (remove /2)
|
||||||
textRadialMirrorRadius.setTooltip(Arrays.asList("How far the radial mirror reaches from its center position.",
|
textRadialMirrorRadius.setTooltip(Arrays.asList("How far the radial mirror reaches from its center position.",
|
||||||
@@ -86,62 +87,46 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
radialMirrorNumberFieldList.add(textRadialMirrorRadius);
|
radialMirrorNumberFieldList.add(textRadialMirrorRadius);
|
||||||
|
|
||||||
y = top + 72;
|
y = top + 72;
|
||||||
buttonCurrentPosition = new GuiIconButton(id++, left + 5, y, 0, 0, BUILDING_ICONS) {
|
buttonCurrentPosition = new GuiIconButton(left + 5, y, 0, 0, BUILDING_ICONS, button -> {
|
||||||
@Override
|
Vec3d pos = new Vec3d(Math.floor(mc.player.posX) + 0.5, Math.floor(mc.player.posY) + 0.5, Math.floor(mc.player.posZ) + 0.5);
|
||||||
public void onClick(double mouseX, double mouseY) {
|
textRadialMirrorPosX.setNumber(pos.x);
|
||||||
super.onClick(mouseX, mouseY);
|
textRadialMirrorPosY.setNumber(pos.y);
|
||||||
Vec3d pos = new Vec3d(Math.floor(mc.player.posX) + 0.5, Math.floor(mc.player.posY) + 0.5, Math.floor(mc.player.posZ) + 0.5);
|
textRadialMirrorPosZ.setNumber(pos.z);
|
||||||
textRadialMirrorPosX.setNumber(pos.x);
|
});
|
||||||
textRadialMirrorPosY.setNumber(pos.y);
|
|
||||||
textRadialMirrorPosZ.setNumber(pos.z);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
buttonCurrentPosition.setTooltip("Set radial mirror position to current player position");
|
buttonCurrentPosition.setTooltip("Set radial mirror position to current player position");
|
||||||
radialMirrorIconButtonList.add(buttonCurrentPosition);
|
radialMirrorIconButtonList.add(buttonCurrentPosition);
|
||||||
|
|
||||||
buttonToggleOdd = new GuiIconButton(id++, left + 35, y, 0, 20, BUILDING_ICONS) {
|
buttonToggleOdd = new GuiIconButton(left + 35, y, 0, 20, BUILDING_ICONS, button -> {
|
||||||
@Override
|
toggleOdd = !toggleOdd;
|
||||||
public void onClick(double mouseX, double mouseY) {
|
buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
||||||
super.onClick(mouseX, mouseY);
|
if (toggleOdd) {
|
||||||
toggleOdd = !toggleOdd;
|
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to corner of block", "for even numbered builds"));
|
||||||
buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
textRadialMirrorPosX.setNumber(textRadialMirrorPosX.getNumber() + 0.5);
|
||||||
if (toggleOdd) {
|
textRadialMirrorPosY.setNumber(textRadialMirrorPosY.getNumber() + 0.5);
|
||||||
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to corner of block", "for even numbered builds"));
|
textRadialMirrorPosZ.setNumber(textRadialMirrorPosZ.getNumber() + 0.5);
|
||||||
textRadialMirrorPosX.setNumber(textRadialMirrorPosX.getNumber() + 0.5);
|
} else {
|
||||||
textRadialMirrorPosY.setNumber(textRadialMirrorPosY.getNumber() + 0.5);
|
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to middle of block", "for odd numbered builds"));
|
||||||
textRadialMirrorPosZ.setNumber(textRadialMirrorPosZ.getNumber() + 0.5);
|
textRadialMirrorPosX.setNumber(Math.floor(textRadialMirrorPosX.getNumber()));
|
||||||
} else {
|
textRadialMirrorPosY.setNumber(Math.floor(textRadialMirrorPosY.getNumber()));
|
||||||
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to middle of block", "for odd numbered builds"));
|
textRadialMirrorPosZ.setNumber(Math.floor(textRadialMirrorPosZ.getNumber()));
|
||||||
textRadialMirrorPosX.setNumber(Math.floor(textRadialMirrorPosX.getNumber()));
|
|
||||||
textRadialMirrorPosY.setNumber(Math.floor(textRadialMirrorPosY.getNumber()));
|
|
||||||
textRadialMirrorPosZ.setNumber(Math.floor(textRadialMirrorPosZ.getNumber()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
buttonToggleOdd.setTooltip(Arrays.asList("Set radial mirror position to middle of block", "for odd numbered builds"));
|
buttonToggleOdd.setTooltip(Arrays.asList("Set radial mirror position to middle of block", "for odd numbered builds"));
|
||||||
radialMirrorIconButtonList.add(buttonToggleOdd);
|
radialMirrorIconButtonList.add(buttonToggleOdd);
|
||||||
|
|
||||||
buttonDrawLines = new GuiIconButton(id++, left + 65, y, 0, 40, BUILDING_ICONS) {
|
buttonDrawLines = new GuiIconButton(left + 65, y, 0, 40, BUILDING_ICONS, button -> {
|
||||||
@Override
|
drawLines = !drawLines;
|
||||||
public void onClick(double mouseX, double mouseY) {
|
buttonDrawLines.setUseAlternateIcon(drawLines);
|
||||||
super.onClick(mouseX, mouseY);
|
buttonDrawLines.setTooltip(drawLines ? "Hide lines" : "Show lines");
|
||||||
drawLines = !drawLines;
|
});
|
||||||
buttonDrawLines.setUseAlternateIcon(drawLines);
|
|
||||||
buttonDrawLines.setTooltip(drawLines ? "Hide lines" : "Show lines");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
buttonDrawLines.setTooltip("Show lines");
|
buttonDrawLines.setTooltip("Show lines");
|
||||||
radialMirrorIconButtonList.add(buttonDrawLines);
|
radialMirrorIconButtonList.add(buttonDrawLines);
|
||||||
|
|
||||||
buttonDrawPlanes = new GuiIconButton(id++, left + 95, y, 0, 60, BUILDING_ICONS) {
|
buttonDrawPlanes = new GuiIconButton(left + 95, y, 0, 60, BUILDING_ICONS, button -> {
|
||||||
@Override
|
drawPlanes = !drawPlanes;
|
||||||
public void onClick(double mouseX, double mouseY) {
|
buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
||||||
super.onClick(mouseX, mouseY);
|
buttonDrawPlanes.setTooltip(drawPlanes ? "Hide area" : "Show area");
|
||||||
drawPlanes = !drawPlanes;
|
});
|
||||||
buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
|
||||||
buttonDrawPlanes.setTooltip(drawPlanes ? "Hide area" : "Show area");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
buttonDrawPlanes.setTooltip("Show area");
|
buttonDrawPlanes.setTooltip("Show area");
|
||||||
radialMirrorIconButtonList.add(buttonDrawPlanes);
|
radialMirrorIconButtonList.add(buttonDrawPlanes);
|
||||||
|
|
||||||
@@ -179,8 +164,6 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
buttonList.addAll(radialMirrorIconButtonList);
|
buttonList.addAll(radialMirrorIconButtonList);
|
||||||
|
|
||||||
setCollapsed(!buttonRadialMirrorEnabled.isChecked());
|
setCollapsed(!buttonRadialMirrorEnabled.isChecked());
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateScreen() {
|
public void updateScreen() {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package nl.requios.effortlessbuilding.gui.elements;
|
|||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
import net.minecraft.client.gui.font;
|
import net.minecraft.client.gui.widget.Widget;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
@@ -27,14 +27,11 @@ public abstract class GuiCollapsibleScrollEntry implements GuiScrollPane.IScroll
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int initGui(int id, List<Button> buttonList) {
|
public void init(List<Widget> buttonList) {
|
||||||
|
left = scrollPane.getWidth() / 2 - 140;
|
||||||
left = scrollPane.width / 2 - 140;
|
right = scrollPane.getWidth() / 2 + 140;
|
||||||
right = scrollPane.width / 2 + 140;
|
top = scrollPane.getHeight() / 2 - 100;
|
||||||
top = scrollPane.height / 2 - 100;
|
bottom = scrollPane.getHeight() / 2 + 100;
|
||||||
bottom = scrollPane.height / 2 + 100;
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ public class GuiIconButton extends Button {
|
|||||||
List<String> tooltip = new ArrayList<>();
|
List<String> tooltip = new ArrayList<>();
|
||||||
private boolean useAltIcon = false;
|
private boolean useAltIcon = false;
|
||||||
|
|
||||||
public GuiIconButton(int buttonId, int x, int y, int iconX, int iconY, ResourceLocation resourceLocation) {
|
public GuiIconButton(int x, int y, int iconX, int iconY, ResourceLocation resourceLocation, Button.IPressable onPress) {
|
||||||
this(buttonId, x, y, 20, 20, iconX, iconY, 20, 20, 20, 0, resourceLocation);
|
this(x, y, 20, 20, iconX, iconY, 20, 20, 20, 0, resourceLocation, onPress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuiIconButton(int buttonId, int x, int y, int width, int height, int iconX, int iconY, int iconWidth, int iconHeight, int iconAltX, int iconAltY, ResourceLocation resourceLocation) {
|
public GuiIconButton(int x, int y, int width, int height, int iconX, int iconY, int iconWidth, int iconHeight, int iconAltX, int iconAltY, ResourceLocation resourceLocation, Button.IPressable onPress) {
|
||||||
super(buttonId, x, y, width, height, "");
|
super(x, y, width, height, "", onPress);
|
||||||
this.iconX = iconX;
|
this.iconX = iconX;
|
||||||
this.iconY = iconY;
|
this.iconY = iconY;
|
||||||
this.iconWidth = iconWidth;
|
this.iconWidth = iconWidth;
|
||||||
@@ -51,7 +51,7 @@ public class GuiIconButton extends Button {
|
|||||||
super.render(mouseX, mouseY, partialTicks);
|
super.render(mouseX, mouseY, partialTicks);
|
||||||
if (this.visible)
|
if (this.visible)
|
||||||
{
|
{
|
||||||
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||||
Minecraft.getInstance().getTextureManager().bindTexture(this.resourceLocation);
|
Minecraft.getInstance().getTextureManager().bindTexture(this.resourceLocation);
|
||||||
int currentIconX = this.iconX;
|
int currentIconX = this.iconX;
|
||||||
int currentIconY = this.iconY;
|
int currentIconY = this.iconY;
|
||||||
@@ -62,17 +62,18 @@ public class GuiIconButton extends Button {
|
|||||||
currentIconY += iconAltY;
|
currentIconY += iconAltY;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.drawTexturedModalRect(this.x, this.y, currentIconX, currentIconY, this.iconWidth, this.iconHeight);
|
//Draws a textured rectangle at the current z-value. Used to be drawTexturedModalRect in Gui.
|
||||||
|
this.blit(this.x, this.y, currentIconX, currentIconY, this.iconWidth, this.iconHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawTooltip(Screen guiScreen, int mouseX, int mouseY) {
|
public void drawTooltip(Screen screen, int mouseX, int mouseY) {
|
||||||
boolean flag = mouseX >= x && mouseX < x + width && mouseY >= y && mouseY < y + height;
|
boolean flag = mouseX >= x && mouseX < x + width && mouseY >= y && mouseY < y + height;
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
List<String> textLines = new ArrayList<>();
|
List<String> textLines = new ArrayList<>();
|
||||||
textLines.addAll(tooltip);
|
textLines.addAll(tooltip);
|
||||||
guiScreen.drawHoveringText(textLines, mouseX - 10, mouseY + 25);
|
screen.renderTooltip(textLines, mouseX - 10, mouseY + 25);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package nl.requios.effortlessbuilding.gui.elements;
|
|||||||
import net.minecraft.client.gui.*;
|
import net.minecraft.client.gui.*;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||||
|
import net.minecraft.client.gui.widget.Widget;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
@@ -25,34 +26,27 @@ public class GuiNumberField extends AbstractGui {
|
|||||||
|
|
||||||
List<String> tooltip = new ArrayList<>();
|
List<String> tooltip = new ArrayList<>();
|
||||||
|
|
||||||
public GuiNumberField(int id1, int id2, int id3, FontRenderer font,
|
public GuiNumberField(FontRenderer font, List<Widget> buttonList, int x, int y, int width, int height) {
|
||||||
List<Button> buttonList, int x, int y, int width, int height) {
|
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
|
||||||
textField = new TextFieldWidget(id1, font, x + buttonWidth + 1, y + 1, width - 2 * buttonWidth - 2, height - 2);
|
textField = new TextFieldWidget(font, x + buttonWidth + 1, y + 1, width - 2 * buttonWidth - 2, height - 2, "");
|
||||||
minusButton = new Button(id2, x, y - 1, buttonWidth, height + 2, "-") {
|
minusButton = new Button(x, y - 1, buttonWidth, height + 2, "-", button -> {
|
||||||
@Override
|
float valueChanged = 1f;
|
||||||
public void onClick(double mouseX, double mouseY) {
|
if (Screen.hasControlDown()) valueChanged = 5f;
|
||||||
float valueChanged = 1f;
|
if (Screen.hasShiftDown()) valueChanged = 10f;
|
||||||
if (Screen.isCtrlKeyDown()) valueChanged = 5f;
|
|
||||||
if (Screen.isShiftKeyDown()) valueChanged = 10f;
|
|
||||||
|
|
||||||
setNumber(getNumber() - valueChanged);
|
setNumber(getNumber() - valueChanged);
|
||||||
}
|
});
|
||||||
};
|
plusButton = new Button(x + width - buttonWidth, y - 1, buttonWidth, height + 2, "+", button -> {
|
||||||
plusButton = new Button(id3, x + width - buttonWidth, y - 1, buttonWidth, height + 2, "+") {
|
float valueChanged = 1f;
|
||||||
@Override
|
if (Screen.hasControlDown()) valueChanged = 5f;
|
||||||
public void onClick(double mouseX, double mouseY) {
|
if (Screen.hasShiftDown()) valueChanged = 10f;
|
||||||
float valueChanged = 1f;
|
|
||||||
if (Screen.isCtrlKeyDown()) valueChanged = 5f;
|
|
||||||
if (Screen.isShiftKeyDown()) valueChanged = 10f;
|
|
||||||
|
|
||||||
setNumber(getNumber() + valueChanged);
|
setNumber(getNumber() + valueChanged);
|
||||||
}
|
});
|
||||||
};
|
|
||||||
|
|
||||||
buttonList.add(minusButton);
|
buttonList.add(minusButton);
|
||||||
buttonList.add(plusButton);
|
buttonList.add(plusButton);
|
||||||
@@ -88,7 +82,7 @@ public class GuiNumberField extends AbstractGui {
|
|||||||
//Rightclicked inside textfield
|
//Rightclicked inside textfield
|
||||||
if (flag && mouseButton == 1) {
|
if (flag && mouseButton == 1) {
|
||||||
textField.setText("");
|
textField.setText("");
|
||||||
textField.setFocused(true);
|
textField.setFocused2(true);
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,12 +94,12 @@ public class GuiNumberField extends AbstractGui {
|
|||||||
minusButton.y = y - 1;
|
minusButton.y = y - 1;
|
||||||
plusButton.y = y - 1;
|
plusButton.y = y - 1;
|
||||||
|
|
||||||
textField.drawTextField(mouseX, mouseY, partialTicks);
|
textField.render(mouseX, mouseY, partialTicks);
|
||||||
minusButton.render(mouseX, mouseY, partialTicks);
|
minusButton.render(mouseX, mouseY, partialTicks);
|
||||||
plusButton.render(mouseX, mouseY, partialTicks);
|
plusButton.render(mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawTooltip(Screen guiScreen, int mouseX, int mouseY) {
|
public void drawTooltip(Screen screen, int mouseX, int mouseY) {
|
||||||
boolean insideTextField = mouseX >= x + buttonWidth && mouseX < x + width - buttonWidth && mouseY >= y && mouseY < y + height;
|
boolean insideTextField = mouseX >= x + buttonWidth && mouseX < x + width - buttonWidth && mouseY >= y && mouseY < y + height;
|
||||||
boolean insideMinusButton = mouseX >= x && mouseX < x + buttonWidth && mouseY >= y && mouseY < y + height;
|
boolean insideMinusButton = mouseX >= x && mouseX < x + buttonWidth && mouseY >= y && mouseY < y + height;
|
||||||
boolean insidePlusButton = mouseX >= x + width - buttonWidth && mouseX < x + width && mouseY >= y && mouseY < y + height;
|
boolean insidePlusButton = mouseX >= x + width - buttonWidth && mouseX < x + width && mouseY >= y && mouseY < y + height;
|
||||||
@@ -128,7 +122,7 @@ public class GuiNumberField extends AbstractGui {
|
|||||||
textLines.add("Hold " + TextFormatting.AQUA + "ctrl " + TextFormatting.RESET + "for " + TextFormatting.DARK_GREEN + "5");
|
textLines.add("Hold " + TextFormatting.AQUA + "ctrl " + TextFormatting.RESET + "for " + TextFormatting.DARK_GREEN + "5");
|
||||||
}
|
}
|
||||||
|
|
||||||
guiScreen.drawHoveringText(textLines, mouseX - 10, mouseY + 25);
|
screen.renderTooltip(textLines, mouseX - 10, mouseY + 25);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,19 +4,15 @@ import com.mojang.blaze3d.platform.GlStateManager;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.*;
|
import net.minecraft.client.gui.*;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import net.minecraft.client.gui.widget.Widget;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.util.Util;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -50,131 +46,110 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getSize() {
|
protected int getItemCount() {
|
||||||
return listEntries.size();
|
return listEntries.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isSelected(int slotIndex) {
|
protected boolean isSelectedItem(int slotIndex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getScrollBarX() {
|
protected int getScrollbarPosition() {
|
||||||
//return width / 2 + 140 + 10;
|
//return width / 2 + 140 + 10;
|
||||||
return width - 15;
|
return width - 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getListWidth() {
|
public int getRowWidth() {
|
||||||
return 280;
|
return 280;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Removed background
|
//Removed background
|
||||||
@Override
|
@Override
|
||||||
public void drawScreen(int mouseXIn, int mouseYIn, float partialTicks)
|
public void render(int mouseXIn, int mouseYIn, float partialTicks)
|
||||||
{
|
{
|
||||||
if (this.visible)
|
if (this.visible) {
|
||||||
{
|
|
||||||
this.mouseX = mouseXIn;
|
this.mouseX = mouseXIn;
|
||||||
this.mouseY = mouseYIn;
|
this.mouseY = mouseYIn;
|
||||||
int scrollBarLeft = this.getScrollBarX();
|
this.renderBackground();
|
||||||
int scrollBarRight = scrollBarLeft + 6;
|
int scrollbarLeft = this.getScrollbarPosition();
|
||||||
this.bindAmountScrolled();
|
int scrollbarRight = scrollbarLeft + 6;
|
||||||
|
this.capYPosition();
|
||||||
GlStateManager.disableLighting();
|
GlStateManager.disableLighting();
|
||||||
GlStateManager.disableFog();
|
GlStateManager.disableFog();
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
BufferBuilder bufferbuilder = tessellator.getBuffer();
|
BufferBuilder bufferbuilder = tessellator.getBuffer();
|
||||||
int insideLeft = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
|
|
||||||
int insideTop = this.top + 4 - (int)this.amountScrolled;
|
|
||||||
|
|
||||||
if (this.hasListHeader) {
|
int insideLeft = this.x0 + this.width / 2 - this.getRowWidth() / 2 + 2;
|
||||||
this.drawListHeader(insideLeft, insideTop, tessellator);
|
int insideTop = this.y0 + 4 - (int) this.yo;
|
||||||
|
if (this.renderHeader) {
|
||||||
|
this.renderHeader(insideLeft, insideTop, tessellator);
|
||||||
}
|
}
|
||||||
|
|
||||||
//All entries
|
//All entries
|
||||||
this.drawSelectionBox(insideLeft, insideTop, mouseXIn, mouseYIn, partialTicks);
|
this.renderList(insideLeft, insideTop, mouseXIn, mouseYIn, partialTicks);
|
||||||
GlStateManager.disableDepthTest();
|
GlStateManager.disableDepthTest();
|
||||||
|
|
||||||
//Dirt overlays on top and bottom
|
//Dirt overlays on top and bottom
|
||||||
// this.overlayBackground(0, this.top, 255, 255);
|
// this.renderHoleBackground(0, this.y0, 255, 255);
|
||||||
// this.overlayBackground(this.bottom, this.height, 255, 255);
|
// this.renderHoleBackground(this.y1, this.height, 255, 255);
|
||||||
|
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ZERO, GlStateManager.DestFactor.ONE);
|
GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ZERO, GlStateManager.DestFactor.ONE);
|
||||||
GlStateManager.disableAlphaTest();
|
GlStateManager.disableAlphaTest();
|
||||||
GlStateManager.shadeModel(7425);
|
GlStateManager.shadeModel(7425);
|
||||||
GlStateManager.disableTexture2D();
|
GlStateManager.disableTexture();
|
||||||
|
|
||||||
// //top fade
|
//top
|
||||||
// bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
// bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||||
// bufferbuilder.pos((double)this.left, (double)(this.top + 5), 0.0D).tex(0.0D, 1.0D).color(100, 100, 100, 0).endVertex();
|
// bufferbuilder.pos((double)this.x0, (double)(this.y0 + 4), 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 0).endVertex();
|
||||||
// bufferbuilder.pos((double)this.right, (double)(this.top + 5), 0.0D).tex(1.0D, 1.0D).color(100, 100, 100, 0).endVertex();
|
// bufferbuilder.pos((double)this.x1, (double)(this.y0 + 4), 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 0).endVertex();
|
||||||
// bufferbuilder.pos((double)this.right, (double)this.top, 0.0D).tex(1.0D, 0.0D).color(100, 100, 100, 100).endVertex();
|
// bufferbuilder.pos((double)this.x1, (double)this.y0, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
||||||
// bufferbuilder.pos((double)this.left, (double)this.top, 0.0D).tex(0.0D, 0.0D).color(100, 100, 100, 100).endVertex();
|
// bufferbuilder.pos((double)this.x0, (double)this.y0, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
||||||
// tessellator.draw();
|
// tessellator.draw();
|
||||||
|
|
||||||
// //top line
|
//bottom
|
||||||
// bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
// bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||||
// bufferbuilder.pos((double)this.left, (double)this.top, 0.0D).tex(0.0D, 1.0D).color(20, 20, 20, 255).endVertex();
|
// bufferbuilder.pos((double)this.x0, (double)this.y1, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
||||||
// bufferbuilder.pos((double)this.right, (double)this.top, 0.0D).tex(1.0D, 1.0D).color(20, 20, 20, 255).endVertex();
|
// bufferbuilder.pos((double)this.x1, (double)this.y1, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
||||||
// bufferbuilder.pos((double)this.right, (double)(this.top - 1), 0.0D).tex(1.0D, 0.0D).color(20, 20, 20, 255).endVertex();
|
// bufferbuilder.pos((double)this.x1, (double)(this.y1 - 4), 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 0).endVertex();
|
||||||
// bufferbuilder.pos((double)this.left, (double)(this.top - 1), 0.0D).tex(0.0D, 0.0D).color(20, 20, 20, 255).endVertex();
|
// bufferbuilder.pos((double)this.x0, (double)(this.y1 - 4), 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 0).endVertex();
|
||||||
// tessellator.draw();
|
|
||||||
|
|
||||||
// //bottom fade
|
|
||||||
// bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
|
||||||
// bufferbuilder.pos((double)this.left, (double)this.bottom, 0.0D).tex(0.0D, 1.0D).color(10, 10, 10, 100).endVertex();
|
|
||||||
// bufferbuilder.pos((double)this.right, (double)this.bottom, 0.0D).tex(1.0D, 1.0D).color(10, 10, 10, 100).endVertex();
|
|
||||||
// bufferbuilder.pos((double)this.right, (double)(this.bottom - 5), 0.0D).tex(1.0D, 0.0D).color(10, 10, 10, 0).endVertex();
|
|
||||||
// bufferbuilder.pos((double)this.left, (double)(this.bottom - 5), 0.0D).tex(0.0D, 0.0D).color(10, 10, 10, 0).endVertex();
|
|
||||||
// tessellator.draw();
|
|
||||||
|
|
||||||
// //bottom line
|
|
||||||
// bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
|
||||||
// bufferbuilder.pos((double)this.left, (double)(this.bottom + 1), 0.0D).tex(0.0D, 1.0D).color(20, 20, 20, 255).endVertex();
|
|
||||||
// bufferbuilder.pos((double)this.right, (double)(this.bottom + 1), 0.0D).tex(1.0D, 1.0D).color(20, 20, 20, 255).endVertex();
|
|
||||||
// bufferbuilder.pos((double)this.right, (double)this.bottom, 0.0D).tex(1.0D, 0.0D).color(20, 20, 20, 255).endVertex();
|
|
||||||
// bufferbuilder.pos((double)this.left, (double)this.bottom, 0.0D).tex(0.0D, 0.0D).color(20, 20, 20, 255).endVertex();
|
|
||||||
// tessellator.draw();
|
// tessellator.draw();
|
||||||
|
|
||||||
//Draw scrollbar
|
//Draw scrollbar
|
||||||
int maxScroll = this.getMaxScroll();
|
int maxScroll = this.getMaxScroll();
|
||||||
if (maxScroll > 0)
|
if (maxScroll > 0) {
|
||||||
{
|
int k1 = (int) ((float) ((this.y1 - this.y0) * (this.y1 - this.y0)) / (float) this.getMaxPosition());
|
||||||
int k1 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();
|
k1 = MathHelper.clamp(k1, 32, this.y1 - this.y0 - 8);
|
||||||
k1 = MathHelper.clamp(k1, 32, this.bottom - this.top - 8);
|
int l1 = (int) this.yo * (this.y1 - this.y0 - k1) / maxScroll + this.y0;
|
||||||
int l1 = (int)this.amountScrolled * (this.bottom - this.top - k1) / maxScroll + this.top;
|
if (l1 < this.y0) {
|
||||||
|
l1 = this.y0;
|
||||||
if (l1 < this.top)
|
|
||||||
{
|
|
||||||
l1 = this.top;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||||
bufferbuilder.pos((double)scrollBarLeft, (double)this.bottom, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
bufferbuilder.pos((double) scrollbarLeft, (double) this.y1, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
||||||
bufferbuilder.pos((double)scrollBarRight, (double)this.bottom, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
bufferbuilder.pos((double) scrollbarRight, (double) this.y1, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
||||||
bufferbuilder.pos((double)scrollBarRight, (double)this.top, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
bufferbuilder.pos((double) scrollbarRight, (double) this.y0, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
||||||
bufferbuilder.pos((double)scrollBarLeft, (double)this.top, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
bufferbuilder.pos((double) scrollbarLeft, (double) this.y0, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||||
bufferbuilder.pos((double)scrollBarLeft, (double)(l1 + k1), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex();
|
bufferbuilder.pos((double) scrollbarLeft, (double) (l1 + k1), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex();
|
||||||
bufferbuilder.pos((double)scrollBarRight, (double)(l1 + k1), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex();
|
bufferbuilder.pos((double) scrollbarRight, (double) (l1 + k1), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex();
|
||||||
bufferbuilder.pos((double)scrollBarRight, (double)l1, 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex();
|
bufferbuilder.pos((double) scrollbarRight, (double) l1, 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex();
|
||||||
bufferbuilder.pos((double)scrollBarLeft, (double)l1, 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex();
|
bufferbuilder.pos((double) scrollbarLeft, (double) l1, 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex();
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||||
bufferbuilder.pos((double)scrollBarLeft, (double)(l1 + k1 - 1), 0.0D).tex(0.0D, 1.0D).color(192, 192, 192, 255).endVertex();
|
bufferbuilder.pos((double) scrollbarLeft, (double) (l1 + k1 - 1), 0.0D).tex(0.0D, 1.0D).color(192, 192, 192, 255).endVertex();
|
||||||
bufferbuilder.pos((double)(scrollBarRight - 1), (double)(l1 + k1 - 1), 0.0D).tex(1.0D, 1.0D).color(192, 192, 192, 255).endVertex();
|
bufferbuilder.pos((double) (scrollbarRight - 1), (double) (l1 + k1 - 1), 0.0D).tex(1.0D, 1.0D).color(192, 192, 192, 255).endVertex();
|
||||||
bufferbuilder.pos((double)(scrollBarRight - 1), (double)l1, 0.0D).tex(1.0D, 0.0D).color(192, 192, 192, 255).endVertex();
|
bufferbuilder.pos((double) (scrollbarRight - 1), (double) l1, 0.0D).tex(1.0D, 0.0D).color(192, 192, 192, 255).endVertex();
|
||||||
bufferbuilder.pos((double)scrollBarLeft, (double)l1, 0.0D).tex(0.0D, 0.0D).color(192, 192, 192, 255).endVertex();
|
bufferbuilder.pos((double) scrollbarLeft, (double) l1, 0.0D).tex(0.0D, 0.0D).color(192, 192, 192, 255).endVertex();
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.enableTexture2D();
|
GlStateManager.enableTexture();
|
||||||
GlStateManager.shadeModel(7424);
|
GlStateManager.shadeModel(7424);
|
||||||
GlStateManager.enableAlphaTest();
|
GlStateManager.enableAlphaTest();
|
||||||
GlStateManager.disableBlend();
|
GlStateManager.disableBlend();
|
||||||
@@ -184,9 +159,9 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
//SLOTHEIGHT MODIFICATIONS
|
//SLOTHEIGHT MODIFICATIONS
|
||||||
//SlotHeight is still relied on for determining how much to scroll
|
//SlotHeight is still relied on for determining how much to scroll
|
||||||
@Override
|
@Override
|
||||||
protected int getContentHeight() {
|
protected int getMaxPosition() {
|
||||||
//Add every entry height
|
//Add every entry height
|
||||||
int height = this.headerPadding;
|
int height = this.headerHeight;
|
||||||
for (IScrollEntry entry : listEntries) {
|
for (IScrollEntry entry : listEntries) {
|
||||||
height += entry.getHeight();
|
height += entry.getHeight();
|
||||||
}
|
}
|
||||||
@@ -194,19 +169,19 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawBackground() {
|
protected void renderBackground() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawSlot(int slotIndex, int xPos, int yPos, int heightIn, int mouseXIn, int mouseYIn, float partialTicks) {
|
protected void renderItem(int slotIndex, int xPos, int yPos, int heightIn, int mouseXIn, int mouseYIn, float partialTicks) {
|
||||||
this.getListEntry(slotIndex).drawEntry(slotIndex, xPos, yPos, this.getListWidth(), heightIn, mouseXIn, mouseYIn,
|
this.getListEntry(slotIndex).drawEntry(slotIndex, xPos, yPos, this.getRowWidth(), heightIn, mouseXIn, mouseYIn,
|
||||||
this.getSlotIndexFromScreenCoords(mouseXIn, mouseYIn) == slotIndex, partialTicks);
|
this.getSlotIndexFromScreenCoords(mouseXIn, mouseYIn) == slotIndex, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getContentHeight(int count) {
|
public int getMaxPosition(int count) {
|
||||||
//Add all count entry heights
|
//Add all count entry heights
|
||||||
int height = this.headerPadding;
|
int height = this.headerHeight;
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
IScrollEntry entry = listEntries.get(i);
|
IScrollEntry entry = listEntries.get(i);
|
||||||
height += entry.getHeight();
|
height += entry.getHeight();
|
||||||
@@ -215,23 +190,23 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getSlotIndexFromScreenCoords(double posX, double posY) {
|
public int getSlotIndexFromScreenCoords(double posX, double posY) {
|
||||||
int left = this.left + (this.width - this.getListWidth()) / 2;
|
int left = this.x0 + (this.width - this.getRowWidth()) / 2;
|
||||||
int right = this.left + (this.width + this.getListWidth()) / 2;
|
int right = this.x0 + (this.width + this.getRowWidth()) / 2;
|
||||||
double relativeMouseY = getRelativeMouseY(mouseY, 0);
|
double relativeMouseY = getRelativeMouseY(mouseY, 0);
|
||||||
|
|
||||||
//Iterate over every entry until relativeMouseY falls within its height
|
//Iterate over every entry until relativeMouseY falls within its height
|
||||||
for (int i = 0; i < listEntries.size(); i++) {
|
for (int i = 0; i < listEntries.size(); i++) {
|
||||||
IScrollEntry entry = listEntries.get(i);
|
IScrollEntry entry = listEntries.get(i);
|
||||||
if (relativeMouseY <= entry.getHeight())
|
if (relativeMouseY <= entry.getHeight())
|
||||||
return posX < this.getScrollBarX() && posX >= left && posX <= right && i >= 0 &&
|
return posX < this.getScrollbarPosition() && posX >= left && posX <= right && i >= 0 &&
|
||||||
relativeMouseY >= 0 && i < this.getSize() ? i : -1;
|
relativeMouseY >= 0 && i < this.getItemCount() ? i : -1;
|
||||||
relativeMouseY -= entry.getHeight();
|
relativeMouseY -= entry.getHeight();
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean mouseClicked(int index, int button, double mouseX, double mouseY) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
int selectedSlot = this.getSlotIndexFromScreenCoords(mouseX, mouseY);
|
int selectedSlot = this.getSlotIndexFromScreenCoords(mouseX, mouseY);
|
||||||
double relativeX = getRelativeMouseX(mouseX);
|
double relativeX = getRelativeMouseX(mouseX);
|
||||||
|
|
||||||
@@ -263,12 +238,12 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseReleased(double p_mouseReleased_1_, double p_mouseReleased_3_, int p_mouseReleased_5_) {
|
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||||
for (int i = 0; i < this.getSize(); ++i)
|
for (int i = 0; i < this.getItemCount(); ++i)
|
||||||
{
|
{
|
||||||
double relativeX = getRelativeMouseX(mouseX);
|
double relativeX = getRelativeMouseX(mouseX);
|
||||||
double relativeY = getRelativeMouseY(mouseY, i);
|
double relativeY = getRelativeMouseY(mouseY, i);
|
||||||
this.getListEntry(i).mouseReleased(i, (int) p_mouseReleased_1_, (int) p_mouseReleased_3_, p_mouseReleased_5_, (int) relativeX, (int) relativeY);
|
this.getListEntry(i).mouseReleased(i, (int) mouseX, (int) mouseY, button, (int) relativeX, (int) relativeY);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
@@ -277,45 +252,39 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
|
|
||||||
public void handleMouseInput() {
|
public void handleMouseInput() {
|
||||||
if (this.isMouseInList(this.mouseX, this.mouseY)) {
|
if (this.isMouseInList(this.mouseX, this.mouseY)) {
|
||||||
if (mc.mouseHelper.isLeftDown() && this.mouseY >= this.top &&
|
if (minecraft.mouseHelper.isLeftDown() && this.mouseY >= this.y0 &&
|
||||||
this.mouseY <= this.bottom) {
|
this.mouseY <= this.y1) {
|
||||||
int i = this.left + (this.width - this.getListWidth()) / 2;
|
int i = this.x0 + (this.width - this.getRowWidth()) / 2;
|
||||||
int j = this.left + (this.width + this.getListWidth()) / 2;
|
int j = this.x0 + (this.width + this.getRowWidth()) / 2;
|
||||||
int slotIndex = getSlotIndexFromScreenCoords(this.mouseX, this.mouseY);
|
int slotIndex = getSlotIndexFromScreenCoords(this.mouseX, this.mouseY);
|
||||||
double relativeMouseY = getRelativeMouseY(mouseY, slotIndex);
|
double relativeMouseY = getRelativeMouseY(mouseY, slotIndex);
|
||||||
|
|
||||||
if (slotIndex > -1) {
|
if (slotIndex > -1) {
|
||||||
this.mouseClicked(slotIndex, 0, this.mouseX, this.mouseY);
|
this.mouseClicked(this.mouseX, this.mouseY, 0);
|
||||||
this.selectedElement = slotIndex;
|
|
||||||
} else if (this.mouseX >= i && this.mouseX <= j && relativeMouseY < 0) {
|
} else if (this.mouseX >= i && this.mouseX <= j && relativeMouseY < 0) {
|
||||||
this.clickedHeader(this.mouseX - i, this.mouseY - this.top + (int) this.amountScrolled - 4);
|
this.clickedHeader(this.mouseX - i, this.mouseY - this.y0 + (int) this.yo - 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc.mouseHelper.isLeftDown() && this.isVisible()) {
|
if (minecraft.mouseHelper.isLeftDown() && this.isVisible()) {
|
||||||
if (this.initialClickY == -1) {
|
if (this.yDrag == -1) {
|
||||||
boolean flag1 = true;
|
boolean flag1 = true;
|
||||||
|
|
||||||
if (this.mouseY >= this.top && this.mouseY <= this.bottom) {
|
if (this.mouseY >= this.y0 && this.mouseY <= this.y1) {
|
||||||
int i2 = this.left + (this.width - this.getListWidth()) / 2;
|
int i2 = this.x0 + (this.width - this.getRowWidth()) / 2;
|
||||||
int j2 = this.left + (this.width + this.getListWidth()) / 2;
|
int j2 = this.x0 + (this.width + this.getRowWidth()) / 2;
|
||||||
int slotIndex = getSlotIndexFromScreenCoords(this.mouseX, this.mouseY);
|
int slotIndex = getSlotIndexFromScreenCoords(this.mouseX, this.mouseY);
|
||||||
double relativeMouseY = getRelativeMouseY(mouseY, slotIndex);
|
double relativeMouseY = getRelativeMouseY(mouseY, slotIndex);
|
||||||
|
|
||||||
if (slotIndex > -1) {
|
if (slotIndex > -1) {
|
||||||
//TODO 1.13 use flag
|
|
||||||
boolean flag = slotIndex == this.selectedElement &&
|
|
||||||
Util.milliTime() - this.lastClicked < 250L;
|
|
||||||
this.mouseClicked(slotIndex, this.mouseX, this.mouseY);
|
this.mouseClicked(slotIndex, this.mouseX, this.mouseY);
|
||||||
this.selectedElement = slotIndex;
|
|
||||||
this.lastClicked = Util.milliTime();
|
|
||||||
} else if (this.mouseX >= i2 && this.mouseX <= j2 && relativeMouseY < 0) {
|
} else if (this.mouseX >= i2 && this.mouseX <= j2 && relativeMouseY < 0) {
|
||||||
this.clickedHeader(this.mouseX - i2,
|
this.clickedHeader(this.mouseX - i2,
|
||||||
this.mouseY - this.top + (int) this.amountScrolled - 4);
|
this.mouseY - this.y0 + (int) this.yo - 4);
|
||||||
flag1 = false;
|
flag1 = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i3 = this.getScrollBarX();
|
int i3 = this.getScrollbarPosition();
|
||||||
int j1 = i3 + 6;
|
int j1 = i3 + 6;
|
||||||
|
|
||||||
if (this.mouseX >= i3 && this.mouseX <= j1) {
|
if (this.mouseX >= i3 && this.mouseX <= j1) {
|
||||||
@@ -326,60 +295,45 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
maxScroll = 1;
|
maxScroll = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int l1 = (int) ((float) ((this.bottom - this.top) * (this.bottom - this.top)) /
|
int l1 = (int) ((float) ((this.y1 - this.y0) * (this.y1 - this.y0)) /
|
||||||
(float) this.getContentHeight());
|
(float) this.getMaxPosition());
|
||||||
l1 = MathHelper.clamp(l1, 32, this.bottom - this.top - 8);
|
l1 = MathHelper.clamp(l1, 32, this.y1 - this.y0 - 8);
|
||||||
this.scrollMultiplier /= (float) (this.bottom - this.top - l1) / (float) maxScroll;
|
this.scrollMultiplier /= (float) (this.y1 - this.y0 - l1) / (float) maxScroll;
|
||||||
} else {
|
} else {
|
||||||
this.scrollMultiplier = 1.0F;
|
this.scrollMultiplier = 1.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag1) {
|
if (flag1) {
|
||||||
this.initialClickY = this.mouseY;
|
this.yDrag = this.mouseY;
|
||||||
} else {
|
} else {
|
||||||
this.initialClickY = -2;
|
this.yDrag = -2;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.initialClickY = -2;
|
this.yDrag = -2;
|
||||||
}
|
}
|
||||||
} else if (this.initialClickY >= 0) {
|
} else if (this.yDrag >= 0) {
|
||||||
this.amountScrolled -= (float) (this.mouseY - this.initialClickY) * this.scrollMultiplier;
|
this.yo -= (float) (this.mouseY - this.yDrag) * this.scrollMultiplier;
|
||||||
this.initialClickY = this.mouseY;
|
this.yDrag = this.mouseY;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.initialClickY = -1;
|
this.yDrag = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Through forge event instead of through the parent, because the parent no longer has scroll functionality in 1.13
|
|
||||||
@SubscribeEvent
|
|
||||||
public void mouseScrolled(GuiScreenEvent.MouseScrollEvent.Pre event) {
|
|
||||||
double scrollDelta = event.getScrollDelta();
|
|
||||||
if (scrollDelta != 0) {
|
|
||||||
if (scrollDelta > 0) {
|
|
||||||
scrollDelta = -1;
|
|
||||||
} else if (scrollDelta < 0) {
|
|
||||||
scrollDelta = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.amountScrolled += (float) (scrollDelta * this.slotHeight / 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Draw in center if it fits
|
//Draw in center if it fits
|
||||||
@Override
|
@Override
|
||||||
protected void drawSelectionBox(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks)
|
protected void renderList(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks)
|
||||||
{
|
{
|
||||||
int size = this.getSize();
|
int itemCount = this.getItemCount();
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
BufferBuilder bufferbuilder = tessellator.getBuffer();
|
BufferBuilder bufferbuilder = tessellator.getBuffer();
|
||||||
|
|
||||||
//Find y to start with
|
//Find y to start with
|
||||||
int y = this.headerPadding + insideTop;
|
int y = this.headerHeight + insideTop;
|
||||||
int contentHeight = getContentHeight();
|
int contentHeight = getMaxPosition();
|
||||||
int insideHeight = this.bottom - this.top - 4;
|
int insideHeight = this.y1 - this.y0 - 4;
|
||||||
|
|
||||||
if (contentHeight < insideHeight) {
|
if (contentHeight < insideHeight) {
|
||||||
//it fits, so we can center it vertically
|
//it fits, so we can center it vertically
|
||||||
@@ -387,66 +341,68 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Draw all entries
|
//Draw all entries
|
||||||
for (int i = 0; i < size; ++i)
|
for (int i = 0; i < itemCount; ++i)
|
||||||
{
|
{
|
||||||
int entryHeight = listEntries.get(i).getHeight();
|
int entryHeight = listEntries.get(i).getHeight();
|
||||||
int entryHeight2 = entryHeight - 4;
|
int entryHeight2 = entryHeight - 4;
|
||||||
|
|
||||||
if (y > this.bottom || y + entryHeight2 < this.top)
|
if (y > this.y1 || y + entryHeight2 < this.y0)
|
||||||
{
|
{
|
||||||
this.updateItemPos(i, insideLeft, y, partialTicks);
|
this.updateItemPosition(i, insideLeft, y, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.showSelectionBox && this.isSelected(i))
|
if (this.renderSelection && this.isSelectedItem(i)) {
|
||||||
{
|
int i1 = this.x0 + this.width / 2 - this.getRowWidth() / 2;
|
||||||
int i1 = this.left + this.width / 2 - this.getListWidth() / 2;
|
int j1 = this.x0 + this.width / 2 + this.getRowWidth() / 2;
|
||||||
int j1 = this.left + this.width / 2 + this.getListWidth() / 2;
|
GlStateManager.disableTexture();
|
||||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
float f = this.isFocused() ? 1.0F : 0.5F;
|
||||||
GlStateManager.disableTexture2D();
|
GlStateManager.color4f(f, f, f, 1.0F);
|
||||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
|
||||||
bufferbuilder.pos((double)i1, (double)(y + entryHeight2 + 2), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex();
|
bufferbuilder.pos((double)i1, (double)(y + entryHeight2 + 2), 0.0D).endVertex();
|
||||||
bufferbuilder.pos((double)j1, (double)(y + entryHeight2 + 2), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex();
|
bufferbuilder.pos((double)j1, (double)(y + entryHeight2 + 2), 0.0D).endVertex();
|
||||||
bufferbuilder.pos((double)j1, (double)(y - 2), 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex();
|
bufferbuilder.pos((double)j1, (double)(y - 2), 0.0D).endVertex();
|
||||||
bufferbuilder.pos((double)i1, (double)(y - 2), 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex();
|
bufferbuilder.pos((double)i1, (double)(y - 2), 0.0D).endVertex();
|
||||||
bufferbuilder.pos((double)(i1 + 1), (double)(y + entryHeight2 + 1), 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
|
||||||
bufferbuilder.pos((double)(j1 - 1), (double)(y + entryHeight2 + 1), 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
|
||||||
bufferbuilder.pos((double)(j1 - 1), (double)(y - 1), 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
|
||||||
bufferbuilder.pos((double)(i1 + 1), (double)(y - 1), 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
GlStateManager.enableTexture2D();
|
GlStateManager.color4f(0.0F, 0.0F, 0.0F, 1.0F);
|
||||||
|
bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
|
||||||
|
bufferbuilder.pos((double)(i1 + 1), (double)(y + entryHeight2 + 1), 0.0D).endVertex();
|
||||||
|
bufferbuilder.pos((double)(j1 - 1), (double)(y + entryHeight2 + 1), 0.0D).endVertex();
|
||||||
|
bufferbuilder.pos((double)(j1 - 1), (double)(y - 1), 0.0D).endVertex();
|
||||||
|
bufferbuilder.pos((double)(i1 + 1), (double)(y - 1), 0.0D).endVertex();
|
||||||
|
tessellator.draw();
|
||||||
|
GlStateManager.enableTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.drawSlot(i, insideLeft, y, entryHeight2, mouseXIn, mouseYIn, partialTicks);
|
this.renderItem(i, insideLeft, y, entryHeight2, mouseXIn, mouseYIn, partialTicks);
|
||||||
y += entryHeight;
|
y += entryHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getRelativeMouseX(double mouseX) {
|
private double getRelativeMouseX(double mouseX) {
|
||||||
int j = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
|
int j = this.x0 + this.width / 2 - this.getRowWidth() / 2 + 2;
|
||||||
return mouseX - j;
|
return mouseX - j;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getRelativeMouseY(double mouseY, int contentIndex) {
|
private double getRelativeMouseY(double mouseY, int contentIndex) {
|
||||||
int k = this.top + 4 - this.getAmountScrolled() + getContentHeight(contentIndex) + this.headerPadding;
|
int k = this.y0 + 4 - this.getScroll() + getMaxPosition(contentIndex) + this.headerHeight;
|
||||||
double relativeMouseY = mouseY - k;
|
double relativeMouseY = mouseY - k;
|
||||||
|
|
||||||
//Content might be centered, adjust relative mouse y accordingly
|
//Content might be centered, adjust relative mouse y accordingly
|
||||||
int contentHeight = getContentHeight();
|
int contentHeight = getMaxPosition();
|
||||||
int insideHeight = this.bottom - this.top - 4;
|
int insideHeight = this.y1 - this.y0 - 4;
|
||||||
|
|
||||||
if (contentHeight < insideHeight) {
|
if (contentHeight < insideHeight) {
|
||||||
//it fits, so we can center it vertically
|
//it fits, so we can center it vertically
|
||||||
relativeMouseY -= (insideHeight - contentHeight) / 2;
|
relativeMouseY -= (insideHeight - contentHeight) / 2f;
|
||||||
}
|
}
|
||||||
return relativeMouseY;
|
return relativeMouseY;
|
||||||
}
|
}
|
||||||
|
|
||||||
//PASSTHROUGHS
|
//PASSTHROUGHS
|
||||||
public int initGui(int id, List<Button> buttonList) {
|
public void init(List<Widget> buttonList) {
|
||||||
for (IScrollEntry entry : this.listEntries) {
|
for (IScrollEntry entry : this.listEntries) {
|
||||||
id = entry.initGui(id, buttonList);
|
entry.init(buttonList);
|
||||||
}
|
}
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateScreen() {
|
public void updateScreen() {
|
||||||
@@ -471,8 +427,17 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
entry.onGuiClosed();
|
entry.onGuiClosed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Make protected values available
|
||||||
|
public int getWidth() {
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeight() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
public interface IScrollEntry {
|
public interface IScrollEntry {
|
||||||
int initGui(int id, List<Button> buttonList);
|
void init(List<Widget> buttonList);
|
||||||
|
|
||||||
void updateScreen();
|
void updateScreen();
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ import java.util.function.Supplier;
|
|||||||
@Mod.EventBusSubscriber(value = {Dist.CLIENT})
|
@Mod.EventBusSubscriber(value = {Dist.CLIENT})
|
||||||
public class ClientProxy implements IProxy {
|
public class ClientProxy implements IProxy {
|
||||||
public static KeyBinding[] keyBindings;
|
public static KeyBinding[] keyBindings;
|
||||||
public static BlockRayTraceResult previousLookAt;
|
public static RayTraceResult previousLookAt;
|
||||||
public static BlockRayTraceResult currentLookAt;
|
public static RayTraceResult currentLookAt;
|
||||||
private static int placeCooldown = 0;
|
private static int placeCooldown = 0;
|
||||||
private static int breakCooldown = 0;
|
private static int breakCooldown = 0;
|
||||||
private static boolean shadersInitialized = false;
|
private static boolean shadersInitialized = false;
|
||||||
@@ -83,10 +83,10 @@ public class ClientProxy implements IProxy {
|
|||||||
keyBindings[2] = new KeyBinding("key.effortlessbuilding.creative.desc", KeyConflictContext.IN_GAME, InputMappings.getInputByCode(GLFW.GLFW_KEY_F4, 0), "key.effortlessbuilding.category");
|
keyBindings[2] = new KeyBinding("key.effortlessbuilding.creative.desc", KeyConflictContext.IN_GAME, InputMappings.getInputByCode(GLFW.GLFW_KEY_F4, 0), "key.effortlessbuilding.category");
|
||||||
keyBindings[3] = new KeyBinding("key.effortlessbuilding.mode.desc", KeyConflictContext.IN_GAME, InputMappings.getInputByCode(GLFW.GLFW_KEY_LEFT_ALT, 0), "key.effortlessbuilding.category") {
|
keyBindings[3] = new KeyBinding("key.effortlessbuilding.mode.desc", KeyConflictContext.IN_GAME, InputMappings.getInputByCode(GLFW.GLFW_KEY_LEFT_ALT, 0), "key.effortlessbuilding.category") {
|
||||||
@Override
|
@Override
|
||||||
public boolean func_197983_b(KeyBinding other) {
|
public boolean conflicts(KeyBinding other) {
|
||||||
//Does not conflict with Chisels and Bits radial menu
|
//Does not conflict with Chisels and Bits radial menu
|
||||||
if (other.getKey().getKeyCode() == getKey().getKeyCode() && other.getKeyDescription().equals("mod.chiselsandbits.other.mode")) return false;
|
if (other.getKey().getKeyCode() == getKey().getKeyCode() && other.getKeyDescription().equals("mod.chiselsandbits.other.mode")) return false;
|
||||||
return super.func_197983_b(other);
|
return super.conflicts(other);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
keyBindings[4] = new KeyBinding("key.effortlessbuilding.undo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, InputMappings.getInputByCode(GLFW.GLFW_KEY_Z, 0), "key.effortlessbuilding.category");
|
keyBindings[4] = new KeyBinding("key.effortlessbuilding.undo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, InputMappings.getInputByCode(GLFW.GLFW_KEY_Z, 0), "key.effortlessbuilding.category");
|
||||||
@@ -105,29 +105,20 @@ public class ClientProxy implements IProxy {
|
|||||||
return (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT ? Minecraft.getInstance().player : ctx.get().getSender());
|
return (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT ? Minecraft.getInstance().player : ctx.get().getSender());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onEntityJoinWorld(EntityJoinWorldEvent event) {
|
|
||||||
if (event.getEntity() == Minecraft.getInstance().player) {
|
|
||||||
event.getWorld().addEventListener(new RenderHandler());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onTextureStitch(final TextureStitchEvent.Pre event) {
|
public static void onTextureStitch(final TextureStitchEvent.Pre event) {
|
||||||
//register icon textures
|
//register icon textures
|
||||||
final AtlasTexture map = event.getMap();
|
|
||||||
|
|
||||||
for ( final BuildModes.BuildModeEnum mode : BuildModes.BuildModeEnum.values() )
|
for ( final BuildModes.BuildModeEnum mode : BuildModes.BuildModeEnum.values() )
|
||||||
{
|
{
|
||||||
final ResourceLocation sprite = new ResourceLocation(EffortlessBuilding.MODID, "icons/" + mode.name().toLowerCase());
|
final ResourceLocation sprite = new ResourceLocation(EffortlessBuilding.MODID, "icons/" + mode.name().toLowerCase());
|
||||||
map.registerSprite(Minecraft.getInstance().getResourceManager(), sprite);
|
event.addSprite(sprite);
|
||||||
buildModeIcons.put(mode, sprite);
|
buildModeIcons.put(mode, sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( final ModeOptions.ActionEnum action : ModeOptions.ActionEnum.values() )
|
for ( final ModeOptions.ActionEnum action : ModeOptions.ActionEnum.values() )
|
||||||
{
|
{
|
||||||
final ResourceLocation sprite = new ResourceLocation(EffortlessBuilding.MODID, "icons/" + action.name().toLowerCase());
|
final ResourceLocation sprite = new ResourceLocation(EffortlessBuilding.MODID, "icons/" + action.name().toLowerCase());
|
||||||
map.registerSprite(Minecraft.getInstance().getResourceManager(), sprite);
|
event.addSprite(sprite);
|
||||||
modeOptionIcons.put(action, sprite);
|
modeOptionIcons.put(action, sprite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,7 +153,7 @@ public class ClientProxy implements IProxy {
|
|||||||
currentLookAt = objectMouseOver;
|
currentLookAt = objectMouseOver;
|
||||||
previousLookAt = objectMouseOver;
|
previousLookAt = objectMouseOver;
|
||||||
} else {
|
} else {
|
||||||
if (currentLookAt.getPos() != objectMouseOver.getPos()) {
|
if (((BlockRayTraceResult) currentLookAt).getPos() != ((BlockRayTraceResult) objectMouseOver).getPos()) {
|
||||||
previousLookAt = currentLookAt;
|
previousLookAt = currentLookAt;
|
||||||
currentLookAt = objectMouseOver;
|
currentLookAt = objectMouseOver;
|
||||||
}
|
}
|
||||||
@@ -210,21 +201,27 @@ public class ClientProxy implements IProxy {
|
|||||||
ItemStack itemStack = CompatHelper.getItemBlockFromStack(currentItemStack);
|
ItemStack itemStack = CompatHelper.getItemBlockFromStack(currentItemStack);
|
||||||
|
|
||||||
//find position in distance
|
//find position in distance
|
||||||
BlockRayTraceResult lookingAt = getLookingAt(player);
|
RayTraceResult lookingAt = getLookingAt(player);
|
||||||
BuildModes.onBlockPlacedMessage(player, lookingAt == null ? new BlockPlacedMessage() : new BlockPlacedMessage(lookingAt, true));
|
if (lookingAt != null && lookingAt.getType() == RayTraceResult.Type.BLOCK) {
|
||||||
PacketHandler.INSTANCE.sendToServer(lookingAt == null ? new BlockPlacedMessage() : new BlockPlacedMessage(lookingAt, true));
|
BlockRayTraceResult blockLookingAt = (BlockRayTraceResult) lookingAt;
|
||||||
|
|
||||||
//play sound if further than normal
|
BuildModes.onBlockPlacedMessage(player, new BlockPlacedMessage(blockLookingAt, true));
|
||||||
if (lookingAt != null && lookingAt.getType() == RayTraceResult.Type.BLOCK &&
|
PacketHandler.INSTANCE.sendToServer(new BlockPlacedMessage(blockLookingAt, true));
|
||||||
(lookingAt.getHitVec().subtract(player.getEyePosition(1f))).lengthSquared() > 25f &&
|
|
||||||
itemStack.getItem() instanceof BlockItem) {
|
|
||||||
|
|
||||||
BlockState state = ((BlockItem) itemStack.getItem()).getBlock().getDefaultState();
|
//play sound if further than normal
|
||||||
BlockPos blockPos = lookingAt.getPos();
|
if ((blockLookingAt.getHitVec().subtract(player.getEyePosition(1f))).lengthSquared() > 25f &&
|
||||||
SoundType soundType = state.getBlock().getSoundType(state, player.world, blockPos, player);
|
itemStack.getItem() instanceof BlockItem) {
|
||||||
player.world.playSound(player, player.getPosition(), soundType.getPlaceSound(), SoundCategory.BLOCKS,
|
|
||||||
0.4f, soundType.getPitch() * 1f);
|
BlockState state = ((BlockItem) itemStack.getItem()).getBlock().getDefaultState();
|
||||||
player.swingArm(Hand.MAIN_HAND);
|
BlockPos blockPos = blockLookingAt.getPos();
|
||||||
|
SoundType soundType = state.getBlock().getSoundType(state, player.world, blockPos, player);
|
||||||
|
player.world.playSound(player, player.getPosition(), soundType.getPlaceSound(), SoundCategory.BLOCKS,
|
||||||
|
0.4f, soundType.getPitch() * 1f);
|
||||||
|
player.swingArm(Hand.MAIN_HAND);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
BuildModes.onBlockPlacedMessage(player, new BlockPlacedMessage());
|
||||||
|
PacketHandler.INSTANCE.sendToServer(new BlockPlacedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,20 +245,26 @@ public class ClientProxy implements IProxy {
|
|||||||
// moving it to after buildmodes fixes that, but introduces this bug
|
// moving it to after buildmodes fixes that, but introduces this bug
|
||||||
if (!ReachHelper.canBreakFar(player)) return;
|
if (!ReachHelper.canBreakFar(player)) return;
|
||||||
|
|
||||||
BlockRayTraceResult lookingAt = getLookingAt(player);
|
RayTraceResult lookingAt = getLookingAt(player);
|
||||||
BuildModes.onBlockBrokenMessage(player, lookingAt == null ? new BlockBrokenMessage() : new BlockBrokenMessage(lookingAt));
|
if (lookingAt != null && lookingAt.getType() == RayTraceResult.Type.BLOCK) {
|
||||||
PacketHandler.INSTANCE.sendToServer(lookingAt == null ? new BlockBrokenMessage() : new BlockBrokenMessage(lookingAt));
|
BlockRayTraceResult blockLookingAt = (BlockRayTraceResult) lookingAt;
|
||||||
|
|
||||||
//play sound if further than normal
|
BuildModes.onBlockBrokenMessage(player, new BlockBrokenMessage(blockLookingAt));
|
||||||
if (lookingAt != null && lookingAt.getType() == RayTraceResult.Type.BLOCK &&
|
PacketHandler.INSTANCE.sendToServer(new BlockBrokenMessage(blockLookingAt));
|
||||||
(lookingAt.getHitVec().subtract(player.getEyePosition(1f))).lengthSquared() > 25f) {
|
|
||||||
|
|
||||||
BlockPos blockPos = lookingAt.getPos();
|
//play sound if further than normal
|
||||||
BlockState state = player.world.getBlockState(blockPos);
|
if ((blockLookingAt.getHitVec().subtract(player.getEyePosition(1f))).lengthSquared() > 25f) {
|
||||||
SoundType soundtype = state.getBlock().getSoundType(state, player.world, blockPos, player);
|
|
||||||
player.world.playSound(player, player.getPosition(), soundtype.getBreakSound(), SoundCategory.BLOCKS,
|
BlockPos blockPos = blockLookingAt.getPos();
|
||||||
0.4f, soundtype.getPitch() * 1f);
|
BlockState state = player.world.getBlockState(blockPos);
|
||||||
player.swingArm(Hand.MAIN_HAND);
|
SoundType soundtype = state.getBlock().getSoundType(state, player.world, blockPos, player);
|
||||||
|
player.world.playSound(player, player.getPosition(), soundtype.getBreakSound(), SoundCategory.BLOCKS,
|
||||||
|
0.4f, soundtype.getPitch() * 1f);
|
||||||
|
player.swingArm(Hand.MAIN_HAND);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
BuildModes.onBlockBrokenMessage(player, new BlockBrokenMessage());
|
||||||
|
PacketHandler.INSTANCE.sendToServer(new BlockBrokenMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (buildMode == BuildModes.BuildModeEnum.NORMAL_PLUS) {
|
else if (buildMode == BuildModes.BuildModeEnum.NORMAL_PLUS) {
|
||||||
@@ -371,7 +374,7 @@ public class ClientProxy implements IProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static BlockRayTraceResult getLookingAt(PlayerEntity player) {
|
public static RayTraceResult getLookingAt(PlayerEntity player) {
|
||||||
World world = player.world;
|
World world = player.world;
|
||||||
|
|
||||||
//base distance off of player ability (config)
|
//base distance off of player ability (config)
|
||||||
@@ -381,7 +384,7 @@ public class ClientProxy implements IProxy {
|
|||||||
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
|
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
|
||||||
Vec3d end = new Vec3d(player.posX + look.x * raytraceRange, player.posY + player.getEyeHeight() + look.y * raytraceRange, player.posZ + look.z * raytraceRange);
|
Vec3d end = new Vec3d(player.posX + look.x * raytraceRange, player.posY + player.getEyeHeight() + look.y * raytraceRange, player.posZ + look.z * raytraceRange);
|
||||||
// return player.rayTrace(raytraceRange, 1f, RayTraceFluidMode.NEVER);
|
// return player.rayTrace(raytraceRange, 1f, RayTraceFluidMode.NEVER);
|
||||||
//TODO 1.14 check if correct, make sure it is a blockraytraceresult
|
//TODO 1.14 check if correct
|
||||||
return world.rayTraceBlocks(new RayTraceContext(start, end, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, player));
|
return world.rayTraceBlocks(new RayTraceContext(start, end, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public class BlockPreviewRenderer {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//Render block previews
|
//Render block previews
|
||||||
BlockRayTraceResult lookingAt = ClientProxy.getLookingAt(player);
|
RayTraceResult lookingAt = ClientProxy.getLookingAt(player);
|
||||||
if (modeSettings.getBuildMode() == BuildModes.BuildModeEnum.NORMAL) lookingAt = Minecraft.getInstance().objectMouseOver;
|
if (modeSettings.getBuildMode() == BuildModes.BuildModeEnum.NORMAL) lookingAt = Minecraft.getInstance().objectMouseOver;
|
||||||
|
|
||||||
ItemStack mainhand = player.getHeldItemMainhand();
|
ItemStack mainhand = player.getHeldItemMainhand();
|
||||||
@@ -107,14 +107,15 @@ public class BlockPreviewRenderer {
|
|||||||
|
|
||||||
//Checking for null is necessary! Even in vanilla when looking down ladders it is occasionally null (instead of Type MISS)
|
//Checking for null is necessary! Even in vanilla when looking down ladders it is occasionally null (instead of Type MISS)
|
||||||
if (lookingAt != null && lookingAt.getType() == RayTraceResult.Type.BLOCK) {
|
if (lookingAt != null && lookingAt.getType() == RayTraceResult.Type.BLOCK) {
|
||||||
startPos = lookingAt.getPos();
|
BlockRayTraceResult blockLookingAt = (BlockRayTraceResult) lookingAt;
|
||||||
|
startPos = blockLookingAt.getPos();
|
||||||
|
|
||||||
//Check if tool (or none) in hand
|
//Check if tool (or none) in hand
|
||||||
//TODO 1.13 replaceable
|
//TODO 1.13 replaceable
|
||||||
boolean replaceable = player.world.getBlockState(startPos).getBlock().getMaterial(player.world.getBlockState(startPos)).isReplaceable();
|
boolean replaceable = player.world.getBlockState(startPos).getBlock().getMaterial(player.world.getBlockState(startPos)).isReplaceable();
|
||||||
boolean becomesDoubleSlab = SurvivalHelper.doesBecomeDoubleSlab(player, startPos, lookingAt.getFace());
|
boolean becomesDoubleSlab = SurvivalHelper.doesBecomeDoubleSlab(player, startPos, blockLookingAt.getFace());
|
||||||
if (!modifierSettings.doQuickReplace() && !toolInHand && !replaceable && !becomesDoubleSlab) {
|
if (!modifierSettings.doQuickReplace() && !toolInHand && !replaceable && !becomesDoubleSlab) {
|
||||||
startPos = startPos.offset(lookingAt.getFace());
|
startPos = startPos.offset(blockLookingAt.getFace());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get under tall grass and other replaceable blocks
|
//Get under tall grass and other replaceable blocks
|
||||||
@@ -122,8 +123,8 @@ public class BlockPreviewRenderer {
|
|||||||
startPos = startPos.down();
|
startPos = startPos.down();
|
||||||
}
|
}
|
||||||
|
|
||||||
sideHit = lookingAt.getFace();
|
sideHit = blockLookingAt.getFace();
|
||||||
hitVec = lookingAt.getHitVec();
|
hitVec = blockLookingAt.getHitVec();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Dont render if in normal mode and modifiers are disabled
|
//Dont render if in normal mode and modifiers are disabled
|
||||||
@@ -265,10 +266,11 @@ public class BlockPreviewRenderer {
|
|||||||
RenderHandler.beginLines();
|
RenderHandler.beginLines();
|
||||||
//Draw outlines if tool in hand
|
//Draw outlines if tool in hand
|
||||||
//Find proper raytrace: either normal range or increased range depending on canBreakFar
|
//Find proper raytrace: either normal range or increased range depending on canBreakFar
|
||||||
BlockRayTraceResult objectMouseOver = Minecraft.getInstance().objectMouseOver;
|
RayTraceResult objectMouseOver = Minecraft.getInstance().objectMouseOver;
|
||||||
BlockRayTraceResult breakingRaytrace = ReachHelper.canBreakFar(player) ? lookingAt : objectMouseOver;
|
RayTraceResult breakingRaytrace = ReachHelper.canBreakFar(player) ? lookingAt : objectMouseOver;
|
||||||
if (toolInHand && breakingRaytrace != null && breakingRaytrace.getType() == RayTraceResult.Type.BLOCK) {
|
if (toolInHand && breakingRaytrace != null && breakingRaytrace.getType() == RayTraceResult.Type.BLOCK) {
|
||||||
List<BlockPos> breakCoordinates = BuildModifiers.findCoordinates(player, breakingRaytrace.getPos());
|
BlockRayTraceResult blockBreakingRaytrace = (BlockRayTraceResult) breakingRaytrace;
|
||||||
|
List<BlockPos> breakCoordinates = BuildModifiers.findCoordinates(player, blockBreakingRaytrace.getPos());
|
||||||
|
|
||||||
//Only render first outline if further than normal reach
|
//Only render first outline if further than normal reach
|
||||||
boolean excludeFirst = objectMouseOver != null && objectMouseOver.getType() == RayTraceResult.Type.BLOCK;
|
boolean excludeFirst = objectMouseOver != null && objectMouseOver.getType() == RayTraceResult.Type.BLOCK;
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
{
|
{
|
||||||
|
"effortlessbuilding.screen.modifier_settings": "Modifier Settings",
|
||||||
|
"effortlessbuilding.screen.radial_menu": "Build Modes",
|
||||||
|
"effortlessbuilding.screen.randomizer_bag": "Randomizer Bag",
|
||||||
|
|
||||||
"key.effortlessbuilding.category": "Effortless Building",
|
"key.effortlessbuilding.category": "Effortless Building",
|
||||||
"key.effortlessbuilding.hud.desc": "Modifier Menu",
|
"key.effortlessbuilding.hud.desc": "Modifier Menu",
|
||||||
"key.effortlessbuilding.replace.desc": "Toggle QuickReplace",
|
"key.effortlessbuilding.replace.desc": "Toggle QuickReplace",
|
||||||
|
|||||||
Reference in New Issue
Block a user