Fix some stuff

This commit is contained in:
grimmauld
2021-01-29 23:42:25 +01:00
parent 7b5f055d22
commit 5fe5978777
15 changed files with 69 additions and 261 deletions

View File

@@ -37,6 +37,8 @@ import nl.requios.effortlessbuilding.proxy.ServerProxy;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.annotation.ParametersAreNonnullByDefault;
// The value here should match an entry in the META-INF/mods.toml file
@Mod(EffortlessBuilding.MODID)
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)

View File

@@ -173,7 +173,7 @@ public class BuildModifiers {
}
public static List<BlockPos> findCoordinates(PlayerEntity player, BlockPos blockPos) {
return findCoordinates(player, new ArrayList<>(Arrays.asList(blockPos)));
return findCoordinates(player, new ArrayList<>(Collections.singletonList(blockPos)));
}
public static List<BlockState> findBlockStates(PlayerEntity player, List<BlockPos> posList, Vector3d hitVec, Direction facing, List<ItemStack> itemStacks) {

View File

@@ -1,71 +0,0 @@
package nl.requios.effortlessbuilding.gui;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.util.math.vector.Matrix4f;
import net.minecraft.util.math.vector.TransformationMatrix;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.util.Arrays;
import java.util.List;
@OnlyIn(Dist.CLIENT)
public class FontRenderHelper {
/*
private static final FontRenderer font = Minecraft.getInstance().fontRenderer;
public static void drawSplitString(MatrixStack ms, String str, int x, int y, int wrapWidth, int textColor) {
str = trimStringNewline(str);
renderSplitString(ms, str, x, y, wrapWidth, textColor);
}
private static void renderSplitString(MatrixStack ms, String str, int x, int y, int wrapWidth, int textColor) {
List<String> list = font.listFormattedStringToWidth(str, wrapWidth);
Matrix4f matrix4f = TransformationMatrix.identity().getMatrix();
for(String s : list) {
float f = (float)x;
if (font.getBidiFlag()) {
int i = font.getStringWidth(font.bidiReorder(s));
f += (float)(wrapWidth - i);
}
font.renderString(s, f, (float)y, textColor, ms.getLast().getMatrix(), false, false);
y += 9;
}
}
private static String trimStringNewline(String text) {
while(text != null && text.endsWith("\n")) {
text = text.substring(0, text.length() - 1);
}
return text;
}
public static List<String> listFormattedStringToWidth(String str, int wrapWidth) {
return Arrays.asList(wrapFormattedStringToWidth(str, wrapWidth).split("\n"));
}
public static String wrapFormattedStringToWidth(String str, int wrapWidth) {
String s;
String s1;
for(s = ""; !str.isEmpty(); s = s + s1 + "\n") {
int i = font.sizeStringToWidth(str, wrapWidth);
if (str.length() <= i) {
return s + str;
}
s1 = str.substring(0, i);
char c0 = str.charAt(i);
boolean flag = c0 == ' ' || c0 == '\n';
str = TextFormatting.getFormatString(s1) + str.substring(i + (flag ? 1 : 0));
}
return s;
}*/
}

View File

@@ -10,7 +10,10 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import nl.requios.effortlessbuilding.EffortlessBuilding;
import javax.annotation.ParametersAreNonnullByDefault;
@OnlyIn(Dist.CLIENT)
@ParametersAreNonnullByDefault
public class RandomizerBagScreen extends ContainerScreen<RandomizerBagContainer> {
private static final ResourceLocation guiTextures =
new ResourceLocation(EffortlessBuilding.MODID, "textures/gui/container/randomizerbag.png");

View File

@@ -366,22 +366,22 @@ public class RadialMenu extends Screen {
//Add keybind in brackets
if (button.action == ActionEnum.UNDO) {
keybind = ClientProxy.keyBindings[4].getTranslationKey();
keybind = I18n.format(ClientProxy.keyBindings[4].getTranslationKey());
}
if (button.action == ActionEnum.REDO) {
keybind = ClientProxy.keyBindings[5].getTranslationKey();
keybind = I18n.format(ClientProxy.keyBindings[5].getTranslationKey());
}
if (button.action == ActionEnum.REPLACE) {
keybind = ClientProxy.keyBindings[1].getTranslationKey();
keybind = I18n.format(ClientProxy.keyBindings[1].getTranslationKey());
}
if (button.action == ActionEnum.OPEN_MODIFIER_SETTINGS) {
keybind = ClientProxy.keyBindings[0].getTranslationKey();
keybind = I18n.format(ClientProxy.keyBindings[0].getTranslationKey());
}
if (currentBuildMode.options.length > 0) {
//Add (ctrl) to first two actions of first option
if (button.action == currentBuildMode.options[0].actions[0]
|| button.action == currentBuildMode.options[0].actions[1]) {
keybind = ClientProxy.keyBindings[6].getTranslationKey();
keybind = I18n.format(ClientProxy.keyBindings[6].getTranslationKey());
if (keybind.equals("Left Control")) keybind = "Ctrl";
}
}

View File

@@ -6,9 +6,12 @@ import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
import javax.annotation.ParametersAreNonnullByDefault;
/**
* This class provides a checkbox style control.
*/
@ParametersAreNonnullByDefault
public class GuiCheckBoxFixed extends Button {
private final int boxWidth;
private boolean isChecked;

View File

@@ -10,11 +10,13 @@ import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@OnlyIn(Dist.CLIENT)
@ParametersAreNonnullByDefault
public class GuiIconButton extends Button {
private final ResourceLocation resourceLocation;
@@ -38,7 +40,7 @@ public class GuiIconButton extends Button {
}
public void setTooltip(ITextComponent tooltip) {
setTooltip(Arrays.asList(tooltip));
setTooltip(Collections.singletonList(tooltip));
}
public void setTooltip(List<ITextComponent> tooltip) {
@@ -72,10 +74,7 @@ public class GuiIconButton extends Button {
boolean flag = mouseX >= x && mouseX < x + width && mouseY >= y && mouseY < y + height;
if (flag) {
StringTextComponent builder = new StringTextComponent("");
tooltip.forEach(c -> builder.append(c).appendString("\n"));
screen.renderTooltip(ms, builder, mouseX - 10, mouseY + 25);
screen.func_243308_b(ms, tooltip, mouseX - 10, mouseY + 25);
}
}
}

View File

@@ -1,27 +1,29 @@
package nl.requios.effortlessbuilding.gui.elements;
import com.mojang.blaze3d.matrix.MatrixStack;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.screen.Screen;
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.util.text.IFormattableTextComponent;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import javax.annotation.ParametersAreNonnullByDefault;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Formattable;
import java.util.Collections;
import java.util.List;
@OnlyIn(Dist.CLIENT)
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class GuiNumberField extends AbstractGui {
public int x, y, width, height;
@@ -72,7 +74,7 @@ public class GuiNumberField extends AbstractGui {
}
public void setTooltip(ITextComponent tooltip) {
setTooltip(Arrays.asList(tooltip));
setTooltip(Collections.singletonList(tooltip));
}
public void setTooltip(List<ITextComponent> tooltip) {
@@ -112,29 +114,29 @@ public class GuiNumberField extends AbstractGui {
// List<String> textLines = new ArrayList<>();
StringTextComponent textLines = new StringTextComponent("");
List<ITextComponent> textLines = new ArrayList<>();
if (insideTextField) {
tooltip.forEach(s -> textLines.append(s).appendString("\n"));
textLines.addAll(tooltip);
// textLines.add(TextFormatting.GRAY + "Tip: try scrolling.");
}
if (insideMinusButton) {
textLines.appendString("Hold ").append(new StringTextComponent("shift ").mergeStyle(TextFormatting.AQUA)).appendString("for ")
.append(new StringTextComponent("10").mergeStyle(TextFormatting.RED)).appendString("\n");
textLines.appendString("Hold ").append(new StringTextComponent("ctrl ").mergeStyle(TextFormatting.AQUA)).appendString("for ")
.append(new StringTextComponent("5").mergeStyle(TextFormatting.RED)).appendString("\n");
textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("shift ").mergeStyle(TextFormatting.AQUA)).appendString("for ")
.append(new StringTextComponent("10").mergeStyle(TextFormatting.RED)));
textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("ctrl ").mergeStyle(TextFormatting.AQUA)).appendString("for ")
.append(new StringTextComponent("5").mergeStyle(TextFormatting.RED)));
}
if (insidePlusButton) {
textLines.appendString("Hold ").append(new StringTextComponent("shift ").mergeStyle(TextFormatting.DARK_GREEN)).appendString("for ")
.append(new StringTextComponent("10").mergeStyle(TextFormatting.RED)).appendString("\n");
textLines.appendString("Hold ").append(new StringTextComponent("ctrl ").mergeStyle(TextFormatting.DARK_GREEN)).appendString("for ")
.append(new StringTextComponent("5").mergeStyle(TextFormatting.RED));
textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("shift ").mergeStyle(TextFormatting.DARK_GREEN)).appendString("for ")
.append(new StringTextComponent("10").mergeStyle(TextFormatting.RED)));
textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("ctrl ").mergeStyle(TextFormatting.DARK_GREEN)).appendString("for ")
.append(new StringTextComponent("5").mergeStyle(TextFormatting.RED)));
}
screen.renderTooltip(ms, textLines, mouseX - 10, mouseY + 25);
screen.func_243308_b(ms, textLines, mouseX - 10, mouseY + 25);
}

View File

@@ -3,6 +3,7 @@ package nl.requios.effortlessbuilding.gui.elements;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.IGuiEventListener;
@@ -16,10 +17,13 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.ArrayList;
import java.util.List;
@OnlyIn(Dist.CLIENT)
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public class GuiScrollPane extends SlotGui {
public Screen parent;

View File

@@ -1,11 +1,9 @@
package nl.requios.effortlessbuilding.gui.elements;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.FocusableGui;
import net.minecraft.client.gui.IGuiEventListener;
import net.minecraft.client.gui.IRenderable;
@@ -25,8 +23,6 @@ import java.util.List;
@MethodsReturnNonnullByDefault
@SuppressWarnings("deprecation")
public abstract class SlotGui extends FocusableGui implements IRenderable {
protected static final int NO_DRAG = -1;
protected static final int DRAG_OUTSIDE = -2;
protected final Minecraft minecraft;
protected final int itemHeight;
protected int width;
@@ -35,7 +31,6 @@ public abstract class SlotGui extends FocusableGui implements IRenderable {
protected int y1;
protected int x1;
protected int x0;
protected boolean centerListVertically = true;
protected int yDrag = -2;
protected double yo;
protected boolean visible = true;
@@ -55,36 +50,10 @@ public abstract class SlotGui extends FocusableGui implements IRenderable {
this.x1 = width;
}
public void updateSize(int p_updateSize_1_, int p_updateSize_2_, int p_updateSize_3_, int p_updateSize_4_) {
this.width = p_updateSize_1_;
this.height = p_updateSize_2_;
this.y0 = p_updateSize_3_;
this.y1 = p_updateSize_4_;
this.x0 = 0;
this.x1 = p_updateSize_1_;
}
public void setRenderSelection(boolean p_setRenderSelection_1_) {
this.renderSelection = p_setRenderSelection_1_;
}
protected void setRenderHeader(boolean p_setRenderHeader_1_, int p_setRenderHeader_2_) {
this.renderHeader = p_setRenderHeader_1_;
this.headerHeight = p_setRenderHeader_2_;
if (!p_setRenderHeader_1_) {
this.headerHeight = 0;
}
}
public boolean isVisible() {
return this.visible;
}
public void setVisible(boolean p_setVisible_1_) {
this.visible = p_setVisible_1_;
}
protected abstract int getItemCount();
public List<? extends IGuiEventListener> children() {
@@ -114,9 +83,6 @@ public abstract class SlotGui extends FocusableGui implements IRenderable {
protected void clickedHeader(int p_clickedHeader_1_, int p_clickedHeader_2_) {
}
protected void renderDecorations(int p_renderDecorations_1_, int p_renderDecorations_2_) {
}
public int getItemAtPosition(double p_getItemAtPosition_1_, double p_getItemAtPosition_3_) {
int i = this.x0 + this.width / 2 - this.getRowWidth() / 2;
int j = this.x0 + this.width / 2 + this.getRowWidth() / 2;
@@ -133,11 +99,6 @@ public abstract class SlotGui extends FocusableGui implements IRenderable {
return Math.max(0, this.getMaxPosition() - (this.y1 - this.y0 - 4));
}
public void centerScrollOn(int p_centerScrollOn_1_) {
this.yo = p_centerScrollOn_1_ * this.itemHeight + this.itemHeight / 2. - (this.y1 - this.y0) / 2.;
this.capYPosition();
}
public int getScroll() {
return (int) this.yo;
}
@@ -146,90 +107,7 @@ public abstract class SlotGui extends FocusableGui implements IRenderable {
return p_isMouseInList_3_ >= (double) this.y0 && p_isMouseInList_3_ <= (double) this.y1 && p_isMouseInList_1_ >= (double) this.x0 && p_isMouseInList_1_ <= (double) this.x1;
}
public int getScrollBottom() {
return (int) this.yo - this.height - this.headerHeight;
}
public void scroll(int p_scroll_1_) {
this.yo += p_scroll_1_;
this.capYPosition();
this.yDrag = -2;
}
public void render(MatrixStack ms, int p_render_1_, int p_render_2_, float p_render_3_) {
if (this.visible) {
this.renderBackground();
int i = this.getScrollbarPosition();
int j = i + 6;
this.capYPosition();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
// Forge: background rendering moved into separate method.
this.drawContainerBackground(tessellator);
int k = this.x0 + this.width / 2 - this.getRowWidth() / 2 + 2;
int l = this.y0 + 4 - (int) this.yo;
if (this.renderHeader) {
this.renderHeader(k, l, tessellator);
}
this.renderList(ms, k, l, p_render_1_, p_render_2_, p_render_3_);
RenderSystem.disableDepthTest();
this.renderHoleBackground(0, this.y0, 255, 255);
this.renderHoleBackground(this.y1, this.height, 255, 255);
RenderSystem.enableBlend();
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ZERO, GlStateManager.DestFactor.ONE);
RenderSystem.disableAlphaTest();
RenderSystem.shadeModel(7425);
RenderSystem.disableTexture();
int i1 = 4;
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos(this.x0, this.y0 + 4, 0.0D).tex(0.0F, 1.0F).color(0, 0, 0, 0).endVertex();
bufferbuilder.pos(this.x1, this.y0 + 4, 0.0D).tex(1.0F, 1.0F).color(0, 0, 0, 0).endVertex();
bufferbuilder.pos(this.x1, this.y0, 0.0D).tex(1.0F, 0.0F).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos(this.x0, this.y0, 0.0D).tex(0.0F, 0.0F).color(0, 0, 0, 255).endVertex();
tessellator.draw();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos(this.x0, this.y1, 0.0D).tex(0.0F, 1.0F).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos(this.x1, this.y1, 0.0D).tex(1.0F, 1.0F).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos(this.x1, this.y1 - 4, 0.0D).tex(1.0F, 0.0F).color(0, 0, 0, 0).endVertex();
bufferbuilder.pos(this.x0, this.y1 - 4, 0.0D).tex(0.0F, 0.0F).color(0, 0, 0, 0).endVertex();
tessellator.draw();
int j1 = this.getMaxScroll();
if (j1 > 0) {
int k1 = (int) ((float) ((this.y1 - this.y0) * (this.y1 - this.y0)) / (float) this.getMaxPosition());
k1 = MathHelper.clamp(k1, 32, this.y1 - this.y0 - 8);
int l1 = (int) this.yo * (this.y1 - this.y0 - k1) / j1 + this.y0;
if (l1 < this.y0) {
l1 = this.y0;
}
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos(i, this.y1, 0.0D).tex(0.0F, 1.0F).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos(j, this.y1, 0.0D).tex(1.0F, 1.0F).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos(j, this.y0, 0.0D).tex(1.0F, 0.0F).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos(i, this.y0, 0.0D).tex(0.0F, 0.0F).color(0, 0, 0, 255).endVertex();
tessellator.draw();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos(i, l1 + k1, 0.0D).tex(0.0F, 1.0F).color(128, 128, 128, 255).endVertex();
bufferbuilder.pos(j, l1 + k1, 0.0D).tex(1.0F, 1.0F).color(128, 128, 128, 255).endVertex();
bufferbuilder.pos(j, l1, 0.0D).tex(1.0F, 0.0F).color(128, 128, 128, 255).endVertex();
bufferbuilder.pos(i, l1, 0.0D).tex(0.0F, 0.0F).color(128, 128, 128, 255).endVertex();
tessellator.draw();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos(i, l1 + k1 - 1, 0.0D).tex(0.0F, 1.0F).color(192, 192, 192, 255).endVertex();
bufferbuilder.pos(j - 1, l1 + k1 - 1, 0.0D).tex(1.0F, 1.0F).color(192, 192, 192, 255).endVertex();
bufferbuilder.pos(j - 1, l1, 0.0D).tex(1.0F, 0.0F).color(192, 192, 192, 255).endVertex();
bufferbuilder.pos(i, l1, 0.0D).tex(0.0F, 0.0F).color(192, 192, 192, 255).endVertex();
tessellator.draw();
}
this.renderDecorations(p_render_1_, p_render_2_);
RenderSystem.enableTexture();
RenderSystem.shadeModel(7424);
RenderSystem.enableAlphaTest();
RenderSystem.disableBlend();
}
}
public abstract void render(MatrixStack ms, int p_render_1_, int p_render_2_, float p_render_3_);
protected void updateScrollingState(double p_updateScrollingState_1_, double p_updateScrollingState_3_, int p_updateScrollingState_5_) {
this.scrolling = p_updateScrollingState_5_ == 0 && p_updateScrollingState_1_ >= (double) this.getScrollbarPosition() && p_updateScrollingState_1_ < (double) (this.getScrollbarPosition() + 6);
@@ -382,40 +260,4 @@ public abstract class SlotGui extends FocusableGui implements IRenderable {
protected int getScrollbarPosition() {
return this.width / 2 + 124;
}
protected void renderHoleBackground(int p_renderHoleBackground_1_, int p_renderHoleBackground_2_, int p_renderHoleBackground_3_, int p_renderHoleBackground_4_) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
this.minecraft.getTextureManager().bindTexture(AbstractGui.BACKGROUND_LOCATION);
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
float f = 32.0F;
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos(this.x0, p_renderHoleBackground_2_, 0.0D).tex(0.0F, (float) p_renderHoleBackground_2_ / 32.0F).color(64, 64, 64, p_renderHoleBackground_4_).endVertex();
bufferbuilder.pos(this.x0 + this.width, p_renderHoleBackground_2_, 0.0D).tex((float) this.width / 32.0F, (float) p_renderHoleBackground_2_ / 32.0F).color(64, 64, 64, p_renderHoleBackground_4_).endVertex();
bufferbuilder.pos(this.x0 + this.width, p_renderHoleBackground_1_, 0.0D).tex((float) this.width / 32.0F, (float) p_renderHoleBackground_1_ / 32.0F).color(64, 64, 64, p_renderHoleBackground_3_).endVertex();
bufferbuilder.pos(this.x0, p_renderHoleBackground_1_, 0.0D).tex(0.0F, (float) p_renderHoleBackground_1_ / 32.0F).color(64, 64, 64, p_renderHoleBackground_3_).endVertex();
tessellator.draw();
}
public void setLeftPos(int p_setLeftPos_1_) {
this.x0 = p_setLeftPos_1_;
this.x1 = p_setLeftPos_1_ + this.width;
}
public int getItemHeight() {
return this.itemHeight;
}
protected void drawContainerBackground(Tessellator tessellator) {
BufferBuilder buffer = tessellator.getBuffer();
this.minecraft.getTextureManager().bindTexture(AbstractGui.BACKGROUND_LOCATION);
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
float scale = 32.0F;
buffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
buffer.pos(this.x0, this.y1, 0.0D).tex(this.x0 / scale, (this.y1 + (int) this.yo) / scale).color(32, 32, 32, 255).endVertex();
buffer.pos(this.x1, this.y1, 0.0D).tex(this.x1 / scale, (this.y1 + (int) this.yo) / scale).color(32, 32, 32, 255).endVertex();
buffer.pos(this.x1, this.y0, 0.0D).tex(this.x1 / scale, (this.y0 + (int) this.yo) / scale).color(32, 32, 32, 255).endVertex();
buffer.pos(this.x0, this.y0, 0.0D).tex(this.x0 / scale, (this.y0 + (int) this.yo) / scale).color(32, 32, 32, 255).endVertex();
tessellator.draw();
}
}

View File

@@ -1,5 +1,6 @@
package nl.requios.effortlessbuilding.item;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.util.ITooltipFlag;
@@ -36,11 +37,14 @@ import nl.requios.effortlessbuilding.gui.RandomizerBagContainer;
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Random;
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public class ItemRandomizerBag extends Item {
public static final int INV_SIZE = 5;

View File

@@ -1,5 +1,6 @@
package nl.requios.effortlessbuilding.item;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
@@ -16,8 +17,11 @@ import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
import nl.requios.effortlessbuilding.helper.ReachHelper;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.List;
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class ItemReachUpgrade1 extends Item {
public ItemReachUpgrade1() {

View File

@@ -1,5 +1,6 @@
package nl.requios.effortlessbuilding.item;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
@@ -16,8 +17,11 @@ import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
import nl.requios.effortlessbuilding.helper.ReachHelper;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.List;
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class ItemReachUpgrade2 extends Item {
public ItemReachUpgrade2() {

View File

@@ -1,5 +1,6 @@
package nl.requios.effortlessbuilding.item;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
@@ -16,8 +17,11 @@ import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
import nl.requios.effortlessbuilding.helper.ReachHelper;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.List;
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class ItemReachUpgrade3 extends Item {
public ItemReachUpgrade3() {

View File

@@ -1,5 +1,6 @@
package nl.requios.effortlessbuilding.proxy;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.client.Minecraft;
@@ -50,10 +51,12 @@ import nl.requios.effortlessbuilding.network.*;
import nl.requios.effortlessbuilding.render.ShaderHandler;
import org.lwjgl.glfw.GLFW;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.function.Supplier;
@Mod.EventBusSubscriber(value = {Dist.CLIENT})
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class ClientProxy implements IProxy {
public static KeyBinding[] keyBindings;
public static RayTraceResult previousLookAt;
@@ -148,7 +151,7 @@ public class ClientProxy implements IProxy {
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);
0.4f, soundType.getPitch());
player.swingArm(Hand.MAIN_HAND);
}
} else {
@@ -190,7 +193,7 @@ public class ClientProxy implements IProxy {
BlockState state = player.world.getBlockState(blockPos);
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);
0.4f, soundtype.getPitch());
player.swingArm(Hand.MAIN_HAND);
}
} else {
@@ -212,6 +215,8 @@ public class ClientProxy implements IProxy {
@SubscribeEvent(receiveCanceled = true)
public static void onKeyPress(InputEvent.KeyInputEvent event) {
ClientPlayerEntity player = Minecraft.getInstance().player;
if (player == null)
return;
//Remember to send packet to server if necessary
//Show Modifier Settings GUI
@@ -280,6 +285,8 @@ public class ClientProxy implements IProxy {
public static void openModifierSettings() {
Minecraft mc = Minecraft.getInstance();
ClientPlayerEntity player = mc.player;
if (player == null)
return;
RadialMenu.instance.setVisibility(0f);
@@ -298,6 +305,8 @@ public class ClientProxy implements IProxy {
public static void openPlayerSettings() {
Minecraft mc = Minecraft.getInstance();
ClientPlayerEntity player = mc.player;
if (player == null)
return;
RadialMenu.instance.setVisibility(0f);
@@ -317,7 +326,6 @@ public class ClientProxy implements IProxy {
}
}
@Nullable
public static RayTraceResult getLookingAt(PlayerEntity player) {
World world = player.world;