Skip to content

Commit

Permalink
1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
kkllffaa committed Jul 20, 2024
1 parent 7f745f2 commit c0eef21
Show file tree
Hide file tree
Showing 11 changed files with 217 additions and 112 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/dev build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup JDK 17
- name: Setup JDK 21
uses: actions/[email protected]
with:
java-version: 17
java-version: 21
distribution: adopt
- name: Build
run: |
Expand All @@ -20,8 +20,8 @@ jobs:
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: '${{ secrets.GITHUB_TOKEN }}'
automatic_release_tag: "mc_1.20.4_meteor_0.5.6_ver_1.3"
automatic_release_tag: "mc_1.21_meteor_0.5.8_ver_1.3"
prerelease: false
title: "Version 1.3 for meteor 0.5.6 and Minecraft 1.20.4"
title: "Version 1.3 for meteor 0.5.8 and Minecraft 1.21"
files: |
./build/libs/*.jar
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Meteor Litematica Printer

Fast printer to litematica mod
Fast printer to litematica made with meteor client

Works best with simple blocks witout rotation or other properties like dirt stone etc.

For 1.21+ use fork of litematica maintaind by [sakura-ryoko](https://github.com/sakura-ryoko)
- [litematica](https://github.com/sakura-ryoko/litematica)
- [malilib (needed for litematica to work)](https://github.com/sakura-ryoko/malilib)
22 changes: 13 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'maven-publish'
id 'fabric-loom' version '1.7-SNAPSHOT'
}

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
Expand All @@ -10,12 +9,14 @@ version = project.mod_version
group = project.maven_group

repositories {

maven { url = "https://www.cursemaven.com" }
maven { url = "https://masa.dy.fi/maven" }

mavenCentral()
maven { url = "https://maven.meteordev.org/releases" }
maven { url = "https://maven.meteordev.org/snapshots" }
maven { url 'https://jitpack.io' }

//maven { url = "https://masa.dy.fi/maven" }


}

dependencies {
Expand All @@ -26,11 +27,14 @@ dependencies {

// Meteor
modImplementation "meteordevelopment:meteor-client:${project.meteor_version}-SNAPSHOT"
modImplementation "meteordevelopment:baritone:${project.minecraft_version}-SNAPSHOT"
//modImplementation "meteordevelopment:baritone:${project.baritone_version}-SNAPSHOT"

//litematica
modImplementation "curse.maven:litematica-${project.litematica_projectid}:${project.litematica_fileid}"
modImplementation "fi.dy.masa.malilib:malilib-fabric-${project.minecraft_version}:${project.malilib_version}"
//modImplementation "curse.maven:litematica-${project.litematica_projectid}:${project.litematica_fileid}"
modImplementation 'com.github.sakura-ryoko:litematica:1.21-sakura.23'
//modImplementation "fi.dy.masa.malilib:malilib-fabric-${project.minecraft_version}:${project.malilib_version}"
modImplementation 'com.github.sakura-ryoko:malilib:1.21-sakura.8'


}

Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
org.gradle.jvmargs=-Xmx4G

# Fabric (https://fabricmc.net/versions.html)
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.7
minecraft_version=1.21
yarn_mappings=1.21+build.9
loader_version=0.15.11

# Mod Properties
mod_version=1.3
maven_group=com.kkllffaa
archives_base_name=meteor-litematica-printer

# litematica
litematica_fileid=5170070
litematica_projectid=308892
malilib_version = 0.18.1
#litematica_fileid=5170070
#litematica_projectid=308892
#malilib_version = 0.18.1

# meteor
meteor_version=0.5.6
meteor_version=0.5.8
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pluginManagement {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
gradlePluginPortal()
}
}
89 changes: 35 additions & 54 deletions src/main/java/com/kkllffaa/meteor_litematica_printer/MyUtils.java
Original file line number Diff line number Diff line change
@@ -1,58 +1,36 @@
package com.kkllffaa.meteor_litematica_printer;

import static meteordevelopment.meteorclient.MeteorClient.mc;
import static meteordevelopment.meteorclient.utils.world.BlockUtils.canPlace;

import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.RayTraceUtils;
import baritone.api.utils.Rotation;
import baritone.api.utils.RotationUtils;
import meteordevelopment.meteorclient.utils.player.Rotations;
import meteordevelopment.meteorclient.utils.world.BlockUtils;
import net.minecraft.block.AmethystClusterBlock;
import net.minecraft.block.AnvilBlock;
import net.minecraft.block.BellBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ButtonBlock;
import net.minecraft.block.ChainBlock;
import net.minecraft.block.EndRodBlock;
import net.minecraft.block.GrindstoneBlock;
import net.minecraft.block.HopperBlock;
import net.minecraft.block.LightningRodBlock;
import net.minecraft.block.ObserverBlock;
import net.minecraft.block.PistonBlock;
import net.minecraft.block.PointedDripstoneBlock;
import net.minecraft.block.ScaffoldingBlock;
import net.minecraft.block.ShulkerBoxBlock;
import net.minecraft.block.SlabBlock;
import net.minecraft.block.StainedGlassBlock;
import net.minecraft.block.StairsBlock;
import net.minecraft.block.TrapdoorBlock;
import net.minecraft.block.*;
import net.minecraft.block.enums.BlockHalf;
import net.minecraft.block.enums.SlabType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket;
import net.minecraft.state.property.Properties;
import net.minecraft.state.property.Property;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Direction.Axis;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.RaycastContext;
import net.minecraft.world.RaycastContext.FluidHandling;
import net.minecraft.world.RaycastContext.ShapeType;

import static meteordevelopment.meteorclient.MeteorClient.mc;
import static meteordevelopment.meteorclient.utils.world.BlockUtils.canPlace;

//import baritone.api.utils.BetterBlockPos;
//import baritone.api.utils.RayTraceUtils;
//import baritone.api.utils.Rotation;
//import baritone.api.utils.RotationUtils;

public class MyUtils {

public static boolean place(BlockPos blockPos, Direction direction, SlabType slabType, BlockHalf blockHalf, Direction blockHorizontalOrientation, Axis wantedAxies, boolean airPlace, boolean swingHand, boolean rotate, boolean clientSide, int range) {
if (mc.player == null) return false;
if (!canPlace(blockPos)) return false;
Expand All @@ -76,8 +54,8 @@ public static boolean place(BlockPos blockPos, Direction direction, SlabType sla
Direction s = direction;

if (rotate) {
BetterBlockPos placeAgainstPos = new BetterBlockPos(neighbour.getX(), neighbour.getY(), neighbour.getZ());
VoxelShape collisionShape = mc.world.getBlockState(placeAgainstPos).getCollisionShape(mc.world, placeAgainstPos);
//BetterBlockPos placeAgainstPos = new BetterBlockPos(neighbour.getX(), neighbour.getY(), neighbour.getZ());
VoxelShape collisionShape = mc.world.getBlockState(neighbour).getCollisionShape(mc.world, neighbour);

if(collisionShape.isEmpty()) {
Rotations.rotate(Rotations.getYaw(hitPos), Rotations.getPitch(hitPos), 50, clientSide,
Expand All @@ -93,30 +71,30 @@ public static boolean place(BlockPos blockPos, Direction direction, SlabType sla
for (double x = 0.1; x < 0.9; x+=0.2)
for (Vec3d placementMultiplier : aabbSideMultipliers(direction.getOpposite())) {

double placeX = placeAgainstPos.x + aabb.minX * x + aabb.maxX * (1 - x);
double placeX = neighbour.getX() + aabb.minX * x + aabb.maxX * (1 - x);
if((slabType != null && slabType != SlabType.DOUBLE || blockHalf != null && direction != Direction.UP && direction != Direction.DOWN) && !mc.player.isCreative()) {
if (slabType == SlabType.BOTTOM || blockHalf == BlockHalf.BOTTOM) {
if (placementMultiplier.y <= 0.5) continue;
} else {
if (placementMultiplier.y > 0.5) continue;
}
}
double placeY = placeAgainstPos.y + aabb.minY * placementMultiplier.y + aabb.maxY * (1 - placementMultiplier.y);
double placeZ = placeAgainstPos.z + aabb.minZ * z + aabb.maxZ * (1 - z);
double placeY = neighbour.getY() + aabb.minY * placementMultiplier.y + aabb.maxY * (1 - placementMultiplier.y);
double placeZ = neighbour.getZ() + aabb.minZ * z + aabb.maxZ * (1 - z);

Vec3d testHitPos = new Vec3d(placeX, placeY, placeZ);
Vec3d playerHead = new Vec3d(mc.player.getX(), mc.player.getEyeY(), mc.player.getZ());

Rotation rot = RotationUtils.calcRotationFromVec3d(playerHead, testHitPos, new Rotation(mc.player.getYaw(), mc.player.getPitch()));
Rotation rot = RotationStuff.calcRotationFromVec3d(playerHead, testHitPos, new Rotation(mc.player.getYaw(), mc.player.getPitch()));
Direction testHorizontalDirection = getHorizontalDirectionFromYaw(rot.normalize().getYaw());
if (blockHorizontalOrientation != null
&& ( testHorizontalDirection.getAxis() != blockHorizontalOrientation.getAxis())) continue;
HitResult res = RayTraceUtils.rayTraceTowards(mc.player, rot, range, false);
HitResult res = RotationStuff.rayTraceTowards(mc.player, rot, range);
BlockHitResult blockHitRes = ((BlockHitResult) res);
if(
res == null ||
res.getType() != HitResult.Type.BLOCK ||
!blockHitRes.getBlockPos().equals(placeAgainstPos) ||
!blockHitRes.getBlockPos().equals(neighbour) ||
blockHitRes.getSide() != direction
) continue;

Expand All @@ -135,6 +113,7 @@ public static boolean place(BlockPos blockPos, Direction direction, SlabType sla
return true;
}


private static void place(BlockHitResult blockHitResult, boolean swing) {
if (mc.player == null || mc.interactionManager == null || mc.getNetworkHandler() == null) return;
boolean wasSneaking = mc.player.input.sneaking;
Expand Down Expand Up @@ -302,11 +281,11 @@ public static boolean isPlayerOrientationDesired(Block block, Direction blockHor

);
}

public static Direction getVisiblePlaceSide(BlockPos placeAt, BlockState placeAtState, SlabType slabType, BlockHalf blockHalf, Direction blockHorizontalOrientation, Axis wantedAxies, int range, Direction requiredDir) {
if (mc.world == null) return null;
for (Direction against : Direction.values()) {
BetterBlockPos placeAgainstPos = new BetterBlockPos(placeAt.getX(), placeAt.getY(), placeAt.getZ()).relative(against);
//BetterBlockPos placeAgainstPos = new BetterBlockPos(placeAt.getX(), placeAt.getY(), placeAt.getZ()).relative(against);
// BlockState placeAgainstState = mc.world.getBlockState(placeAgainstPos);

if(wantedAxies != null && against.getAxis() != wantedAxies || blockHalf != null && (against == Direction.UP && blockHalf == BlockHalf.BOTTOM || against == Direction.DOWN && blockHalf == BlockHalf.TOP))
Expand All @@ -324,41 +303,41 @@ public static Direction getVisiblePlaceSide(BlockPos placeAt, BlockState placeAt

if(!canPlaceAgainst(
placeAtState,
mc.world.getBlockState(placeAgainstPos),
mc.world.getBlockState(placeAt),
against
) || BlockUtils.isClickable(mc.world.getBlockState(placeAgainstPos).getBlock()))
) || BlockUtils.isClickable(mc.world.getBlockState(placeAt).getBlock()))
continue;
Box aabb = mc.world.getBlockState(placeAgainstPos).getCollisionShape(mc.world, placeAgainstPos).getBoundingBox();
Box aabb = mc.world.getBlockState(placeAt).getCollisionShape(mc.world, placeAt).getBoundingBox();

for (double z = 0.1; z < 0.9; z+=0.2)
for (double x = 0.1; x < 0.9; x+=0.2)
for (Vec3d placementMultiplier : aabbSideMultipliers(against)) {
double placeX = placeAgainstPos.x + aabb.minX * x + aabb.maxX * (1 - x);
double placeX = placeAt.getX() + aabb.minX * x + aabb.maxX * (1 - x);
if((slabType != null && slabType != SlabType.DOUBLE || blockHalf != null && against != Direction.DOWN && against != Direction.UP) && !mc.player.isCreative()) {
if (slabType == SlabType.BOTTOM || blockHalf == BlockHalf.BOTTOM) {
if (placementMultiplier.y <= 0.5) continue;
} else {
if (placementMultiplier.y > 0.5) continue;
}
}
double placeY = placeAgainstPos.y + aabb.minY * placementMultiplier.y + aabb.maxY * (1 - placementMultiplier.y);
double placeZ = placeAgainstPos.z + aabb.minZ * z + aabb.maxZ * (1 - z);
double placeY = placeAt.getY() + aabb.minY * placementMultiplier.y + aabb.maxY * (1 - placementMultiplier.y);
double placeZ = placeAt.getZ() + aabb.minZ * z + aabb.maxZ * (1 - z);

Vec3d hitPos = new Vec3d(placeX, placeY, placeZ);
Vec3d playerHead = new Vec3d(mc.player.getX(), mc.player.getEyeY(), mc.player.getZ());
Rotation rot = RotationUtils.calcRotationFromVec3d(playerHead, hitPos, new Rotation(mc.player.getYaw(), mc.player.getPitch()));
Rotation rot = RotationStuff.calcRotationFromVec3d(playerHead, hitPos, new Rotation(mc.player.getYaw(), mc.player.getPitch()));

Direction testHorizontalDirection = getHorizontalDirectionFromYaw(rot.normalize().getYaw());
if (placeAtState.getBlock() instanceof TrapdoorBlock && !(against != Direction.DOWN && against != Direction.UP) && !isPlayerOrientationDesired(placeAtState.getBlock(), blockHorizontalOrientation, testHorizontalDirection)
|| !(placeAtState.getBlock() instanceof TrapdoorBlock) && !isPlayerOrientationDesired(placeAtState.getBlock(), blockHorizontalOrientation, testHorizontalDirection)
) continue;
HitResult res = RayTraceUtils.rayTraceTowards(mc.player, rot, range, false);
HitResult res = RotationStuff.rayTraceTowards(mc.player, rot, range);
BlockHitResult blockHitRes = ((BlockHitResult) res);

if(
res == null
|| res.getType() != HitResult.Type.BLOCK
|| !blockHitRes.getBlockPos().equals(placeAgainstPos)
|| !blockHitRes.getBlockPos().equals(placeAt)
|| blockHitRes.getSide() != against.getOpposite()
) continue;

Expand Down Expand Up @@ -403,7 +382,7 @@ public static Direction getPlaceSide(BlockPos blockPos, BlockState placeAtState,

Vec3d hitPos = new Vec3d(neighbor.getX(), neighbor.getY(), neighbor.getZ());
Vec3d playerHead = new Vec3d(mc.player.getX(), mc.player.getEyeY(), mc.player.getZ());
Rotation rot = RotationUtils.calcRotationFromVec3d(playerHead, hitPos, new Rotation(mc.player.getYaw(), mc.player.getPitch()));
Rotation rot = RotationStuff.calcRotationFromVec3d(playerHead, hitPos, new Rotation(mc.player.getYaw(), mc.player.getPitch()));

Direction testHorizontalDirection = getHorizontalDirectionFromYaw(rot.normalize().getYaw());

Expand All @@ -417,7 +396,9 @@ public static Direction getPlaceSide(BlockPos blockPos, BlockState placeAtState,
return null;
}

/*
public static NbtCompound getNbtFromBlockState (ItemStack itemStack, BlockState state) {
//NbtCompound nbt = itemStack.getOrCreateNbt();
NbtCompound nbt = itemStack.getOrCreateNbt();
NbtCompound subNbt = new NbtCompound();
for (Property<?> property : state.getProperties()) {
Expand All @@ -427,7 +408,7 @@ public static NbtCompound getNbtFromBlockState (ItemStack itemStack, BlockState
return nbt;
}

*/
private static Vec3d[] aabbSideMultipliers(Direction side) {
switch (side) {
case UP:
Expand Down
Loading

0 comments on commit c0eef21

Please sign in to comment.