This Rocks 1.1.0

Added Starfish
Added Underwater Generation
Changed Block Sounds
Changed SelectionBox sizes
New Seashell Loot Table
Update MidnightHats
This commit is contained in:
Motschen
2020-11-01 15:45:45 +01:00
parent 83279cc769
commit c6b4e00e0e
29 changed files with 568 additions and 41 deletions

View File

@@ -0,0 +1,90 @@
package eu.midnightdust.motschen.rocks.block;
import eu.midnightdust.motschen.rocks.RocksMain;
import eu.midnightdust.motschen.rocks.block.blockentity.StarfishBlockEntity;
import eu.midnightdust.motschen.rocks.blockstates.SeashellVariation;
import eu.midnightdust.motschen.rocks.blockstates.StarfishVariation;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
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.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
public class Starfish extends Block implements BlockEntityProvider, Waterloggable {
private static final VoxelShape SHAPE;
private static final EnumProperty<StarfishVariation> STARFISH_VARIATION = RocksMain.STARFISH_VARIATION;
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
public Starfish() {
super(FabricBlockSettings.copy(Blocks.POPPY).nonOpaque().sounds(BlockSoundGroup.CORAL));
this.setDefaultState(this.stateManager.getDefaultState().with(STARFISH_VARIATION, StarfishVariation.RED).with(WATERLOGGED, false));
}
@Override
public FluidState getFluidState(BlockState blockState_1) {
return blockState_1.get(WATERLOGGED) ? Fluids.WATER.getStill(true) : super.getFluidState(blockState_1);
}
@Override
public BlockEntity createBlockEntity(BlockView view) {
return new StarfishBlockEntity();
}
@Override
public BlockState getPlacementState(ItemPlacementContext itemPlacementContext) {
FluidState fluidState = itemPlacementContext.getWorld().getFluidState(itemPlacementContext.getBlockPos());
return super.getPlacementState(itemPlacementContext)
.with(STARFISH_VARIATION, StarfishVariation.RED).with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER);
}
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (player.isCreative()) {
if (state.get(STARFISH_VARIATION) == StarfishVariation.RED) {
world.setBlockState(pos, state.with(STARFISH_VARIATION, StarfishVariation.PINK));
}
if (state.get(STARFISH_VARIATION) == StarfishVariation.PINK) {
world.setBlockState(pos, state.with(STARFISH_VARIATION, StarfishVariation.ORANGE));
}
if (state.get(STARFISH_VARIATION) == StarfishVariation.ORANGE) {
world.setBlockState(pos, state.with(STARFISH_VARIATION, StarfishVariation.RED));
}
return ActionResult.SUCCESS;
}
else return ActionResult.FAIL;
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(STARFISH_VARIATION,WATERLOGGED);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) {
return SHAPE;
}
static {
VoxelShape shape = createCuboidShape(0, 0, 0, 16, 1, 16);
SHAPE = shape;
}
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return world.getBlockState(pos.down()).isSideSolidFullSquare(world,pos,Direction.UP);
}
}