Skip to content

Commit 69b2770

Browse files
committed
feat: Add builder message blocks
1 parent 703671f commit 69b2770

File tree

16 files changed

+112
-2
lines changed

16 files changed

+112
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ $RECYCLE.BIN/
103103

104104
.gradle
105105
build/
106+
src/generated
106107

107108
# Ignore Gradle GUI config
108109
gradle-app.setting
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.wanderersoftherift.botr.block;
2+
3+
import com.mojang.serialization.MapCodec;
4+
import net.minecraft.world.item.context.BlockPlaceContext;
5+
import net.minecraft.world.level.block.Block;
6+
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
7+
import net.minecraft.world.level.block.state.BlockState;
8+
import net.minecraft.world.level.block.state.StateDefinition;
9+
import org.jetbrains.annotations.NotNull;
10+
11+
public class MessageBlock extends HorizontalDirectionalBlock {
12+
public static final MapCodec<MessageBlock> CODEC = simpleCodec(MessageBlock::new);
13+
14+
public MessageBlock(Properties properties) {
15+
super(properties);
16+
}
17+
18+
@Override
19+
protected @NotNull MapCodec<? extends HorizontalDirectionalBlock> codec() {
20+
return CODEC;
21+
}
22+
23+
@Override
24+
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
25+
builder.add(FACING);
26+
}
27+
28+
@Override
29+
public BlockState getStateForPlacement(BlockPlaceContext context) {
30+
return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection());
31+
}
32+
}

src/main/java/com/wanderersoftherift/botr/datagen/BotrLanguageProvider.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.wanderersoftherift.botr.datagen;
22

33
import com.wanderersoftherift.botr.BuildersOfTheRift;
4+
import com.wanderersoftherift.botr.init.BotrBlocks;
45
import net.minecraft.core.registries.BuiltInRegistries;
56
import net.minecraft.data.PackOutput;
67
import net.minecraft.world.level.block.Block;
@@ -25,6 +26,19 @@ protected void addTranslations() {
2526
* https://docs.neoforged.net/docs/1.21.1/resources/client/i18n/ for translation of other types.
2627
*/
2728

29+
add(BotrBlocks.POI_3x3.get(), "3x3 PoI");
30+
add(BotrBlocks.POI_5x5.get(), "5x5 PoI");
31+
add(BotrBlocks.POI_7x7.get(), "7x7 PoI");
32+
add(BotrBlocks.POI_9x9.get(), "9x9 PoI");
33+
add(BotrBlocks.POI_11x11.get(), "11x11 PoI");
34+
add(BotrBlocks.POI_PLACING.get(), "I'm Placing PoIs");
35+
add(BotrBlocks.POI_HELP.get(), "Help with PoIs");
36+
add(BotrBlocks.FEEDBACK.get(), "Seeking Feedback");
37+
add(BotrBlocks.NOT_READY.get(), "Not Ready");
38+
add(BotrBlocks.READY.get(), "Ready");
39+
40+
add("itemGroup." + BuildersOfTheRift.MODID, "Builders of the Rift");
41+
2842
}
2943

3044
private static @NotNull String getTranslationString(Block block) {

src/main/java/com/wanderersoftherift/botr/datagen/BotrModelProvider.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package com.wanderersoftherift.botr.datagen;
22

33
import com.wanderersoftherift.botr.BuildersOfTheRift;
4+
import com.wanderersoftherift.botr.init.BotrBlocks;
45
import net.minecraft.client.data.models.BlockModelGenerators;
56
import net.minecraft.client.data.models.ItemModelGenerators;
67
import net.minecraft.client.data.models.ModelProvider;
8+
import net.minecraft.client.data.models.model.TextureSlot;
9+
import net.minecraft.client.data.models.model.TexturedModel;
710
import net.minecraft.data.PackOutput;
11+
import net.minecraft.resources.ResourceLocation;
812
import org.jetbrains.annotations.NotNull;
913

1014
public class BotrModelProvider extends ModelProvider {
@@ -14,7 +18,34 @@ public BotrModelProvider(PackOutput output) {
1418

1519
@Override
1620
protected void registerModels(BlockModelGenerators blockModels, @NotNull ItemModelGenerators itemModels) {
21+
blockModels.createHorizontallyRotatedBlock(BotrBlocks.POI_3x3.get(),
22+
singleTexturedOrientableOnlyTop(modLocation("block/poi_3x3")));
23+
blockModels.createHorizontallyRotatedBlock(BotrBlocks.POI_5x5.get(),
24+
singleTexturedOrientableOnlyTop(modLocation("block/poi_5x5")));
25+
blockModels.createHorizontallyRotatedBlock(BotrBlocks.POI_7x7.get(),
26+
singleTexturedOrientableOnlyTop(modLocation("block/poi_7x7")));
27+
blockModels.createHorizontallyRotatedBlock(BotrBlocks.POI_9x9.get(),
28+
singleTexturedOrientableOnlyTop(modLocation("block/poi_9x9")));
29+
blockModels.createHorizontallyRotatedBlock(BotrBlocks.POI_11x11.get(),
30+
singleTexturedOrientableOnlyTop(modLocation("block/poi_11x11")));
31+
blockModels.createHorizontallyRotatedBlock(BotrBlocks.POI_PLACING.get(),
32+
singleTexturedOrientableOnlyTop(modLocation("block/poi_placing")));
33+
blockModels.createHorizontallyRotatedBlock(BotrBlocks.POI_HELP.get(),
34+
singleTexturedOrientableOnlyTop(modLocation("block/poi_help")));
35+
blockModels.createHorizontallyRotatedBlock(BotrBlocks.FEEDBACK.get(),
36+
singleTexturedOrientableOnlyTop(modLocation("block/feedback")));
37+
blockModels.createHorizontallyRotatedBlock(BotrBlocks.NOT_READY.get(),
38+
singleTexturedOrientableOnlyTop(modLocation("block/not_ready")));
39+
blockModels.createHorizontallyRotatedBlock(BotrBlocks.READY.get(),
40+
singleTexturedOrientableOnlyTop(modLocation("block/ready")));
41+
}
1742

43+
public TexturedModel.Provider singleTexturedOrientableOnlyTop(ResourceLocation texture) {
44+
return TexturedModel.ORIENTABLE_ONLY_TOP.updateTexture(updater -> {
45+
updater.put(TextureSlot.TOP, texture);
46+
updater.put(TextureSlot.SIDE, texture);
47+
updater.put(TextureSlot.FRONT, texture);
48+
});
1849
}
1950

2051
}

src/main/java/com/wanderersoftherift/botr/init/BotrBlocks.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.wanderersoftherift.botr.init;
22

33
import com.wanderersoftherift.botr.BuildersOfTheRift;
4+
import com.wanderersoftherift.botr.block.MessageBlock;
45
import net.minecraft.core.registries.Registries;
56
import net.minecraft.resources.ResourceKey;
67
import net.minecraft.resources.ResourceLocation;
78
import net.minecraft.world.level.block.Block;
9+
import net.minecraft.world.level.block.SoundType;
10+
import net.minecraft.world.level.block.state.BlockBehaviour;
811
import net.neoforged.neoforge.registries.DeferredBlock;
912
import net.neoforged.neoforge.registries.DeferredRegister;
1013

@@ -13,6 +16,36 @@
1316
public class BotrBlocks {
1417
public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(BuildersOfTheRift.MODID);
1518

19+
public static final DeferredBlock<Block> POI_3x3 = registerBlock("poi_3x3", () -> new MessageBlock(
20+
BlockBehaviour.Properties.of().setId(blockId("poi_3x3")).strength(0.8f).sound(SoundType.WOOL)));
21+
22+
public static final DeferredBlock<Block> POI_5x5 = registerBlock("poi_5x5", () -> new MessageBlock(
23+
BlockBehaviour.Properties.of().setId(blockId("poi_5x5")).strength(0.8f).sound(SoundType.WOOL)));
24+
25+
public static final DeferredBlock<Block> POI_7x7 = registerBlock("poi_7x7", () -> new MessageBlock(
26+
BlockBehaviour.Properties.of().setId(blockId("poi_7x7")).strength(0.8f).sound(SoundType.WOOL)));
27+
28+
public static final DeferredBlock<Block> POI_9x9 = registerBlock("poi_9x9", () -> new MessageBlock(
29+
BlockBehaviour.Properties.of().setId(blockId("poi_9x9")).strength(0.8f).sound(SoundType.WOOL)));
30+
31+
public static final DeferredBlock<Block> POI_11x11 = registerBlock("poi_11x11", () -> new MessageBlock(
32+
BlockBehaviour.Properties.of().setId(blockId("poi_11x11")).strength(0.8f).sound(SoundType.WOOL)));
33+
34+
public static final DeferredBlock<Block> FEEDBACK = registerBlock("feedback", () -> new MessageBlock(
35+
BlockBehaviour.Properties.of().setId(blockId("feedback")).strength(0.8f).sound(SoundType.WOOL)));
36+
37+
public static final DeferredBlock<Block> POI_HELP = registerBlock("poi_help", () -> new MessageBlock(
38+
BlockBehaviour.Properties.of().setId(blockId("poi_help")).strength(0.8f).sound(SoundType.WOOL)));
39+
40+
public static final DeferredBlock<Block> POI_PLACING = registerBlock("poi_placing", () -> new MessageBlock(
41+
BlockBehaviour.Properties.of().setId(blockId("poi_placing")).strength(0.8f).sound(SoundType.WOOL)));
42+
43+
public static final DeferredBlock<Block> NOT_READY = registerBlock("not_ready", () -> new MessageBlock(
44+
BlockBehaviour.Properties.of().setId(blockId("not_ready")).strength(0.8f).sound(SoundType.WOOL)));
45+
46+
public static final DeferredBlock<Block> READY = registerBlock("ready", () -> new MessageBlock(
47+
BlockBehaviour.Properties.of().setId(blockId("ready")).strength(0.8f).sound(SoundType.WOOL)));
48+
1649
private static <T extends Block> DeferredBlock<T> registerBlock(String key, Supplier<T> sup) {
1750
DeferredBlock<T> register = BLOCKS.register(key, sup);
1851
BotrItems.registerSimpleBlockItem(key, register);

src/main/java/com/wanderersoftherift/botr/init/BotrCreativeTabs.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import net.minecraft.network.chat.Component;
66
import net.minecraft.world.item.CreativeModeTab;
77
import net.minecraft.world.item.CreativeModeTabs;
8-
import net.minecraft.world.item.Items;
98
import net.neoforged.neoforge.registries.DeferredHolder;
109
import net.neoforged.neoforge.registries.DeferredRegister;
1110

@@ -18,7 +17,7 @@ public class BotrCreativeTabs {
1817
() -> CreativeModeTab.builder()
1918
.title(Component.translatable("itemGroup." + BuildersOfTheRift.MODID))
2019
.withTabsBefore(CreativeModeTabs.COMBAT)
21-
.icon(Items.IRON_SHOVEL::getDefaultInstance)
20+
.icon(() -> BotrBlocks.NOT_READY.asItem().getDefaultInstance())
2221
.displayItems((parameters, output) -> {
2322
BotrItems.BLOCK_ITEMS.forEach(item -> output.accept(item.get()));
2423
})
353 Bytes
Loading
316 Bytes
Loading
220 Bytes
Loading
230 Bytes
Loading

0 commit comments

Comments
 (0)