Skip to content

Commit

Permalink
add cosmetic blocks
Browse files Browse the repository at this point in the history
Took 1 hour 15 minutes
  • Loading branch information
xkball committed Oct 5, 2024
1 parent db00e21 commit 2cb6e0e
Show file tree
Hide file tree
Showing 31 changed files with 270 additions and 21 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod_name=Power Tool
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GPL-3.0
# The mod version. See https://semver.org/
mod_version=1.4.13
mod_version=1.4.14
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,52 @@
// 1.21.1 2024-09-28T14:16:00.3767043 Block States: powertool
// 1.21.1 2024-10-05T16:36:45.6046984 Block States: powertool
ae6ddabd13bd84907c7fc7fdb01186954fc13502 assets/powertool/blockstates/cosmetic_barrel.json
f2ba93d02d22c027abeeea15860c72a3e6a46cb6 assets/powertool/blockstates/cosmetic_beacon.json
05b788f1ac0190925f20bbc680cb68c445d80223 assets/powertool/blockstates/cosmetic_beehive.json
e771ba4339b87af1e3d3af179b69b99b0221f4f6 assets/powertool/blockstates/cosmetic_blast_furnace.json
b967eaee066e68a6d96ab5c8fb5f9f75dfab8f86 assets/powertool/blockstates/cosmetic_brain_coral_block.json
f4b5c6779e5abc63a237d9cd8bf873d8baf6106c assets/powertool/blockstates/cosmetic_bubble_coral_block.json
58d540b705bebe6eeac65cbbb9a1bc2df7fa1bc6 assets/powertool/blockstates/cosmetic_cartography_table.json
73d337b16e2c9e9f6da8c89b9b04a7922dee3a7e assets/powertool/blockstates/cosmetic_crafting_table.json
b825aff79fdf08fe701998ba56536cf1f106603a assets/powertool/blockstates/cosmetic_enchanting_table.json
0c1c987cced2e39340414af7e894e64745146116 assets/powertool/blockstates/cosmetic_fire_coral_block.json
6f41528406fec589da84008d2e1859c87acce433 assets/powertool/blockstates/cosmetic_fletching_table.json
bc3d25275ab66ee6de97cc3f7a46bc192d6e9861 assets/powertool/blockstates/cosmetic_furnace.json
f37e3dfe4acc540146d7d4ce599fb508ef16650e assets/powertool/blockstates/cosmetic_gravel.json
2b25a59d11e5f2af7f6b9882f6b4b5b490e25c3a assets/powertool/blockstates/cosmetic_horn_coral_block.json
82ce04089243c18fcc378c68c15690bc5c7d1484 assets/powertool/blockstates/cosmetic_redstone_block.json
59eb8dd5b7ffb922c678282ad4a98e1e5ae23f67 assets/powertool/blockstates/cosmetic_red_sand.json
49a234a2bae6b4887904b3149f03838c3b488928 assets/powertool/blockstates/cosmetic_sand.json
e01d538de9ee2f12215bb211c0788f5493a3d863 assets/powertool/blockstates/cosmetic_smithing_table.json
88e2d563c03f93042e995a101bb092cbb7b5abb9 assets/powertool/blockstates/cosmetic_smoker.json
e7af329147e693d304482e605f84838e0e640fee assets/powertool/blockstates/cosmetic_stonecutter.json
7d416e6e49bae0cf46ac11c9b2a85bca567c4ef0 assets/powertool/blockstates/cosmetic_tube_coral_block.json
38eb9c4431dd893f9b6a19659bf14c7dacf8a47d assets/powertool/blockstates/gray_trash_can.json
a8239321f2713befc6b352461dd0ddfc0731ae04 assets/powertool/blockstates/green_trash_can.json
3d258da627707754ef6244ae11a0bce62bcba95f assets/powertool/blockstates/green_trash_can_cap.json
73e34f2417a5c4eef6cecd3fb144d7498e3c0730 assets/powertool/blockstates/temple.json
72358d0b2db425861fdcbe0e22e92b9405895c88 assets/powertool/blockstates/white_trash_can.json
cd29f633a654dfdb0c65433112a02d9269f7a24e assets/powertool/blockstates/white_trash_can_cap.json
5ba92d5de29d707f0cce235504a8170bd5a4d2e0 assets/powertool/models/block/cosmetic_beacon.json
3a87aba93140e66ff5772eb5fb355054be7f5236 assets/powertool/models/item/cosmetic_barrel.json
fc424e967be5eeee755df8ebf05243c68dcdb0e3 assets/powertool/models/item/cosmetic_beacon.json
db77b806b2be1fcdb0081b214fd264d048911a43 assets/powertool/models/item/cosmetic_beehive.json
9db8ff6b8f62a90066f9ec6f113f30579ef147b4 assets/powertool/models/item/cosmetic_blast_furnace.json
09534ca2a8e9cdd11e946a3e69b56bbc68ac448c assets/powertool/models/item/cosmetic_brain_coral_block.json
aa0a4f2563510784290b3a9bd67849aa1a1d83c0 assets/powertool/models/item/cosmetic_bubble_coral_block.json
ffc9aca15acd4879cacd93452b9bfbc5ced87c9e assets/powertool/models/item/cosmetic_cartography_table.json
f36fa54bdee70580abfce02e1255eefca84974e6 assets/powertool/models/item/cosmetic_crafting_table.json
eeb8902113ed70e7881f713ef7fe4573524a32d7 assets/powertool/models/item/cosmetic_enchanting_table.json
9b72bc2e6e4bb294d9b0c95cf119c7b5a18b5c87 assets/powertool/models/item/cosmetic_fire_coral_block.json
ccb572d42f2347546027eb372e80b12955aa1256 assets/powertool/models/item/cosmetic_fletching_table.json
60287266a73cc75aea724a679eef047886e30aa3 assets/powertool/models/item/cosmetic_furnace.json
c6e080a1706f251ee859af248d69f6a3b4c34dc3 assets/powertool/models/item/cosmetic_gravel.json
cd46fb64b9fa15c031746f3b79df8c7d386d4eb9 assets/powertool/models/item/cosmetic_horn_coral_block.json
4749967c4d9cf2a0f0d9c422051f3b86f15c2783 assets/powertool/models/item/cosmetic_redstone_block.json
45fccb0be21da6968a6c93247b969b22df5895c5 assets/powertool/models/item/cosmetic_red_sand.json
976371ded304bf028cd5462a3568320aedc8085c assets/powertool/models/item/cosmetic_sand.json
e7f5580926bba0bbcefc0ad45fca6417f698cbe4 assets/powertool/models/item/cosmetic_smithing_table.json
e1d94ad1dd05c29f6208458328189cab4c326d58 assets/powertool/models/item/cosmetic_smoker.json
aac50ef69b31feae6f21e3acfc9fc98327266ad7 assets/powertool/models/item/cosmetic_stonecutter.json
b0141832911b272755538b29b60e23038bf58a6f assets/powertool/models/item/cosmetic_tube_coral_block.json
6b3d3a1333f9b9ec7176e51af29476ccf52002f2 assets/powertool/models/item/gray_trash_can.json
1fe5241a345d5d17219bb128a8246aed214d0ee2 assets/powertool/models/item/green_trash_can.json
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "powertool:block/cosmetic_beacon"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "minecraft:block/cartography_table"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "minecraft:block/crafting_table"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "minecraft:block/enchanting_table"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "minecraft:block/fletching_table"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "minecraft:block/smithing_table"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"variants": {
"facing=east,lit=false": {
"model": "minecraft:block/smoker",
"y": 450
},
"facing=east,lit=true": {
"model": "minecraft:block/smoker_on",
"y": 450
},
"facing=north,lit=false": {
"model": "minecraft:block/smoker",
"y": 360
},
"facing=north,lit=true": {
"model": "minecraft:block/smoker_on",
"y": 360
},
"facing=south,lit=false": {
"model": "minecraft:block/smoker",
"y": 180
},
"facing=south,lit=true": {
"model": "minecraft:block/smoker_on",
"y": 180
},
"facing=west,lit=false": {
"model": "minecraft:block/smoker",
"y": 270
},
"facing=west,lit=true": {
"model": "minecraft:block/smoker_on",
"y": 270
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"variants": {
"facing=east": {
"model": "minecraft:block/stonecutter",
"y": 90
},
"facing=north": {
"model": "minecraft:block/stonecutter"
},
"facing=south": {
"model": "minecraft:block/stonecutter",
"y": 180
},
"facing=west": {
"model": "minecraft:block/stonecutter",
"y": 270
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"parent": "minecraft:block/beacon",
"render_type": "cutout"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "powertool:block/cosmetic_beacon"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "minecraft:block/cartography_table"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "minecraft:block/crafting_table"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "minecraft:block/enchanting_table"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "minecraft:block/fletching_table"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "minecraft:block/smithing_table"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "minecraft:block/smoker"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "minecraft:block/stonecutter"
}
4 changes: 4 additions & 0 deletions src/main/java/org/teacon/powertool/block/CosmeticBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.teacon.powertool.block;

public interface CosmeticBlock {
}
29 changes: 20 additions & 9 deletions src/main/java/org/teacon/powertool/block/PowerToolBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
import org.teacon.powertool.block.cosmetical.CosmeticCampfireBlock;
import org.teacon.powertool.block.cosmetical.CosmeticFurnace;
import org.teacon.powertool.block.cosmetical.CosmeticHopper;
import org.teacon.powertool.block.cosmetical.CosmeticHorizontalDirectionalBlock;
import org.teacon.powertool.block.cosmetical.CosmeticSimpleBlock;
import org.teacon.powertool.block.cosmetical.CosmeticTrapdoor;
import org.teacon.powertool.block.cosmetical.CosmeticWaterloggedBlock;
import org.teacon.powertool.block.entity.CommonHolographicSignBlockEntity;
import org.teacon.powertool.block.entity.ItemDisplayBlockEntity;
import org.teacon.powertool.block.entity.ItemSupplierBlockEntity;
Expand All @@ -48,6 +50,7 @@

import java.util.List;
import java.util.Map;
import java.util.function.Function;

import static org.teacon.powertool.item.PowerToolItems.ITEMS;

Expand All @@ -68,7 +71,7 @@ public class PowerToolBlocks {
() -> SoundEvents.GLOW_ITEM_FRAME_REMOVE_ITEM,
() -> SoundEvents.MOSS_CARPET_FALL);

public static final List<Block> SIMPLE_BLOCKS = List.of(Blocks.SAND, Blocks.RED_SAND, Blocks.GRAVEL, Blocks.TUBE_CORAL_BLOCK, Blocks.BRAIN_CORAL_BLOCK, Blocks.BUBBLE_CORAL_BLOCK, Blocks.FIRE_CORAL_BLOCK, Blocks.HORN_CORAL_BLOCK, Blocks.REDSTONE_BLOCK);
public static final List<Block> SIMPLE_BLOCKS = List.of(Blocks.SAND, Blocks.RED_SAND, Blocks.GRAVEL, Blocks.TUBE_CORAL_BLOCK, Blocks.BRAIN_CORAL_BLOCK, Blocks.BUBBLE_CORAL_BLOCK, Blocks.FIRE_CORAL_BLOCK, Blocks.HORN_CORAL_BLOCK, Blocks.REDSTONE_BLOCK, Blocks.CARTOGRAPHY_TABLE, Blocks.CRAFTING_TABLE, Blocks.FLETCHING_TABLE, Blocks.SMITHING_TABLE,Blocks.BEACON);

public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(Registries.BLOCK, PowerTool.MODID);
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(Registries.BLOCK_ENTITY_TYPE, PowerTool.MODID);
Expand All @@ -87,7 +90,8 @@ public class PowerToolBlocks {
public static DeferredHolder<Block,CosmeticCampfireBlock> COSMETIC_SOUL_CAMPFIRE;
public static DeferredHolder<Block, CosmeticBeehive> COSMETIC_BEEHIVE;
public static DeferredHolder<Block, CosmeticFurnace> COSMETIC_FURNACE;
public static DeferredHolder<Block,CosmeticFurnace> COSMETIC_BLAST_FURNACE;
public static DeferredHolder<Block, CosmeticFurnace> COSMETIC_BLAST_FURNACE;
public static DeferredHolder<Block, CosmeticFurnace> COSMETIC_SMOKER;
public static DeferredHolder<Block, CosmeticBarrel> COSMETIC_BARREL;

public static DeferredHolder<Block, HolographicSignBlock> HOLOGRAPHIC_SIGN;
Expand Down Expand Up @@ -232,17 +236,22 @@ public static void register(IEventBus bus) {
BlockSetType.IRON, Blocks.IRON_TRAPDOOR
));

regSimpleCosmetic(SIMPLE_BLOCKS);
regCosmetic(SIMPLE_BLOCKS,CosmeticSimpleBlock::new);
regCosmetic(List.of(Blocks.ENCHANTING_TABLE),CosmeticWaterloggedBlock::new);
regCosmetic(List.of(Blocks.STONECUTTER), CosmeticHorizontalDirectionalBlock::new);

COSMETIC_BEEHIVE = BLOCKS.register("cosmetic_beehive", () -> new CosmeticBeehive(BlockBehaviour.Properties.ofFullCopy(Blocks.BEEHIVE)));
COSMETIC_FURNACE = BLOCKS.register("cosmetic_furnace", () -> new CosmeticFurnace(BlockBehaviour.Properties.ofFullCopy(Blocks.FURNACE)));
COSMETIC_BLAST_FURNACE = BLOCKS.register("cosmetic_blast_furnace", () -> new CosmeticFurnace(BlockBehaviour.Properties.ofFullCopy(Blocks.BLAST_FURNACE)));
COSMETIC_SMOKER = BLOCKS.register("cosmetic_smoker",() -> new CosmeticFurnace(BlockBehaviour.Properties.ofFullCopy(Blocks.SMOKER)));
COSMETIC_BARREL = BLOCKS.register("cosmetic_barrel", () -> new CosmeticBarrel(BlockBehaviour.Properties.ofFullCopy(Blocks.BARREL)));

ITEMS.register("cosmetic_beehive", () -> new BlockItem(COSMETIC_BEEHIVE.get(), new Item.Properties()));
ITEMS.register("cosmetic_furnace", () -> new BlockItem(COSMETIC_FURNACE.get(), new Item.Properties()));
ITEMS.register("cosmetic_blast_furnace", () -> new BlockItem(COSMETIC_BLAST_FURNACE.get(), new Item.Properties()));
ITEMS.register("cosmetic_smoker",() -> new BlockItem(COSMETIC_SMOKER.get(), new Item.Properties()));
ITEMS.register("cosmetic_barrel", () -> new BlockItem(COSMETIC_BARREL.get(), new Item.Properties()));

ITEMS.register("command_block", () -> new BlockItem(COMMAND_BLOCK.get(), new Item.Properties().rarity(Rarity.EPIC)));
ITEMS.register("power_supply", () -> new BlockItem(POWER_SUPPLY.get(), new Item.Properties()));
ITEMS.register("item_display", () -> new BlockItem(ITEM_DISPLAY.get(), new Item.Properties()));
Expand Down Expand Up @@ -285,12 +294,14 @@ private static void regTrapDoors(Map<BlockSetType, Block> existing) {
ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties()));
}
}

@SuppressWarnings("SameParameterValue")
private static void regSimpleCosmetic(List<Block> existing) {

private static void regCosmetic(List<Block> existing, Function<BlockBehaviour.Properties,Block> factory) {
for (var existingBlock : existing) {
var name = "cosmetic_" + BuiltInRegistries.BLOCK.getKey(existingBlock).getPath();
var block = BLOCKS.register(name, () -> new CosmeticSimpleBlock(BlockBehaviour.Properties.ofFullCopy(existingBlock)));
var flag = existingBlock.defaultBlockState().useShapeForLightOcclusion();
var properties = BlockBehaviour.Properties.ofFullCopy(existingBlock);
if(flag) properties.noOcclusion();
var block = BLOCKS.register(name, () -> factory.apply(properties));
ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
import org.teacon.powertool.block.CosmeticBlock;
import org.teacon.powertool.utils.VanillaUtils;

import javax.annotation.ParametersAreNonnullByDefault;
import java.util.List;

@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public class CosmeticCampfireBlock extends Block implements SimpleWaterloggedBlock {
public class CosmeticCampfireBlock extends Block implements SimpleWaterloggedBlock, CosmeticBlock {

protected static final VoxelShape SHAPE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 7.0D, 16.0D);
public static final BooleanProperty LIT = BlockStateProperties.LIT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.teacon.powertool.block.CosmeticBlock;

import javax.annotation.ParametersAreNonnullByDefault;
import java.util.List;
Expand All @@ -34,7 +35,7 @@
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public class CosmeticHopper extends Block {
public class CosmeticHopper extends Block implements CosmeticBlock {
private static final DirectionProperty FACING = BlockStateProperties.FACING_HOPPER;
private static final VoxelShape TOP = Block.box(0.0D, 10.0D, 0.0D, 16.0D, 16.0D, 16.0D);
private static final VoxelShape FUNNEL = Block.box(4.0D, 4.0D, 4.0D, 12.0D, 10.0D, 12.0D);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.minecraft.world.level.block.state.properties.DirectionProperty;


public abstract class CosmeticHorizontalDirectionalBlock extends CosmeticSimpleBlock{
public class CosmeticHorizontalDirectionalBlock extends CosmeticSimpleBlock{

public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
package org.teacon.powertool.block.cosmetical;

import net.minecraft.ChatFormatting;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import org.teacon.powertool.block.CosmeticBlock;

import javax.annotation.ParametersAreNonnullByDefault;
import java.util.List;

@ParametersAreNonnullByDefault
public class CosmeticSimpleBlock extends Block {
public class CosmeticSimpleBlock extends Block implements CosmeticBlock {

public CosmeticSimpleBlock(Properties p) {
super(p);
Expand All @@ -21,5 +24,5 @@ public CosmeticSimpleBlock(Properties p) {
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
tooltipComponents.add(Component.translatable("block.powertool.cosmetic_block.tooltip").withStyle(ChatFormatting.DARK_GRAY));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.teacon.powertool.block.CosmeticBlock;

import javax.annotation.ParametersAreNonnullByDefault;
import java.util.List;

@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public class CosmeticTrapdoor extends DirectionalBlock implements SimpleWaterloggedBlock {
public class CosmeticTrapdoor extends DirectionalBlock implements SimpleWaterloggedBlock, CosmeticBlock {

public static final MapCodec<CosmeticTrapdoor> CODEC = simpleCodec(CosmeticTrapdoor::new);

Expand Down
Loading

0 comments on commit 2cb6e0e

Please sign in to comment.