Skip to content

Commit

Permalink
1.1.0 regular blocks + init moisture detector
Browse files Browse the repository at this point in the history
  • Loading branch information
lumiscosity committed Jul 26, 2024
1 parent 4d76935 commit 8bbebfc
Show file tree
Hide file tree
Showing 20 changed files with 178 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/client/java/com/lumiscosity/rounded/RoundedClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ public class RoundedClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
BlockRenderLayerMap.INSTANCE.putBlock(RegisterBlocks.LUSTERSHROOM_PLANT, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(RegisterBlocks.DEAD_BLADDERWRACK, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(RegisterBlocks.BLADDERWRACK, RenderLayer.getCutout());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "rounded:block/dead_bladderwrack_block"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"model": "rounded:block/smooth_prismarine_slab"
},
"type=double": {
"model": "rounded:block/smooth_prismarine"
"model": "rounded:block/smooth_prismarine_slab_double"
},
"type=top": {
"model": "rounded:block/smooth_prismarine_slab_top"
Expand Down
4 changes: 4 additions & 0 deletions src/client/resources/assets/rounded/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
"block.rounded.prismarine_lantern": "Prismarine Lantern",
"block.rounded.dead_bladderwrack": "Dead Bladderwrack",
"block.rounded.bladderwrack": "Bladderwrack",
"block.rounded.dead_bladderwrack_block": "Dead Bladderwrack Block",
"block.rounded.bladderwrack_block": "Bladderwrack Block",
"block.rounded.moisture_detector": "Moisture Detector",

"subtitles.rounded.block.trough_fill": "Trough filled",
"subtitles.rounded.block.trough_consume": "Trough consumed",
"subtitles.rounded.block.trough_rustle": "Feed rustles",

"tag.worldgen.biome.rounded.has_lustershrooms": "Has lustershrooms",
"tag.worldgen.biome.rounded.has_more_lustershrooms": "Has more lustershrooms",
"tag.worldgen.biome.rounded.has_smooth_basalt_sea_rocks": "Has Smooth Basalt sea rocks",
Expand All @@ -37,6 +40,7 @@
"tag.item.c.grain": "Grain",
"tag.item.c.mushrooms": "Mushrooms",
"tag.item.c.mushroom_caps": "Mushroom Caps",

"block.rounded.compat.treated_hevea_brasiliensis_planks": "Treated Hevea Brasiliensis Planks",
"block.rounded.compat.betterend.treated_dragon_tree_planks": "Treated Dragon Tree Planks",
"block.rounded.compat.betterend.treated_end_lotus_planks": "Treated End Lotus Planks",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "rounded:block/dead_bladderwrack_block"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "rounded:block/dead_bladderwrack_block"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"animation": {
"frametime": 8
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/main/java/com/lumiscosity/rounded/RegisterMisc.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.lumiscosity.rounded;

import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
import net.minecraft.loot.LootPool;
import net.minecraft.loot.LootTables;
import net.minecraft.loot.entry.ItemEntry;
Expand All @@ -9,6 +10,7 @@

public class RegisterMisc {
public static void initMisc() {
CompostingChanceRegistry.INSTANCE.add(BLADDERWRACK_ITEM, 0.3f);
LootTableEvents.MODIFY.register((key, tableBuilder, source) -> {
if (LootTables.FISHING_JUNK_GAMEPLAY.equals(key)) {
LootPool.Builder poolBuilder = LootPool.builder().with(ItemEntry.builder(BLADDERWRACK_ITEM).weight(10));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package com.lumiscosity.rounded.blocks;

import com.mojang.serialization.MapCodec;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.fluid.FluidState;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.IntProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

import static com.lumiscosity.rounded.blocks.RegisterBlocks.MOISTURE_DETECTOR_BE;

public class MoistureDetectorBlock extends BlockWithEntity {
public static final MapCodec<MoistureDetectorBlock> CODEC = createCodec(MoistureDetectorBlock::new);
public static final IntProperty POWER = Properties.POWER;

@Override
public MapCodec<MoistureDetectorBlock> getCodec() {
return CODEC;
}

public MoistureDetectorBlock(AbstractBlock.Settings settings) {
super(settings);
this.setDefaultState(this.stateManager.getDefaultState().with(POWER, 0));
}

@Override
protected int getWeakRedstonePower(BlockState state, BlockView world, BlockPos pos, Direction direction) {
return state.get(POWER);
}

public static void getWaterLevel(BlockState state, World world, BlockPos pos, FluidState water) {
int i = water.getLevel() * 2;
i = MathHelper.clamp(i, 0, 15);
if (state.get(POWER) != i) {
world.setBlockState(pos, state.with(POWER, i), Block.NOTIFY_ALL);
}
}

public static void getRainLevel(BlockState state, World world, BlockPos pos) {
int i = world.isRaining() ? world.isThundering() ? 15 : 7 : 0;
if (state.get(POWER) != i) {
world.setBlockState(pos, state.with(POWER, i), Block.NOTIFY_ALL);
}
}

@Override
protected boolean emitsRedstonePower(BlockState state) {
return true;
}

public static class MoistureDetectorBlockEntity extends BlockEntity {
public MoistureDetectorBlockEntity(BlockPos pos, BlockState state) {
super(MOISTURE_DETECTOR_BE, pos, state);
}
}

@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new MoistureDetectorBlockEntity(pos, state);
}

@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return !world.isClient ? validateTicker(type, MOISTURE_DETECTOR_BE, MoistureDetectorBlock::tick) : null;
}

private static void tick(World world, BlockPos pos, BlockState state, MoistureDetectorBlockEntity blockEntity) {
if (world.getTime() % 2L == 0L) {
BlockPos check_pos = pos.up();
if (world.getBlockState(check_pos).isOf(Blocks.WATER)) {
getWaterLevel(state, world, pos, world.getFluidState(check_pos));
} else if (world.getBlockState(check_pos).contains(Properties.WATERLOGGED) ? world.getBlockState(check_pos).get(Properties.WATERLOGGED) : false) {
if (state.get(POWER) != 15) {
world.setBlockState(pos, state.with(POWER, 15), Block.NOTIFY_ALL);
}
} else if (world.hasRain(pos)) {
getRainLevel(state, world, pos);
}
}
}

@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(POWER);
}
}
47 changes: 43 additions & 4 deletions src/main/java/com/lumiscosity/rounded/blocks/RegisterBlocks.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.lumiscosity.rounded.blocks;

import com.mojang.datafixers.types.Type;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
import net.fabricmc.fabric.api.registry.LandPathNodeTypesRegistry;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.block.entity.JukeboxBlockEntity;
import net.minecraft.block.enums.NoteBlockInstrument;
import net.minecraft.block.piston.PistonBehavior;
import net.minecraft.datafixer.TypeReferences;
import net.minecraft.entity.ai.pathing.PathNodeType;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
Expand All @@ -16,7 +20,9 @@
import net.minecraft.registry.RegistryKeys;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;

import static com.lumiscosity.rounded.Rounded.LOGGER;
import static com.lumiscosity.rounded.Rounded.MOD_ID;

public class RegisterBlocks {
Expand Down Expand Up @@ -168,10 +174,30 @@ public class RegisterBlocks {
.sounds(BlockSoundGroup.WET_GRASS)
.pistonBehavior(PistonBehavior.DESTROY)
);
public static final Block BLADDERWRACK_BLOCK = new Block(AbstractBlock.Settings.create().mapColor(MapColor.GREEN).strength(0.5F, 2.5F).sounds(BlockSoundGroup.GRASS));
public static final Block DEAD_BLADDERWRACK_BLOCK = new Block(AbstractBlock.Settings.create()
.mapColor(MapColor.GRAY)
.solid()
.instrument(NoteBlockInstrument.BASEDRUM)
.requiresTool()
.strength(1.5F, 6.0F)
);
public static final Block BLADDERWRACK_BLOCK = new CoralBlockBlock(DEAD_BLADDERWRACK_BLOCK, AbstractBlock.Settings.create()
.mapColor(MapColor.TERRACOTTA_BROWN)
.instrument(NoteBlockInstrument.BASEDRUM)
.requiresTool()
.strength(1.5F, 6.0F)
.sounds(BlockSoundGroup.CORAL));
public static final BlockItem DEAD_BLADDERWRACK_ITEM = new BlockItem(DEAD_BLADDERWRACK, new Item.Settings());
public static final BlockItem BLADDERWRACK_ITEM = new BlockItem(BLADDERWRACK, new Item.Settings());
public static final BlockItem BLADDERWRACK_BLOCK_ITEM = new BlockItem(BLADDERWRACK_BLOCK, new Item.Settings());
public static final BlockItem DEAD_BLADDERWRACK_BLOCK_ITEM = new BlockItem(DEAD_BLADDERWRACK_BLOCK, new Item.Settings());

// Moisture Detector
public static final Block MOISTURE_DETECTOR = new MoistureDetectorBlock(
AbstractBlock.Settings.create().mapColor(MapColor.DIAMOND_BLUE).instrument(NoteBlockInstrument.BASEDRUM).requiresTool().strength(1.5F, 6.0F)
);
public static final BlockItem MOISTURE_DETECTOR_ITEM = new BlockItem(MOISTURE_DETECTOR, new Item.Settings());
public static final BlockEntityType<MoistureDetectorBlock.MoistureDetectorBlockEntity> MOISTURE_DETECTOR_BE = register_be("moisture_detector",BlockEntityType.Builder.create(MoistureDetectorBlock.MoistureDetectorBlockEntity::new, MOISTURE_DETECTOR));



Expand Down Expand Up @@ -227,6 +253,7 @@ public static void initBlocks() {

register_block("dead_bladderwrack", DEAD_BLADDERWRACK, DEAD_BLADDERWRACK_ITEM);
register_block("bladderwrack", BLADDERWRACK, BLADDERWRACK_ITEM);
register_block("dead_bladderwrack_block", DEAD_BLADDERWRACK_BLOCK, DEAD_BLADDERWRACK_BLOCK_ITEM);
register_block("bladderwrack_block", BLADDERWRACK_BLOCK, BLADDERWRACK_BLOCK_ITEM);
ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(content -> {
content.addAfter(Registries.BLOCK.get(Identifier.of("minecraft", "dead_horn_coral_fan")), DEAD_BLADDERWRACK_ITEM);
Expand All @@ -235,9 +262,16 @@ public static void initBlocks() {
content.addAfter(Registries.BLOCK.get(Identifier.of("minecraft", "horn_coral_fan")), BLADDERWRACK_ITEM);
});
ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(content -> {
content.addAfter(Registries.BLOCK.get(Identifier.of("minecraft", "dried_kelp_block")), BLADDERWRACK_BLOCK_ITEM);
content.addAfter(Registries.BLOCK.get(Identifier.of("minecraft", "dead_horn_coral_block")), DEAD_BLADDERWRACK_BLOCK_ITEM);
});
ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(content -> {
content.addAfter(Registries.BLOCK.get(Identifier.of("minecraft", "horn_coral_block")), BLADDERWRACK_BLOCK_ITEM);
});

register_block("moisture_detector", MOISTURE_DETECTOR, MOISTURE_DETECTOR_ITEM);
ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(content -> {
content.addAfter(Registries.BLOCK.get(Identifier.of("minecraft", "daylight_detector")), BLADDERWRACK_BLOCK_ITEM);
});
CompostingChanceRegistry.INSTANCE.add(BLADDERWRACK_ITEM, 0.3f);
}

public static void register_treated_plank(String name, Block block, Item item, String source_mod, String plank_type) {
Expand All @@ -252,4 +286,9 @@ private static void register_block(String name, Block block, Item item) {
Registry.register(Registries.BLOCK, Identifier.of(MOD_ID, name), block);
Registry.register(Registries.ITEM, Identifier.of(MOD_ID, name), item);
}

private static <T extends BlockEntity> BlockEntityType<T> register_be(String id, BlockEntityType.Builder<T> builder) {
Type<?> type = Util.getChoiceType(TypeReferences.BLOCK_ENTITY, id);
return Registry.register(Registries.BLOCK_ENTITY_TYPE, id, builder.build(type));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
{
"replace": false,
"values": [
"rounded:luster_cluster"
"rounded:luster_cluster",
"rounded:smooth_prismarine",
"rounded:smooth_prismarine_slab",
"rounded:chiseled_prismarine_bricks",
"rounded:prismarine_lantern",
"rounded:dead_bladderwrack",
"rounded:bladderwrack",
"rounded:dead_bladderwrack_block",
"rounded:bladderwrack_block"
]
}

0 comments on commit 8bbebfc

Please sign in to comment.