Flamboyant Refabricated Integration (WIP)
This commit is contained in:
parent
a2ca5fe3df
commit
b933b0e522
9 changed files with 128 additions and 17 deletions
|
@ -4,6 +4,7 @@ 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 ru.betterend.interfaces.IColorProvider;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class BulbVineLanternColoredBlock extends BulbVineLanternBlock implements IColorProvider {
|
||||
|
@ -26,7 +27,7 @@ public class BulbVineLanternColoredBlock extends BulbVineLanternBlock implements
|
|||
}
|
||||
|
||||
private int getColor() {
|
||||
int color = this.getDefaultMaterialColor().color;
|
||||
int color = BlocksHelper.getBlockColor(this);
|
||||
int b = (color & 255);
|
||||
int g = ((color >> 8) & 255);
|
||||
int r = ((color >> 16) & 255);
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.client.color.item.ItemColorProvider;
|
|||
import net.minecraft.util.Identifier;
|
||||
import ru.betterend.interfaces.IColorProvider;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements IColorProvider {
|
||||
public HydraluxPetalColoredBlock(FabricBlockSettings settings) {
|
||||
|
@ -17,14 +18,14 @@ public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements ICo
|
|||
@Override
|
||||
public BlockColorProvider getProvider() {
|
||||
return (state, world, pos, tintIndex) -> {
|
||||
return this.getDefaultMaterialColor().color;
|
||||
return BlocksHelper.getBlockColor(this);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemColorProvider getItemProvider() {
|
||||
return (stack, tintIndex) -> {
|
||||
return this.getDefaultMaterialColor().color;
|
||||
return BlocksHelper.getBlockColor(this);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -7,32 +7,54 @@ import com.google.common.collect.Maps;
|
|||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.item.DyeItem;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import ru.betterend.recipe.builders.GridRecipe;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
public class ColoredMaterial {
|
||||
private final Map<DyeColor, Block> colors = Maps.newEnumMap(DyeColor.class);
|
||||
private static final Map<Integer, ItemConvertible> DYES = Maps.newHashMap();
|
||||
private static final Map<Integer, String> COLORS = Maps.newHashMap();
|
||||
private final Map<Integer, Block> colors = Maps.newHashMap();
|
||||
|
||||
public ColoredMaterial(Function<FabricBlockSettings, Block> constructor, Block source, boolean craftEight) {
|
||||
this(constructor, source, COLORS, DYES, craftEight);
|
||||
}
|
||||
|
||||
public ColoredMaterial(Function<FabricBlockSettings, Block> constructor, Block source, Map<Integer, String> colors, Map<Integer, ItemConvertible> dyes, boolean craftEight) {
|
||||
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();
|
||||
colors.forEach((color, name) -> {
|
||||
String blockName = id + "_" + name;
|
||||
Block block = constructor.apply(FabricBlockSettings.copyOf(source).materialColor(MaterialColor.BLACK));
|
||||
EndBlocks.registerBlock(blockName, block);
|
||||
if (craftEight) {
|
||||
GridRecipe.make(blockName, block).setOutputCount(8).setShape("###", "#D#", "###").addMaterial('#', source).addMaterial('D', DyeItem.byColor(color)).build();
|
||||
GridRecipe.make(blockName, block).setOutputCount(8).setShape("###", "#D#", "###").addMaterial('#', source).addMaterial('D', dyes.get(color)).build();
|
||||
}
|
||||
else {
|
||||
GridRecipe.make(blockName, block).setList("#D").addMaterial('#', source).addMaterial('D', DyeItem.byColor(color)).build();
|
||||
GridRecipe.make(blockName, block).setList("#D").addMaterial('#', source).addMaterial('D', dyes.get(color)).build();
|
||||
}
|
||||
colors.put(color, block);
|
||||
}
|
||||
}
|
||||
this.colors.put(color, block);
|
||||
BlocksHelper.addBlockColor(block, color);
|
||||
});
|
||||
}
|
||||
|
||||
public Block getByColor(DyeColor color) {
|
||||
return colors.get(color.getMaterialColor().color);
|
||||
}
|
||||
|
||||
public Block getByColor(int color) {
|
||||
return colors.get(color);
|
||||
}
|
||||
|
||||
static {
|
||||
for (DyeColor color: DyeColor.values()) {
|
||||
int colorRGB = color.getMaterialColor().color;
|
||||
COLORS.put(colorRGB, color.getName());
|
||||
DYES.put(colorRGB, DyeItem.byColor(color));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue