Small format fixes, javadocs

This commit is contained in:
paulevsGitch 2021-07-23 00:07:47 +03:00
parent 7be63c814d
commit 8dbce734d5
3 changed files with 24 additions and 27 deletions

View file

@ -19,17 +19,25 @@ import java.util.List;
import java.util.function.Consumer;
public class PostInitAPI {
private static List<Consumer<Void>> postInitFunctions = Lists.newArrayList();
private static List<Consumer<Boolean>> postInitFunctions = Lists.newArrayList();
public static void register(Consumer<Void> function) {
/**
* Register a new function which will be called after all mods are initiated. Will be called on both client and server.
* @param function {@link Consumer} with {@code boolean} parameter ({@code true} for client, {@code false} for server).
*/
public static void register(Consumer<Boolean> function) {
postInitFunctions.add(function);
}
/**
* Called in proper BCLib entry points, for internal usage only.
* @param isClient {@code boolean}, {@code true} for client, {@code false} for server.
*/
public static void postInit(boolean isClient) {
if (postInitFunctions == null) {
return;
}
postInitFunctions.forEach(function -> function.accept(null));
postInitFunctions.forEach(function -> function.accept(isClient));
Registry.BLOCK.forEach(block -> {
processBlockCommon(block);
if (isClient) {

View file

@ -35,7 +35,7 @@ import java.util.HashMap;
@Environment(EnvType.CLIENT)
public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChestBlockEntity> {
private static final HashMap<Block, RenderType[]> LAYERS = Maps.newHashMap();
private static final RenderType[] defaultLayer;
private static final RenderType[] RENDER_TYPES;
private static final int ID_NORMAL = 0;
private static final int ID_LEFT = 1;
@ -147,7 +147,7 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
}
public static VertexConsumer getConsumer(MultiBufferSource provider, Block block, ChestType chestType) {
RenderType[] layers = LAYERS.getOrDefault(block, defaultLayer);
RenderType[] layers = LAYERS.getOrDefault(block, RENDER_TYPES);
return provider.getBuffer(getChestTexture(chestType, layers));
}
@ -158,10 +158,7 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
LAYERS.put(
block,
new RenderType[] {
RenderType.entityCutout(new ResourceLocation(
modId,
"textures/entity/chest/" + path + ".png"
)),
RenderType.entityCutout(new ResourceLocation(modId, "textures/entity/chest/" + path + ".png")),
RenderType.entityCutout(new ResourceLocation(modId, "textures/entity/chest/" + path + "_left.png")),
RenderType.entityCutout(new ResourceLocation(modId, "textures/entity/chest/" + path + "_right.png"))
}
@ -169,7 +166,7 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
}
static {
defaultLayer = new RenderType[] {
RENDER_TYPES = new RenderType[] {
RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal.png")),
RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal_left.png")),
RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal_right.png"))

View file

@ -35,19 +35,16 @@ import java.util.HashMap;
import java.util.List;
public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSignBlockEntity> {
private static final HashMap<Block, RenderType> LAYERS = Maps.newHashMap();
private static final RenderType defaultLayer;
private final Font font;
private final SignRenderer.SignModel model;
private static final HashMap<Block, RenderType> RENDER_TYPES = Maps.newHashMap();
private static final int OUTLINE_RENDER_DISTANCE = Mth.square(16);
private static final RenderType RENDER_TYPE;
private final SignRenderer.SignModel model;
private final Font font;
public BaseSignBlockEntityRenderer(BlockEntityRendererProvider.Context ctx) {
super();
this.font = ctx.getFont();
//set up a default model
model = new SignRenderer.SignModel(ctx.bakeLayer(ModelLayers.createSignModelName(WoodType.OAK)));
}
@ -76,9 +73,7 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
VertexConsumer vertexConsumer = getConsumer(provider, state.getBlock());
model.root.render(matrixStack, vertexConsumer, light, overlay);
//model.stick.render(matrixStack, vertexConsumer, light, overlay);
matrixStack.popPose();
//Font textRenderer = renderer.getFont();
matrixStack.translate(0.0D, 0.3333333432674408D, 0.046666666865348816D);
matrixStack.scale(0.010416667F, -0.010416667F, 0.010416667F);
int m = signBlockEntity.getColor().getTextColor();
@ -179,19 +174,16 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
}
public static VertexConsumer getConsumer(MultiBufferSource provider, Block block) {
return provider.getBuffer(LAYERS.getOrDefault(block, defaultLayer));
return provider.getBuffer(RENDER_TYPES.getOrDefault(block, RENDER_TYPE));
}
public static void registerRenderLayer(Block block) {
ResourceLocation blockId = Registry.BLOCK.getKey(block);
RenderType layer = RenderType.entitySolid(new ResourceLocation(
blockId.getNamespace(),
"textures/entity/sign/" + blockId.getPath() + ".png"
));
LAYERS.put(block, layer);
RenderType layer = RenderType.entitySolid(new ResourceLocation(blockId.getNamespace(), "textures/entity/sign/" + blockId.getPath() + ".png"));
RENDER_TYPES.put(block, layer);
}
static {
defaultLayer = RenderType.entitySolid(new ResourceLocation("textures/entity/signs/oak.png"));
RENDER_TYPE = RenderType.entitySolid(new ResourceLocation("textures/entity/signs/oak.png"));
}
}