Skip to content

Commit

Permalink
This Rocks 1.1.0
Browse files Browse the repository at this point in the history
Added Starfish
Added Underwater Generation
Changed Block Sounds
Changed SelectionBox sizes
New Seashell Loot Table
Update MidnightHats
  • Loading branch information
Motschen committed Nov 1, 2020
1 parent 83279cc commit c6b4e00
Show file tree
Hide file tree
Showing 29 changed files with 568 additions and 41 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ org.gradle.jvmargs=-Xmx2G
loader_version=0.9.1+build.205

# Mod Properties
mod_version = 1.0.0
mod_version = 1.1.0
maven_group = eu.midnightdust.motschen
archives_base_name = rocks

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.17.2+build.396-1.16
midnighthats_version=1.0.2
midnighthats_version=2.0.0
32 changes: 32 additions & 0 deletions src/main/java/eu/midnightdust/motschen/rocks/RocksClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package eu.midnightdust.motschen.rocks;

import eu.midnightdust.motschen.rocks.block.*;
import eu.midnightdust.motschen.rocks.block.blockentity.BlockEntityInit;
import eu.midnightdust.motschen.rocks.block.render.StarfishBlockEntityRenderer;
import eu.midnightdust.motschen.rocks.blockstates.RockVariation;
import eu.midnightdust.motschen.rocks.blockstates.SeashellVariation;
import eu.midnightdust.motschen.rocks.blockstates.StickVariation;
import eu.midnightdust.motschen.rocks.world.FeatureInjector;
import eu.midnightdust.motschen.rocks.world.MiscFeatures;
import eu.midnightdust.motschen.rocks.world.RockFeatures;
import eu.midnightdust.motschen.rocks.world.StickFeatures;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry;
import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

public class RocksClient implements ClientModInitializer {

@Override
public void onInitializeClient() {
BlockEntityRendererRegistry.INSTANCE.register(BlockEntityInit.STARFISH_BE, StarfishBlockEntityRenderer::new);
}
}
13 changes: 9 additions & 4 deletions src/main/java/eu/midnightdust/motschen/rocks/RocksMain.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package eu.midnightdust.motschen.rocks;

import eu.midnightdust.motschen.rocks.block.*;
import eu.midnightdust.motschen.rocks.block.blockentity.BlockEntityInit;
import eu.midnightdust.motschen.rocks.blockstates.RockVariation;
import eu.midnightdust.motschen.rocks.blockstates.SeashellVariation;
import eu.midnightdust.motschen.rocks.blockstates.StarfishVariation;
import eu.midnightdust.motschen.rocks.blockstates.StickVariation;
import eu.midnightdust.motschen.rocks.world.FeatureInjector;
import eu.midnightdust.motschen.rocks.world.MiscFeatures;
import eu.midnightdust.motschen.rocks.world.RockFeatures;
import eu.midnightdust.motschen.rocks.world.StickFeatures;
import eu.midnightdust.motschen.rocks.world.*;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.minecraft.block.Block;
Expand All @@ -25,6 +24,7 @@ public class RocksMain implements ModInitializer {
public static final EnumProperty<RockVariation> ROCK_VARIATION = EnumProperty.of("variation", RockVariation.class);
public static final EnumProperty<StickVariation> STICK_VARIATION = EnumProperty.of("variation", StickVariation.class);
public static final EnumProperty<SeashellVariation> SEASHELL_VARIATION = EnumProperty.of("variation", SeashellVariation.class);
public static final EnumProperty<StarfishVariation> STARFISH_VARIATION = EnumProperty.of("variation", StarfishVariation.class);

public static Block Rock = new Rock();
public static Block SandRock = new Rock();
Expand All @@ -40,6 +40,7 @@ public class RocksMain implements ModInitializer {

public static Block Pinecone = new Pinecone();
public static Block Seashell = new Seashell();
public static Block Starfish = new Starfish();

public static Item CobbleStoneSplitter = new Item(new Item.Settings().group(RocksMain.RocksGroup));
public static Item SandStoneSplitter = new Item(new Item.Settings().group(RocksMain.RocksGroup));
Expand Down Expand Up @@ -74,15 +75,19 @@ public void onInitialize() {
Registry.register(Registry.ITEM, new Identifier(MOD_ID,"pinecone"), new BlockItem(Pinecone, new Item.Settings().group(RocksMain.RocksGroup)));
Registry.register(Registry.BLOCK, new Identifier(MOD_ID,"seashell"), Seashell);
Registry.register(Registry.ITEM, new Identifier(MOD_ID,"seashell"), new BlockItem(Seashell, new Item.Settings().group(RocksMain.RocksGroup)));
Registry.register(Registry.BLOCK, new Identifier(MOD_ID,"starfish"), Starfish);
Registry.register(Registry.ITEM, new Identifier(MOD_ID,"starfish"), new BlockItem(Starfish, new Item.Settings().group(RocksMain.RocksGroup)));

Registry.register(Registry.ITEM, new Identifier(MOD_ID,"cobblestone_splitter"), CobbleStoneSplitter);
Registry.register(Registry.ITEM, new Identifier(MOD_ID,"sandstone_splitter"), SandStoneSplitter);
Registry.register(Registry.ITEM, new Identifier(MOD_ID,"red_sandstone_splitter"), RedSandStoneSplitter);
Registry.register(Registry.ITEM, new Identifier(MOD_ID,"end_stone_splitter"), EndStoneSplitter);

new FeatureRegistry();
RockFeatures.init();
StickFeatures.init();
MiscFeatures.init();
FeatureInjector.init();
BlockEntityInit.init();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Pinecone extends Block {
private static final VoxelShape SHAPE;

public Pinecone() {
super(FabricBlockSettings.copy(Blocks.POPPY).nonOpaque().sounds(BlockSoundGroup.STONE));
super(FabricBlockSettings.copy(Blocks.POPPY).nonOpaque().sounds(BlockSoundGroup.WOOD));
this.setDefaultState(this.stateManager.getDefaultState());
}

Expand Down
25 changes: 17 additions & 8 deletions src/main/java/eu/midnightdust/motschen/rocks/block/Seashell.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@

import eu.midnightdust.motschen.rocks.RocksMain;
import eu.midnightdust.motschen.rocks.blockstates.SeashellVariation;
import eu.midnightdust.motschen.rocks.blockstates.StarfishVariation;
import eu.midnightdust.motschen.rocks.blockstates.StickVariation;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.*;
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.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
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;
Expand All @@ -25,20 +27,27 @@
import net.minecraft.world.World;
import net.minecraft.world.WorldView;

public class Seashell extends Block {
public class Seashell extends Block implements Waterloggable {

private static final VoxelShape SHAPE;
private static final EnumProperty<SeashellVariation> SEASHELL_VARIATION = RocksMain.SEASHELL_VARIATION;
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;

public Seashell() {
super(FabricBlockSettings.copy(Blocks.POPPY).nonOpaque().sounds(BlockSoundGroup.STONE));
this.setDefaultState(this.stateManager.getDefaultState().with(SEASHELL_VARIATION, SeashellVariation.PINK));
this.setDefaultState(this.stateManager.getDefaultState().with(SEASHELL_VARIATION, SeashellVariation.PINK).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 BlockState getPlacementState(ItemPlacementContext itemPlacementContext) {
FluidState fluidState = itemPlacementContext.getWorld().getFluidState(itemPlacementContext.getBlockPos());
return super.getPlacementState(itemPlacementContext)
.with(SEASHELL_VARIATION, SeashellVariation.PINK);
.with(SEASHELL_VARIATION, SeashellVariation.PINK).with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER);
}

public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
Expand All @@ -59,7 +68,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt

@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(SEASHELL_VARIATION);
builder.add(SEASHELL_VARIATION, WATERLOGGED);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) {
Expand Down
90 changes: 90 additions & 0 deletions src/main/java/eu/midnightdust/motschen/rocks/block/Starfish.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
4 changes: 2 additions & 2 deletions src/main/java/eu/midnightdust/motschen/rocks/block/Stick.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Stick extends Block {
private static final EnumProperty<StickVariation> STICK_VARIATION = RocksMain.STICK_VARIATION;

public Stick() {
super(FabricBlockSettings.copy(Blocks.POPPY).nonOpaque().sounds(BlockSoundGroup.STONE));
super(FabricBlockSettings.copy(Blocks.POPPY).nonOpaque().sounds(BlockSoundGroup.WOOD));
this.setDefaultState(this.stateManager.getDefaultState().with(STICK_VARIATION, StickVariation.SMALL));
}

Expand Down Expand Up @@ -60,7 +60,7 @@ public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos
return SHAPE;
}
static {
VoxelShape shape = createCuboidShape(0, 0, 0, 16, 3, 16);
VoxelShape shape = createCuboidShape(0, 0, 0, 16, 1, 16);

SHAPE = shape;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package eu.midnightdust.motschen.rocks.block.blockentity;

import eu.midnightdust.motschen.rocks.RocksMain;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

public class BlockEntityInit {
public static BlockEntityType<StarfishBlockEntity> STARFISH_BE;

public static void init() {
STARFISH_BE = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(RocksMain.MOD_ID,"starfish_blockentity"), BlockEntityType.Builder.create(StarfishBlockEntity::new, RocksMain.Starfish).build(null));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package eu.midnightdust.motschen.rocks.block.blockentity;

import eu.midnightdust.motschen.rocks.RocksMain;
import eu.midnightdust.motschen.rocks.blockstates.StarfishVariation;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.Tickable;
import net.minecraft.util.math.BlockPos;

public class StarfishBlockEntity extends BlockEntity implements Tickable {
private String variation;

public StarfishBlockEntity() {
super(BlockEntityInit.STARFISH_BE);
}

@Override
public void tick() {
BlockPos pos = this.pos;
BlockState state = this.world.getBlockState(pos);

if (world != null && state.get(RocksMain.STARFISH_VARIATION) == StarfishVariation.RED) {
variation = String.valueOf(StarfishVariation.RED);
return;
}
else if (world != null && state.get(RocksMain.STARFISH_VARIATION) == StarfishVariation.PINK) {
variation = String.valueOf(StarfishVariation.PINK);
return;
}
else {
variation = String.valueOf(StarfishVariation.ORANGE);
return;
}
}
public String getVariation() {
return variation;
}
}

Loading

0 comments on commit c6b4e00

Please sign in to comment.