From bcafb40cee497873c35b18575531ace237141770 Mon Sep 17 00:00:00 2001 From: Sakura Ryoko Date: Tue, 10 Dec 2024 02:44:34 -0500 Subject: [PATCH] Update MaLiLib --- .../fi/dy/masa/litematica/InitHandler.java | 7 +++++++ .../litematica/data/EntitiesDataStorage.java | 2 +- .../TaskPasteSchematicPerChunkCommand.java | 21 ++++++++++++------- .../masa/litematica/util/InventoryUtils.java | 3 ++- .../masa/litematica/util/PickBlockUtils.java | 15 +++++++------ 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/main/java/fi/dy/masa/litematica/InitHandler.java b/src/main/java/fi/dy/masa/litematica/InitHandler.java index d7169a0a81..2195f929a6 100644 --- a/src/main/java/fi/dy/masa/litematica/InitHandler.java +++ b/src/main/java/fi/dy/masa/litematica/InitHandler.java @@ -6,10 +6,13 @@ import fi.dy.masa.malilib.event.*; import fi.dy.masa.malilib.interfaces.IInitializationHandler; import fi.dy.masa.malilib.interfaces.IRenderer; +import fi.dy.masa.malilib.registry.Registry; +import fi.dy.masa.malilib.util.data.ModInfo; import fi.dy.masa.litematica.config.Configs; import fi.dy.masa.litematica.data.DataManager; import fi.dy.masa.litematica.data.EntitiesDataStorage; import fi.dy.masa.litematica.event.*; +import fi.dy.masa.litematica.gui.GuiConfigs; import fi.dy.masa.litematica.render.infohud.StatusInfoRenderer; import fi.dy.masa.litematica.scheduler.ClientTickHandler; @@ -19,6 +22,10 @@ public class InitHandler implements IInitializationHandler public void registerModHandlers() { ConfigManager.getInstance().registerConfigHandler(Reference.MOD_ID, new Configs()); + Registry.CONFIG_SCREEN.registerConfigScreenFactory( + new ModInfo(Reference.MOD_ID, Reference.MOD_NAME, GuiConfigs::new) + ); + EntitiesDataStorage.getInstance().onGameInit(); InputEventHandler.getKeybindManager().registerKeybindProvider(InputHandler.getInstance()); diff --git a/src/main/java/fi/dy/masa/litematica/data/EntitiesDataStorage.java b/src/main/java/fi/dy/masa/litematica/data/EntitiesDataStorage.java index 2758478cc7..a7fd366cf0 100644 --- a/src/main/java/fi/dy/masa/litematica/data/EntitiesDataStorage.java +++ b/src/main/java/fi/dy/masa/litematica/data/EntitiesDataStorage.java @@ -36,8 +36,8 @@ import fi.dy.masa.malilib.network.IPluginClientPlayHandler; import fi.dy.masa.malilib.util.Constants; import fi.dy.masa.malilib.util.InventoryUtils; -import fi.dy.masa.malilib.util.nbt.NbtUtils; import fi.dy.masa.malilib.util.nbt.NbtKeys; +import fi.dy.masa.malilib.util.nbt.NbtUtils; import fi.dy.masa.litematica.Litematica; import fi.dy.masa.litematica.Reference; import fi.dy.masa.litematica.config.Configs; diff --git a/src/main/java/fi/dy/masa/litematica/scheduler/tasks/TaskPasteSchematicPerChunkCommand.java b/src/main/java/fi/dy/masa/litematica/scheduler/tasks/TaskPasteSchematicPerChunkCommand.java index 6127a8484c..fe36f5243f 100644 --- a/src/main/java/fi/dy/masa/litematica/scheduler/tasks/TaskPasteSchematicPerChunkCommand.java +++ b/src/main/java/fi/dy/masa/litematica/scheduler/tasks/TaskPasteSchematicPerChunkCommand.java @@ -1,12 +1,13 @@ package fi.dy.masa.litematica.scheduler.tasks; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.util.*; import java.util.function.Consumer; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import com.google.common.collect.Queues; import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap; import it.unimi.dsi.fastutil.longs.LongArrayList; + import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.SignBlockEntity; @@ -29,13 +30,13 @@ import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.WorldChunk; + import fi.dy.masa.malilib.gui.Message.MessageType; -import fi.dy.masa.malilib.util.InfoUtils; -import fi.dy.masa.malilib.util.IntBoundingBox; -import fi.dy.masa.malilib.util.LayerRange; -import fi.dy.masa.malilib.util.PositionUtils; +import fi.dy.masa.malilib.util.game.BlockUtils; +import fi.dy.masa.malilib.util.*; import fi.dy.masa.litematica.config.Configs; import fi.dy.masa.litematica.data.DataManager; +import fi.dy.masa.litematica.mixin.IMixinAbstractBlock; import fi.dy.masa.litematica.render.infohud.InfoHud; import fi.dy.masa.litematica.schematic.placement.SchematicPlacement; import fi.dy.masa.litematica.util.EntityUtils; @@ -987,11 +988,15 @@ protected static boolean preparePickedStack(BlockPos pos, BlockState state, Bloc { return false; } - ItemStack stack = state.getBlock().getPickStack(world, pos, state); + + ItemStack stack = ((IMixinAbstractBlock) state.getBlock()).litematica_getPickStack(world, pos, state, false); if (stack.isEmpty() == false) { - be.setStackNbt(stack, registryManager); + // FIXME + //be.setStackNbt(stack, registryManager); + //BlockItem.setBlockEntityData(stack, be.getType(), nbt); + BlockUtils.setStackNbt(stack, be, registryManager); mc.player.getInventory().offHand.set(0, stack); mc.interactionManager.clickCreativeStack(stack, 45); return true; diff --git a/src/main/java/fi/dy/masa/litematica/util/InventoryUtils.java b/src/main/java/fi/dy/masa/litematica/util/InventoryUtils.java index 4046487ffa..cb529e9546 100644 --- a/src/main/java/fi/dy/masa/litematica/util/InventoryUtils.java +++ b/src/main/java/fi/dy/masa/litematica/util/InventoryUtils.java @@ -140,7 +140,8 @@ public static void schematicWorldPickBlock(ItemStack stack, BlockPos pos, // Otherwise it would try to write whatever that TE is into the picked ItemStack. if (GuiBase.isCtrlDown() && te != null && mc.world.isAir(pos)) { - te.setStackNbt(stack, schematicWorld.getRegistryManager()); + //te.setStackNbt(stack, schematicWorld.getRegistryManager()); + fi.dy.masa.malilib.util.game.BlockUtils.setStackNbt(stack, te, schematicWorld.getRegistryManager()); //stack.set(DataComponentTypes.LORE, new LoreComponent(ImmutableList.of(Text.of("(+NBT)")))); } diff --git a/src/main/java/fi/dy/masa/litematica/util/PickBlockUtils.java b/src/main/java/fi/dy/masa/litematica/util/PickBlockUtils.java index fb83353603..bddc03036e 100644 --- a/src/main/java/fi/dy/masa/litematica/util/PickBlockUtils.java +++ b/src/main/java/fi/dy/masa/litematica/util/PickBlockUtils.java @@ -2,8 +2,6 @@ import javax.annotation.Nullable; -import org.jetbrains.annotations.ApiStatus; - import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; import net.minecraft.client.MinecraftClient; @@ -16,14 +14,14 @@ import fi.dy.masa.malilib.gui.GuiBase; import fi.dy.masa.malilib.registry.Registry; +import fi.dy.masa.malilib.util.game.BlockUtils; import fi.dy.masa.malilib.util.game.PlacementUtils; import fi.dy.masa.litematica.materials.MaterialCache; import fi.dy.masa.litematica.world.SchematicWorldHandler; /** - * Post Re-Write Code + * Post Re-Write code */ -@ApiStatus.Experimental public class PickBlockUtils { @Nullable @@ -37,7 +35,7 @@ public static Hand doPickBlockForStack(ItemStack stack) } //boolean ignoreNbt = Configs.Generic.PICK_BLOCK_IGNORE_NBT.getBooleanValue(); boolean ignoreNbt = false; - Hand hand = EntityUtils.getUsedHandForItem(player, stack, ignoreNbt); + Hand hand = EntityUtils.PRW_getUsedHandForItem(player, stack, ignoreNbt); if (stack.isEmpty() == false && hand == null) { @@ -73,7 +71,7 @@ public static Hand pickBlockLast() { double reach = mc.player.getBlockInteractionRange(); Entity entity = mc.getCameraEntity(); - pos = RayTraceUtils.getPickBlockLastTrace(world, entity, reach, true); + pos = RayTraceUtils.PRW_getPickBlockLastTrace(world, entity, reach, true); } if (pos != null && PlacementUtils.isReplaceable(world, pos, true)) @@ -107,7 +105,7 @@ private static Hand doPickBlockForPosition(BlockPos pos) if (stack.isEmpty() == false) { - Hand hand = EntityUtils.getUsedHandForItem(player, stack, ignoreNbt); + Hand hand = EntityUtils.PRW_getUsedHandForItem(player, stack, ignoreNbt); if (hand == null) { @@ -122,7 +120,8 @@ private static Hand doPickBlockForPosition(BlockPos pos) { stack = stack.copy(); //ItemUtils.storeBlockEntityInStack(stack, te); - te.setStackNbt(stack, clientWorld.getRegistryManager()); + //te.setStackNbt(stack, clientWorld.getRegistryManager()); + BlockUtils.setStackNbt(stack, te, clientWorld.getRegistryManager()); } }