-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Starfish Added Underwater Generation Changed Block Sounds Changed SelectionBox sizes New Seashell Loot Table Update MidnightHats
- Loading branch information
Showing
29 changed files
with
568 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/eu/midnightdust/motschen/rocks/RocksClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/main/java/eu/midnightdust/motschen/rocks/block/Starfish.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/eu/midnightdust/motschen/rocks/block/blockentity/BlockEntityInit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/eu/midnightdust/motschen/rocks/block/blockentity/StarfishBlockEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
Oops, something went wrong.