Skip to content

Commit

Permalink
Implement potted flowers
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSpen210 committed Dec 24, 2019
1 parent 8988d58 commit 1ac9c31
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 0 deletions.
Expand Up @@ -22,6 +22,7 @@
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.DoublePlantBlock;
import net.minecraft.block.FlowerPotBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialColor;
Expand All @@ -44,6 +45,8 @@
import net.minecraftforge.registries.IForgeRegistry;
import slimeknights.mantle.pulsar.pulse.Pulse;

import java.util.function.Supplier;

@Pulse(id = InspirationsBuilding.pulseID, description = "A collection of features to improve building")
public class InspirationsBuilding extends PulseBase {
public static final String pulseID = "InspirationsBuilding";
Expand Down Expand Up @@ -80,6 +83,11 @@ public class InspirationsBuilding extends PulseBase {
public static FlowerBlock flower_paeonia;
public static FlowerBlock flower_rose;

public static FlowerPotBlock potted_cyan;
public static FlowerPotBlock potted_syringa;
public static FlowerPotBlock potted_paeonia;
public static FlowerPotBlock potted_rose;

public static EnlightenedBushBlock whiteEnlightenedBush;
public static EnlightenedBushBlock redEnlightenedBush;
public static EnlightenedBushBlock greenEnlightenedBush;
Expand Down Expand Up @@ -171,6 +179,24 @@ public void registerBlocks(Register<Block> event) {
flower_paeonia = registerBlock(r, new FlowerBlock((DoublePlantBlock) Blocks.PEONY), "paeonia");
flower_rose = registerBlock(r, new FlowerBlock((DoublePlantBlock) Blocks.ROSE_BUSH), "rose");

Supplier<FlowerPotBlock> emptyPot = () -> (FlowerPotBlock) Blocks.FLOWER_POT;
potted_cyan = registerBlock(r,
new FlowerPotBlock(emptyPot, () -> flower_cyan, Block.Properties.from(Blocks.FLOWER_POT)),
"potted_cyan"
);
potted_syringa = registerBlock(r,
new FlowerPotBlock(emptyPot, () -> flower_syringa, Block.Properties.from(Blocks.FLOWER_POT)),
"potted_syringa"
);
potted_paeonia = registerBlock(r,
new FlowerPotBlock(emptyPot, () -> flower_paeonia, Block.Properties.from(Blocks.FLOWER_POT)),
"potted_paeonia"
);
potted_rose = registerBlock(r,
new FlowerPotBlock(emptyPot, () -> flower_rose, Block.Properties.from(Blocks.FLOWER_POT)),
"potted_rose"
);

whiteEnlightenedBush = registerBlock(r, new EnlightenedBushBlock(-1), "white_enlightened_bush");
redEnlightenedBush = registerBlock(r, new EnlightenedBushBlock(0xBF0000), "red_enlightened_bush");
greenEnlightenedBush = registerBlock(r, new EnlightenedBushBlock(0x267F00), "green_enlightened_bush");
Expand Down Expand Up @@ -220,6 +246,12 @@ public void registerItems(Register<Item> event) {
registerBlockItem(r, flower_paeonia, ItemGroup.DECORATIONS);
registerBlockItem(r, flower_rose, ItemGroup.DECORATIONS);

// Register the flower items with the empty flower pot block.
((FlowerPotBlock)Blocks.FLOWER_POT).addPlant(flower_cyan.getRegistryName(), () -> potted_cyan);

This comment has been minimized.

Copy link
@KnightMiner

KnightMiner Dec 26, 2019

Owner

Check instanceof for safety and make a nice warning of not, some mod is going to registry sub this to the wrong type and the crash report will blame us

((FlowerPotBlock)Blocks.FLOWER_POT).addPlant(flower_syringa.getRegistryName(), () -> potted_syringa);
((FlowerPotBlock)Blocks.FLOWER_POT).addPlant(flower_paeonia.getRegistryName(), () -> potted_paeonia);
((FlowerPotBlock)Blocks.FLOWER_POT).addPlant(flower_rose.getRegistryName(), () -> potted_rose);

Item.Properties deco_props = new Item.Properties().group(ItemGroup.DECORATIONS);
registerBlockItem(r, new TextureBlockItem(whiteEnlightenedBush, deco_props, ItemTags.LEAVES));
registerBlockItem(r, new TextureBlockItem(redEnlightenedBush, deco_props, ItemTags.LEAVES));
Expand Down
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "inspirations:block/potted/cyan" }
}
}
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "inspirations:block/potted/paeonia" }
}
}
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "inspirations:block/potted/rose" }
}
}
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "inspirations:block/potted/syringa" }
}
}
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/flower_pot_cross",
"textures" : {
"plant": "inspirations:block/flower_cyan"
}
}
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/flower_pot_cross",
"textures" : {
"plant": "inspirations:block/flower_paeonia"
}
}
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/flower_pot_cross",
"textures" : {
"plant": "inspirations:block/flower_rose"
}
}
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/flower_pot_cross",
"textures" : {
"plant": "inspirations:block/flower_syringa"
}
}
@@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:flower_pot"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
},
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "inspirations:cyan_flower"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}
@@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:flower_pot"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
},
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "inspirations:paeonia"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}
@@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:flower_pot"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
},
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "inspirations:rose"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}
@@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:flower_pot"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
},
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "inspirations:syringa"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}
9 changes: 9 additions & 0 deletions src/main/resources/data/minecraft/tags/blocks/flowerpots.json
@@ -0,0 +1,9 @@
{
"replace": false,
"values": [
"inspirations:potted_cyan",
"inspirations:potted_paeonia",
"inspirations:potted_rose",
"inspirations:potted_syringa"
]
}

0 comments on commit 1ac9c31

Please sign in to comment.