Skip to content

Commit

Permalink
Added support for 1.19.3, updated code base sync scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksilassila committed Dec 14, 2022
1 parent c44733c commit 309fb0f
Show file tree
Hide file tree
Showing 60 changed files with 2,662 additions and 70 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ val buildAll = tasks.create("buildAll") {
dependsOn(":v1_17:build")
dependsOn(":v1_18:build")
dependsOn(":v1_19:build")
dependsOn(":v1_19_3:build")
doLast {
println("Copying files...")
file("v1_19_3/build/libs/v1_19_3.jar").copyTo(file("build/${archives_base_name}-1.19.3-${mod_version}.jar"), true)
file("v1_19/build/libs/v1_19.jar").copyTo(file("build/${archives_base_name}-1.19-${mod_version}.jar"), true)
file("v1_18/build/libs/v1_18.jar").copyTo(file("build/${archives_base_name}-1.18-${mod_version}.jar"), true)
file("v1_17/build/libs/v1_17.jar").copyTo(file("build/${archives_base_name}-1.17-${mod_version}.jar"), true)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx2G
# Mod Properties
mod_version=3.0
mod_version=3.1
maven_group=net.fabricmc
archives_base_name=litematica-printer
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pluginManagement {
gradlePluginPortal()
}
}
include 'v1_19_3'
include 'v1_19'
include 'v1_18'
include 'v1_17'
39 changes: 22 additions & 17 deletions v1_17/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,46 @@ repositories {
maven("https://www.cursemaven.com")
}

fun copyFile(source: File, sourceVersion: String, targetVersion: String) {
val destination = file(source.absolutePath.replace(sourceVersion, targetVersion))
println("Copying ${source.absolutePath} to ${destination.absolutePath}")
destination.parentFile.mkdirs()
source.copyTo(destination, true)
destination.writeText(destination.readText().replace(sourceVersion, targetVersion))
val sourceModule = "v1_17"
val targetModules = arrayOf("v1_19", "v1_18", "v1_19_3")

fun copyFile(source: File) {
for (targetModule in targetModules) {
val destination = file(source.absolutePath.replace(sourceModule, targetModule))
println("Copying ${source.absolutePath} to ${destination.absolutePath}")
destination.parentFile.mkdirs()
source.copyTo(destination, true)
destination.writeText(destination.readText().replace(sourceModule, targetModule))
}
}

fun deleteOldFiles(sourceBase: File, sourceVersion: String, targetVersion: String) {
val targetBase = file(sourceBase.absolutePath.replace(sourceVersion, targetVersion))
fun deleteOldFiles(sourceBase: File) {
for (targetModule in targetModules) {
val targetBase = file(sourceBase.absolutePath.replace(sourceModule, targetModule))

for (file in targetBase.listFiles()) {
if (file.name.equals("implementation")) continue
println("Deleting recursively ${file.absolutePath}")
file.deleteRecursively()
for (file in targetBase.listFiles()) {
if (file.name.equals("implementation")) continue
println("Deleting recursively ${file.absolutePath}")
file.deleteRecursively()
}
}
}

val syncImplementations = tasks.create("syncImplementations") {
doFirst {
val sourceStart =
this.project.projectDir.absolutePath + "/src/main/java/me/aleksilassila/litematica/printer/v1_17"
this.project.projectDir.absolutePath + "/src/main/java/me/aleksilassila/litematica/printer/" + sourceModule
val sourceDir = file(sourceStart)

deleteOldFiles(sourceDir, "v1_17", "v1_18")
deleteOldFiles(sourceDir, "v1_17", "v1_19")
deleteOldFiles(sourceDir)

for (sourceFile in sourceDir.listFiles()) {
if (sourceFile.name.equals("implementation")) continue

sourceFile.walk()
.filter { it.isFile }
.forEach {
copyFile(it, "v1_17", "v1_18")
copyFile(it, "v1_17", "v1_19")
copyFile(it)
}
}
}
Expand Down
39 changes: 22 additions & 17 deletions v1_18/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,46 @@ repositories {
maven("https://www.cursemaven.com")
}

fun copyFile(source: File, sourceVersion: String, targetVersion: String) {
val destination = file(source.absolutePath.replace(sourceVersion, targetVersion))
println("Copying ${source.absolutePath} to ${destination.absolutePath}")
destination.parentFile.mkdirs()
source.copyTo(destination, true)
destination.writeText(destination.readText().replace(sourceVersion, targetVersion))
val sourceModule = "v1_18"
val targetModules = arrayOf("v1_19", "v1_19_3", "v1_17")

fun copyFile(source: File) {
for (targetModule in targetModules) {
val destination = file(source.absolutePath.replace(sourceModule, targetModule))
println("Copying ${source.absolutePath} to ${destination.absolutePath}")
destination.parentFile.mkdirs()
source.copyTo(destination, true)
destination.writeText(destination.readText().replace(sourceModule, targetModule))
}
}

fun deleteOldFiles(sourceBase: File, sourceVersion: String, targetVersion: String) {
val targetBase = file(sourceBase.absolutePath.replace(sourceVersion, targetVersion))
fun deleteOldFiles(sourceBase: File) {
for (targetModule in targetModules) {
val targetBase = file(sourceBase.absolutePath.replace(sourceModule, targetModule))

for (file in targetBase.listFiles()) {
if (file.name.equals("implementation")) continue
println("Deleting recursively ${file.absolutePath}")
file.deleteRecursively()
for (file in targetBase.listFiles()) {
if (file.name.equals("implementation")) continue
println("Deleting recursively ${file.absolutePath}")
file.deleteRecursively()
}
}
}

val syncImplementations = tasks.create("syncImplementations") {
doFirst {
val sourceStart =
this.project.projectDir.absolutePath + "/src/main/java/me/aleksilassila/litematica/printer/v1_18"
this.project.projectDir.absolutePath + "/src/main/java/me/aleksilassila/litematica/printer/" + sourceModule
val sourceDir = file(sourceStart)

deleteOldFiles(sourceDir, "v1_18", "v1_19")
deleteOldFiles(sourceDir, "v1_18", "v1_17")
deleteOldFiles(sourceDir)

for (sourceFile in sourceDir.listFiles()) {
if (sourceFile.name.equals("implementation")) continue

sourceFile.walk()
.filter { it.isFile }
.forEach {
copyFile(it, "v1_18", "v1_19")
copyFile(it, "v1_18", "v1_17")
copyFile(it)
}
}
}
Expand Down
39 changes: 22 additions & 17 deletions v1_19/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,46 @@ repositories {
maven("https://www.cursemaven.com")
}

fun copyFile(source: File, sourceVersion: String, targetVersion: String) {
val destination = file(source.absolutePath.replace(sourceVersion, targetVersion))
println("Copying ${source.absolutePath} to ${destination.absolutePath}")
destination.parentFile.mkdirs()
source.copyTo(destination, true)
destination.writeText(destination.readText().replace(sourceVersion, targetVersion))
val sourceModule = "v1_19"
val targetModules = arrayOf("v1_19_3", "v1_18", "v1_17")

fun copyFile(source: File) {
for (targetModule in targetModules) {
val destination = file(source.absolutePath.replace(sourceModule, targetModule))
println("Copying ${source.absolutePath} to ${destination.absolutePath}")
destination.parentFile.mkdirs()
source.copyTo(destination, true)
destination.writeText(destination.readText().replace(sourceModule, targetModule))
}
}

fun deleteOldFiles(sourceBase: File, sourceVersion: String, targetVersion: String) {
val targetBase = file(sourceBase.absolutePath.replace(sourceVersion, targetVersion))
fun deleteOldFiles(sourceBase: File) {
for (targetModule in targetModules) {
val targetBase = file(sourceBase.absolutePath.replace(sourceModule, targetModule))

for (file in targetBase.listFiles()) {
if (file.name.equals("implementation")) continue
println("Deleting recursively ${file.absolutePath}")
file.deleteRecursively()
for (file in targetBase.listFiles()) {
if (file.name.equals("implementation")) continue
println("Deleting recursively ${file.absolutePath}")
file.deleteRecursively()
}
}
}

val syncImplementations = tasks.create("syncImplementations") {
doFirst {
val sourceStart =
this.project.projectDir.absolutePath + "/src/main/java/me/aleksilassila/litematica/printer/v1_19"
this.project.projectDir.absolutePath + "/src/main/java/me/aleksilassila/litematica/printer/" + sourceModule
val sourceDir = file(sourceStart)

deleteOldFiles(sourceDir, "v1_19", "v1_18")
deleteOldFiles(sourceDir, "v1_19", "v1_17")
deleteOldFiles(sourceDir)

for (sourceFile in sourceDir.listFiles()) {
if (sourceFile.name.equals("implementation")) continue

sourceFile.walk()
.filter { it.isFile }
.forEach {
copyFile(it, "v1_19", "v1_18")
copyFile(it, "v1_19", "v1_17")
copyFile(it)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package me.aleksilassila.litematica.printer.v1_19;

import net.minecraft.block.*;

abstract public class BlockHelper {
abstract public Class<?>[] getInteractiveBlocks();

public static Class<?>[] interactiveBlocks = new Class[]{
AbstractChestBlock.class, AbstractFurnaceBlock.class, CraftingTableBlock.class, LeverBlock.class,
DoorBlock.class, TrapdoorBlock.class, BedBlock.class, RedstoneWireBlock.class, ScaffoldingBlock.class,
HopperBlock.class, EnchantingTableBlock.class, NoteBlock.class, JukeboxBlock.class, CakeBlock.class,
FenceGateBlock.class, BrewingStandBlock.class, DragonEggBlock.class, CommandBlock.class,
BeaconBlock.class, AnvilBlock.class, ComparatorBlock.class, RepeaterBlock.class,
DropperBlock.class, DispenserBlock.class, ShulkerBoxBlock.class, LecternBlock.class,
FlowerPotBlock.class, BarrelBlock.class, BellBlock.class, SmithingTableBlock.class,
LoomBlock.class, CartographyTableBlock.class, GrindstoneBlock.class,
StonecutterBlock.class, AbstractSignBlock.class,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState;
import me.aleksilassila.litematica.printer.v1_19.actions.Action;
import me.aleksilassila.litematica.printer.v1_19.implementation.BlockHelperImpl;
import net.minecraft.block.BlockState;
import net.minecraft.block.CoralBlock;
import net.minecraft.client.network.ClientPlayerEntity;
Expand All @@ -15,7 +16,7 @@
import java.util.List;
import java.util.Optional;

abstract public class Guide {
abstract public class Guide extends BlockHelperImpl {
protected final SchematicBlockState state;
protected final BlockState currentState;
protected final BlockState targetState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
Expand Down Expand Up @@ -112,8 +111,8 @@ private static VoxelShape getOutlineShape(World world, BlockPos pos) {
return world.getBlockState(pos).getOutlineShape(world, pos);
}

public static boolean isInteractive(Block block) {
for (Class<?> clazz : interactiveBlocks) {
public boolean isInteractive(Block block) {
for (Class<?> clazz : getInteractiveBlocks()) {
if (clazz.isInstance(block)) {
return true;
}
Expand All @@ -126,7 +125,7 @@ private boolean canPlaceInWater(BlockState blockState) {
Block block = blockState.getBlock();
if (block instanceof FluidFillable) {
return true;
} else if (!(block instanceof DoorBlock) && !blockState.isIn(BlockTags.SIGNS) && !blockState.isOf(Blocks.LADDER) && !blockState.isOf(Blocks.SUGAR_CANE) && !blockState.isOf(Blocks.BUBBLE_COLUMN)) {
} else if (!(block instanceof DoorBlock) && !(blockState.getBlock() instanceof AbstractSignBlock) && !blockState.isOf(Blocks.LADDER) && !blockState.isOf(Blocks.SUGAR_CANE) && !blockState.isOf(Blocks.BUBBLE_COLUMN)) {
Material material = blockState.getMaterial();
if (material != Material.PORTAL && material != Material.STRUCTURE_VOID && material != Material.UNDERWATER_PLANT && material != Material.REPLACEABLE_UNDERWATER_PLANT) {
return material.blocksMovement();
Expand All @@ -137,17 +136,4 @@ private boolean canPlaceInWater(BlockState blockState) {

return true;
}

public static Class<?>[] interactiveBlocks = new Class[]{
AbstractChestBlock.class, AbstractFurnaceBlock.class, CraftingTableBlock.class,
AbstractButtonBlock.class, LeverBlock.class, DoorBlock.class, TrapdoorBlock.class,
BedBlock.class, RedstoneWireBlock.class, ScaffoldingBlock.class, HopperBlock.class,
EnchantingTableBlock.class, NoteBlock.class, JukeboxBlock.class, CakeBlock.class,
FenceGateBlock.class, BrewingStandBlock.class, DragonEggBlock.class, CommandBlock.class,
BeaconBlock.class, AnvilBlock.class, ComparatorBlock.class, RepeaterBlock.class,
DropperBlock.class, DispenserBlock.class, ShulkerBoxBlock.class, LecternBlock.class,
FlowerPotBlock.class, BarrelBlock.class, BellBlock.class, SmithingTableBlock.class,
LoomBlock.class, CartographyTableBlock.class, GrindstoneBlock.class,
StonecutterBlock.class, AbstractSignBlock.class,
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package me.aleksilassila.litematica.printer.v1_19.implementation;

import me.aleksilassila.litematica.printer.v1_19.BlockHelper;

public class BlockHelperImpl extends BlockHelper {
@Override
public Class<?>[] getInteractiveBlocks() {
return BlockHelper.interactiveBlocks;
}
}
77 changes: 77 additions & 0 deletions v1_19_3/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
plugins {
id("fabric-loom").version("1.0-SNAPSHOT")
id("maven-publish")
}

java.sourceCompatibility = JavaVersion.VERSION_17
java.targetCompatibility = JavaVersion.VERSION_17

val archives_base_name: String by project
val minecraft_version: String by project
val yarn_mappings: String by project
val loader_version: String by project
val fabric_version: String by project
val malilib_version: String by project
val litematica_projectid: String by project
val litematica_fileid: String by project

dependencies {
// implementation(project(":common"))
minecraft("com.mojang:minecraft:${minecraft_version}")
mappings("net.fabricmc:yarn:${yarn_mappings}:v2")

modImplementation("net.fabricmc:fabric-loader:${loader_version}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${fabric_version}")
modImplementation("fi.dy.masa.malilib:malilib-fabric-${malilib_version}")
modImplementation("curse.maven:litematica-${litematica_projectid}:${litematica_fileid}")
}

repositories {
maven("https://masa.dy.fi/maven")
maven("https://www.cursemaven.com")
}

val sourceModule = "v1_19_3"
val targetModules = arrayOf("v1_19", "v1_18", "v1_17")

fun copyFile(source: File) {
for (targetModule in targetModules) {
val destination = file(source.absolutePath.replace(sourceModule, targetModule))
println("Copying ${source.absolutePath} to ${destination.absolutePath}")
destination.parentFile.mkdirs()
source.copyTo(destination, true)
destination.writeText(destination.readText().replace(sourceModule, targetModule))
}
}

fun deleteOldFiles(sourceBase: File) {
for (targetModule in targetModules) {
val targetBase = file(sourceBase.absolutePath.replace(sourceModule, targetModule))

for (file in targetBase.listFiles()) {
if (file.name.equals("implementation")) continue
println("Deleting recursively ${file.absolutePath}")
file.deleteRecursively()
}
}
}

val syncImplementations = tasks.create("syncImplementations") {
doFirst {
val sourceStart =
this.project.projectDir.absolutePath + "/src/main/java/me/aleksilassila/litematica/printer/" + sourceModule
val sourceDir = file(sourceStart)

deleteOldFiles(sourceDir)

for (sourceFile in sourceDir.listFiles()) {
if (sourceFile.name.equals("implementation")) continue

sourceFile.walk()
.filter { it.isFile }
.forEach {
copyFile(it)
}
}
}
}
Loading

0 comments on commit 309fb0f

Please sign in to comment.