Adjust model and hitbox sizes of fruit

This commit is contained in:
Sollace 2022-09-25 14:47:04 +02:00
parent 1cd3390b1e
commit b2e3008141
5 changed files with 38 additions and 13 deletions

View file

@ -7,26 +7,25 @@ import com.minelittlepony.unicopia.ability.EarthPonyKickAbility.Buckable;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.*;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.random.Random; import net.minecraft.util.math.random.Random;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.*; import net.minecraft.world.*;
public class FruitBlock extends Block implements Buckable { public class FruitBlock extends Block implements Buckable {
public static final int DEFAULT_FRUIT_SIZE = 8; public static final int DEFAULT_FRUIT_SIZE = 5;
public static final VoxelShape DEFAULT_SHAPE = createFruitShape(DEFAULT_FRUIT_SIZE); 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 Direction attachmentFace;
private final Block stem; private final Block stem;
private final VoxelShape shape; private final VoxelShape shape;
public static VoxelShape createFruitShape(int fruitSize) { public static VoxelShape createFruitShape(double stemOffset, double fruitSize) {
int min = (16 - fruitSize) / 2; final double min = (16 - fruitSize) * 0.5;
int max = 16 - min; final double max = 16 - min;
final double top = 16 - stemOffset;
return VoxelShapes.cuboid(min / 16D, (max - fruitSize) / 16D, min / 16D, max / 16D, 1, max / 16D); return createCuboidShape(min, top - fruitSize, min, max, top, max);
} }
public FruitBlock(Settings settings, Direction attachmentFace, Block stem, VoxelShape shape) { public FruitBlock(Settings settings, Direction attachmentFace, Block stem, VoxelShape shape) {

View file

@ -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" }
}
}
]
}

View file

@ -1,5 +1,5 @@
{ {
"parent": "minecraft:block/cross", "parent": "unicopia:block/fruit",
"textures": { "textures": {
"cross": "unicopia:item/green_apple" "cross": "unicopia:item/green_apple"
} }

View file

@ -1,5 +1,5 @@
{ {
"parent": "minecraft:block/cross", "parent": "unicopia:block/fruit",
"textures": { "textures": {
"cross": "unicopia:item/zap_apple" "cross": "unicopia:item/zap_apple"
} }

View file

@ -1,5 +1,5 @@
{ {
"parent": "minecraft:block/cross", "parent": "unicopia:block/fruit",
"textures": { "textures": {
"cross": "unicopia:item/zap_bulb" "cross": "unicopia:item/zap_bulb"
} }