Colored lanterns
This commit is contained in:
parent
6564429aa1
commit
3399253010
31 changed files with 378 additions and 7 deletions
|
@ -30,7 +30,7 @@ public class BlockBulbVineLantern extends BlockBaseNotFull implements IRenderTyp
|
|||
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
|
||||
|
||||
public BlockBulbVineLantern() {
|
||||
super(FabricBlockSettings.of(Material.METAL)
|
||||
this(FabricBlockSettings.of(Material.METAL)
|
||||
.sounds(BlockSoundGroup.LANTERN)
|
||||
.hardness(1)
|
||||
.resistance(1)
|
||||
|
@ -40,6 +40,10 @@ public class BlockBulbVineLantern extends BlockBaseNotFull implements IRenderTyp
|
|||
.luminance(15));
|
||||
}
|
||||
|
||||
public BlockBulbVineLantern(FabricBlockSettings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
||||
stateManager.add(WATERLOGGED);
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.color.block.BlockColorProvider;
|
||||
import net.minecraft.client.color.item.ItemColorProvider;
|
||||
import net.minecraft.util.Identifier;
|
||||
import ru.betterend.interfaces.IColorProvider;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
|
||||
public class BlockBulbVineLanternColored extends BlockBulbVineLantern implements IColorProvider, BlockPatterned {
|
||||
private final BlockColorProvider blockProvider;
|
||||
private final ItemColorProvider itemProvider;
|
||||
|
||||
public BlockBulbVineLanternColored(FabricBlockSettings settings) {
|
||||
super(settings);
|
||||
|
||||
blockProvider = (state, world, pos, tintIndex) -> {
|
||||
return this.getDefaultMaterialColor().color;
|
||||
};
|
||||
|
||||
itemProvider = (stack, tintIndex) -> {
|
||||
return this.getDefaultMaterialColor().color;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockColorProvider getProvider() {
|
||||
return blockProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemColorProvider getItemProvider() {
|
||||
return itemProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String path = "betterend:block/bulb_lantern_colored";
|
||||
return Patterns.createJson(data, path, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
return Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_COLORED, "", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier statePatternId() {
|
||||
return Patterns.STATE_DIRECT;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package ru.betterend.blocks.complex;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.DyeItem;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import ru.betterend.recipe.builders.GridRecipe;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
||||
public class ColoredMaterial {
|
||||
private final Map<DyeColor, Block> colors = Maps.newEnumMap(DyeColor.class);
|
||||
|
||||
public ColoredMaterial(Function<FabricBlockSettings, Block> constructor, Block source) {
|
||||
String id = Registry.BLOCK.getId(source).getPath();
|
||||
for (DyeColor color: DyeColor.values()) {
|
||||
Block block = constructor.apply(FabricBlockSettings.copyOf(source).materialColor(color));
|
||||
String blockName = id + "_" + color.getName();
|
||||
EndBlocks.registerBlock(blockName, block);
|
||||
GridRecipe.make(blockName, block).setList("#D").addMaterial('#', source).addMaterial('D', DyeItem.byColor(color)).build();
|
||||
colors.put(color, block);
|
||||
}
|
||||
}
|
||||
|
||||
public Block getByColor(DyeColor color) {
|
||||
return colors.get(color);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue