Skip to content

Commit

Permalink
Merge branch '1.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHillcox committed May 20, 2024
2 parents cedd338 + 1e3d977 commit d1c863e
Show file tree
Hide file tree
Showing 16 changed files with 238 additions and 70 deletions.
13 changes: 9 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Changelog

## Changed
## Changed

- Ported to 1.19.3
- Ported to 1.19.4

## Added

- `uk_ua` translation [#732](https://github.com/direworlf20-mc/issues/732)

## Fixed

- An old issue where the construction paste containers don't render their filled amount. This used to happen pre 1.16.5...
- Couple odd issues here and there, nothing special
- A couple of long standing porting issues
- Crashes being caused by construction blocks not checking for null correctly [#738](https://github.com/direworlf20-mc/issues/738)
- Commands not being registered correctly [#734](https://github.com/direworlf20-mc/issues/734)
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
org.gradle.jvmargs=-Xmx2G
org.gradle.daemon=false
minecraft_version=1.19.3
forge_version=44.1.20
version=3.17.0
jei_version=12.2.0.17
minecraft_version=1.19.4
forge_version=45.2.15
version=3.18.0
jei_version=13.1.0.16
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public int getWidth(Font font) {
}

@Override
public void renderImage(Font font, int x, int y, PoseStack poseStack, ItemRenderer itemRenderer, int p_194053_) {
public void renderImage(Font font, int x, int y, PoseStack poseStack, ItemRenderer itemRenderer) {
if (this.tooltipData.stack == null || !(this.tooltipData.stack.getItem() instanceof GadgetCopyPaste))
return;

Expand Down Expand Up @@ -155,13 +155,13 @@ private static int renderRequiredBlocks(PoseStack matrices, ItemRenderer itemRen

boolean hasReq = req > 0;

itemRenderer.renderAndDecorateItem(itemStack, x, y);
itemRenderer.renderGuiItemDecorations(mc.font, itemStack, x, y);
itemRenderer.renderAndDecorateItem(matrices, itemStack, x, y);
itemRenderer.renderGuiItemDecorations(matrices, mc.font, itemStack, x, y);

MultiBufferSource.BufferSource irendertypebuffer$impl = Minecraft.getInstance().renderBuffers().bufferSource();

matrices.pushPose();
matrices.translate(x + 8 - w1 / 4f, y + (hasReq ? 12 : 14), itemRenderer.blitOffset + 250);
matrices.translate(x + 8 - w1 / 4f, y + (hasReq ? 12 : 14), ItemRenderer.ITEM_COUNT_BLIT_OFFSET + 250);
matrices.scale(.5f, .5f, 0);
mc.font.draw(matrices, s1, 0, 0, 0xFFFFFF);
matrices.popPose();
Expand All @@ -175,9 +175,9 @@ private static int renderRequiredBlocks(PoseStack matrices, ItemRenderer itemRen
int w2 = mc.font.width(s2);

matrices.pushPose();
matrices.translate(x + 8 - w2 / 4f, y + 17, itemRenderer.blitOffset + 250);
matrices.translate(x + 8 - w2 / 4f, y + 17, ItemRenderer.ITEM_COUNT_BLIT_OFFSET + 250);
matrices.scale(.5f, .5f, 0);
mc.font.drawInBatch(s2, 0, 0, 0xFF0000, true, matrices.last().pose(), irendertypebuffer$impl, false, 0, 15728880);
mc.font.drawInBatch(s2, 0, 0, 0xFF0000, true, matrices.last().pose(), irendertypebuffer$impl, Font.DisplayMode.NORMAL, 0, 15728880);
matrices.popPose();

missingCount = (req - count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,12 @@ public static int getYForAlignedCenter(int top, int bottom, int height) {
public static void renderTextVerticalCenter(PoseStack matrices, String text, int leftX, int top, int bottom, int color) {
Font fontRenderer = Minecraft.getInstance().font;
int y = getYForAlignedCenter(top, bottom, fontRenderer.lineHeight);
RenderSystem.enableTexture();
fontRenderer.draw(matrices, text, leftX, y, color);
}

public static void renderTextHorizontalRight(PoseStack matrices, String text, int right, int y, int color) {
Font fontRenderer = Minecraft.getInstance().font;
int x = getXForAlignedRight(right, fontRenderer.width(text));
RenderSystem.enableTexture();
fontRenderer.draw(matrices, text, x, y, color);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private void updateButtons(ItemStack tool) {
button.setWidth(dim);
button.setHeight(dim);
if (isDestruction)
button.setX(height / 2 + (isRight ? 10 : -button.getHeight() - 10));
button.setY(height / 2 + (isRight ? 10 : -button.getHeight() - 10));
else
button.setX(width / 2 + offset);
}
Expand Down Expand Up @@ -453,7 +453,7 @@ public void render(PoseStack matrices, int mx, int my, float partialTicks) {
stack.scale(s, s, s);
matrices.popPose();
stack.translate(x / s - (tool.getItem() instanceof GadgetCopyPaste ? 8 : 8.5), y / s - 8, 0);
this.itemRenderer.renderAndDecorateItem(tool, 0, 0);
this.itemRenderer.renderAndDecorateItem(stack, tool, 0, 0);
stack.popPose();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
import com.google.common.collect.ImmutableMultiset;
import com.google.common.collect.Iterators;
import com.google.common.collect.Multiset;
import com.mojang.blaze3d.platform.Lighting;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.ObjectSelectionList;
import com.mojang.blaze3d.platform.Lighting;
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.util.Mth;
import org.lwjgl.glfw.GLFW;

import java.awt.*;
Expand All @@ -28,7 +27,6 @@

import static com.direwolf20.buildinggadgets.client.screen.MaterialListGUI.*;
import static com.direwolf20.buildinggadgets.client.screen.ScrollingMaterialList.Entry;
import static org.lwjgl.opengl.GL11.*;

// Todo change to AbstractList as it's an easy fix compared to duping the class
class ScrollingMaterialList extends EntryList<Entry> {
Expand Down Expand Up @@ -149,38 +147,18 @@ public void render(PoseStack matrices, int index, int topY, int leftX, int entry
int slotX = leftX + MARGIN;
int slotY = topY + MARGIN;

matrices.pushPose();
drawIcon(matrices, stack, slotX, slotY);
drawTextOverlay(matrices, right, topY, bottom, slotX);
drawHoveringText(stack, slotX, slotY, mouseX, mouseY);
matrices.popPose();
}

private void drawTextOverlay(PoseStack matrices, int right, int top, int bottom, int slotX) {
int itemNameX = slotX + SLOT_SIZE + MARGIN;
// -1 because the bottom x coordinate is exclusive
renderTextVerticalCenter(matrices, itemName, itemNameX, top, bottom, Color.WHITE.getRGB());
renderTextHorizontalRight(matrices, amount, right, getYForAlignedCenter(top, bottom, Minecraft.getInstance().font.lineHeight), getTextColor());

drawGuidingLine(right, top, bottom, itemNameX, widthItemName, widthAmount);
}

private void drawGuidingLine(int right, int top, int bottom, int itemNameX, int widthItemName, int widthAmount) {
if (!isSelected()) {
int lineXStart = itemNameX + widthItemName + LINE_SIDE_MARGIN;
int lineXEnd = right - widthAmount - LINE_SIDE_MARGIN;
int lineY = getYForAlignedCenter(top, bottom - 1, 1);
RenderSystem.enableBlend();
RenderSystem.disableTexture();
RenderSystem.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
RenderSystem.setShaderColor(255, 255, 255, 34);

// glLineWidth(1);
// glBegin(GL_LINES);
// glVertex3f(lineXStart, lineY, 0);
// glVertex3f(lineXEnd, lineY, 0);
// glEnd();

RenderSystem.enableTexture();
}
}

private void drawHoveringText(ItemStack item, int slotX, int slotY, int mouseX, int mouseY) {
Expand All @@ -189,10 +167,10 @@ private void drawHoveringText(ItemStack item, int slotX, int slotY, int mouseX,
}

private void drawIcon(PoseStack matrices, ItemStack item, int slotX, int slotY) {
Lighting.setupForFlatItems();
Minecraft.getInstance().getItemRenderer().renderAndDecorateItem(item, slotX, slotY);
// RenderSystem.color3f(1, 1, 1);
Lighting.setupFor3DItems();
Minecraft.getInstance().getItemRenderer().renderAndDecorateItem(matrices, item, slotX, slotY);
// RenderSystem.color3f(1, 1, 1);
Lighting.setupForFlatItems();
}

private boolean hasEnoughItems() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.SharedConstants;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.EditBox;
Expand Down Expand Up @@ -274,8 +275,8 @@ private void renderRequirement(PoseStack matrices, int mouseX, int mouseY) {
ItemStack stack = e.getElement().createStack();
int x = (-20 - (column * 25)), y = (20 + (index * 25));

itemRenderer.renderAndDecorateItem(stack, x + 4, y + 4);
itemRenderer.renderGuiItemDecorations(Minecraft.getInstance().font, stack, x + 4, y + 4, GadgetUtils.withSuffix(foundItems.count(e.getElement())));
itemRenderer.renderAndDecorateItem(matrices, stack, x + 4, y + 4);
itemRenderer.renderGuiItemDecorations(matrices, Minecraft.getInstance().font, stack, x + 4, y + 4, GadgetUtils.withSuffix(foundItems.count(e.getElement())));

int space = (int) (25 - (.2f * 25));
int zoneX = ((leftPos - 32) + (-15 - (column * space))), zoneY = (topPos - 9) + (20 + (index * space));
Expand Down Expand Up @@ -631,7 +632,7 @@ private void onPaste() {
if (!tagFromJson.contains("header")) {
BuildingGadgets.LOG.error("Attempted to use a 1.12 compound on a newer MC version");
getMinecraft().player.displayClientMessage(MessageTranslation.PASTE_FAILED_WRONG_MC_VERSION
.componentTranslation("(1.12.x)", Minecraft.getInstance().getGame().getVersion().getName()).setStyle(Styles.RED), false);
.componentTranslation("(1.12.x)", "1.14.x", SharedConstants.VERSION_STRING).setStyle(Styles.RED), false);
return;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void renderParts(PoseStack matrices, int mouseX, int mouseY, float parti

int k = getRowLeft();
int l = getTop() + 4 - (int) getScrollAmount();
renderHeader(matrices, k, l, tessellator);
renderHeader(matrices, k, l);

renderList(matrices, k, l, partialTicks);
RenderSystem.disableDepthTest();
Expand All @@ -63,7 +63,6 @@ private void renderParts(PoseStack matrices, int mouseX, int mouseY, float parti
int x1 = getScrollbarPosition();
int x2 = x1 + 6;

RenderSystem.disableTexture();
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
bufferbuilder.vertex(x1, getBottom(), 0.0D).color(0, 0, 0, 255).endVertex();
bufferbuilder.vertex(x2, getBottom(), 0.0D).color(0, 0, 0, 255).endVertex();
Expand All @@ -83,7 +82,6 @@ private void renderParts(PoseStack matrices, int mouseX, int mouseY, float parti
}

renderDecorations(matrices, mouseX, mouseX);
RenderSystem.enableTexture();
RenderSystem.disableBlend();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void setValue(int value) {
}

@Override
public void render(PoseStack matrices, int mouseX, int mouseY, float partialTick) {
public void renderWidget(PoseStack matrices, int mouseX, int mouseY, float partialTick) {
this.plusButton.render(matrices, mouseX, mouseY, partialTick);
this.minusButton.render(matrices, mouseX, mouseY, partialTick);
this.field.render(matrices, mouseX, mouseY, partialTick);
Expand Down Expand Up @@ -112,12 +112,6 @@ public boolean charTyped(char p_charTyped_1_, int p_charTyped_2_) {
return true;
}

@Override
protected void onFocusedChanged(boolean isFocused) {
this.field.changeFocus(isFocused);
super.onFocusedChanged(isFocused);
}

public int getX() {
return x;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public IncrementalSliderWidget(int x, int y, int width, int height, double min,
}

@Override
public void renderButton(PoseStack poseStack, int mouseX, int mouseY, float partialTick) {
public void renderWidget(PoseStack poseStack, int mouseX, int mouseY, float partialTick) {
fill(poseStack, this.getX(), this.getY(), this.getX() + this.width, this.getY() + this.height, BACKGROUND);
this.drawBorderedRect(poseStack, (this.getX() + (int)(this.value * (double)(this.width - 8)) + 4) - 4, this.getY(), 8, this.height);
this.renderText(poseStack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public BuildingGadgets() {

MinecraftForge.EVENT_BUS.addListener(this::serverLoaded);
MinecraftForge.EVENT_BUS.addListener(this::serverStopped);
MinecraftForge.EVENT_BUS.addListener(this::commandRegister);

eventBus.addListener(this::setup);
eventBus.addListener(this::clientSetup);
Expand All @@ -92,7 +93,7 @@ private void registerCreativeTab(CreativeModeTabEvent.Register register) {
stack.getOrCreateTag().putByte(NBTKeys.CREATIVE_MARKER, (byte) 0);
return stack;
})
.displayItems((featureFlags, output, hasPermission) -> {
.displayItems((featureFlags, output) -> {
// Register it alL!
OurItems.ITEMS.getEntries()
.forEach(e -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos,
@Override
public VoxelShape getOcclusionShape(BlockState state, BlockGetter worldIn, BlockPos pos) {
BlockState mimic = getActualMimicBlock(worldIn, pos);
if (!mimic.canOcclude()) {
if (!isMimicNull(mimic) && !mimic.canOcclude()) {
return Shapes.empty();
}
return !isMimicNull(mimic) ? mimic.getBlockSupportShape(worldIn, pos) : super.getOcclusionShape(state, worldIn, pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.direwolf20.buildinggadgets.common.items.ConstructionPasteContainer;
import com.google.gson.JsonObject;
import net.minecraft.core.RegistryAccess;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingBookCategory;
Expand All @@ -19,8 +20,8 @@ public RecipeConstructionPaste(ResourceLocation id, String group, CraftingBookCa
}

@Override
public ItemStack assemble(CraftingContainer craftingInventory) {
final ItemStack output = super.assemble(craftingInventory); // Get the default output
public ItemStack assemble(CraftingContainer craftingInventory, RegistryAccess registryAccess) {
final ItemStack output = super.assemble(craftingInventory, registryAccess); // Get the default output
if (!output.isEmpty()) {
int totalPaste = 0;
for (int i = 0; i < craftingInventory.getContainerSize(); i++) { // For each slot in the crafting inventory,
Expand All @@ -40,11 +41,12 @@ public RecipeSerializer<?> getSerializer() {

public static final class Serializer extends ShapedRecipe.Serializer {
public static final Serializer INSTANCE = new Serializer();

@Override
public ShapedRecipe fromJson(ResourceLocation recipeId, JsonObject json) {
ShapedRecipe recipe = super.fromJson(recipeId, json);
return new RecipeConstructionPaste(recipe.getId(), recipe.getGroup(), CraftingBookCategory.MISC, recipe.getRecipeWidth(),
recipe.getRecipeHeight(), recipe.getIngredients(), recipe.getResultItem());
recipe.getRecipeHeight(), recipe.getIngredients(), recipe.getResultItem(RegistryAccess.EMPTY));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void register() {

public static void sendTo(Object msg, ServerPlayer player) {
if (!(player instanceof FakePlayer))
HANDLER.sendTo(msg, player.connection.getConnection(), NetworkDirection.PLAY_TO_CLIENT);
HANDLER.sendTo(msg, player.connection.connection, NetworkDirection.PLAY_TO_CLIENT);
}

public static void sendToServer(Object msg) {
Expand Down
Loading

0 comments on commit d1c863e

Please sign in to comment.