Skip to content

Commit

Permalink
Bug fixes and updated to 1.18.2
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksilassila committed Mar 21, 2022
1 parent 5934eaa commit a5169ff
Show file tree
Hide file tree
Showing 10 changed files with 379 additions and 453 deletions.
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/versions.html
minecraft_version=1.18.1
yarn_mappings=1.18.1+build.14
loader_version=0.12.12
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.2
loader_version=0.13.3

# Mod Properties
mod_version = 2.1
maven_group = net.fabricmc
archives_base_name = litematica-printer

malilib_version = 1.18.0:0.10.0-dev.26
litematica_fileid=3545947
malilib_version = 1.18.2:0.12.0
litematica_fileid=3692244
litematica_projectid=308892

# Dependencies
fabric_version=0.45.0+1.18
fabric_version=0.48.0+1.18.2
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class LitematicaMixinMod implements ModInitializer {
public static final ConfigBoolean PRINT_MODE = new ConfigBoolean("printingMode", false, "Autobuild / print loaded selection.\nBe aware that some servers and anticheat plugins do not allow printing.");
public static final ConfigBoolean REPLACE_FLUIDS = new ConfigBoolean("replaceFluids", false, "Whether or not fluid source blocks should be replaced by the printer.");
public static final ConfigBoolean STRIP_LOGS = new ConfigBoolean("stripLogs", false, "Whether or not the printer should use normal logs if stripped\nversions are not available and then strip them with an axe.");
public static boolean shouldPrintInAir = PRINT_IN_AIR.getBooleanValue();

public static ImmutableList<IConfigBase> getConfigList() {
List<IConfigBase> list = new java.util.ArrayList<>(Configs.Generic.OPTIONS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
import me.aleksilassila.litematica.printer.mixin.PlayerMoveC2SPacketAccessor;
import me.aleksilassila.litematica.printer.printer.PlacementGuide;
import me.aleksilassila.litematica.printer.printer.Printer;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.MappingResolver;
import net.minecraft.block.*;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.player.PlayerAbilities;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.network.Packet;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.util.math.Direction;
Expand All @@ -20,6 +24,15 @@
* be the only file that has to be changed in every printer branch.
*/
public class Implementation {
public static final Item[] HOES = {Items.DIAMOND_HOE, Items.IRON_HOE, Items.GOLDEN_HOE,
Items.NETHERITE_HOE, Items.STONE_HOE, Items.WOODEN_HOE};

public static final Item[] SHOVELS = {Items.DIAMOND_SHOVEL, Items.IRON_SHOVEL, Items.GOLDEN_SHOVEL,
Items.NETHERITE_SHOVEL, Items.STONE_SHOVEL, Items.WOODEN_SHOVEL};

public static final Item[] AXES = {Items.DIAMOND_AXE, Items.IRON_AXE, Items.GOLDEN_AXE,
Items.NETHERITE_AXE, Items.STONE_AXE, Items.WOODEN_AXE};

public static PlayerInventory getInventory(ClientPlayerEntity playerEntity) {
return playerEntity.getInventory();
}
Expand Down Expand Up @@ -82,16 +95,43 @@ protected static float getRequiredPitch(ClientPlayerEntity playerEntity, Directi
}
}

public static boolean isInteractable(Block block) {
MappingResolver resolver = FabricLoader.getInstance().getMappingResolver();

// try {
// return block.getClass().getMethod(resolver.unmapClassName("intermediary", AbstractBlock.class.getName()))
// .getDeclaringClass().equals(AbstractBlock.class);
// } catch (NoSuchMethodException ignored) {
// return false;
// }

for (Class<?> clazz : interactableBlocks) {
if (clazz.isInstance(block)) {
return true;
}
}

return false;
}

public enum NewBlocks {
LICHEN(AbstractLichenBlock.class),
ROD(RodBlock.class),
CANDLES(CandleBlock.class),
AMETHYST(AmethystClusterBlock.class);

public Class<?> clazz;
public final Class<?> clazz;

NewBlocks(Class<?> clazz) {
this.clazz = clazz;
}
}

public static Class<?>[] interactableBlocks = {
ChestBlock.class, AbstractFurnaceBlock.class, CraftingTableBlock.class,
AbstractButtonBlock.class, LeverBlock.class, DoorBlock.class, TrapdoorBlock.class,
BedBlock.class, RedstoneWireBlock.class,
};


}
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package me.aleksilassila.litematica.printer.mixin;

import me.aleksilassila.litematica.printer.interfaces.IClientPlayerInteractionManager;
import me.aleksilassila.litematica.printer.printer.PlacementGuide;
import me.aleksilassila.litematica.printer.printer.Printer;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.MappingResolver;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerInteractionManager;
Expand All @@ -19,6 +25,8 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.lang.reflect.Method;

@Mixin(ClientPlayerInteractionManager.class)
public abstract class MixinClientPlayerInteractionManager implements IClientPlayerInteractionManager {
@Shadow
Expand All @@ -42,8 +50,14 @@ public abstract ActionResult interactBlock(
public abstract ActionResult interactItem(PlayerEntity playerEntity_1,
World world_1, Hand hand_1);

@Inject(at = @At("HEAD"), method = "interactBlock")
public void interactBlock(ClientPlayerEntity player, ClientWorld world, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> cir) {
System.out.println("Player interactBlock: pos: (" + hitResult.getBlockPos().toShortString() + "), side: " + hitResult.getSide().getName() + ", vector: " + hitResult.getPos().toString());
}
// @Inject(at = @At("HEAD"), method = "interactBlock")
// public void interactBlock(ClientPlayerEntity player, ClientWorld world, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> cir) {
// System.out.println("Player interactBlock: pos: (" + hitResult.getBlockPos().toShortString() + "), side: " + hitResult.getSide().getName() + ", vector: " + hitResult.getPos().toString());
// PlacementGuide.Action a = Printer.getPrinter().guide.getAction(hitResult.getBlockPos());
// for (Direction side : a.getSides().keySet()) {
// System.out.println("Side: " + side + ", " + a.getSides().get(side).toString());
// }
// System.out.println("Valid: " + a.getValidSide(world, hitResult.getBlockPos()));
// System.out.println("Look: " + a.getLookDirection());
// }
}

This file was deleted.

Loading

0 comments on commit a5169ff

Please sign in to comment.