Skip to content

Commit

Permalink
Update to 1.21 thanks to @sakura-ryoko
Browse files Browse the repository at this point in the history
Migrate sakura's forks to JITPACK & RC.1 Cleanups
  • Loading branch information
aria1th authored Jun 13, 2024
2 parents d3290e8 + e39e043 commit 3eb86f9
Show file tree
Hide file tree
Showing 25 changed files with 102 additions and 7,812 deletions.
17 changes: 12 additions & 5 deletions common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ repositories {
maven { url 'https://masa.dy.fi/maven' }
maven { url = "https://www.cursemaven.com" }
maven { url "https://maven.terraformersmc.com/releases/" }
maven {
url "https://jitpack.io"
}
maven {
url "https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1"
}
Expand All @@ -64,7 +61,12 @@ dependencies {
// 1.20.1 then kosmolot-unofficial-malilib-fabric-1.20-0.15.4+ksm.3.jar
}
else {
modImplementation "curse.maven:malilib-${project.malilib_projectid}:${project.malilib_fileid}"
if (mcVersion >= 12005) {
modImplementation "com.github.sakura-ryoko:malilib:${project.malilib_fileid}"
}
else {
modImplementation "curse.maven:malilib-${project.malilib_projectid}:${project.malilib_fileid}"
}
//modImplementation "fi.dy.masa.malilib:malilib-fabric-${project.minecraft_version_out}:${project.malilib_version}"
}
// check project.litematica_projectid and project.litematica_fileid in gradle.properties.
Expand All @@ -74,7 +76,12 @@ dependencies {
// 1.20.1 then kosmolot-unofficial-litematica-fabric-1.20-0.14.3+ksm.3.jar
}
else {
modImplementation "curse.maven:litematica-${project.litematica_projectid}:${project.litematica_fileid}"
if (mcVersion >= 12005) {
modImplementation "com.github.sakura-ryoko:litematica:${project.litematica_fileid}"
}
else {
modImplementation "curse.maven:litematica-${project.litematica_projectid}:${project.litematica_fileid}"
}
//modImplementation "fi.dy.masa.litematica:litematica-fabric-${project.minecraft_version_out}:${project.litematica_version}"
}
annotationProcessor "com.github.LlamaLad7:MixinExtras:0.1.1"
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed external/malilib-fabric-1.21-pre2-0.18.999-snap.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package io.github.eatmyvenom.litematicin.mixin.Litematica;

import fi.dy.masa.litematica.render.schematic.BufferBuilderCache;
import fi.dy.masa.litematica.render.schematic.ChunkCacheSchematic;
import fi.dy.masa.litematica.render.schematic.ChunkRenderDataSchematic;
import fi.dy.masa.litematica.render.schematic.ChunkRendererSchematicVbo;
import fi.dy.masa.litematica.render.schematic.*;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.render.RenderLayer;
Expand All @@ -28,7 +25,11 @@ public class ChunkRendererSchematicVboMixin {
protected ChunkCacheSchematic schematicWorldView;

@Inject(method = "renderBlocksAndOverlay", at = @At("HEAD"), cancellable = true, remap = false)
//#if MC >= 12100
//$$ private void onRenderBlocksAndOverlay(BlockPos pos, ChunkRenderDataSchematic data, BufferAllocatorCache allocators, Set<BlockEntity> tileEntities, Set<RenderLayer> usedLayers, MatrixStack matrixStack, CallbackInfo ci) {
//#else
private void onRenderBlocksAndOverlay(BlockPos pos, ChunkRenderDataSchematic data, Set<BlockEntity> tileEntities, Set<RenderLayer> usedLayers, MatrixStack matrices, BufferBuilderCache buffers, CallbackInfo ci) {
//#endif
if (!RENDER_ONLY_HOLDING_ITEMS.getBooleanValue()) return;
BlockState stateSchematic = this.schematicWorldView.getBlockState(pos);
Item item = stateSchematic.getBlock().asItem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import io.github.eatmyvenom.litematicin.utils.*;
import net.minecraft.client.MinecraftClient;
//#if MC >= 12006
//$$ import net.minecraft.client.gui.screen.DownloadingTerrainScreen;
//#endif
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
Expand Down Expand Up @@ -34,7 +37,11 @@ public abstract class MinecraftClientMixin {

// On join a new world/server
@Inject(at = @At("HEAD"), method = "joinWorld")
//#if MC >= 12006
//$$ public void joinWorld(ClientWorld world, DownloadingTerrainScreen.WorldEntryReason worldEntryReason, CallbackInfo ci) {
//#else
public void joinWorld(ClientWorld world, CallbackInfo ci) {
//#endif
Printer.worldBottomY = world.getBottomY();
Printer.worldTopY = world.getTopY();
}
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/io/github/eatmyvenom/litematicin/utils/Breaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
//#if MC >= 12100
//$$ import java.util.Optional;
//$$ import net.minecraft.enchantment.Enchantment;
//$$ import net.minecraft.enchantment.Enchantments;
//$$ import net.minecraft.registry.RegistryKeys;
//$$ import net.minecraft.registry.entry.RegistryEntry;
//#endif

/**
* The breaking needs to be done every tick, since the WorldUtils.easyPlaceOnUseTick (which calls our Printer)
Expand Down Expand Up @@ -94,8 +101,14 @@ public static float getBlockBreakingSpeed(BlockState block, MinecraftClient mc,
}
float f = InventoryUtils.getInventory(mc.player).main.get(slotId).getMiningSpeedMultiplier(block);
if (f > 1.0F) {
//#if MC >= 12100
//$$ ItemStack itemStack = mc.player.getInventory().getMainHandStack();
//$$ Optional<RegistryEntry.Reference<Enchantment>> optional = mc.world.getRegistryManager().get(RegistryKeys.ENCHANTMENT).getEntry(Enchantments.EFFICIENCY);
//$$ int i = optional.map(enchantmentReference -> EnchantmentHelper.getLevel(enchantmentReference, itemStack)).orElse(0);
//#else
int i = EnchantmentHelper.getEfficiency(mc.player);
ItemStack itemStack = mc.player.getInventory().getMainHandStack();
//#endif
if (i > 0 && !itemStack.isEmpty()) {
f += (float) (i * i + 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
import net.minecraft.block.entity.LootableContainerBlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
//#if MC >= 12006
//$$ import net.minecraft.component.DataComponentTypes;
//$$ import net.minecraft.component.type.ContainerComponent;
//#endif
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventories;
import net.minecraft.inventory.Inventory;
Expand Down Expand Up @@ -103,6 +107,19 @@ private static void calculateCache() {
BlockItem blockItem = (BlockItem) item;
if (blockItem.getBlock() instanceof ShulkerBoxBlock) {
int invSize = 27;
//#if MC >= 12006
//$$ DefaultedList<ItemStack> returnStacks = DefaultedList.ofSize(invSize, ItemStack.EMPTY);
//$$ ContainerComponent container = stack.getComponents().get(DataComponentTypes.CONTAINER);
//$$ if (container != null) {
//$$ container.copyTo(returnStacks);
//$$ for (ItemStack returnStack : returnStacks) {
//$$ Item returnItem = returnStack.getItem();
//$$ if (returnItem != null) {
//$$ ITEMS.add(returnItem);
//$$ }
//$$ }
//$$ }
//#else
NbtCompound compound = stack.getSubNbt("BlockEntityTag");
if (compound == null) {
continue;
Expand All @@ -117,6 +134,7 @@ private static void calculateCache() {
ITEMS.add(returnItem);
}
}
//#endif
}
}
}
Expand Down Expand Up @@ -235,7 +253,11 @@ private static boolean exceptToolItems(ItemStack a, ItemStack b) {
return a.getItem() == b.getItem();
}
boolean isItemEqual = ItemStack.areItemsEqual(a, b);
//#if MC >= 12006
//$$ boolean nbtCondition = LitematicaMixinMod.PRINTER_IGNORE_NBT.getBooleanValue() || ItemStack.areItemsAndComponentsEqual(a, b);
//#else
boolean nbtCondition = PRINTER_IGNORE_NBT.getBooleanValue() || ItemStack.areNbtEqual(a, b);
//#endif
return isItemEqual && nbtCondition;
}

Expand All @@ -246,7 +268,11 @@ public static boolean areItemsExactCount(ItemStack a, ItemStack b, boolean allow
if (allowNamed) {
return areItemsExactAllowNamed(a, b);
}
//#if MC >= 12006
//$$ boolean nbtCondition = LitematicaMixinMod.PRINTER_IGNORE_NBT.getBooleanValue() || ItemStack.areItemsAndComponentsEqual(a, b);
//#else
boolean nbtCondition = PRINTER_IGNORE_NBT.getBooleanValue() || ItemStack.areNbtEqual(a, b);
//#endif
return ItemStack.areItemsEqual(a, b) && nbtCondition;
}

Expand Down Expand Up @@ -274,7 +300,11 @@ public static boolean areItemsExactAllowNamed(ItemStack a, ItemStack b) {
else if (a.getItem() instanceof ToolItem || b.getItem() instanceof ToolItem) {
return false; // safety
}
//#if MC >= 12006
//$$ return ItemStack.areItemsEqual(a, b) || a.getMaxCount() == b.getMaxCount() && a.contains(DataComponentTypes.CUSTOM_NAME) && b.contains(DataComponentTypes.CUSTOM_NAME);
//#else
return ItemStack.areItemsEqual(a, b) || a.getMaxCount() == b.getMaxCount() && a.hasCustomName() && b.hasCustomName();
//#endif
}

public static boolean requiresSwap(ClientPlayerEntity player, ItemStack stack) {
Expand Down Expand Up @@ -411,7 +441,11 @@ public static int getSlotWithStack(ClientPlayerEntity player, ItemStack stack) {
public static void printAllItems(PlayerInventory inv, ItemStack stack) {
// Debug
for (int i = 0; i < inv.main.size(); i++) {
//#if MC >= 12006
//$$ boolean areNbtsEqual = ItemStack.areItemsAndComponentsEqual(inv.getStack(i), stack);
//#else
boolean areNbtsEqual = ItemStack.areNbtEqual(inv.getStack(i), stack);
//#endif
boolean areItemsEqual = ItemStack.areItemsEqual(inv.getStack(i), stack);
MessageHolder.sendUniqueDebugMessage("Slot " + i + ", " + inv.getStack(i).getItem() + " : " + areItemsEqual + " : " + areNbtsEqual);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ private static void clearCursor(MinecraftClient client) {
ItemStack cursorStack = player.currentScreenHandler.getCursorStack();
ScreenHandler handler = player.currentScreenHandler;
for (int i = 0; i < handler.slots.size(); i++) {
//#if MC >= 12006
//$$ if (ItemStack.areItemsAndComponentsEqual(cursorStack, handler.getSlot(i).getStack())) {
//#else
if (ItemStack.canCombine(cursorStack, handler.getSlot(i).getStack())) {
//#endif
client.interactionManager.clickSlot(handler.syncId, handler.getSlot(i).id, 0, SlotActionType.PICKUP, player);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,11 @@ else if (stateSchematic.isOf(Blocks.FARMLAND) && PRINTER_PRINT_DIRT_VARIANTS.get
MessageHolder.sendUniqueMessage(mc.player, "Can't pick item " + stateSchematic.getBlock().asItem().getTranslationKey() + " at " + pos.toShortString());
continue;
}
//#if MC >= 12006
//$$ if (!stateSchematic.canPlaceAt(mc.world, pos)) {
//#else
if (!blockSchematic.canPlaceAt(stateSchematic, mc.world, pos)) {
//#endif
recordCause(pos, stateSchematic.getBlock().toString() + "(" + pos.toShortString() + ", can't be placed)", pos);
MessageHolder.sendUniqueMessage(mc.player, stateSchematic.getBlock().getTranslationKey() + " can't be placed at " + pos.toShortString());
continue;
Expand Down Expand Up @@ -1473,7 +1477,11 @@ private static boolean checkObserverOutputs(MinecraftClient mc, World world, Blo

private static boolean willFall(BlockState stateSchematic, World clientWorld, BlockPos pos) {
if (stateSchematic.getBlock() instanceof ScaffoldingBlock) {
//#if MC >= 12006
//$$ return !stateSchematic.canPlaceAt(clientWorld, pos);
//#else
return !stateSchematic.getBlock().canPlaceAt(stateSchematic, clientWorld, pos);
//#endif
}
return false;
}
Expand Down
14 changes: 7 additions & 7 deletions versions/1.20.6/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
minecraft_version_out = 1.20.6

# Mod Properties
#malilib_projectid=303119
#malilib_fileid=4946328
#litematica_fileid=4946471
#litematica_projectid=308892
essentialclient_filename=essential-client-1.20.1-1.3.6.jar
malilib_filename=malilib-fabric-1.20.6-0.18.999-sakura.4.jar
litematica_filename=litematica-fabric-1.20.6-0.17.999-sakura.8.jar
# (Jitpack.io) https://github.com/sakura-ryoko/malilib
malilib_projectid = "sakura-jitpack"
malilib_fileid = 795cbdd15c
# (Jitpack.io) https://github.com/sakura-ryoko/litematica
litematica_projectid = "sakura-jitpack"
litematica_fileid = 3b9d213f1b
essentialclient_filename = essential-client-1.20.1-1.3.6.jar

This file was deleted.

This file was deleted.

Loading

0 comments on commit 3eb86f9

Please sign in to comment.