From b5ceb0defe099f19d79f4a3572d0028f252ae757 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 18 May 2023 01:33:09 +0200 Subject: [PATCH] [Feature] Added `BehaviourBuilders` --- .../complexmaterials/BehaviourBuilders.java | 76 +++++++++++++++++++ src/main/resources/bclib.accesswidener | 4 + 2 files changed, 80 insertions(+) create mode 100644 src/main/java/org/betterx/bclib/complexmaterials/BehaviourBuilders.java diff --git a/src/main/java/org/betterx/bclib/complexmaterials/BehaviourBuilders.java b/src/main/java/org/betterx/bclib/complexmaterials/BehaviourBuilders.java new file mode 100644 index 00000000..b3c5eade --- /dev/null +++ b/src/main/java/org/betterx/bclib/complexmaterials/BehaviourBuilders.java @@ -0,0 +1,76 @@ +package org.betterx.bclib.complexmaterials; + +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MaterialColor; + +public class BehaviourBuilders { + public static BlockBehaviour.Properties createPlant() { + return BlockBehaviour.Properties.of(Material.PLANT) + .color(MaterialColor.PLANT) + .noCollission() + .instabreak(); + } + + public static BlockBehaviour.Properties createTickingPlant() { + return createPlant().randomTicks(); + } + + public static BlockBehaviour.Properties createReplaceablePlant() { + return BlockBehaviour.Properties.of(Material.REPLACEABLE_PLANT) + .color(MaterialColor.PLANT) + .noCollission() + .instabreak(); + } + + public static BlockBehaviour.Properties createWaterPlant() { + return BlockBehaviour.Properties.of(Material.WATER_PLANT) + .noCollission() + .instabreak(); + } + + public static BlockBehaviour.Properties createReplaceableWaterPlant() { + return BlockBehaviour.Properties.of(Material.REPLACEABLE_WATER_PLANT) + .noCollission() + .instabreak(); + } + + public static BlockBehaviour.Properties createLeaves() { + return createLeaves(MaterialColor.PLANT); + } + + public static BlockBehaviour.Properties createLeaves(MaterialColor color) { + return BlockBehaviour.Properties.of(Material.LEAVES) + .color(color) + .strength(0.2f) + .randomTicks() + .noOcclusion() + .isValidSpawn(Blocks::ocelotOrParrot) + .isSuffocating(Blocks::never) + .isViewBlocking(Blocks::never) + .isRedstoneConductor(Blocks::never); + } + + public static BlockBehaviour.Properties createStone() { + return createStone(MaterialColor.STONE); + } + + public static BlockBehaviour.Properties createStone(MaterialColor color) { + return BlockBehaviour.Properties.of(Material.STONE) + .color(color); + } + + public static BlockBehaviour.Properties createSign(MaterialColor color) { + return BlockBehaviour.Properties.of(Material.WOOD) + .color(color) + .noCollission() + .strength(1.0f); + } + + public static BlockBehaviour.Properties createWallSign(MaterialColor color, Block dropBlock) { + return createSign(color).dropsLike(dropBlock); + + } +} diff --git a/src/main/resources/bclib.accesswidener b/src/main/resources/bclib.accesswidener index 90bc1787..51ec7695 100644 --- a/src/main/resources/bclib.accesswidener +++ b/src/main/resources/bclib.accesswidener @@ -29,6 +29,10 @@ accessible method net/minecraft/world/level/levelgen/NoiseRouterData slideNether accessible method net/minecraft/tags/TagEntry elementOrTag ()Lnet/minecraft/util/ExtraCodecs$TagOrElementLocation; accessible method net/minecraft/data/worldgen/biome/OverworldBiomes calculateSkyColor (F)I accessible method net/minecraft/advancements/Advancement$Builder (Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/advancements/DisplayInfo;Lnet/minecraft/advancements/AdvancementRewards;Ljava/util/Map;[[Ljava/lang/String;)V +accessible method net/minecraft/world/level/block/Blocks ocelotOrParrot (Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/EntityType;)Ljava/lang/Boolean; +accessible method net/minecraft/world/level/block/Blocks never (Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/EntityType;)Ljava/lang/Boolean; +accessible method net/minecraft/world/level/block/Blocks never (Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Z + #Fields accessible field net/minecraft/world/entity/ai/village/poi/PoiTypes TYPE_BY_STATE Ljava/util/Map; \ No newline at end of file