From b2e3008141249aaad36cdd2e472798b08f12ca9f Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 25 Sep 2022 14:47:04 +0200 Subject: [PATCH] Adjust model and hitbox sizes of fruit --- .../unicopia/block/FruitBlock.java | 19 +++++++------- .../assets/unicopia/models/block/fruit.json | 26 +++++++++++++++++++ .../unicopia/models/block/green_apple.json | 2 +- .../unicopia/models/block/zap_apple.json | 2 +- .../unicopia/models/block/zap_bulb.json | 2 +- 5 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 src/main/resources/assets/unicopia/models/block/fruit.json diff --git a/src/main/java/com/minelittlepony/unicopia/block/FruitBlock.java b/src/main/java/com/minelittlepony/unicopia/block/FruitBlock.java index cdcc47f8..ff690c5e 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/FruitBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/FruitBlock.java @@ -7,26 +7,25 @@ import com.minelittlepony.unicopia.ability.EarthPonyKickAbility.Buckable; import net.minecraft.block.*; import net.minecraft.item.ItemStack; import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.util.math.*; import net.minecraft.util.math.random.Random; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.*; public class FruitBlock extends Block implements Buckable { - public static final int DEFAULT_FRUIT_SIZE = 8; - public static final VoxelShape DEFAULT_SHAPE = createFruitShape(DEFAULT_FRUIT_SIZE); + public static final int DEFAULT_FRUIT_SIZE = 5; + public static final double DEFAULT_STEM_OFFSET = 2.6F; + public static final VoxelShape DEFAULT_SHAPE = createFruitShape(DEFAULT_STEM_OFFSET, DEFAULT_FRUIT_SIZE); private final Direction attachmentFace; private final Block stem; private final VoxelShape shape; - public static VoxelShape createFruitShape(int fruitSize) { - int min = (16 - fruitSize) / 2; - int max = 16 - min; - - return VoxelShapes.cuboid(min / 16D, (max - fruitSize) / 16D, min / 16D, max / 16D, 1, max / 16D); + public static VoxelShape createFruitShape(double stemOffset, double fruitSize) { + final double min = (16 - fruitSize) * 0.5; + final double max = 16 - min; + final double top = 16 - stemOffset; + return createCuboidShape(min, top - fruitSize, min, max, top, max); } public FruitBlock(Settings settings, Direction attachmentFace, Block stem, VoxelShape shape) { diff --git a/src/main/resources/assets/unicopia/models/block/fruit.json b/src/main/resources/assets/unicopia/models/block/fruit.json new file mode 100644 index 00000000..c2b9fd16 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/fruit.json @@ -0,0 +1,26 @@ +{ + "ambientocclusion": false, + "textures": { + "particle": "#cross" + }, + "elements": [ + { "from": [ 4.8, 8, 8 ], + "to": [ 11.2, 16, 8 ], + "rotation": { "origin": [ 8, 8, 8 ], "axis": "y", "angle": 45, "rescale": true }, + "shade": false, + "faces": { + "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#cross" }, + "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#cross" } + } + }, + { "from": [ 8, 8, 4.8 ], + "to": [ 8, 16, 11.2 ], + "rotation": { "origin": [ 8, 8, 8 ], "axis": "y", "angle": 45, "rescale": true }, + "shade": false, + "faces": { + "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#cross" }, + "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#cross" } + } + } + ] +} diff --git a/src/main/resources/assets/unicopia/models/block/green_apple.json b/src/main/resources/assets/unicopia/models/block/green_apple.json index 5c22c73d..b9e24b76 100644 --- a/src/main/resources/assets/unicopia/models/block/green_apple.json +++ b/src/main/resources/assets/unicopia/models/block/green_apple.json @@ -1,5 +1,5 @@ { - "parent": "minecraft:block/cross", + "parent": "unicopia:block/fruit", "textures": { "cross": "unicopia:item/green_apple" } diff --git a/src/main/resources/assets/unicopia/models/block/zap_apple.json b/src/main/resources/assets/unicopia/models/block/zap_apple.json index c5b0e7a4..4e0081c9 100644 --- a/src/main/resources/assets/unicopia/models/block/zap_apple.json +++ b/src/main/resources/assets/unicopia/models/block/zap_apple.json @@ -1,5 +1,5 @@ { - "parent": "minecraft:block/cross", + "parent": "unicopia:block/fruit", "textures": { "cross": "unicopia:item/zap_apple" } diff --git a/src/main/resources/assets/unicopia/models/block/zap_bulb.json b/src/main/resources/assets/unicopia/models/block/zap_bulb.json index 2ada77fe..97329f1f 100644 --- a/src/main/resources/assets/unicopia/models/block/zap_bulb.json +++ b/src/main/resources/assets/unicopia/models/block/zap_bulb.json @@ -1,5 +1,5 @@ { - "parent": "minecraft:block/cross", + "parent": "unicopia:block/fruit", "textures": { "cross": "unicopia:item/zap_bulb" }