Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ Added new Decoration Table block #549

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.daemon=false

mod_id=sophisticatedstorage
mod_group_id=sophisticatedstorage
mod_version=0.10.50
mod_version=0.11.0
sonar_project_key=sophisticatedstorage:SophisticatedStorage
github_package_url=https://maven.pkg.github.com/P3pp3rF1y/SophisticatedStorage

Expand All @@ -30,6 +30,6 @@ jade_cf_file_id=4614153
chipped_cf_file_id=5077656
resourcefullib_cf_file_id=5070629
athena_cf_file_id=4764357
sc_version=[1.20.1-0.7.3,1.20.4)
sc_version=[1.20.1-0.7.12,1.20.4)
sb_version=[1.20.1-3.20.5,1.20.4)
parchment_version=2023.09.03-1.20.1
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"sophisticatedstorage:iron_chest",
"sophisticatedstorage:gold_chest",
"sophisticatedstorage:diamond_chest",
"sophisticatedstorage:netherite_chest"
"sophisticatedstorage:netherite_chest",
"sophisticatedstorage:decoration_table"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_the_recipe": {
"conditions": {
"recipe": "sophisticatedstorage:decoration_table"
},
"trigger": "minecraft:recipe_unlocked"
},
"has_upgrade_base": {
"conditions": {
"items": [
{
"items": [
"sophisticatedstorage:upgrade_base"
]
}
]
},
"trigger": "minecraft:inventory_changed"
}
},
"requirements": [
[
"has_upgrade_base",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"sophisticatedstorage:decoration_table"
]
},
"sends_telemetry_event": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "sophisticatedstorage:decoration_table"
}
],
"name": "main",
"rolls": 1.0
}
],
"random_sequence": "sophisticatedstorage:blocks/decoration_table"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"type": "minecraft:crafting_shaped",
"category": "misc",
"key": {
"B": {
"item": "sophisticatedstorage:upgrade_base"
},
"L": {
"tag": "minecraft:logs"
},
"P": {
"tag": "minecraft:planks"
}
},
"pattern": [
"LLL",
"PBP",
"P P"
],
"result": {
"item": "sophisticatedstorage:decoration_table"
},
"show_notification": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package net.p3pp3rf1y.sophisticatedstorage.block;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.SimpleMenuProvider;
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.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.DirectionProperty;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.network.NetworkHooks;
import net.p3pp3rf1y.sophisticatedcore.util.BlockBase;
import net.p3pp3rf1y.sophisticatedcore.util.WorldHelper;
import net.p3pp3rf1y.sophisticatedstorage.common.gui.DecorationTableMenu;

import javax.annotation.Nullable;

public class DecorationTableBlock extends BlockBase implements EntityBlock {
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
protected static final VoxelShape SHAPE = Shapes.or(
Block.box(0, 12, 0, 16, 16, 16),
Block.box(1, 8, 1, 15, 12, 15),
Block.box(1, 0, 1, 4, 8, 4),
Block.box(12, 0, 1, 15, 8, 4),
Block.box(1, 0, 12, 4, 8, 15),
Block.box(12, 0, 12, 15, 8, 15)
);

public DecorationTableBlock() {
super(Properties.of().mapColor(MapColor.WOOD).strength(2.5F, 2.5F).sound(SoundType.WOOD));
registerDefaultState(stateDefinition.any().setValue(FACING, Direction.NORTH));
}

@Override
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
return SHAPE;
}

@Nullable
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite());
}

@SuppressWarnings("deprecation")
@Override
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (level.isClientSide) {
return InteractionResult.SUCCESS;
}

NetworkHooks.openScreen((ServerPlayer) player, new SimpleMenuProvider((w, p, pl) -> new DecorationTableMenu(w, pl, pos), getName()), pos);

return InteractionResult.CONSUME;
}

@Override
public boolean onDestroyedByPlayer(BlockState state, Level level, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) {
//TODO drop contents either here or in loot table
return super.onDestroyedByPlayer(state, level, pos, player, willHarvest, fluid);
}

@Nullable
@Override
public DecorationTableBlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new DecorationTableBlockEntity(pos, state);
}

@SuppressWarnings("deprecation")
@Override
public BlockState mirror(BlockState state, Mirror mirror) {
return state.rotate(mirror.getRotation(state.getValue(FACING)));
}

@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(FACING);
}

@Override
public boolean isPathfindable(BlockState pState, BlockGetter pLevel, BlockPos pPos, PathComputationType pType) {
return false;
}
}
Loading
Loading