[Feature] Support for hanging Signs
This commit is contained in:
parent
490ad640cd
commit
d4d5c74349
9 changed files with 140 additions and 9 deletions
|
@ -0,0 +1,45 @@
|
||||||
|
package org.betterx.bclib.blocks.signs;
|
||||||
|
|
||||||
|
import org.betterx.bclib.complexmaterials.BCLWoodTypeWrapper;
|
||||||
|
import org.betterx.bclib.complexmaterials.BehaviourBuilders;
|
||||||
|
import org.betterx.bclib.interfaces.BlockModelProvider;
|
||||||
|
import org.betterx.bclib.interfaces.CustomItemProvider;
|
||||||
|
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.item.BlockItem;
|
||||||
|
import net.minecraft.world.item.HangingSignItem;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.level.block.CeilingHangingSignBlock;
|
||||||
|
import net.minecraft.world.level.block.StandingSignBlock;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.block.state.properties.RotationSegment;
|
||||||
|
import net.minecraft.world.level.block.state.properties.WoodType;
|
||||||
|
import net.minecraft.world.level.material.MapColor;
|
||||||
|
|
||||||
|
public class BaseHangingSignBlock extends CeilingHangingSignBlock implements BlockModelProvider, CustomItemProvider {
|
||||||
|
public final BaseWallHangingSignBlock wallSign;
|
||||||
|
|
||||||
|
public BaseHangingSignBlock(WoodType type) {
|
||||||
|
this(type, MapColor.WOOD);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseHangingSignBlock(BCLWoodTypeWrapper type) {
|
||||||
|
this(type.type, type.color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseHangingSignBlock(WoodType type, MapColor color) {
|
||||||
|
super(BehaviourBuilders.createSign(color), type);
|
||||||
|
this.wallSign = new BaseWallHangingSignBlock(BehaviourBuilders.createWallSign(color, this), type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getYRotationDegrees(BlockState blockState) {
|
||||||
|
return RotationSegment.convertToDegrees(blockState.getValue(StandingSignBlock.ROTATION));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockItem getCustomItem(ResourceLocation blockID, Item.Properties settings) {
|
||||||
|
return new HangingSignItem(this, wallSign, settings.stacksTo(16));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.betterx.bclib.blocks;
|
package org.betterx.bclib.blocks.signs;
|
||||||
|
|
||||||
import org.betterx.bclib.complexmaterials.BCLWoodTypeWrapper;
|
import org.betterx.bclib.complexmaterials.BCLWoodTypeWrapper;
|
||||||
import org.betterx.bclib.complexmaterials.BehaviourBuilders;
|
import org.betterx.bclib.complexmaterials.BehaviourBuilders;
|
||||||
|
@ -10,7 +10,6 @@ import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.SignItem;
|
import net.minecraft.world.item.SignItem;
|
||||||
import net.minecraft.world.level.block.StandingSignBlock;
|
import net.minecraft.world.level.block.StandingSignBlock;
|
||||||
import net.minecraft.world.level.block.WallSignBlock;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.block.state.properties.RotationSegment;
|
import net.minecraft.world.level.block.state.properties.RotationSegment;
|
||||||
import net.minecraft.world.level.block.state.properties.WoodType;
|
import net.minecraft.world.level.block.state.properties.WoodType;
|
||||||
|
@ -18,7 +17,7 @@ import net.minecraft.world.level.material.MapColor;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class BaseSignBlock extends StandingSignBlock implements BlockModelProvider, CustomItemProvider {
|
public class BaseSignBlock extends StandingSignBlock implements BlockModelProvider, CustomItemProvider {
|
||||||
public final WallSignBlock wallSign;
|
public final BaseWallSignBlock wallSign;
|
||||||
|
|
||||||
public BaseSignBlock(WoodType type) {
|
public BaseSignBlock(WoodType type) {
|
||||||
this(type, MapColor.WOOD);
|
this(type, MapColor.WOOD);
|
|
@ -0,0 +1,13 @@
|
||||||
|
package org.betterx.bclib.blocks.signs;
|
||||||
|
|
||||||
|
import net.minecraft.world.level.block.WallHangingSignBlock;
|
||||||
|
import net.minecraft.world.level.block.state.properties.WoodType;
|
||||||
|
|
||||||
|
public class BaseWallHangingSignBlock extends WallHangingSignBlock {
|
||||||
|
public BaseWallHangingSignBlock(
|
||||||
|
Properties properties,
|
||||||
|
WoodType woodType
|
||||||
|
) {
|
||||||
|
super(properties, woodType);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.betterx.bclib.blocks;
|
package org.betterx.bclib.blocks.signs;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.WallSignBlock;
|
import net.minecraft.world.level.block.WallSignBlock;
|
||||||
import net.minecraft.world.level.block.state.properties.WoodType;
|
import net.minecraft.world.level.block.state.properties.WoodType;
|
|
@ -0,0 +1,65 @@
|
||||||
|
package org.betterx.bclib.complexmaterials.set.wood;
|
||||||
|
|
||||||
|
import org.betterx.bclib.blocks.signs.BaseHangingSignBlock;
|
||||||
|
import org.betterx.bclib.complexmaterials.WoodenComplexMaterial;
|
||||||
|
import org.betterx.bclib.complexmaterials.entry.BlockEntry;
|
||||||
|
import org.betterx.bclib.complexmaterials.entry.MaterialSlot;
|
||||||
|
import org.betterx.bclib.complexmaterials.entry.RecipeEntry;
|
||||||
|
import org.betterx.bclib.recipes.BCLRecipeBuilder;
|
||||||
|
|
||||||
|
import net.minecraft.data.recipes.RecipeCategory;
|
||||||
|
import net.minecraft.tags.BlockTags;
|
||||||
|
import net.minecraft.tags.ItemTags;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class HangingSign extends MaterialSlot<WoodenComplexMaterial> {
|
||||||
|
@NotNull
|
||||||
|
public static final String WALL_SUFFFIX = "wall_hanging_sign";
|
||||||
|
|
||||||
|
public HangingSign() {
|
||||||
|
super("hanging_sign");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addBlockEntry(WoodenComplexMaterial parentMaterial, Consumer<BlockEntry> adder) {
|
||||||
|
var signEntry = new BlockEntry(
|
||||||
|
suffix,
|
||||||
|
(complexMaterial, settings) -> new BaseHangingSignBlock(parentMaterial.woodType)
|
||||||
|
).setBlockTags(BlockTags.CEILING_HANGING_SIGNS)
|
||||||
|
.setItemTags(ItemTags.HANGING_SIGNS);
|
||||||
|
|
||||||
|
var wallSignEntry = new BlockEntry(
|
||||||
|
WALL_SUFFFIX,
|
||||||
|
false,
|
||||||
|
(complexMaterial, settings) -> {
|
||||||
|
if (complexMaterial.getBlock(suffix) instanceof BaseHangingSignBlock sign) {
|
||||||
|
return sign.wallSign;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
).setBlockTags(BlockTags.WALL_HANGING_SIGNS);
|
||||||
|
adder.accept(signEntry);
|
||||||
|
adder.accept(wallSignEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addRecipeEntry(
|
||||||
|
WoodenComplexMaterial parentMaterial,
|
||||||
|
Consumer<RecipeEntry> adder
|
||||||
|
) {
|
||||||
|
adder.accept(new RecipeEntry(suffix, (mat, id) ->
|
||||||
|
BCLRecipeBuilder
|
||||||
|
.crafting(id, parentMaterial.getBlock(suffix))
|
||||||
|
.setOutputCount(3)
|
||||||
|
.setShape("###", "###", " I ")
|
||||||
|
.addMaterial('#', parentMaterial.getBlock(WoodSlots.PLANKS))
|
||||||
|
.addMaterial('I', Items.STICK)
|
||||||
|
.setGroup("sign")
|
||||||
|
.setCategory(RecipeCategory.DECORATIONS)
|
||||||
|
.build()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package org.betterx.bclib.complexmaterials.set.wood;
|
package org.betterx.bclib.complexmaterials.set.wood;
|
||||||
|
|
||||||
import org.betterx.bclib.blocks.BaseSignBlock;
|
import org.betterx.bclib.blocks.signs.BaseSignBlock;
|
||||||
import org.betterx.bclib.complexmaterials.WoodenComplexMaterial;
|
import org.betterx.bclib.complexmaterials.WoodenComplexMaterial;
|
||||||
import org.betterx.bclib.complexmaterials.entry.BlockEntry;
|
import org.betterx.bclib.complexmaterials.entry.BlockEntry;
|
||||||
import org.betterx.bclib.complexmaterials.entry.MaterialSlot;
|
import org.betterx.bclib.complexmaterials.entry.MaterialSlot;
|
||||||
|
@ -28,7 +28,7 @@ public class Sign extends MaterialSlot<WoodenComplexMaterial> {
|
||||||
var signEntry = new BlockEntry(
|
var signEntry = new BlockEntry(
|
||||||
suffix,
|
suffix,
|
||||||
(complexMaterial, settings) -> new BaseSignBlock(parentMaterial.woodType)
|
(complexMaterial, settings) -> new BaseSignBlock(parentMaterial.woodType)
|
||||||
).setBlockTags(BlockTags.SIGNS)
|
).setBlockTags(BlockTags.STANDING_SIGNS)
|
||||||
.setItemTags(ItemTags.SIGNS);
|
.setItemTags(ItemTags.SIGNS);
|
||||||
|
|
||||||
var wallSignEntry = new BlockEntry(
|
var wallSignEntry = new BlockEntry(
|
||||||
|
|
|
@ -19,6 +19,7 @@ public class WoodSlots {
|
||||||
public static final MaterialSlot<WoodenComplexMaterial> DOOR = new Door();
|
public static final MaterialSlot<WoodenComplexMaterial> DOOR = new Door();
|
||||||
public static final MaterialSlot<WoodenComplexMaterial> LADDER = new Ladder();
|
public static final MaterialSlot<WoodenComplexMaterial> LADDER = new Ladder();
|
||||||
public static final Sign SIGN = new Sign();
|
public static final Sign SIGN = new Sign();
|
||||||
|
public static final HangingSign HANGING_SIGN = new HangingSign();
|
||||||
public static final MaterialSlot<WoodenComplexMaterial> CHEST = new Chest();
|
public static final MaterialSlot<WoodenComplexMaterial> CHEST = new Chest();
|
||||||
public static final MaterialSlot<WoodenComplexMaterial> BARREL = new Barrel();
|
public static final MaterialSlot<WoodenComplexMaterial> BARREL = new Barrel();
|
||||||
public static final MaterialSlot<WoodenComplexMaterial> CRAFTING_TABLE = new CraftingTable();
|
public static final MaterialSlot<WoodenComplexMaterial> CRAFTING_TABLE = new CraftingTable();
|
||||||
|
@ -28,6 +29,7 @@ public class WoodSlots {
|
||||||
public static final MaterialSlot<WoodenComplexMaterial> CHEST_BOAT = new ChestBoat();
|
public static final MaterialSlot<WoodenComplexMaterial> CHEST_BOAT = new ChestBoat();
|
||||||
|
|
||||||
public static final String WALL_SIGN = Sign.WALL_SUFFFIX;
|
public static final String WALL_SIGN = Sign.WALL_SUFFFIX;
|
||||||
|
public static final String WALL_HANGING_SIGN = HangingSign.WALL_SUFFFIX;
|
||||||
public static final String SAPLING = AbstractSaplingSlot.SAPLING_SUFFIX;
|
public static final String SAPLING = AbstractSaplingSlot.SAPLING_SUFFIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package org.betterx.bclib.mixin.common.signs;
|
package org.betterx.bclib.mixin.common.signs;
|
||||||
|
|
||||||
import org.betterx.bclib.blocks.BaseSignBlock;
|
import org.betterx.bclib.blocks.signs.BaseHangingSignBlock;
|
||||||
import org.betterx.bclib.blocks.BaseWallSignBlock;
|
import org.betterx.bclib.blocks.signs.BaseSignBlock;
|
||||||
|
import org.betterx.bclib.blocks.signs.BaseWallHangingSignBlock;
|
||||||
|
import org.betterx.bclib.blocks.signs.BaseWallSignBlock;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
|
@ -22,6 +24,11 @@ public class BlockEntityTypeMixin {
|
||||||
if ((block instanceof BaseSignBlock) || (block instanceof BaseWallSignBlock)) {
|
if ((block instanceof BaseSignBlock) || (block instanceof BaseWallSignBlock)) {
|
||||||
cir.setReturnValue(true);
|
cir.setReturnValue(true);
|
||||||
}
|
}
|
||||||
|
} else if (self == BlockEntityType.HANGING_SIGN) {
|
||||||
|
final Block block = blockState.getBlock();
|
||||||
|
if ((block instanceof BaseHangingSignBlock) || (block instanceof BaseWallHangingSignBlock)) {
|
||||||
|
cir.setReturnValue(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import org.betterx.bclib.blockentities.DynamicBlockEntityType.BlockEntitySupplie
|
||||||
import org.betterx.bclib.blocks.BaseBarrelBlock;
|
import org.betterx.bclib.blocks.BaseBarrelBlock;
|
||||||
import org.betterx.bclib.blocks.BaseChestBlock;
|
import org.betterx.bclib.blocks.BaseChestBlock;
|
||||||
import org.betterx.bclib.blocks.BaseFurnaceBlock;
|
import org.betterx.bclib.blocks.BaseFurnaceBlock;
|
||||||
import org.betterx.bclib.blocks.BaseSignBlock;
|
import org.betterx.bclib.blocks.signs.BaseSignBlock;
|
||||||
|
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue