Skip to content

Commit

Permalink
hanging signs
Browse files Browse the repository at this point in the history
  • Loading branch information
khjxiaogu committed Sep 12, 2024
1 parent ac78c1f commit 1569c6e
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected void addTags(Provider pProvider) {
tag(BlockTags.WALL_SIGNS).add(cp(wood + "_wall_sign"));
tag(BlockTags.FENCE_GATES).add(cp(wood + "_fence_gate"));
tag(BlockTags.UNSTABLE_BOTTOM_CENTER).add(cp(wood + "_fence_gate"));

tag(BlockTags.WALL_HANGING_SIGNS).add(cp(wood+"_hanging_sign"));
tag(CPTags.Blocks.FRUITS_GROWABLE_ON).add(cp(wood + "_leaves"));
tag(frl("fence_gates")).add(cp(wood + "_fence_gate"));
tag(frl("fence_gates/wooden")).add(cp(wood + "_fence_gate"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ protected void registerModels() {
texture("bamboo_skimmer");
texture("iron_skimmer");
texture("scraps");
texture("walnut_hanging_sign");
itemModel(CPBlocks.SILPHIUM.get().asItem(),"silphium").transforms().transform(ItemDisplayContext.GUI).scale(0.5f).rotation(0, 45, 0).translation(0, -4, 0).end().end();
/*System.out.println(new File("").getAbsolutePath());
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
import net.minecraft.core.Vec3i;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.models.model.ModelTemplates;
import net.minecraft.data.models.model.TextureMapping;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.PackType;
import net.minecraft.world.item.ItemDisplayContext;
Expand Down Expand Up @@ -197,8 +199,9 @@ protected void registerStatesAndModels() {

blockItemModel("stripped_" + wood + "_log");
blockItemModel("stripped_" + wood + "_wood");

// blockItemModel(wood+"_trapdoor","_top");
super.models().sign(wood+"_hanging_sign",modLoc("block/"+wood+"_planks"));
super.models().sign(wood+"_wall_hanging_sign",modLoc("block/"+wood+"_planks"));
// blockItemModel(wood+"_trapdoor","_top")

}
blockItemModel(Utils.getRegistryName(CPBlocks.STONE_PAN).getPath());
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/teammoeg/caupona/CPBlockEntityTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.stream.Collectors;

import com.google.common.collect.ImmutableSet;
import com.teammoeg.caupona.blocks.decoration.CPHangingSignBlockEntity;
import com.teammoeg.caupona.blocks.decoration.CPSignBlockEntity;
import com.teammoeg.caupona.blocks.dolium.CounterDoliumBlockEntity;
import com.teammoeg.caupona.blocks.foods.BowlBlockEntity;
Expand Down Expand Up @@ -65,6 +66,8 @@ public class CPBlockEntityTypes {
()->List.of(CPBlocks.BOWL,CPBlocks.LOAF_BOWL)));
public static final DeferredHolder<BlockEntityType<?>,BlockEntityType<CPSignBlockEntity>> SIGN = REGISTER.register("sign",makeTypes(CPSignBlockEntity::new,
()->CPBlocks.signs));
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<CPHangingSignBlockEntity>> HANGING_SIGN = REGISTER.register("hanging_sign",makeTypes(CPHangingSignBlockEntity::new,
()->CPBlocks.hanging_signs));
public static final DeferredHolder<BlockEntityType<?>,BlockEntityType<ChimneyPotBlockEntity>> CHIMNEY_POT = REGISTER.register("chimney_pot",makeTypes(ChimneyPotBlockEntity::new,
()->CPBlocks.chimney));
public static final DeferredHolder<BlockEntityType<?>,BlockEntityType<FumaroleVentBlockEntity>> FUMAROLE = REGISTER.register("fumarole_vent", makeType(FumaroleVentBlockEntity::new,
Expand Down
45 changes: 41 additions & 4 deletions src/main/java/com/teammoeg/caupona/CPBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@
import com.teammoeg.caupona.blocks.CPHorizontalBlock;
import com.teammoeg.caupona.blocks.decoration.BaseColumnBlock;
import com.teammoeg.caupona.blocks.decoration.CPButtonBlock;
import com.teammoeg.caupona.blocks.decoration.CPCeilingHangingSignBlock;
import com.teammoeg.caupona.blocks.decoration.CPDoorBlock;
import com.teammoeg.caupona.blocks.decoration.CPPressurePlateBlock;
import com.teammoeg.caupona.blocks.decoration.CPRoadBlock;
import com.teammoeg.caupona.blocks.decoration.CPRoadSideBlock;
import com.teammoeg.caupona.blocks.decoration.CPStandingSignBlock;
import com.teammoeg.caupona.blocks.decoration.CPTrapDoorBlock;
import com.teammoeg.caupona.blocks.decoration.CPWallHangingSignBlock;
import com.teammoeg.caupona.blocks.decoration.CPWallSignBlock;
import com.teammoeg.caupona.blocks.decoration.ChimneyFluteBlock;
import com.teammoeg.caupona.blocks.decoration.ColumnCapitalBlock;
Expand Down Expand Up @@ -72,6 +74,7 @@
import com.teammoeg.caupona.blocks.stove.KitchenStove;
import com.teammoeg.caupona.blocks.stove.KitchenStoveBlockEntity;
import com.teammoeg.caupona.item.CPBlockItem;
import com.teammoeg.caupona.item.CPHangingSignItem;
import com.teammoeg.caupona.item.CPSignItem;
import com.teammoeg.caupona.item.DishItem;
import com.teammoeg.caupona.item.LoafDishItem;
Expand All @@ -85,6 +88,7 @@
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.CeilingHangingSignBlock;
import net.minecraft.world.level.block.FenceBlock;
import net.minecraft.world.level.block.FenceGateBlock;
import net.minecraft.world.level.block.LeavesBlock;
Expand All @@ -94,13 +98,15 @@
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.StairBlock;
import net.minecraft.world.level.block.WallBlock;
import net.minecraft.world.level.block.WallHangingSignBlock;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.grower.TreeGrower;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockBehaviour.OffsetType;
import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockSetType;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.level.block.state.properties.WoodType;
import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.level.material.PushReaction;
Expand Down Expand Up @@ -131,6 +137,7 @@ public class CPBlocks {
// Block Lists for use in other registries
public static final List<DeferredHolder<Block,KitchenStove>> stoves = new ArrayList<>();
public static final List<Block> signs = new ArrayList<>();
public static final List<Block> hanging_signs = new ArrayList<>();
public static final Map<String, DeferredHolder<Block,Block>> stoneBlocks = new HashMap<>();
public static final List<Block> chimney = new ArrayList<>();
public static final List<Block> dolium = new ArrayList<>();
Expand Down Expand Up @@ -215,6 +222,7 @@ public class CPBlocks {
public static final DeferredHolder<Block,SlabBlock> LOAF=foodblock("loaf",()->new LoafBlock(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).sound(SoundType.WOOL).instabreak().noOcclusion()
.isRedstoneConductor(CPBlocks::isntSolid).isSuffocating(CPBlocks::isntSolid)
.isViewBlocking(CPBlocks::isntSolid)));

// Bulk register blocks
static {

Expand Down Expand Up @@ -324,24 +332,53 @@ private static void registerWood(String wood, WoodType wt, Supplier<TreeGrower>
() -> new CPPressurePlateBlock(BlockBehaviour.Properties.of()
.mapColor(MapColor.WOOD).noCollission().strength(0.5F).sound(SoundType.WOOD).ignitedByLava(),
WALNUT_TYPE));
CPCommonBootStrap.asCompositable(
CPCommonBootStrap.asCompositable(CPCommonBootStrap.asFlamable(
maindecoblock(wood + "_sapling", () -> new SaplingBlock(growth.get(), BlockBehaviour.Properties.of()
.mapColor(MapColor.PLANT).noCollission().randomTicks().instabreak().sound(SoundType.GRASS).ignitedByLava())),
.mapColor(MapColor.PLANT).noCollission().randomTicks().instabreak().sound(SoundType.GRASS).ignitedByLava())),5,5),
0.3F);
DeferredHolder<Block,Block> s = BLOCKS.register(wood + "_sign",
() -> new CPStandingSignBlock(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).noCollission()
.strength(1.0F).sound(SoundType.WOOD).ignitedByLava(), wt));

DeferredHolder<Block,Block> ws = BLOCKS.register(wood + "_wall_sign",
() -> new CPWallSignBlock(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).noCollission()
.strength(1.0F).sound(SoundType.WOOD).ignitedByLava(), wt));

DeferredHolder<Block,Block> hs = CPCommonBootStrap.asFlamable(BLOCKS.register(wood + "_hanging_sign",
() -> new CPCeilingHangingSignBlock(
wt,
BlockBehaviour.Properties.of()
.mapColor(MapColor.WOOD)
.forceSolidOn()
.instrument(NoteBlockInstrument.BASS)
.noCollission()
.strength(1.0F)
.ignitedByLava()
)),5,5);
DeferredHolder<Block,Block> whs = CPCommonBootStrap.asFlamable(BLOCKS.register(wood + "_wall_hanging_sign",
() -> new CPWallHangingSignBlock(
wt,
BlockBehaviour.Properties.of()
.mapColor(MapColor.WOOD)
.forceSolidOn()
.instrument(NoteBlockInstrument.BASS)
.noCollission()
.strength(1.0F)
.ignitedByLava()
)),5,5);


CPItems.ITEMS.register(wood + "_sign",
() -> new CPSignItem((new Item.Properties()).stacksTo(16), s.get(), ws.get(), TabType.DECORATION));
CPItems.ITEMS.register(wood + "_hanging_sign",
() -> new CPHangingSignItem(hs.get(), whs.get(),(new Item.Properties()).stacksTo(16), TabType.DECORATION));

CPCommonBootStrap.asFlamable(decoblock(wood + "_slab", () -> new SlabBlock(
BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).strength(2.0F, 3.0F).sound(SoundType.WOOD).ignitedByLava())),5,20);
CPCommonBootStrap.asFlamable(decoblock(wood + "_stairs", () -> new StairBlock(planks.get().defaultBlockState(),
BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).strength(2.0F, 3.0F).sound(SoundType.WOOD))),5,20);
decoblock(wood + "_trapdoor", () -> new CPTrapDoorBlock(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD)
.strength(3.0F).sound(SoundType.WOOD).noOcclusion().isValidSpawn(CPBlocks::never).ignitedByLava(), WALNUT_TYPE));
CPCommonBootStrap.asFlamable(decoblock(wood + "_trapdoor", () -> new CPTrapDoorBlock(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD)
.strength(3.0F).sound(SoundType.WOOD).noOcclusion().isValidSpawn(CPBlocks::never).ignitedByLava(), WALNUT_TYPE)),5,5);
DeferredHolder<Block,Block> sw = CPCommonBootStrap.asFlamable(decoblock("stripped_" + wood + "_wood", () -> new RotatedPillarBlock(
BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).strength(2.0F).sound(SoundType.WOOD).ignitedByLava())),5,5);
CPCommonBootStrap.asFlamable(decoblock(wood + "_wood", () -> new CPStripPillerBlock(sw,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/teammoeg/caupona/CPCommonBootStrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static <R extends ItemLike,T extends R> DeferredHolder<R,T> asCompositabl
compositables.add(Pair.of(obj, val));
return obj;
}
public static <R extends Block,T extends R> DeferredHolder<R,T> asFlamable(DeferredHolder<R,T> obj,int v1,int v2) {
public static <T extends Block> DeferredHolder<Block,T> asFlamable(DeferredHolder<Block,T> obj,int v1,int v2) {
flamables.add(Pair.of(obj, Pair.of(v1, v2)));
return obj;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.teammoeg.caupona.blocks.decoration;

import com.teammoeg.caupona.CPBlocks;

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.CeilingHangingSignBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.WoodType;

public class CPCeilingHangingSignBlock extends CeilingHangingSignBlock {

public CPCeilingHangingSignBlock(WoodType type, Properties properties) {
super(type, properties);
CPBlocks.hanging_signs.add(this);
}
@Override
public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) {
return new CPHangingSignBlockEntity(pPos, pState);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.teammoeg.caupona.blocks.decoration;

import com.teammoeg.caupona.CPBlockEntityTypes;

import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.block.entity.SignBlockEntity;
import net.minecraft.world.level.block.state.BlockState;

public class CPHangingSignBlockEntity extends SignBlockEntity {
private static final int MAX_TEXT_LINE_WIDTH = 60;
private static final int TEXT_LINE_HEIGHT = 9;
public CPHangingSignBlockEntity(BlockPos p_250603_, BlockState p_251674_) {
super(CPBlockEntityTypes.HANGING_SIGN.get(), p_250603_, p_251674_);
}

@Override
public int getTextLineHeight() {
return TEXT_LINE_HEIGHT;
}

@Override
public int getMaxTextLineWidth() {
return MAX_TEXT_LINE_WIDTH;
}

@Override
public SoundEvent getSignInteractionFailedSoundEvent() {
return SoundEvents.WAXED_HANGING_SIGN_INTERACT_FAIL;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.teammoeg.caupona.blocks.decoration;

import com.teammoeg.caupona.CPBlocks;

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.WallHangingSignBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.WoodType;

public class CPWallHangingSignBlock extends WallHangingSignBlock {

public CPWallHangingSignBlock(WoodType type, Properties properties) {
super(type, properties);
CPBlocks.hanging_signs.add(this);
}
@Override
public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) {
return new CPHangingSignBlockEntity(pPos, pState);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.client.renderer.Sheets;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.client.renderer.blockentity.HangingSignRenderer;
import net.minecraft.client.renderer.blockentity.SignRenderer;
import net.minecraft.client.renderer.entity.EntityRenderers;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -94,6 +95,7 @@ public static void onClientSetupEvent(FMLClientSetupEvent event) {
BlockEntityRenderers.register(CPBlockEntityTypes.STEW_POT.get(), StewPotRenderer::new);
BlockEntityRenderers.register(CPBlockEntityTypes.BOWL.get(), BowlRenderer::new);
BlockEntityRenderers.register(CPBlockEntityTypes.SIGN.get(), SignRenderer::new);
BlockEntityRenderers.register(CPBlockEntityTypes.HANGING_SIGN.get(), HangingSignRenderer::new);
BlockEntityRenderers.register(CPBlockEntityTypes.DOLIUM.get(), CounterDoliumRenderer::new);
BlockEntityRenderers.register(CPBlockEntityTypes.PAN.get(), PanRenderer::new);
//BlockEntityRenderers.register(CPBlockEntityTypes.BOWL.get(), LoafBowlRenderer::new);
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/com/teammoeg/caupona/item/CPHangingSignItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.teammoeg.caupona.item;

import com.teammoeg.caupona.util.CreativeTabItemHelper;
import com.teammoeg.caupona.util.ICreativeModeTabItem;
import com.teammoeg.caupona.util.TabType;

import net.minecraft.world.item.HangingSignItem;
import net.minecraft.world.level.block.Block;

public class CPHangingSignItem extends HangingSignItem implements ICreativeModeTabItem {

public CPHangingSignItem(Block block, Block wallBlock, Properties properties, TabType tab) {
super(block, wallBlock, properties);
this.tab = tab;
}

TabType tab;

@Override
public void fillItemCategory(CreativeTabItemHelper helper) {
if(helper.isType(tab))helper.accept(this);
}


}

0 comments on commit 1569c6e

Please sign in to comment.