Skip to content

Commit

Permalink
Make painted planks flammable, add #adorn:painted_planks
Browse files Browse the repository at this point in the history
  • Loading branch information
Juuxel committed Aug 14, 2024
1 parent 275ddc8 commit 728867b
Show file tree
Hide file tree
Showing 13 changed files with 147 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"values": [
"adorn:white_planks",
"adorn:orange_planks",
"adorn:magenta_planks",
"adorn:light_blue_planks",
"adorn:yellow_planks",
"adorn:lime_planks",
"adorn:pink_planks",
"adorn:gray_planks",
"adorn:light_gray_planks",
"adorn:cyan_planks",
"adorn:purple_planks",
"adorn:blue_planks",
"adorn:brown_planks",
"adorn:green_planks",
"adorn:red_planks",
"adorn:black_planks"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"values": [
"adorn:white_planks",
"adorn:orange_planks",
"adorn:magenta_planks",
"adorn:light_blue_planks",
"adorn:yellow_planks",
"adorn:lime_planks",
"adorn:pink_planks",
"adorn:gray_planks",
"adorn:light_gray_planks",
"adorn:cyan_planks",
"adorn:purple_planks",
"adorn:blue_planks",
"adorn:brown_planks",
"adorn:green_planks",
"adorn:red_planks",
"adorn:black_planks"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"#adorn:painted_planks"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"#adorn:painted_planks"
]
}
2 changes: 1 addition & 1 deletion common/src/main/java/juuxel/adorn/block/AdornBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public final class AdornBlocks {
DyeColor.values(),
color -> HELPER.registerBlock(
color.asString() + "_planks",
() -> new Block(BlockVariant.OAK.createSettings().mapColor(color))
() -> PlatformBridges.get().getBlockFactory().createPaintedPlanks(BlockVariant.OAK.createSettings().mapColor(color))
)
);

Expand Down
1 change: 1 addition & 0 deletions common/src/main/java/juuxel/adorn/lib/AdornTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public final class AdornTags {
public static final TagPair TABLE_LAMPS = blockAndItem("table_lamps");
public static final TagPair CANDLELIT_LANTERNS = blockAndItem("candlelit_lanterns");
public static final TagPair COPPER_PIPES = blockAndItem("copper_pipes");
public static final TagPair PAINTED_PLANKS = blockAndItem("painted_planks");
public static final TagKey<Block> COPPER_PIPES_CONNECT_TO = block("copper_pipes_connect_to");
public static final TagKey<Item> WATERING_CAN_FERTILIZERS = item("watering_can_fertilizers");

Expand Down
6 changes: 6 additions & 0 deletions common/src/main/java/juuxel/adorn/platform/BlockFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

import juuxel.adorn.block.SofaBlock;
import juuxel.adorn.block.variant.BlockVariant;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;

public interface BlockFactory {
BlockFactory DEFAULT = new BlockFactory() {};

default SofaBlock createSofa(BlockVariant variant) {
return new SofaBlock(variant);
}

default Block createPaintedPlanks(AbstractBlock.Settings settings) {
return new Block(settings);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package juuxel.adorn.data;

import juuxel.adorn.block.AdornBlocks;
import juuxel.adorn.lib.AdornTags;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.block.Block;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.BlockTags;

import java.util.concurrent.CompletableFuture;

public final class AdornBlockTagGenerator extends FabricTagProvider.BlockTagProvider {
public AdornBlockTagGenerator(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(output, registriesFuture);
}

@Override
protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) {
getOrCreateTagBuilder(AdornTags.PAINTED_PLANKS.block())
.add(AdornBlocks.PLANKS.get().values().toArray(Block[]::new));
getOrCreateTagBuilder(BlockTags.PLANKS).addTag(AdornTags.PAINTED_PLANKS.block());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
pack.addProvider(AdornBlockLootTableGenerator::new);
pack.addProvider(AdornModelGenerator::new);
pack.addProvider(AdornRecipeGenerator::new);
var blockTags = pack.addProvider(AdornBlockTagGenerator::new);
pack.addProvider((output, registriesFuture) -> new AdornItemTagGenerator(output, registriesFuture, blockTags));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package juuxel.adorn.data;

import juuxel.adorn.lib.AdornTags;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.registry.tag.ItemTags;

import java.util.concurrent.CompletableFuture;

public final class AdornItemTagGenerator extends FabricTagProvider.ItemTagProvider {
public AdornItemTagGenerator(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture, FabricTagProvider.BlockTagProvider blockTagProvider) {
super(output, registriesFuture, blockTagProvider);
}

@Override
protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) {
copy(AdornTags.PAINTED_PLANKS);
copy(BlockTags.PLANKS, ItemTags.PLANKS);
}

private void copy(AdornTags.TagPair tagPair) {
copy(tagPair.block(), tagPair.item());
}
}
3 changes: 3 additions & 0 deletions fabric/src/main/java/juuxel/adorn/lib/AdornBlocksFabric.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.fabricmc.fabric.api.registry.OxidizableBlocksRegistry;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage;
import net.minecraft.block.entity.BlockEntity;
Expand Down Expand Up @@ -51,6 +52,8 @@ public static void init() {
OxidizableBlocksRegistry.registerWaxableBlockPair(AdornBlocks.EXPOSED_COPPER_PIPE.get(), AdornBlocks.WAXED_EXPOSED_COPPER_PIPE.get());
OxidizableBlocksRegistry.registerWaxableBlockPair(AdornBlocks.WEATHERED_COPPER_PIPE.get(), AdornBlocks.WAXED_WEATHERED_COPPER_PIPE.get());
OxidizableBlocksRegistry.registerWaxableBlockPair(AdornBlocks.OXIDIZED_COPPER_PIPE.get(), AdornBlocks.WAXED_OXIDIZED_COPPER_PIPE.get());

FlammableBlockRegistry.getDefaultInstance().add(AdornTags.PAINTED_PLANKS.block(), 5, 20);
}

public static void afterRegister() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import juuxel.adorn.block.SofaBlock;
import juuxel.adorn.block.variant.BlockVariant;
import juuxel.adorn.platform.BlockFactory;
import juuxel.adorn.platform.forge.block.PaintedPlanksBlockNeo;
import juuxel.adorn.platform.forge.block.SofaBlockForge;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;

public final class BlockFactoryImpl implements BlockFactory {
public static final BlockFactoryImpl INSTANCE = new BlockFactoryImpl();
Expand All @@ -12,4 +15,9 @@ public final class BlockFactoryImpl implements BlockFactory {
public SofaBlock createSofa(BlockVariant variant) {
return new SofaBlockForge(variant);
}

@Override
public Block createPaintedPlanks(AbstractBlock.Settings settings) {
return new PaintedPlanksBlockNeo(settings);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package juuxel.adorn.platform.forge.block;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;

public final class PaintedPlanksBlockNeo extends Block {
public PaintedPlanksBlockNeo(Settings arg) {
super(arg);
}

// getFireSpreadSpeed = burnChance
// getFlammability = spreadChance

@Override
public int getFireSpreadSpeed(BlockState state, BlockView level, BlockPos pos, Direction direction) {
return 5;
}

@Override
public int getFlammability(BlockState state, BlockView level, BlockPos pos, Direction direction) {
return 20;
}
}

0 comments on commit 728867b

Please sign in to comment.