Skip to content

Commit

Permalink
update ldlib on 1.21 (#2043)
Browse files Browse the repository at this point in the history
  • Loading branch information
screret authored Sep 29, 2024
1 parent 6316e4b commit 2025395
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 33 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ loader_version = 2
# Mod Info
mod_id = gtceu
mod_name = GregTech
mod_version = 1.4.4
mod_version = 1.4.5
mod_description = GregTech CE Unofficial, ported from 1.12.2
mod_license = LGPL-3.0 license
mod_url = https://github.com/GregTechCEu/GregTech-Modern/
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dependencyResolutionManagement {
def vineFlowerVersion = "1.+"
def macheteVersion = "1.+"
def configurationVersion = "5616143"
def ldLibVersion = "1.0.27.b"
def ldLibVersion = "1.0.28.d"
def shimmerVersion = "0.2.4"
def modDevGradleVersion = "2.0.28-beta"
def lombokPluginVersion = "8.7.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public CompoundTag serializeNBT(HolderLookup.Provider provider) {
}

@Override
public void deserializeNBT(CompoundTag tag, HolderLookup.Provider provider) {
super.deserializeNBT(tag, provider);
public void deserializeNBT(HolderLookup.Provider provider, CompoundTag tag) {
super.deserializeNBT(provider, tag);
if (tag.contains("machine")) {
machineDefinition = GTRegistries.MACHINES.get(ResourceLocation.parse(tag.getString("machine")));
}
Expand Down Expand Up @@ -142,7 +142,7 @@ public void attachMenu(Editor editor, String name, TreeBuilder.Menu menu) {
m.leaf(new ItemStackTexture(definition.asStack()), definition.getDescriptionId(), () -> {
root.clearAllWidgets();
if (editableUI.hasCustomUI()) {
deserializeNBT(editableUI.getCustomUI(), Platform.getFrozenRegistry());
deserializeNBT(Platform.getFrozenRegistry(), editableUI.getCustomUI());
} else {
var template = editableUI.createDefault();
template.setSelfPosition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public CompoundTag serializeNBT(HolderLookup.Provider provider) {
}

@Override
public void deserializeNBT(CompoundTag tag, HolderLookup.Provider provider) {
super.deserializeNBT(tag, provider);
public void deserializeNBT(HolderLookup.Provider provider, CompoundTag tag) {
super.deserializeNBT(provider, tag);
if (tag.contains("recipe_type")) {
recipeType = GTRegistries.RECIPE_TYPES.get(ResourceLocation.parse(tag.getString("recipe_type")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ protected PatternPreviewWidget(MultiblockMachineDefinition controllerDefinition)
.setXScrollBarHeight(4)
.setXBarStyle(GuiTextures.SLIDER_BACKGROUND, GuiTextures.BUTTON)
.setScrollable(true)
.setDraggable(true);
// TODO update LDLib
// scrollableWidgetGroup.setScrollWheelDirection(DraggableScrollableWidgetGroup.ScrollWheelDirection.HORIZONTAL);
.setDraggable(true)
.setScrollWheelDirection(DraggableScrollableWidgetGroup.ScrollWheelDirection.HORIZONTAL);
scrollableWidgetGroup.setScrollYOffset(0);
addWidget(scrollableWidgetGroup);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.gregtechceu.gtceu.api.gui.GuiTextures;
import com.gregtechceu.gtceu.client.TooltipsHandler;
import com.gregtechceu.gtceu.integration.ae2.utils.AEUtil;

import com.lowdragmc.lowdraglib.Platform;
import com.lowdragmc.lowdraglib.gui.util.DrawerHelper;
Expand Down Expand Up @@ -53,7 +54,6 @@ public void drawInBackground(@NotNull GuiGraphics graphics, int mouseX, int mous
int stackX = position.x + 1;
int stackY = position.y + 1;
if (fluid != null) {
// TODO fix nbt once AE2 1.20.5 is out
FluidStack fluidStack = fluid.what() instanceof AEFluidKey key ?
key.toStack((int) fluid.amount()) : FluidStack.EMPTY;
DrawerHelper.drawFluidForGui(graphics, fluidStack, fluid.amount(), stackX, stackY, 17, 17);
Expand All @@ -70,9 +70,7 @@ public void drawInForeground(@NotNull GuiGraphics graphics, int mouseX, int mous
if (isMouseOverElement(mouseX, mouseY)) {
GenericStack fluid = this.gridWidget.getAt(this.index);
if (fluid != null) {
// TODO fix nbt once AE2 1.20.5 is out
FluidStack fluidStack = fluid.what() instanceof AEFluidKey key ?
new FluidStack(key.getFluid(), (int) fluid.amount()/* , key.getTag() */) : FluidStack.EMPTY;
FluidStack fluidStack = AEUtil.toFluidStack(fluid);
List<Component> tooltips = new ArrayList<>();
tooltips.add(fluidStack.getHoverName());
tooltips.add(Component.literal(String.format("%,d ", fluid.amount())).append(FluidHelper.getUnit()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public void drawInBackground(@NotNull GuiGraphics graphics, int mouseX, int mous
}
}
}
// TODO fix nbt once AE2 1.20.5 is out
if (stock != null) {
var stack = AEUtil.toFluidStack(stock);
if (!stack.isEmpty()) {
Expand Down Expand Up @@ -214,10 +213,10 @@ public void readUpdateInfo(int id, RegistryFriendlyByteBuf buffer) {

FluidStack stack = new FluidStack(key.getFluid(), (int) slot.getStock().amount());

// TODO fix nbt once AE2 1.20.5 is out
// if (key.hasTag()) {
// stack.setTag(key.getTag().copy());
// }
// this is inverted for some reason
if (!key.hasComponents()) {
stack.applyComponents(key.toStack(1).getComponents());
}
GenericStack stack1 = ExportOnlyAESlot.copy(slot.getStock(),
Math.max(0, (slot.getStock().amount() - stack.getAmount())));
slot.setStock(stack1.amount() == 0 ? null : stack1);
Expand Down Expand Up @@ -257,10 +256,7 @@ public boolean mouseWheelMove(double mouseX, double mouseY, double scrollX, doub
if (slot.getConfig() == null || scrollY == 0 || !rectangle.contains((int) mouseX, (int) mouseY)) {
return false;
}
// TODO fix nbt once AE2 1.20.5 is out
FluidStack fluid = slot.getConfig().what() instanceof AEFluidKey fluidKey ?
new FluidStack(fluidKey.getFluid(), (int) slot.getConfig().amount()/* , fluidKey.getTag() */) :
FluidStack.EMPTY;
FluidStack fluid = AEUtil.toFluidStack(slot.getConfig());
long amt;
if (isCtrlDown()) {
amt = scrollY > 0 ? fluid.getAmount() * 2L : fluid.getAmount() / 2L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,9 @@ public void handleClientAction(int id, RegistryFriendlyByteBuf buffer) {
slot.getStock().what() instanceof AEItemKey key) {
ItemStack stack = new ItemStack(key.getItem(), Math.min((int) slot.getStock().amount(),
key.getItem().getMaxStackSize(key.getItem().getDefaultInstance())));
// TODO fix nbt once AE2 1.20.5 is out
// if (key.hasTag()) {
// stack.setTag(key.getTag().copy());
// }
if (key.getItem().components().isEmpty()) {
stack.applyComponents(key.getItem().components());
}
this.gui.getModularUIContainer().setCarried(stack);
GenericStack stack1 = ExportOnlyAESlot.copy(slot.getStock(),
Math.max(0, (slot.getStock().amount() - stack.getCount())));
Expand All @@ -187,8 +186,7 @@ public void readUpdateInfo(int id, RegistryFriendlyByteBuf buffer) {
}
if (id == UPDATE_ID) {
ItemStack item = ItemStack.OPTIONAL_STREAM_CODEC.decode(buffer);
// TODO fix nbt once AE2 1.20.5 is out
slot.setConfig(new GenericStack(AEItemKey.of(item.getItem()/* , item.getTag() */), item.getCount()));
slot.setConfig(new GenericStack(AEItemKey.of(item), item.getCount()));
}
if (id == AMOUNT_CHANGE_ID) {
if (slot.getConfig() != null) {
Expand All @@ -200,10 +198,9 @@ public void readUpdateInfo(int id, RegistryFriendlyByteBuf buffer) {
if (slot.getStock() != null && slot.getStock().what() instanceof AEItemKey key) {
ItemStack stack = new ItemStack(key.getItem(), Math.min((int) slot.getStock().amount(),
key.getItem().getMaxStackSize(key.getItem().getDefaultInstance())));
// TODO fix nbt once AE2 1.20.5 is out
// if (key.hasTag()) {
// stack.setTag(key.getTag().copy());
// }
if (key.getItem().components().isEmpty()) {
stack.applyComponents(key.getItem().components());
}
this.gui.getModularUIContainer().setCarried(stack);
GenericStack stack1 = ExportOnlyAESlot.copy(slot.getStock(),
Math.max(0, (slot.getStock().amount() - stack.getCount())));
Expand Down

0 comments on commit 2025395

Please sign in to comment.