Evil Block

This commit is contained in:
Vos
2025-11-06 18:58:15 -06:00
parent 6aefb8af6b
commit f6a46c555c
11 changed files with 78 additions and 3 deletions
@@ -0,0 +1,10 @@
{
"variants": {
"clicked=false": {
"model": "acesbs:block/evil_block"
},
"clicked=true": {
"model": "acesbs:block/evil_block_on"
}
}
}
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "acesbs:block/evil_block"
}
}
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "acesbs:block/evil_block_on"
}
}
@@ -0,0 +1,3 @@
{
"parent": "acesbs:block/evil_block"
}
@@ -2,6 +2,7 @@ package com.acethewildfire.acesbs.block;
import com.acethewildfire.acesbs.AcesBS; import com.acethewildfire.acesbs.AcesBS;
import com.acethewildfire.acesbs.block.custom.EntropyBlock; import com.acethewildfire.acesbs.block.custom.EntropyBlock;
import com.acethewildfire.acesbs.block.custom.EvilBlock;
import com.acethewildfire.acesbs.block.custom.StableEntropyBlock; import com.acethewildfire.acesbs.block.custom.StableEntropyBlock;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.block.enums.NoteBlockInstrument; import net.minecraft.block.enums.NoteBlockInstrument;
@@ -132,6 +133,13 @@ public class ModBlocks {
.nonOpaque() .nonOpaque()
)); ));
public static final Block EVIL_BLOCK = registerBlock("evil_block",
new EvilBlock(AbstractBlock.Settings.create()
.strength(5f)
.luminance(state -> state.get(EvilBlock.CLICKED) ? 15 : 0)
.requiresTool()
.sounds(BlockSoundGroup.LODESTONE)));
private static Block registerBlock(String name, Block block){ private static Block registerBlock(String name, Block block){
registerBlockItem(name, block); registerBlockItem(name, block);
return Registry.register(Registries.BLOCK, Identifier.of(AcesBS.MOD_ID, name), block); return Registry.register(Registries.BLOCK, Identifier.of(AcesBS.MOD_ID, name), block);
@@ -0,0 +1,34 @@
package com.acethewildfire.acesbs.block.custom;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class EvilBlock extends Block {
public static final BooleanProperty CLICKED = BooleanProperty.of("clicked");
public EvilBlock(Settings settings) {
super(settings);
setDefaultState(this.getDefaultState().with(CLICKED, false));
}
@Override
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
if(!world.isClient()){
world.setBlockState(pos, state.cycle(CLICKED));
}
return ActionResult.SUCCESS;
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(CLICKED);
}
}
@@ -1,12 +1,12 @@
package com.acethewildfire.acesbs.datagen; package com.acethewildfire.acesbs.datagen;
import com.acethewildfire.acesbs.block.ModBlocks; import com.acethewildfire.acesbs.block.ModBlocks;
import com.acethewildfire.acesbs.block.custom.EvilBlock;
import com.acethewildfire.acesbs.item.ModItems; import com.acethewildfire.acesbs.item.ModItems;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider; import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider;
import net.minecraft.data.client.BlockStateModelGenerator; import net.minecraft.data.client.*;
import net.minecraft.data.client.ItemModelGenerator; import net.minecraft.util.Identifier;
import net.minecraft.data.client.Models;
public class ModModelProvider extends FabricModelProvider { public class ModModelProvider extends FabricModelProvider {
@@ -36,6 +36,10 @@ public class ModModelProvider extends FabricModelProvider {
blockStateModelGenerator.registerDoor(ModBlocks.LEMONWOOD_DOOR); blockStateModelGenerator.registerDoor(ModBlocks.LEMONWOOD_DOOR);
blockStateModelGenerator.registerTrapdoor(ModBlocks.LEMONWOOD_TRAPDOOR); blockStateModelGenerator.registerTrapdoor(ModBlocks.LEMONWOOD_TRAPDOOR);
Identifier lampOffIdentifier = TexturedModel.CUBE_ALL.upload(ModBlocks.EVIL_BLOCK, blockStateModelGenerator.modelCollector);
Identifier lampOnIdentifier = blockStateModelGenerator.createSubModel(ModBlocks.EVIL_BLOCK, "_on", Models.CUBE_ALL, TextureMap::all);
blockStateModelGenerator.blockStateCollector.accept(VariantsBlockStateSupplier.create(ModBlocks.EVIL_BLOCK)
.coordinate(BlockStateModelGenerator.createBooleanModelMap(EvilBlock.CLICKED, lampOnIdentifier, lampOffIdentifier)));
} }
@@ -47,6 +47,8 @@ public class ModItemGroups {
entries.add(ModBlocks.LEMONWOOD_DOOR); entries.add(ModBlocks.LEMONWOOD_DOOR);
entries.add(ModBlocks.LEMONWOOD_TRAPDOOR); entries.add(ModBlocks.LEMONWOOD_TRAPDOOR);
entries.add(ModBlocks.EVIL_BLOCK);
}) })
.build()); .build());
@@ -26,6 +26,8 @@
"block.acesbs.lemonwood_door": "Lemonwood Door", "block.acesbs.lemonwood_door": "Lemonwood Door",
"block.acesbs.lemonwood_trapdoor": "Lemonwood Trapdoor", "block.acesbs.lemonwood_trapdoor": "Lemonwood Trapdoor",
"block.acesbs.evil_block": "Evil Block",
"itemgroup.acesbs.items": "Ace's BS Items", "itemgroup.acesbs.items": "Ace's BS Items",
"itemgroup.acesbs.blocks": "Ace's BS Blocks", "itemgroup.acesbs.blocks": "Ace's BS Blocks",
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB