Skip to content

Commit

Permalink
Update MaLiLib
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Dec 11, 2024
1 parent 852090e commit bcafb40
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 18 deletions.
7 changes: 7 additions & 0 deletions src/main/java/fi/dy/masa/litematica/InitHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/fi/dy/masa/litematica/util/InventoryUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)"))));
}

Expand Down
15 changes: 7 additions & 8 deletions src/main/java/fi/dy/masa/litematica/util/PickBlockUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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)
{
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
{
Expand All @@ -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());
}
}

Expand Down

0 comments on commit bcafb40

Please sign in to comment.