Skip to content

Commit

Permalink
Ported changes & fixed flowerpots sometimes blocking the placement.
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksilassila committed Dec 15, 2022
1 parent 309fb0f commit fd296c9
Show file tree
Hide file tree
Showing 21 changed files with 107 additions and 48 deletions.
10 changes: 9 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@ val buildAll = tasks.create("buildAll") {
dependsOn(":v1_18:build")
dependsOn(":v1_19:build")
dependsOn(":v1_19_3:build")
// This isn't working.... you still have to run each build individually
tasks.findByName(":v1_19:build")?.mustRunAfter(":v1_19_3:build")
tasks.findByName(":v1_18:build")?.mustRunAfter(":v1_19:build")
tasks.findByName(":v1_17:build")?.mustRunAfter(":v1_18: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_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
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=false
# Mod Properties
mod_version=3.1
maven_group=net.fabricmc
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package me.aleksilassila.litematica.printer.v1_17;

import net.minecraft.block.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

abstract public class BlockHelper {
public static List<Class<?>> interactiveBlocks = new ArrayList<>(Arrays.asList(
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 @@ -9,7 +9,7 @@
import java.util.Scanner;

public class UpdateChecker {
public static final String version = "v3.0";
public static final String version = "v3.1";

public static String getPrinterVersion() {
try (InputStream inputStream = new URL("https://api.github.com/repos/aleksilassila/litematica-printer/tags").openStream(); Scanner scanner = new Scanner(inputStream)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState;
import me.aleksilassila.litematica.printer.v1_17.actions.Action;
import me.aleksilassila.litematica.printer.v1_17.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 @@ -27,6 +27,7 @@ public FlowerPotFillGuide(SchematicBlockState state) {
@Override
public boolean canExecute(ClientPlayerEntity player) {
if (content == null) return false;
if (!(currentState.getBlock() instanceof FlowerPotBlock)) return false;

return super.canExecute(player);
}
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,7 +111,7 @@ private static VoxelShape getOutlineShape(World world, BlockPos pos) {
return world.getBlockState(pos).getOutlineShape(world, pos);
}

public static boolean isInteractive(Block block) {
public boolean isInteractive(Block block) {
for (Class<?> clazz : interactiveBlocks) {
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,14 @@
package me.aleksilassila.litematica.printer.v1_17.implementation;

import me.aleksilassila.litematica.printer.v1_17.BlockHelper;
import net.minecraft.block.AbstractButtonBlock;

import java.util.Arrays;

public class BlockHelperImpl extends BlockHelper {
static {
interactiveBlocks.addAll(Arrays.asList(
AbstractButtonBlock.class
));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package me.aleksilassila.litematica.printer.v1_18;

import net.minecraft.block.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

abstract public class BlockHelper {
public static List<Class<?>> interactiveBlocks = new ArrayList<>(Arrays.asList(
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 @@ -9,7 +9,7 @@
import java.util.Scanner;

public class UpdateChecker {
public static final String version = "v3.0";
public static final String version = "v3.1";

public static String getPrinterVersion() {
try (InputStream inputStream = new URL("https://api.github.com/repos/aleksilassila/litematica-printer/tags").openStream(); Scanner scanner = new Scanner(inputStream)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState;
import me.aleksilassila.litematica.printer.v1_18.actions.Action;
import me.aleksilassila.litematica.printer.v1_18.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 @@ -27,6 +27,7 @@ public FlowerPotFillGuide(SchematicBlockState state) {
@Override
public boolean canExecute(ClientPlayerEntity player) {
if (content == null) return false;
if (!(currentState.getBlock() instanceof FlowerPotBlock)) return false;

return super.canExecute(player);
}
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,7 +111,7 @@ private static VoxelShape getOutlineShape(World world, BlockPos pos) {
return world.getBlockState(pos).getOutlineShape(world, pos);
}

public static boolean isInteractive(Block block) {
public boolean isInteractive(Block block) {
for (Class<?> clazz : interactiveBlocks) {
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,14 @@
package me.aleksilassila.litematica.printer.v1_18.implementation;

import me.aleksilassila.litematica.printer.v1_18.BlockHelper;
import net.minecraft.block.AbstractButtonBlock;

import java.util.Arrays;

public class BlockHelperImpl extends BlockHelper {
static {
interactiveBlocks.addAll(Arrays.asList(
AbstractButtonBlock.class
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import net.minecraft.block.*;

abstract public class BlockHelper {
abstract public Class<?>[] getInteractiveBlocks();
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public static Class<?>[] interactiveBlocks = new Class[]{
abstract public class BlockHelper {
public static List<Class<?>> interactiveBlocks = new ArrayList<>(Arrays.asList(
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,
Expand All @@ -14,6 +16,5 @@ abstract public class BlockHelper {
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,
};
StonecutterBlock.class, AbstractSignBlock.class));
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.Scanner;

public class UpdateChecker {
public static final String version = "v3.0";
public static final String version = "v3.1";

public static String getPrinterVersion() {
try (InputStream inputStream = new URL("https://api.github.com/repos/aleksilassila/litematica-printer/tags").openStream(); Scanner scanner = new Scanner(inputStream)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public FlowerPotFillGuide(SchematicBlockState state) {
@Override
public boolean canExecute(ClientPlayerEntity player) {
if (content == null) return false;
if (!(currentState.getBlock() instanceof FlowerPotBlock)) return false;

return super.canExecute(player);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private static VoxelShape getOutlineShape(World world, BlockPos pos) {
}

public boolean isInteractive(Block block) {
for (Class<?> clazz : getInteractiveBlocks()) {
for (Class<?> clazz : interactiveBlocks) {
if (clazz.isInstance(block)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package me.aleksilassila.litematica.printer.v1_19.implementation;

import me.aleksilassila.litematica.printer.v1_19.BlockHelper;
import net.minecraft.block.AbstractButtonBlock;

import java.util.Arrays;

public class BlockHelperImpl extends BlockHelper {
@Override
public Class<?>[] getInteractiveBlocks() {
return BlockHelper.interactiveBlocks;
static {
interactiveBlocks.addAll(Arrays.asList(
AbstractButtonBlock.class
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public FlowerPotFillGuide(SchematicBlockState state) {
@Override
public boolean canExecute(ClientPlayerEntity player) {
if (content == null) return false;
if (!(currentState.getBlock() instanceof FlowerPotBlock)) return false;

return super.canExecute(player);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import net.minecraft.block.ButtonBlock;

import java.util.Arrays;
import java.util.List;

public class BlockHelperImpl extends BlockHelper {
static {
Expand Down

0 comments on commit fd296c9

Please sign in to comment.