Skip to content

Commit

Permalink
[~] Stone Fence shapes, moulding recipes/advancements
Browse files Browse the repository at this point in the history
  • Loading branch information
crispytwig committed Feb 28, 2024
1 parent bea38df commit df0b430
Show file tree
Hide file tree
Showing 17 changed files with 404 additions and 33 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ loader_version=0.14.24
mod_menu_version=7.2.2

# Mod Properties
mod_version=0.5b-fabric
mod_version=0.6b-fabric
maven_group=com.starfish_studios
archives_base_name=foundation

Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,47 @@
package com.starfish_studios.foundation.block;

import com.starfish_studios.foundation.registry.FoundationTags;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.RandomSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;

import java.util.Random;
import java.util.Map;

public class StoneFenceBlock extends FenceBlock {
private final VoxelShape[] occlusionByIndex;
public class StoneFenceBlock extends Block implements SimpleWaterloggedBlock {
public static final BooleanProperty NORTH = BlockStateProperties.NORTH;
public static final BooleanProperty EAST = BlockStateProperties.EAST;
public static final BooleanProperty SOUTH = BlockStateProperties.SOUTH;
public static final BooleanProperty WEST = BlockStateProperties.WEST;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
protected static final Map<Direction, BooleanProperty> PROPERTY_BY_DIRECTION =
PipeBlock.PROPERTY_BY_DIRECTION.entrySet().stream().filter((entry) -> entry.getKey().getAxis().isHorizontal()).collect(Util.toMap());
public static final BooleanProperty SIDE_FILL = BooleanProperty.create("side_fill");
public static final BooleanProperty PILLAR = BooleanProperty.create("pillar");


public VoxelShape PILLAR_AABB = Block.box(4.0D, 0.0D, 4.0D, 12.0D, 16.0D, 12.0D);
public VoxelShape NORTH_AABB = Block.box(4.0D, 0.0D, 0.0D, 12.0D, 16.0D, 4.0D);
public VoxelShape EAST_AABB = Block.box(12.0D, 0.0D, 4.0D, 16.0D, 16.0D, 12.0D);
public VoxelShape SOUTH_AABB = Block.box(4.0D, 0.0D, 12.0D, 12.0D, 16.0D, 16.0D);
public VoxelShape WEST_AABB = Block.box(0.0D, 0.0D, 4.0D, 4.0D, 16.0D, 12.0D);

public StoneFenceBlock(Properties properties) {
super(properties);
this.registerDefaultState((this.stateDefinition.any()
Expand All @@ -40,7 +50,15 @@ public StoneFenceBlock(Properties properties) {
.setValue(WATERLOGGED, false)
.setValue(SIDE_FILL, false)
.setValue(PILLAR, true));
this.occlusionByIndex = this.makeShapes(2.0F, 1.0F, 16.0F, 6.0F, 15.0F);
}

public VoxelShape getShape(BlockState state, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) {
VoxelShape shape = PILLAR_AABB;
if (state.getValue(NORTH)) shape = Shapes.or(shape, NORTH_AABB);
if (state.getValue(EAST)) shape = Shapes.or(shape, EAST_AABB);
if (state.getValue(SOUTH)) shape = Shapes.or(shape, SOUTH_AABB);
if (state.getValue(WEST)) shape = Shapes.or(shape, WEST_AABB);
return shape;
}

public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
Expand All @@ -49,7 +67,14 @@ public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource
}
}

@Override
public VoxelShape getVisualShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) {
return this.getShape(blockState, blockGetter, blockPos, collisionContext);
}

public boolean isPathfindable(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, PathComputationType pathComputationType) {
return false;
}

public boolean connectsTo(BlockState blockState, boolean bl, Direction direction) {
Block block = blockState.getBlock();
boolean bl2 = this.isSameFence(blockState);
Expand Down Expand Up @@ -97,6 +122,41 @@ public BlockState updateShape(BlockState blockState, Direction direction, BlockS
: super.updateShape(blockState, direction, blockState2, levelAccessor, blockPos, blockPos2);
}

public BlockState rotate(BlockState blockState, Rotation rotation) {
return switch (rotation) {
case CLOCKWISE_180 ->
blockState
.setValue(NORTH, blockState.getValue(SOUTH))
.setValue(EAST, blockState.getValue(WEST))
.setValue(SOUTH, blockState.getValue(NORTH))
.setValue(WEST, blockState.getValue(EAST));
case COUNTERCLOCKWISE_90 ->
blockState
.setValue(NORTH, blockState.getValue(EAST))
.setValue(EAST, blockState.getValue(SOUTH))
.setValue(SOUTH, blockState.getValue(WEST))
.setValue(WEST, blockState.getValue(NORTH));
case CLOCKWISE_90 ->
blockState
.setValue(NORTH, blockState.getValue(WEST))
.setValue(EAST, blockState.getValue(NORTH))
.setValue(SOUTH, blockState.getValue(EAST))
.setValue(WEST, blockState.getValue(SOUTH));
default -> blockState;
};
}

public BlockState mirror(BlockState blockState, Mirror mirror) {
switch (mirror) {
case LEFT_RIGHT:
return blockState.setValue(NORTH, blockState.getValue(SOUTH)).setValue(SOUTH, blockState.getValue(NORTH));
case FRONT_BACK:
return blockState.setValue(EAST, blockState.getValue(WEST)).setValue(WEST, blockState.getValue(EAST));
default:
return super.mirror(blockState, mirror);
}
}


@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateDefinition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class FoundationBlocks {



public static final Block STONE_URN = register("stone_urn", new UrnBlock(FabricBlockSettings.copy((Blocks.STONE)).noOcclusion().pushReaction(PushReaction.DESTROY)));
public static final Block BLACKSTONE_URN = register("blackstone_urn", new UrnBlock(FabricBlockSettings.copy((Blocks.BLACKSTONE)).noOcclusion().pushReaction(PushReaction.DESTROY)));
public static final Block DEEPSLATE_URN = register("deepslate_urn", new UrnBlock(FabricBlockSettings.copy((Blocks.DEEPSLATE_BRICKS)).noOcclusion().pushReaction(PushReaction.DESTROY)));
public static final Block NETHER_BRICK_URN = register("nether_brick_urn", new UrnBlock(FabricBlockSettings.copy((Blocks.NETHER_BRICKS)).noOcclusion().pushReaction(PushReaction.DESTROY)));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_block": {
"conditions": {
"items": [
{
"items": [
"minecraft:blackstone"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "foundation:blackstone_moulding"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_block",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"foundation:blackstone_moulding"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_block": {
"conditions": {
"items": [
{
"items": [
"minecraft:deepslate"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "foundation:deepslate_moulding"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_block",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"foundation:deepslate_moulding"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_block": {
"conditions": {
"items": [
{
"items": [
"minecraft:nether_bricks"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "foundation:nether_brick_moulding"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_block",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"foundation:nether_brick_moulding"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_block": {
"conditions": {
"items": [
{
"items": [
"minecraft:quartz_block"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "foundation:quartz_moulding"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_block",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"foundation:quartz_moulding"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_block": {
"conditions": {
"items": [
{
"items": [
"minecraft:red_sandstone"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "foundation:red_sandstone_moulding"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_block",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"foundation:red_sandstone_moulding"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_block": {
"conditions": {
"items": [
{
"items": [
"minecraft:sandstone"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "foundation:sandstone_moulding"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_block",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"foundation:sandstone_moulding"
]
}
}
20 changes: 0 additions & 20 deletions src/main/resources/data/foundation/loot_tables/blocks/urn.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"group": "foundation/mouldings",
"type": "minecraft:crafting_shaped",
"pattern": [
"# ",
"###",
"###"
],
"key": {
"#": {
"item": "minecraft:blackstone"
}
},
"result": {
"item": "foundation:blackstone_moulding",
"count": 8
}
}
Loading

0 comments on commit df0b430

Please sign in to comment.