First release

Yay!
This commit is contained in:
Motschen
2020-10-29 13:47:16 +01:00
parent 4da8817481
commit 83279cc769
111 changed files with 3279 additions and 2 deletions

View File

@@ -0,0 +1,71 @@
package eu.midnightdust.motschen.rocks.block;
import eu.midnightdust.motschen.rocks.RocksMain;
import eu.midnightdust.motschen.rocks.blockstates.RockVariation;
import eu.midnightdust.motschen.rocks.blockstates.StickVariation;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.*;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty;
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 Stick extends Block {
private static final VoxelShape SHAPE;
private static final EnumProperty<StickVariation> STICK_VARIATION = RocksMain.STICK_VARIATION;
public Stick() {
super(FabricBlockSettings.copy(Blocks.POPPY).nonOpaque().sounds(BlockSoundGroup.STONE));
this.setDefaultState(this.stateManager.getDefaultState().with(STICK_VARIATION, StickVariation.SMALL));
}
@Override
public BlockState getPlacementState(ItemPlacementContext itemPlacementContext) {
return super.getPlacementState(itemPlacementContext)
.with(STICK_VARIATION, StickVariation.SMALL);
}
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (player.isCreative()) {
if (state.get(STICK_VARIATION) == StickVariation.SMALL) {
world.setBlockState(pos, state.with(STICK_VARIATION, StickVariation.MEDIUM));
}
if (state.get(STICK_VARIATION) == StickVariation.MEDIUM) {
world.setBlockState(pos, state.with(STICK_VARIATION, StickVariation.LARGE));
}
if (state.get(STICK_VARIATION) == StickVariation.LARGE) {
world.setBlockState(pos, state.with(STICK_VARIATION, StickVariation.SMALL));
}
return ActionResult.SUCCESS;
}
else return ActionResult.FAIL;
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(STICK_VARIATION);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) {
return SHAPE;
}
static {
VoxelShape shape = createCuboidShape(0, 0, 0, 16, 3, 16);
SHAPE = shape;
}
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return world.getBlockState(pos.down()).isSideSolidFullSquare(world,pos,Direction.UP);
}
}