+ fan_block

This commit is contained in:
Glitchlabs
2026-08-04 15:43:16 +02:00
parent a4236cea9a
commit 48a1ecf7e4
21 changed files with 160 additions and 9 deletions
@@ -1,4 +1,4 @@
// 1.21.1 2026-08-04T13:43:14.812806206 Tags for minecraft:block mod id ornamentum
// 1.21.1 2026-08-04T15:40:22.174290355 Tags for minecraft:block mod id ornamentum
585e131e594c65c425b3e81803fae3fdd63e2f03 data/c/tags/block/concretes.json
354a0712e83c8365d9054ffc2a122cf7dd69ad53 data/c/tags/block/dyed.json
8281ec180c87b02f17e4be444a350685b52f1e31 data/c/tags/block/dyed/black.json
@@ -31,10 +31,10 @@ ae7d2e386f2eb4df7cd8f8f3e0a4040cae7a13bf data/minecraft/tags/block/incorrect_for
5bf3d2f5afa06168fa3bb8de07bdbaff4f7980db data/minecraft/tags/block/incorrect_for_stone_tool.json
ae7d2e386f2eb4df7cd8f8f3e0a4040cae7a13bf data/minecraft/tags/block/incorrect_for_wooden_tool.json
26a948fa0b92ea3e254ed5b6aa26e1ab478e0715 data/minecraft/tags/block/mineable/axe.json
07f81b358a4b30fc07f6a51f5cae46b9622d05df data/minecraft/tags/block/mineable/pickaxe.json
d069cc13cfb3d900d448089fa1423891be6b25a7 data/minecraft/tags/block/mineable/pickaxe.json
ec379d82d3fd4ddd3a9f6664ddb9aaaf0290834d data/minecraft/tags/block/needs_diamond_tool.json
bad82b905081d37caba6026145cd8611bd369d5c data/minecraft/tags/block/needs_iron_tool.json
69abee467a122fbf58d494d6dc24648af511923e data/minecraft/tags/block/needs_stone_tool.json
20f898296b7e69ff74393d2b1d7e15dbfae5e8b5 data/minecraft/tags/block/needs_stone_tool.json
8b771a730def8958b41eb9c4e3b6628365c5d429 data/minecraft/tags/block/occludes_vibration_signals.json
aad2571fcde7dc73bb943c24237eb17699067cfb data/minecraft/tags/block/sculk_replaceable.json
6014324ec06e8974ac7b92e7c0724c7710a6331c data/minecraft/tags/block/sculk_replaceable_world_gen.json
@@ -1,4 +1,4 @@
// 1.21.1 2026-08-04T13:43:14.807775051 Loot Tables
// 1.21.1 2026-08-04T15:40:22.170254506 Loot Tables
b840d3c223a8269ea4ead11f9d1a337f16c87728 data/ornamentum/loot_table/blocks/agender_flag.json
c5c3cbbff0b4af321ae05896dbd68e551f598c86 data/ornamentum/loot_table/blocks/amethyst_grate.json
f44341b5b821a1ea423b1f9e81a020e324a3952e data/ornamentum/loot_table/blocks/ametist_bricks.json
@@ -72,6 +72,7 @@ a5396a39055338fecb45c276985a6d7e004a5b3d data/ornamentum/loot_table/blocks/cyan_
3bf1da00d5160a863281eae4449868c077c4aa32 data/ornamentum/loot_table/blocks/denmark_flag.json
d5759aa6b55f402e60d0d2034b7706549ca17e82 data/ornamentum/loot_table/blocks/diamond_grate.json
9e63d610e9391c9aa5275b7f277265e457a6adf4 data/ornamentum/loot_table/blocks/duck.json
31be1ee454c2cb98ba7018dcbf7822620e60e0af data/ornamentum/loot_table/blocks/fan_block.json
d026ac89fab7221c3f60d828bad42af0562ab9c7 data/ornamentum/loot_table/blocks/finland_flag.json
f2c529d110328314d042609045907cbf565aabe9 data/ornamentum/loot_table/blocks/france_flag.json
cb1c2b6f83f213c65dae3f8a644479a61c0954bd data/ornamentum/loot_table/blocks/gay_men_flag.json
@@ -1,2 +1,2 @@
// 1.21.1 2026-08-04T13:43:14.811220915 Languages: en_us for mod: ornamentum
5c39b0c9dc87aec3a911d84281f46fcb8944db15 assets/ornamentum/lang/en_us.json
// 1.21.1 2026-08-04T15:40:22.173401134 Languages: en_us for mod: ornamentum
62aa32c03952421205e9465fffaf8a6f551b9fd9 assets/ornamentum/lang/en_us.json
@@ -72,6 +72,7 @@
"block.ornamentum.denmark_flag": "Denmark Flag",
"block.ornamentum.diamond_grate": "Diamond Grate",
"block.ornamentum.duck": "Duck",
"block.ornamentum.fan_block": "Fan Block",
"block.ornamentum.finland_flag": "Finland Flag",
"block.ornamentum.france_flag": "France Flag",
"block.ornamentum.gay_men_flag": "Gay Men Flag",
@@ -1,5 +1,6 @@
{
"values": [
"ornamentum:fan_block",
"ornamentum:link_block",
"ornamentum:iron_shelf",
"ornamentum:red_pattern_block",
@@ -2,6 +2,7 @@
"values": [
"ornamentum:iron_shelf",
"ornamentum:iron_grate",
"ornamentum:link_block"
"ornamentum:link_block",
"ornamentum:fan_block"
]
}
@@ -0,0 +1,21 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "ornamentum:fan_block"
}
],
"rolls": 1.0
}
],
"random_sequence": "ornamentum:blocks/fan_block"
}
@@ -17,6 +17,9 @@ public class ModBlocks {
public static final DeferredRegister.Blocks BLOCKS =
DeferredRegister.createBlocks(Ornamentum.MODID);
public static final DeferredBlock<Block> FAN_BLOCK = registerBlock("fan_block",
() -> new FanBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.IRON_BLOCK).noOcclusion()));
public static final DeferredBlock<Block> LINK_BLOCK = registerBlock("link_block",
() -> new LinkBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.BLACK_CONCRETE).isRedstoneConductor((bs, br, bp) -> true).noOcclusion()));
@@ -0,0 +1,89 @@
package ovh.glitchlabs.ornamentum.blocks.custom;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.phys.BlockHitResult;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashSet;
import java.util.Set;
/**
* A block that can be toggled on/off via shift-right-click.
* Toggling propagates through directly adjacent FanBlocks (BFS / flood-fill),
* similar to how a redstone wire network shares state.
*/
public class FanBlock extends Block {
public static final BooleanProperty ON = BooleanProperty.create("on");
// Safety cap so an absurdly large network can't cause a huge single-tick update.
private static final int MAX_NETWORK_SIZE = 4096;
public FanBlock(Properties properties) {
super(properties);
this.registerDefaultState(this.stateDefinition.any().setValue(ON, false));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(ON);
}
@Override
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) {
if (player.isShiftKeyDown()) {
if (!level.isClientSide) {
toggleNetwork(level, pos, !state.getValue(ON));
}
return InteractionResult.SUCCESS;
}
return InteractionResult.PASS;
}
/**
* Flood-fills outward from {@code origin} through orthogonally adjacent FanBlocks
* and sets all of them to {@code newState}.
*/
private void toggleNetwork(Level level, BlockPos origin, boolean newState) {
Set<BlockPos> visited = new HashSet<>();
Deque<BlockPos> queue = new ArrayDeque<>();
visited.add(origin.immutable());
queue.add(origin);
while (!queue.isEmpty() && visited.size() <= MAX_NETWORK_SIZE) {
BlockPos pos = queue.poll();
BlockState state = level.getBlockState(pos);
if (!(state.getBlock() instanceof FanBlock)) {
continue;
}
if (state.getValue(ON) != newState) {
level.setBlock(pos, state.setValue(ON, newState), Block.UPDATE_ALL);
}
for (Direction direction : Direction.values()) {
BlockPos neighborPos = pos.relative(direction);
if (visited.contains(neighborPos)) {
continue;
}
BlockState neighborState = level.getBlockState(neighborPos);
if (neighborState.getBlock() instanceof FanBlock) {
visited.add(neighborPos.immutable());
queue.add(neighborPos);
}
}
}
}
}
@@ -18,6 +18,7 @@ public class ModBlockLootTableProvider extends BlockLootSubProvider {
protected void generate() {
dropSelf(ModBlocks.DUCK.get());
dropSelf(ModBlocks.FAN_BLOCK.get());
dropSelf(ModBlocks.BABY_TURTLE.get());
dropSelf(ModBlocks.LINK_BLOCK.get());
dropSelf(ModBlocks.IRON_SHELF.get());
@@ -1,5 +1,6 @@
package ovh.glitchlabs.ornamentum.datagen;
import net.minecraft.world.entity.TamableAnimal;
import net.minecraft.world.level.block.Block;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
@@ -89,6 +90,7 @@ public class ModBlockTagProvider extends BlockTagsProvider {
;
tag(BlockTags.MINEABLE_WITH_PICKAXE)
.add(ModBlocks.FAN_BLOCK.get())
.add(ModBlocks.LINK_BLOCK.get())
.add(ModBlocks.IRON_SHELF.get())
@@ -403,6 +405,7 @@ public class ModBlockTagProvider extends BlockTagsProvider {
.add(ModBlocks.IRON_SHELF.get())
.add(ModBlocks.IRON_GRATE.get())
.add(ModBlocks.LINK_BLOCK.get())
.add(ModBlocks.FAN_BLOCK.get())
;
tag(BlockTags.INCORRECT_FOR_GOLD_TOOL)
@@ -1529,6 +1532,5 @@ public class ModBlockTagProvider extends BlockTagsProvider {
.add(ModBlocks.DUCK.get())
.add(ModBlocks.BABY_TURTLE.get())
;
}
}
@@ -342,6 +342,7 @@ public class ModLanguageProvider extends LanguageProvider {
add(ModBlocks.CRACKED_OBSIDIAN_TILES.get(), "Cracked Obsidian Tiles");
add(ModBlocks.LINK_BLOCK.get(), "Link Block");
add(ModBlocks.FAN_BLOCK.get(), "Fan Block");
add(ModBlocks.IRON_SHELF.get(), "Iron Shelf");
add(ModBlocks.DUCK.get(), "Duck");
@@ -25,6 +25,7 @@ public class ModCreativeModeTabs {
output.accept(ModBlocks.IRON_SHELF);
output.accept(ModBlocks.LINK_BLOCK);
output.accept(ModBlocks.FAN_BLOCK);
//toys
output.accept(ModBlocks.DUCK);
@@ -0,0 +1,10 @@
{
"variants": {
"on=false": {
"model": "ornamentum:block/fan_block"
},
"on=true": {
"model": "ornamentum:block/fan_block_on"
}
}
}
@@ -1,4 +1,3 @@
{
"variants": {
"facing=north,on=false": {
@@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "ornamentum:block/fan_off"
}
}
@@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "ornamentum:block/fan_on"
}
}
@@ -0,0 +1,3 @@
{
"parent": "ornamentum:block/fan_block_on"
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

@@ -0,0 +1,5 @@
{
"animation": {
"frametime": 1
}
}