Compatibility with Plated (#47) and other similar mods
This commit is contained in:
parent
8d56a7ec7e
commit
f3fbe60ab5
6 changed files with 88 additions and 90 deletions
|
@ -2,9 +2,12 @@ package ru.betterend;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
import net.minecraft.block.SlabBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
import ru.betterend.api.BetterEndPlugin;
|
import ru.betterend.api.BetterEndPlugin;
|
||||||
import ru.betterend.config.Configs;
|
import ru.betterend.config.Configs;
|
||||||
import ru.betterend.effects.EndEnchantments;
|
import ru.betterend.effects.EndEnchantments;
|
||||||
|
@ -76,6 +79,13 @@ public class BetterEnd implements ModInitializer {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RegistryEntryAddedCallback.event(Registry.BLOCK).register((i, id, block) -> {
|
||||||
|
if (block instanceof SlabBlock) {
|
||||||
|
// Do Some Stuff
|
||||||
|
System.out.println(id);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasGuideBook() {
|
public static boolean hasGuideBook() {
|
||||||
|
|
52
src/main/java/ru/betterend/blocks/basis/EndPlateBlock.java
Normal file
52
src/main/java/ru/betterend/blocks/basis/EndPlateBlock.java
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
package ru.betterend.blocks.basis;
|
||||||
|
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.PressurePlateBlock;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.loot.context.LootContext;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import ru.betterend.patterns.BlockPatterned;
|
||||||
|
import ru.betterend.patterns.Patterns;
|
||||||
|
|
||||||
|
public class EndPlateBlock extends PressurePlateBlock implements BlockPatterned {
|
||||||
|
private final Block parent;
|
||||||
|
|
||||||
|
public EndPlateBlock(ActivationRule rule, Block source) {
|
||||||
|
super(rule, FabricBlockSettings.copyOf(source).noCollision().nonOpaque().strength(0.5F));
|
||||||
|
this.parent = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||||
|
return Collections.singletonList(new ItemStack(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getStatesPattern(Reader data) {
|
||||||
|
Identifier blockId = Registry.BLOCK.getId(this);
|
||||||
|
Identifier parentId = Registry.BLOCK.getId(parent);
|
||||||
|
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getModelPattern(String block) {
|
||||||
|
Identifier blockId = Registry.BLOCK.getId(this);
|
||||||
|
Identifier parentId = Registry.BLOCK.getId(parent);
|
||||||
|
if (block.contains("down")) {
|
||||||
|
return Patterns.createJson(Patterns.BLOCK_PLATE_DOWN, parentId.getPath(), blockId.getPath());
|
||||||
|
}
|
||||||
|
return Patterns.createJson(Patterns.BLOCK_PLATE_UP, parentId.getPath(), blockId.getPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Identifier statePatternId() {
|
||||||
|
return this.stateManager.getProperty("facing") != null ? Patterns.STATE_PLATE_ROTATED : Patterns.STATE_PLATE;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,52 +1,9 @@
|
||||||
package ru.betterend.blocks.basis;
|
package ru.betterend.blocks.basis;
|
||||||
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.PressurePlateBlock;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.loot.context.LootContext;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import net.minecraft.util.registry.Registry;
|
|
||||||
import ru.betterend.patterns.BlockPatterned;
|
|
||||||
import ru.betterend.patterns.Patterns;
|
|
||||||
|
|
||||||
public class EndStonelateBlock extends PressurePlateBlock implements BlockPatterned {
|
|
||||||
private final Block parent;
|
|
||||||
|
|
||||||
|
public class EndStonelateBlock extends EndPlateBlock {
|
||||||
public EndStonelateBlock(Block source) {
|
public EndStonelateBlock(Block source) {
|
||||||
super(ActivationRule.MOBS, FabricBlockSettings.copyOf(source).nonOpaque());
|
super(ActivationRule.MOBS, source);
|
||||||
this.parent = source;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
|
||||||
return Collections.singletonList(new ItemStack(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getStatesPattern(Reader data) {
|
|
||||||
Identifier blockId = Registry.BLOCK.getId(this);
|
|
||||||
Identifier parentId = Registry.BLOCK.getId(parent);
|
|
||||||
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getModelPattern(String block) {
|
|
||||||
Identifier blockId = Registry.BLOCK.getId(this);
|
|
||||||
Identifier parentId = Registry.BLOCK.getId(parent);
|
|
||||||
if (block.contains("down")) {
|
|
||||||
return Patterns.createJson(Patterns.BLOCK_PLATE_DOWN, parentId.getPath(), blockId.getPath());
|
|
||||||
}
|
|
||||||
return Patterns.createJson(Patterns.BLOCK_PLATE_UP, parentId.getPath(), blockId.getPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Identifier statePatternId() {
|
|
||||||
return Patterns.STATE_PLATE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,52 +1,9 @@
|
||||||
package ru.betterend.blocks.basis;
|
package ru.betterend.blocks.basis;
|
||||||
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.PressurePlateBlock;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.loot.context.LootContext;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import net.minecraft.util.registry.Registry;
|
|
||||||
import ru.betterend.patterns.BlockPatterned;
|
|
||||||
import ru.betterend.patterns.Patterns;
|
|
||||||
|
|
||||||
public class EndWoodenPlateBlock extends PressurePlateBlock implements BlockPatterned {
|
|
||||||
private final Block parent;
|
|
||||||
|
|
||||||
|
public class EndWoodenPlateBlock extends EndPlateBlock {
|
||||||
public EndWoodenPlateBlock(Block source) {
|
public EndWoodenPlateBlock(Block source) {
|
||||||
super(ActivationRule.EVERYTHING, FabricBlockSettings.copyOf(source).noCollision().nonOpaque().strength(0.5F));
|
super(ActivationRule.EVERYTHING, source);
|
||||||
this.parent = source;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
|
||||||
return Collections.singletonList(new ItemStack(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getStatesPattern(Reader data) {
|
|
||||||
Identifier blockId = Registry.BLOCK.getId(this);
|
|
||||||
Identifier parentId = Registry.BLOCK.getId(parent);
|
|
||||||
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getModelPattern(String block) {
|
|
||||||
Identifier blockId = Registry.BLOCK.getId(this);
|
|
||||||
Identifier parentId = Registry.BLOCK.getId(parent);
|
|
||||||
if (block.contains("down")) {
|
|
||||||
return Patterns.createJson(Patterns.BLOCK_PLATE_DOWN, parentId.getPath(), blockId.getPath());
|
|
||||||
}
|
|
||||||
return Patterns.createJson(Patterns.BLOCK_PLATE_UP, parentId.getPath(), blockId.getPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Identifier statePatternId() {
|
|
||||||
return Patterns.STATE_PLATE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ public class Patterns {
|
||||||
public final static Identifier STATE_BUTTON = BetterEnd.makeID("patterns/blockstate/button.json");
|
public final static Identifier STATE_BUTTON = BetterEnd.makeID("patterns/blockstate/button.json");
|
||||||
public final static Identifier STATE_PILLAR = BetterEnd.makeID("patterns/blockstate/pillar.json");
|
public final static Identifier STATE_PILLAR = BetterEnd.makeID("patterns/blockstate/pillar.json");
|
||||||
public final static Identifier STATE_PLATE = BetterEnd.makeID("patterns/blockstate/pressure_plate.json");
|
public final static Identifier STATE_PLATE = BetterEnd.makeID("patterns/blockstate/pressure_plate.json");
|
||||||
|
public final static Identifier STATE_PLATE_ROTATED = BetterEnd.makeID("patterns/blockstate/pressure_plate_rotated.json");
|
||||||
public final static Identifier STATE_DOOR = BetterEnd.makeID("patterns/blockstate/door.json");
|
public final static Identifier STATE_DOOR = BetterEnd.makeID("patterns/blockstate/door.json");
|
||||||
public final static Identifier STATE_SAPLING = BetterEnd.makeID("patterns/blockstate/sapling.json");
|
public final static Identifier STATE_SAPLING = BetterEnd.makeID("patterns/blockstate/sapling.json");
|
||||||
public final static Identifier STATE_GATE = BetterEnd.makeID("patterns/blockstate/fence_gate.json");
|
public final static Identifier STATE_GATE = BetterEnd.makeID("patterns/blockstate/fence_gate.json");
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"facing=up,powered=false": { "model": "betterend:pattern/%block%/%block%_up" },
|
||||||
|
"facing=up,powered=true": { "model": "betterend:pattern/%block%/%block%_down" },
|
||||||
|
|
||||||
|
"facing=down,powered=false": { "model": "betterend:pattern/%block%/%block%_up", "x": 180 },
|
||||||
|
"facing=down,powered=true": { "model": "betterend:pattern/%block%/%block%_down", "x": 180 },
|
||||||
|
|
||||||
|
"facing=north,powered=false": { "model": "betterend:pattern/%block%/%block%_up", "x": 90 },
|
||||||
|
"facing=north,powered=true": { "model": "betterend:pattern/%block%/%block%_down", "x": 90 },
|
||||||
|
|
||||||
|
"facing=south,powered=false": { "model": "betterend:pattern/%block%/%block%_up", "x": 90, "y": 180 },
|
||||||
|
"facing=south,powered=true": { "model": "betterend:pattern/%block%/%block%_down", "x": 90, "y": 180 },
|
||||||
|
|
||||||
|
"facing=east,powered=false": { "model": "betterend:pattern/%block%/%block%_up", "x": 90, "y": 90 },
|
||||||
|
"facing=east,powered=true": { "model": "betterend:pattern/%block%/%block%_down", "x": 90, "y": 90 },
|
||||||
|
|
||||||
|
"facing=west,powered=false": { "model": "betterend:pattern/%block%/%block%_up", "x": 90, "y": 270 },
|
||||||
|
"facing=west,powered=true": { "model": "betterend:pattern/%block%/%block%_down", "x": 90, "y": 270 }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue