Barrel and Leaves patterns

This commit is contained in:
Aleksey 2020-10-14 15:15:27 +03:00
parent 6c74d8c364
commit 10322fda16
13 changed files with 123 additions and 91 deletions

View file

@ -1,5 +1,6 @@
package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.List;
import java.util.Random;
@ -18,14 +19,17 @@ import net.minecraft.server.world.ServerWorld;
import net.minecraft.stat.Stats;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import ru.betterend.blocks.entities.EBarrelBlockEntity;
import ru.betterend.interfaces.Patterned;
import ru.betterend.registry.BlockEntityRegistry;
public class BlockBarrel extends BarrelBlock {
public class BlockBarrel extends BarrelBlock implements Patterned {
public BlockBarrel(Block source) {
super(FabricBlockSettings.copyOf(source).nonOpaque());
}
@ -82,4 +86,24 @@ public class BlockBarrel extends BarrelBlock {
}
}
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
return Patterned.createJson(data, blockId, blockId.getPath());
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
if (block.contains("open")) {
return Patterned.createJson(Patterned.BARREL_MODEL_OPEN, blockId, blockId.getPath());
}
return Patterned.createJson(Patterned.BLOCK_BOTTOM_TOP_MODEL, blockId, blockId.getPath());
}
@Override
public Identifier statePatternId() {
return Patterned.BARREL_STATES_PATTERN;
}
}

View file

@ -1,11 +1,16 @@
package ru.betterend.blocks.basis;
import java.io.Reader;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Blocks;
import net.minecraft.block.LeavesBlock;
import net.minecraft.block.MaterialColor;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import ru.betterend.interfaces.Patterned;
public class BlockLeaves extends LeavesBlock {
public class BlockLeaves extends LeavesBlock implements Patterned {
public BlockLeaves(MaterialColor color) {
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES).materialColor(color));
}
@ -13,4 +18,21 @@ public class BlockLeaves extends LeavesBlock {
public BlockLeaves(MaterialColor color, int light) {
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES).materialColor(color).lightLevel(light));
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
return Patterned.createJson(data, blockId, blockId.getPath());
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
return Patterned.createJson(Patterned.BASE_BLOCK_MODEL, blockId, blockId.getPath());
}
@Override
public Identifier statePatternId() {
return Patterned.BLOCK_STATES_PATTERN;
}
}

View file

@ -29,11 +29,13 @@ public interface Patterned {
public final static Identifier GATE_STATES_PATTERN = BetterEnd.makeID("patterns/blockstate/pattern_fence_gate.json");
public final static Identifier TRAPDOOR_STATES_PATTERN = BetterEnd.makeID("patterns/blockstate/pattern_trapdoor.json");
public final static Identifier LADDER_STATES_PATTERN = BetterEnd.makeID("patterns/blockstate/pattern_ladder.json");
public final static Identifier BARREL_STATES_PATTERN = BetterEnd.makeID("patterns/blockstate/pattern_barrel.json");
//Models Block
public final static Identifier EMPTY_MODEL = BetterEnd.makeID("patterns/block/pattern_empty.json");
public final static Identifier BASE_BLOCK_MODEL = BetterEnd.makeID("patterns/block/pattern_block.json");
public final static Identifier SIDED_BLOCK_MODEL = BetterEnd.makeID("patterns/block/pattern_block_sided.json");
public final static Identifier BLOCK_BOTTOM_TOP_MODEL = BetterEnd.makeID("patterns/block/pattern_block_bottom_top.json");
public final static Identifier SLAB_BLOCK_MODEL = BetterEnd.makeID("patterns/block/pattern_slab.json");
public final static Identifier STAIRS_MODEL = BetterEnd.makeID("patterns/block/pattern_stairs.json");
public final static Identifier STAIRS_MODEL_INNER = BetterEnd.makeID("patterns/block/pattern_inner_stairs.json");
@ -59,6 +61,7 @@ public interface Patterned {
public final static Identifier GATE_MODEL_WALL_OPEN = BetterEnd.makeID("patterns/block/pattern_wall_gate_open.json");
public final static Identifier TRAPDOOR_MODEL = BetterEnd.makeID("patterns/block/pattern_trapdoor.json");
public final static Identifier LADDER_MODEL = BetterEnd.makeID("patterns/block/pattern_ladder.json");
public final static Identifier BARREL_MODEL_OPEN = BetterEnd.makeID("patterns/block/pattern_barrel_open.json");
//Models Item
public final static Identifier WALL_ITEM_MODEL = BetterEnd.makeID("patterns/item/pattern_wall.json");

View file

@ -1,56 +0,0 @@
{
"variants": {
"facing=down,open=false": {
"model": "betterend:block/pythadendron_barrel",
"x": 180
},
"facing=down,open=true": {
"model": "betterend:block/pythadendron_barrel_open",
"x": 180
},
"facing=east,open=false": {
"model": "betterend:block/pythadendron_barrel",
"x": 90,
"y": 90
},
"facing=east,open=true": {
"model": "betterend:block/pythadendron_barrel_open",
"x": 90,
"y": 90
},
"facing=north,open=false": {
"model": "betterend:block/pythadendron_barrel",
"x": 90
},
"facing=north,open=true": {
"model": "betterend:block/pythadendron_barrel_open",
"x": 90
},
"facing=south,open=false": {
"model": "betterend:block/pythadendron_barrel",
"x": 90,
"y": 180
},
"facing=south,open=true": {
"model": "betterend:block/pythadendron_barrel_open",
"x": 90,
"y": 180
},
"facing=up,open=false": {
"model": "betterend:block/pythadendron_barrel"
},
"facing=up,open=true": {
"model": "betterend:block/pythadendron_barrel_open"
},
"facing=west,open=false": {
"model": "betterend:block/pythadendron_barrel",
"x": 90,
"y": 270
},
"facing=west,open=true": {
"model": "betterend:block/pythadendron_barrel_open",
"x": 90,
"y": 270
}
}
}

View file

@ -1,5 +0,0 @@
{
"variants": {
"": { "model": "betterend:block/pythadendron_leaves" }
}
}

View file

@ -1,8 +0,0 @@
{
"parent": "minecraft:block/cube_bottom_top",
"textures": {
"bottom": "betterend:block/pythadendron_barrel_bottom",
"side": "betterend:block/pythadendron_barrel_side",
"top": "betterend:block/pythadendron_barrel_top"
}
}

View file

@ -1,8 +0,0 @@
{
"parent": "minecraft:block/cube_bottom_top",
"textures": {
"bottom": "betterend:block/pythadendron_barrel_bottom",
"side": "betterend:block/pythadendron_barrel_side",
"top": "betterend:block/pythadendron_barrel_top_open"
}
}

View file

@ -1,6 +0,0 @@
{
"parent": "block/cube_all",
"textures": {
"all": "betterend:block/pythadendron_leaves"
}
}

View file

@ -1,3 +0,0 @@
{
"parent": "betterend:block/pythadendron_barrel"
}

View file

@ -1,3 +0,0 @@
{
"parent": "betterend:block/pythadendron_leaves"
}

View file

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/cube_bottom_top",
"textures": {
"bottom": "betterend:block/%block%_bottom",
"side": "betterend:block/%block%_side",
"top": "betterend:block/%block%_top_open"
}
}

View file

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/cube_bottom_top",
"textures": {
"bottom": "betterend:block/%block%_bottom",
"side": "betterend:block/%block%_side",
"top": "betterend:block/%block%_top"
}
}

View file

@ -0,0 +1,56 @@
{
"variants": {
"facing=down,open=false": {
"model": "betterend:pattern/%block%",
"x": 180
},
"facing=down,open=true": {
"model": "betterend:pattern/%block%/%block%_open",
"x": 180
},
"facing=east,open=false": {
"model": "betterend:pattern/%block%",
"x": 90,
"y": 90
},
"facing=east,open=true": {
"model": "betterend:pattern/%block%/%block%_open",
"x": 90,
"y": 90
},
"facing=north,open=false": {
"model": "betterend:pattern/%block%",
"x": 90
},
"facing=north,open=true": {
"model": "betterend:pattern/%block%/%block%_open",
"x": 90
},
"facing=south,open=false": {
"model": "betterend:pattern/%block%",
"x": 90,
"y": 180
},
"facing=south,open=true": {
"model": "betterend:pattern/%block%/%block%_open",
"x": 90,
"y": 180
},
"facing=up,open=false": {
"model": "betterend:pattern/%block%"
},
"facing=up,open=true": {
"model": "betterend:pattern/%block%/%block%_open"
},
"facing=west,open=false": {
"model": "betterend:pattern/%block%",
"x": 90,
"y": 270
},
"facing=west,open=true": {
"model": "betterend:pattern/%block%/%block%_open",
"x": 90,
"y": 270
}
}
}