Skip to content

Commit

Permalink
Merge branch 'Mrbysco-eyemineV2_mc1_16_5' into eyemineV2_mc1_16_5
Browse files Browse the repository at this point in the history
  • Loading branch information
kmcnaught committed Mar 24, 2021
2 parents 292e49a + 8393bee commit da45dd2
Show file tree
Hide file tree
Showing 55 changed files with 821 additions and 663 deletions.
32 changes: 22 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
build/**
.gradle/**
/bin/
.metadata/**
.settings/**
run/**
.project
**.swp
# eclipse
bin
*.launch
.settings
.metadata
.classpath
/.gradle/
/build/
.project
.swp

# idea
out
*.ipr
*.iws
*.iml
.idea

# gradle
build
.gradle

# other
eclipse
run
logs
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

mcversion=1.14.4
forgeversion=28.2.0
mcversion=1.16.5
forgeversion=36.1.0
forgegroup=net.minecraftforge
mcp_mappings=20190719-1.14.3
mcp_mappings=20210309-1.16.5

modversion=2.1.13
modversion=3.0.2


2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
43 changes: 25 additions & 18 deletions src/main/java/at/feldim2425/moreoverlays/gui/ConfigScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
import java.util.List;

import at.feldim2425.moreoverlays.gui.config.ConfigOptionList;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.fml.client.config.GuiUnicodeGlyphButton;
import net.minecraftforge.fml.client.gui.widget.UnicodeGlyphButton;


public class ConfigScreen extends Screen {
Expand Down Expand Up @@ -59,7 +62,7 @@ protected void init() {
// Lower buttons layout with padding will be:
// 2*p | button | p | button | p | button | p | button | 2*p
int pad = 5;
int buttonWidth = (Minecraft.getInstance().mainWindow.getScaledWidth() - 7*pad)/4;
int buttonWidth = (Minecraft.getInstance().getMainWindow().getScaledWidth() - 7*pad)/4;
final int buttonHeight = 20;

// Button positions
Expand All @@ -68,15 +71,15 @@ protected void init() {
final int xDefaultAll = this.width - buttonWidth - pad*2;
final int xUndoAll = xDefaultAll - buttonWidth - pad;

this.btnReset = new GuiUnicodeGlyphButton(xDefaultAll, buttonY, buttonWidth, buttonHeight,
" " + this.txtReset, ConfigOptionList.RESET_CHAR, 1.0f,
this.btnReset = new UnicodeGlyphButton(xDefaultAll, buttonY, buttonWidth, buttonHeight,
new StringTextComponent(" " + this.txtReset), ConfigOptionList.RESET_CHAR, 1.0f,
(btn) -> this.optionList.reset());

this.btnUndo = new GuiUnicodeGlyphButton(xUndoAll, buttonY, buttonWidth, buttonHeight,
" " + this.txtUndo, ConfigOptionList.UNDO_CHAR, 1.0f,
this.btnUndo = new UnicodeGlyphButton(xUndoAll, buttonY, buttonWidth, buttonHeight,
new StringTextComponent(" " + this.txtUndo), ConfigOptionList.UNDO_CHAR, 1.0f,
(btn) -> this.optionList.undo());

this.btnBack = new Button(xBack, buttonY, buttonWidth, buttonHeight, this.txtDone,
this.btnBack = new Button(xBack, buttonY, buttonWidth, buttonHeight, new StringTextComponent(this.txtDone),
(btn) -> this.back());

this.children.add(this.optionList);
Expand All @@ -100,18 +103,18 @@ private void back() {
}
}

@Override
public void render(int mouseX, int mouseY, float partialTick) {
this.renderBackground();
this.optionList.render(mouseX, mouseY, partialTick);
this.btnReset.render(mouseX, mouseY, partialTick);
this.btnUndo.render(mouseX, mouseY, partialTick);
this.btnBack.render(mouseX, mouseY, partialTick);
this.drawCenteredString(this.font, this.title.getFormattedText(), this.width / 2, 8, 16777215);
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTick) {
this.renderBackground(matrixStack);
this.optionList.render(matrixStack, mouseX, mouseY, partialTick);
this.btnReset.render(matrixStack, mouseX, mouseY, partialTick);
this.btnUndo.render(matrixStack, mouseX, mouseY, partialTick);
this.btnBack.render(matrixStack, mouseX, mouseY, partialTick);
this.drawCenteredString(matrixStack, this.font, this.title.getString(), this.width / 2, 8, 16777215);
if(this.categoryTitle != null){
this.drawCenteredString(this.font, this.categoryTitle, this.width / 2, 24, 16777215);
this.drawCenteredString(matrixStack, this.font, this.categoryTitle, this.width / 2, 24, 16777215);
}
super.render(mouseX, mouseY, partialTick);
super.render(matrixStack, mouseX, mouseY, partialTick);
}

private void save(){
Expand Down Expand Up @@ -142,7 +145,7 @@ public void updatePath(final List<String> newPath){
if (categoryComment != null) {
this.categoryTitle = categoryComment;
}
}
}
}

pathCache.clear();
Expand All @@ -159,4 +162,8 @@ public boolean keyPressed(int key, int p_keyPressed_2_, int p_keyPressed_3_) {
return super.keyPressed(key, p_keyPressed_2_, p_keyPressed_3_);
}
}

public void drawRightAlignedString(MatrixStack matrixStack, FontRenderer fontRenderer, String font, int text, int x, int y) {
fontRenderer.drawStringWithShadow(matrixStack, font, (float)(text - fontRenderer.getStringWidth(font)), (float)x, y);
}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
package at.feldim2425.moreoverlays.gui.config;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import at.feldim2425.moreoverlays.gui.ConfigScreen;
import com.electronwill.nightconfig.core.CommentedConfig;
import com.electronwill.nightconfig.core.UnmodifiableConfig;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;

import at.feldim2425.moreoverlays.gui.ConfigScreen;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.IGuiEventListener;
import net.minecraft.client.gui.INestedGuiEventHandler;
import net.minecraft.client.gui.widget.list.AbstractOptionList;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.common.ForgeConfigSpec;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

// TODO: As I wrote this system I noticed, that the way AbstractOptionList renders items and passes events is not optimal for this purpose
// Rendering is done in one pass therefore Tooltips will usually be rendered below other items further down and events are only passed
Expand Down Expand Up @@ -74,16 +73,15 @@ public void updateGui() {
this.updateSize(this.parent.width, this.parent.height, 43, this.parent.height - 32);
}


@Override
protected void renderDecorations(int p_renderDecorations_1_, int p_renderDecorations_2_) {
protected void renderDecorations(MatrixStack matrixStack, int p_renderDecorations_1_, int p_renderDecorations_2_) {
int i = this.getItemCount();
for(int j = 0; j < i; ++j) {
int k = this.getRowTop(j);
int l = this.getRowTop(j) + ITEM_HEIGHT;
if (l >= this.y0 && k <= this.y1) {
ConfigOptionList.OptionEntry e = this.getEntry(j);
e.runRenderTooltip();
e.runRenderTooltip(matrixStack);
}
}
}
Expand Down Expand Up @@ -180,9 +178,9 @@ public void pop(int amount) {
public boolean mouseClicked(double p_mouseClicked_1_, double p_mouseClicked_3_, int p_mouseClicked_5_) {
boolean flag = super.mouseClicked(p_mouseClicked_1_, p_mouseClicked_3_, p_mouseClicked_5_);
OptionEntry selected = this.getEntryAtPosition(p_mouseClicked_1_, p_mouseClicked_3_);
for(final OptionEntry entry : this.children()){
for(final OptionEntry entry : this.getEventListeners()){
if(entry != selected){
entry.setFocused(null);
entry.setListener(null);
}
}

Expand Down Expand Up @@ -216,7 +214,7 @@ else if(cEntry.getValue() instanceof ForgeConfigSpec.BooleanValue){
this.addEntry(new OptionGeneric<>(this, (ForgeConfigSpec.ConfigValue<?>)cEntry.getValue(), (ForgeConfigSpec.ValueSpec)rootConfig.getSpec().get(fullPath)));
}
}
this.setFocused(null);
this.setListener(null);
}

public List<String> getCurrentPath() {
Expand All @@ -233,7 +231,7 @@ public String getModId(){

public boolean isSaveable(){
boolean hasChanges = false;
for(final OptionEntry entry : this.children()){
for(final OptionEntry entry : this.getEventListeners()){
if(!entry.isValid()){
return false;
}
Expand All @@ -244,34 +242,34 @@ public boolean isSaveable(){

public boolean isResettable(){
boolean resettable = false;
for(final OptionEntry entry : this.children()){
for(final OptionEntry entry : this.getEventListeners()){
resettable = resettable || entry.isResettable();
}
return resettable;
}

public boolean isUndoable(){
boolean hasChanges = false;
for(final OptionEntry entry : this.children()){
for(final OptionEntry entry : this.getEventListeners()){
hasChanges = hasChanges || entry.hasChanges();
}
return hasChanges;
}

public void reset(){
for(final OptionEntry entry : this.children()){
for(final OptionEntry entry : this.getEventListeners()){
entry.reset();
}
}

public void undo(){
for(final OptionEntry entry : this.children()){
for(final OptionEntry entry : this.getEventListeners()){
entry.undo();
}
}

public void save() {
for(final OptionEntry entry : this.children()){
for(final OptionEntry entry : this.getEventListeners()){
if (entry.isValid()) {
entry.save();
}
Expand All @@ -291,7 +289,7 @@ public OptionEntry(ConfigOptionList list) {
}

@Override
public void render(int itemindex, int rowTop, int rowLeft, int rowWidth, int itemHeight, int mouseX, int mouseY,
public void render(MatrixStack matrixStack, int itemindex, int rowTop, int rowLeft, int rowWidth, int itemHeight, int mouseX, int mouseY,
boolean mouseOver, float partialTick) {
this.rowTop = rowTop;
this.rowLeft = rowLeft;
Expand All @@ -304,12 +302,12 @@ public void render(int itemindex, int rowTop, int rowLeft, int rowWidth, int ite
mouseX -= rowLeft;
mouseY -= rowTop;
GlStateManager.translatef(rowLeft, rowTop, 0);
renderControls(rowTop, rowLeft, rowWidth, itemHeight, mouseX, mouseY, mouseOver, partialTick);
renderControls(matrixStack, rowTop, rowLeft, rowWidth, itemHeight, mouseX, mouseY, mouseOver, partialTick);

GlStateManager.translatef(-rowLeft, -rowTop, 0);
}

protected abstract void renderControls(int rowTop, int rowLeft, int rowWidth, int itemHeight, int mouseX, int mouseY,
protected abstract void renderControls(MatrixStack matrixStack, int rowTop, int rowLeft, int rowWidth, int itemHeight, int mouseX, int mouseY,
boolean mouseOver, float partialTick);

/*
Expand All @@ -319,19 +317,19 @@ protected abstract void renderControls(int rowTop, int rowLeft, int rowWidth, in
* Not the best way but AbstractOptionList doesn't seem to have any better hooks to do that.
* A custom Implementation would be better but I'm too lazy to do that
*/
public void runRenderTooltip(){
public void runRenderTooltip(MatrixStack matrixStack){
if(this.mouseOver){
this.renderTooltip(this.rowTop, this.rowLeft, this.rowWidth, this.itemHeight, this.mouseX, this.mouseY);
this.renderTooltip(matrixStack, this.rowTop, this.rowLeft, this.rowWidth, this.itemHeight, this.mouseX, this.mouseY);
RenderHelper.disableStandardItemLighting();
GlStateManager.disableLighting();
}
}

protected void renderTooltip(int rowTop, int rowLeft, int rowWidth, int itemHeight,int mouseX, int mouseY){
protected void renderTooltip(MatrixStack stack, int rowTop, int rowLeft, int rowWidth, int itemHeight,int mouseX, int mouseY){
}

@Override
public List<? extends IGuiEventListener> children() {
public List<? extends IGuiEventListener> getEventListeners() {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package at.feldim2425.moreoverlays.gui.config;

import java.util.ArrayList;
import java.util.List;

import com.mojang.realmsclient.gui.ChatFormatting;

import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.gui.IGuiEventListener;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.ForgeConfigSpec;

import java.util.ArrayList;
import java.util.List;

public class OptionBoolean
extends OptionValueEntry<Boolean> {

Expand All @@ -19,31 +20,31 @@ public OptionBoolean(ConfigOptionList list, ForgeConfigSpec.BooleanValue valSpec
super(list, valSpec, spec);
this.showValidity = false;

btnChange = new Button(OptionValueEntry.TITLE_WIDTH + 5, 0,this.getConfigOptionList().getRowWidth() - OptionValueEntry.TITLE_WIDTH - 5 - OptionValueEntry.CONTROL_WIDTH_VALIDATOR,20, "", this::buttonPressed);
btnChange = new Button(OptionValueEntry.TITLE_WIDTH + 5, 0,this.getConfigOptionList().getRowWidth() - OptionValueEntry.TITLE_WIDTH - 5 - OptionValueEntry.CONTROL_WIDTH_VALIDATOR,20, new StringTextComponent(""), this::buttonPressed);
this.overrideUnsaved(this.value.get());
}

@Override
protected void renderControls(int rowTop, int rowLeft, int rowWidth, int itemHeight, int mouseX, int mouseY,
boolean mouseOver, float partialTick) {
super.renderControls(rowTop, rowLeft, rowWidth, itemHeight, mouseX, mouseY, mouseOver, partialTick);
this.btnChange.render(mouseX, mouseY, 0);
protected void renderControls(MatrixStack matrixStack, int rowTop, int rowLeft, int rowWidth, int itemHeight, int mouseX, int mouseY,
boolean mouseOver, float partialTick) {
super.renderControls(matrixStack, rowTop, rowLeft, rowWidth, itemHeight, mouseX, mouseY, mouseOver, partialTick);
this.btnChange.render(matrixStack, mouseX, mouseY, 0);
}

@Override
protected void overrideUnsaved(Boolean value) {
this.state = value;
if(this.state){
this.btnChange.setMessage(ChatFormatting.GREEN + "TRUE");
this.btnChange.setMessage(new StringTextComponent("TRUE").mergeStyle(TextFormatting.GREEN));
}
else {
this.btnChange.setMessage(ChatFormatting.RED + "FALSE");
this.btnChange.setMessage(new StringTextComponent("FALSE").mergeStyle(TextFormatting.RED));
}
}

@Override
public List<? extends IGuiEventListener> children() {
List<IGuiEventListener> childs = new ArrayList<>(super.children());
public List<? extends IGuiEventListener> getEventListeners() {
List<IGuiEventListener> childs = new ArrayList<>(super.getEventListeners());
childs.add(this.btnChange);
return childs;
}
Expand Down
Loading

0 comments on commit da45dd2

Please sign in to comment.