You can now compact clouds with a shovel

This commit is contained in:
Sollace 2023-10-19 21:37:19 +01:00
parent a72ac2f080
commit b27cbf814b
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
13 changed files with 539 additions and 3 deletions

View file

@ -7,7 +7,8 @@ import java.util.List;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.block.cloud.CloudPillarBlock;
import com.minelittlepony.unicopia.block.cloud.CloudSlabBlock;
import com.minelittlepony.unicopia.block.cloud.PoreousCloudBlock;
import com.minelittlepony.unicopia.block.cloud.CompactedCloudBlock;
import com.minelittlepony.unicopia.block.cloud.NaturalCloudBlock;
import com.minelittlepony.unicopia.block.cloud.CloudBlock;
import com.minelittlepony.unicopia.block.cloud.SoggyCloudBlock;
import com.minelittlepony.unicopia.block.cloud.SoggyCloudSlabBlock;
@ -132,8 +133,9 @@ public interface UBlocks {
Block MYSTERIOUS_EGG = register("mysterious_egg", new PileBlock(Settings.copy(Blocks.SLIME_BLOCK), PileBlock.MYSTERIOUS_EGG_SHAPES), ItemGroups.NATURAL);
Block SLIME_PUSTULE = register("slime_pustule", new SlimePustuleBlock(Settings.copy(Blocks.SLIME_BLOCK)), ItemGroups.NATURAL);
Block CLOUD = register("cloud", new PoreousCloudBlock(Settings.create().mapColor(MapColor.OFF_WHITE).hardness(0.3F).resistance(0).sounds(BlockSoundGroup.WOOL), true, () -> UBlocks.SOGGY_CLOUD));
Block CLOUD = register("cloud", new NaturalCloudBlock(Settings.create().mapColor(MapColor.OFF_WHITE).hardness(0.3F).resistance(0).sounds(BlockSoundGroup.WOOL), true, () -> UBlocks.SOGGY_CLOUD));
Block CLOUD_SLAB = register("cloud_slab", new CloudSlabBlock(Settings.copy(CLOUD), true, () -> UBlocks.SOGGY_CLOUD_SLAB));
Block COMPACTED_CLOUD = register("compacted_cloud", new CompactedCloudBlock(Settings.copy(CLOUD)));
Block UNSTABLE_CLOUD = register("unstable_cloud", new UnstableCloudBlock(Settings.copy(CLOUD)));
SoggyCloudBlock SOGGY_CLOUD = register("soggy_cloud", new SoggyCloudBlock(Settings.copy(CLOUD), () -> UBlocks.CLOUD));
SoggyCloudSlabBlock SOGGY_CLOUD_SLAB = register("soggy_cloud_slab", new SoggyCloudSlabBlock(Settings.copy(CLOUD), () -> UBlocks.CLOUD_SLAB));

View file

@ -0,0 +1,79 @@
package com.minelittlepony.unicopia.block.cloud;
import java.util.Collection;
import java.util.Map;
import java.util.function.Function;
import com.minelittlepony.unicopia.EquineContext;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ConnectingBlock;
import net.minecraft.block.ShapeContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.tag.ItemTags;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Property;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Util;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class CompactedCloudBlock extends CloudBlock {
static final Map<Direction, BooleanProperty> FACING_PROPERTIES = ConnectingBlock.FACING_PROPERTIES;
static final Collection<BooleanProperty> PROPERTIES = FACING_PROPERTIES.values();
static final Function<BlockState, VoxelShape> SHAPE_CACHE = Util.memoize(state -> {
return Block.createCuboidShape(
state.get(ConnectingBlock.WEST) ? 0 : 2,
state.get(ConnectingBlock.DOWN) ? 0 : 2,
state.get(ConnectingBlock.NORTH) ? 0 : 2,
state.get(ConnectingBlock.EAST) ? 16 : 14,
state.get(ConnectingBlock.UP) ? 16 : 14,
state.get(ConnectingBlock.SOUTH) ? 16 : 14
);
});
public CompactedCloudBlock(Settings settings) {
super(settings, true);
PROPERTIES.forEach(property -> {
setDefaultState(getDefaultState().with(property, true));
});
}
@Override
protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, EquineContext equineContext) {
return SHAPE_CACHE.apply(state);
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(PROPERTIES.toArray(Property[]::new));
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
ItemStack stack = player.getStackInHand(hand);
if (stack.isIn(ItemTags.SHOVELS)) {
BooleanProperty property = FACING_PROPERTIES.get(hit.getSide());
if (state.get(property)) {
world.setBlockState(pos, state.with(property, false));
stack.damage(1, player, p -> p.sendToolBreakStatus(hand));
world.playSound(null, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS);
return ActionResult.SUCCESS;
}
}
return ActionResult.PASS;
}
}

View file

@ -0,0 +1,42 @@
package com.minelittlepony.unicopia.block.cloud;
import java.util.function.Supplier;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.block.UBlocks;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.tag.ItemTags;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class NaturalCloudBlock extends PoreousCloudBlock {
public NaturalCloudBlock(Settings settings, boolean meltable, @Nullable Supplier<Soakable> soggyBlock) {
super(settings.nonOpaque(), meltable, soggyBlock);
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
ItemStack stack = player.getStackInHand(hand);
if (stack.isIn(ItemTags.SHOVELS)) {
BooleanProperty property = CompactedCloudBlock.FACING_PROPERTIES.get(hit.getSide());
world.setBlockState(pos, UBlocks.COMPACTED_CLOUD.getDefaultState().with(property, false));
stack.damage(1, player, p -> p.sendToolBreakStatus(hand));
world.playSound(null, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS);
return ActionResult.SUCCESS;
}
return ActionResult.PASS;
}
}

View file

@ -176,7 +176,8 @@ public interface URenderers {
UBlocks.MYSTERIOUS_EGG, UBlocks.SLIME_PUSTULE,
UBlocks.CLOUD, UBlocks.DENSE_CLOUD, UBlocks.CLOUD_PILLAR,
UBlocks.CLOUD_SLAB, UBlocks.DENSE_CLOUD_SLAB,
UBlocks.SOGGY_CLOUD, UBlocks.SOGGY_CLOUD_SLAB
UBlocks.SOGGY_CLOUD, UBlocks.SOGGY_CLOUD_SLAB,
UBlocks.COMPACTED_CLOUD
);
// for lava boats
BlockRenderLayerMap.INSTANCE.putFluids(RenderLayer.getTranslucent(), Fluids.LAVA, Fluids.FLOWING_LAVA);

View file

@ -0,0 +1,268 @@
{
"multipart": [
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_full", "uvlock": true },
"when": { "down": true, "north": true, "east": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_x", "uvlock": true },
"when": { "down": true, "north": true, "east": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_y", "uvlock": true },
"when": { "down": false, "north": true, "east": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_z", "uvlock": true },
"when": { "down": true, "north": false, "east": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xz", "uvlock": true },
"when": { "down": true, "north": false, "east": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xy", "uvlock": true },
"when": { "down": false, "north": true, "east": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_yz", "uvlock": true },
"when": { "down": false, "north": false, "east": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xyz", "uvlock": true },
"when": { "down": false, "north": false, "east": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_full", "uvlock": true, "y": 90 },
"when": { "down": true, "south": true, "east": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_z", "uvlock": true, "y": 90 },
"when": { "down": true, "south": true, "east": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_y", "uvlock": true, "y": 90 },
"when": { "down": false, "south": true, "east": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_x", "uvlock": true, "y": 90 },
"when": { "down": true, "south": false, "east": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xz", "uvlock": true, "y": 90 },
"when": { "down": true, "south": false, "east": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_yz", "uvlock": true, "y": 90 },
"when": { "down": false, "south": true, "east": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xy", "uvlock": true, "y": 90 },
"when": { "down": false, "south": false, "east": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xyz", "uvlock": true, "y": 90 },
"when": { "down": false, "south": false, "east": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_full", "uvlock": true, "y": 180 },
"when": { "down": true, "south": true, "west": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_x", "uvlock": true, "y": 180 },
"when": { "down": true, "south": true, "west": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_y", "uvlock": true, "y": 180 },
"when": { "down": false, "south": true, "west": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_z", "uvlock": true, "y": 180 },
"when": { "down": true, "south": false, "west": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xz", "uvlock": true, "y": 180 },
"when": { "down": true, "south": false, "west": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xy", "uvlock": true, "y": 180 },
"when": { "down": false, "south": true, "west": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_yz", "uvlock": true, "y": 180 },
"when": { "down": false, "south": false, "west": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xyz", "uvlock": true, "y": 180 },
"when": { "down": false, "south": false, "west": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_full", "uvlock": true, "y": 270 },
"when": { "down": true, "north": true, "west": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_z", "uvlock": true, "y": 270 },
"when": { "down": true, "north": true, "west": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_y", "uvlock": true, "y": 270 },
"when": { "down": false, "north": true, "west": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_x", "uvlock": true, "y": 270 },
"when": { "down": true, "north": false, "west": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xz", "uvlock": true, "y": 270 },
"when": { "down": true, "north": false, "west": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_yz", "uvlock": true, "y": 270 },
"when": { "down": false, "north": true, "west": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xy", "uvlock": true, "y": 270 },
"when": { "down": false, "north": false, "west": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xyz", "uvlock": true, "y": 270 },
"when": { "down": false, "north": false, "west": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_full", "uvlock": true, "x": 180 },
"when": { "up": true, "south": true, "east": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_x", "uvlock": true, "x": 180 },
"when": { "up": true, "south": true, "east": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_y", "uvlock": true, "x": 180 },
"when": { "up": false, "south": true, "east": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_z", "uvlock": true, "x": 180 },
"when": { "up": true, "south": false, "east": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xz", "uvlock": true, "x": 180 },
"when": { "up": true, "south": false, "east": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xy", "uvlock": true, "x": 180 },
"when": { "up": false, "south": true, "east": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_yz", "uvlock": true, "x": 180 },
"when": { "up": false, "south": false, "east": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xyz", "uvlock": true, "x": 180 },
"when": { "up": false, "south": false, "east": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_full", "uvlock": true, "x": 180, "y": 90 },
"when": { "up": true, "south": true, "west": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_z", "uvlock": true, "x": 180, "y": 90 },
"when": { "up": true, "south": true, "west": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_y", "uvlock": true, "x": 180, "y": 90 },
"when": { "up": false, "south": true, "west": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_x", "uvlock": true, "x": 180, "y": 90 },
"when": { "up": true, "south": false, "west": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xz", "uvlock": true, "x": 180, "y": 90 },
"when": { "up": true, "south": false, "west": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_yz", "uvlock": true, "x": 180, "y": 90 },
"when": { "up": false, "south": true, "west": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xy", "uvlock": true, "x": 180, "y": 90 },
"when": { "up": false, "south": false, "west": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xyz", "uvlock": true, "x": 180, "y": 90 },
"when": { "up": false, "south": false, "west": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_full", "uvlock": true, "x": 180, "y": 180 },
"when": { "up": true, "north": true, "west": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_x", "uvlock": true, "x": 180, "y": 180 },
"when": { "up": true, "north": true, "west": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_y", "uvlock": true, "x": 180, "y": 180 },
"when": { "up": false, "north": true, "west": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_z", "uvlock": true, "x": 180, "y": 180 },
"when": { "up": true, "north": false, "west": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xz", "uvlock": true, "x": 180, "y": 180 },
"when": { "up": true, "north": false, "west": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xy", "uvlock": true, "x": 180, "y": 180 },
"when": { "up": false, "north": true, "west": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_yz", "uvlock": true, "x": 180, "y": 180 },
"when": { "up": false, "north": false, "west": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xyz", "uvlock": true, "x": 180, "y": 180 },
"when": { "up": false, "north": false, "west": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_full", "uvlock": true, "x": 180, "y": 270 },
"when": { "up": true, "north": true, "east": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_z", "uvlock": true, "x": 180, "y": 270 },
"when": { "up": true, "north": true, "east": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_y", "uvlock": true, "x": 180, "y": 270 },
"when": { "up": false, "north": true, "east": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_x", "uvlock": true, "x": 180, "y": 270 },
"when": { "up": true, "north": false, "east": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xz", "uvlock": true, "x": 180, "y": 270 },
"when": { "up": true, "north": false, "east": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_yz", "uvlock": true, "x": 180, "y": 270 },
"when": { "up": false, "north": true, "east": false }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xy", "uvlock": true, "x": 180, "y": 270 },
"when": { "up": false, "north": false, "east": true }
},
{
"apply": { "model": "unicopia:block/flattened_cloud_corner_xyz", "uvlock": true, "x": 180, "y": 270 },
"when": { "up": false, "north": false, "east": false }
}
]
}

View file

@ -0,0 +1,18 @@
{
"textures": {
"0": "unicopia:block/cloud",
"particle": "unicopia:block/cloud"
},
"elements": [
{
"from": [8, 0, 0],
"to": [16, 8, 8],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [0, 0, 8, 8], "texture": "#0"},
"east": {"uv": [0, 0, 8, 8], "texture": "#0"},
"down": {"uv": [0, 0, 8, 8], "texture": "#0"}
}
}
]
}

View file

@ -0,0 +1,18 @@
{
"textures": {
"0": "unicopia:block/cloud",
"particle": "unicopia:block/cloud"
},
"elements": [
{
"from": [8, 0, 0],
"to": [14, 8, 8],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [0, 0, 6, 8], "texture": "#0"},
"east": {"uv": [0, 0, 8, 8], "texture": "#0"},
"down": {"uv": [0, 0, 6, 8], "texture": "#0"}
}
}
]
}

View file

@ -0,0 +1,18 @@
{
"textures": {
"0": "unicopia:block/cloud",
"particle": "unicopia:block/cloud"
},
"elements": [
{
"from": [8, 2, 0],
"to": [14, 8, 8],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [0, 0, 6, 6], "texture": "#0"},
"east": {"uv": [0, 0, 8, 6], "texture": "#0"},
"down": {"uv": [0, 0, 6, 8], "texture": "#0"}
}
}
]
}

View file

@ -0,0 +1,18 @@
{
"textures": {
"0": "unicopia:block/cloud",
"particle": "unicopia:block/cloud"
},
"elements": [
{
"from": [8, 2, 2],
"to": [14, 8, 8],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [0, 0, 6, 6], "texture": "#0"},
"east": {"uv": [0, 0, 6, 6], "texture": "#0"},
"down": {"uv": [0, 0, 6, 6], "texture": "#0"}
}
}
]
}

View file

@ -0,0 +1,18 @@
{
"textures": {
"0": "unicopia:block/cloud",
"particle": "unicopia:block/cloud"
},
"elements": [
{
"from": [8, 0, 2],
"to": [14, 8, 8],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [0, 0, 6, 8], "texture": "#0"},
"east": {"uv": [0, 0, 6, 8], "texture": "#0"},
"down": {"uv": [0, 0, 6, 6], "texture": "#0"}
}
}
]
}

View file

@ -0,0 +1,18 @@
{
"textures": {
"0": "unicopia:block/cloud",
"particle": "unicopia:block/cloud"
},
"elements": [
{
"from": [8, 2, 0],
"to": [16, 8, 8],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [0, 0, 8, 6], "texture": "#0"},
"east": {"uv": [0, 0, 8, 6], "texture": "#0"},
"down": {"uv": [0, 0, 8, 8], "texture": "#0"}
}
}
]
}

View file

@ -0,0 +1,18 @@
{
"textures": {
"0": "unicopia:block/cloud",
"particle": "unicopia:block/cloud"
},
"elements": [
{
"from": [8, 2, 2],
"to": [16, 8, 8],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [0, 0, 8, 6], "texture": "#0"},
"east": {"uv": [0, 0, 6, 6], "texture": "#0"},
"down": {"uv": [0, 0, 8, 6], "texture": "#0"}
}
}
]
}

View file

@ -0,0 +1,18 @@
{
"textures": {
"0": "unicopia:block/cloud",
"particle": "unicopia:block/cloud"
},
"elements": [
{
"from": [8, 0, 2],
"to": [16, 8, 8],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [0, 0, 8, 8], "texture": "#0"},
"east": {"uv": [0, 0, 6, 8], "texture": "#0"},
"down": {"uv": [0, 0, 8, 6], "texture": "#0"}
}
}
]
}