Reformated

This commit is contained in:
Frank 2022-06-08 20:57:21 +02:00
parent 079b51e3f6
commit 852e5a6abc
385 changed files with 6924 additions and 5656 deletions

View file

@ -1,12 +1,5 @@
package org.betterx.bclib.client;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.resources.ResourceLocation;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.model.*;
import org.betterx.bclib.api.v2.ModIntegrationAPI;
import org.betterx.bclib.api.v2.PostInitAPI;
import org.betterx.bclib.api.v2.dataexchange.DataExchangeAPI;
@ -14,6 +7,13 @@ import org.betterx.bclib.client.models.CustomModelBakery;
import org.betterx.bclib.client.presets.WorldPresetsUI;
import org.betterx.bclib.registry.BaseBlockEntityRenders;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.resources.ResourceLocation;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.model.*;
import org.jetbrains.annotations.Nullable;
public class BCLibClient implements ClientModInitializer, ModelResourceProvider, ModelVariantProvider {
@ -34,14 +34,18 @@ public class BCLibClient implements ClientModInitializer, ModelResourceProvider,
}
@Override
public @Nullable UnbakedModel loadModelResource(ResourceLocation resourceId,
ModelProviderContext context) throws ModelProviderException {
public @Nullable UnbakedModel loadModelResource(
ResourceLocation resourceId,
ModelProviderContext context
) throws ModelProviderException {
return modelBakery.getBlockModel(resourceId);
}
@Override
public @Nullable UnbakedModel loadModelVariant(ModelResourceLocation modelId,
ModelProviderContext context) throws ModelProviderException {
public @Nullable UnbakedModel loadModelVariant(
ModelResourceLocation modelId,
ModelProviderContext context
) throws ModelProviderException {
return modelId.getVariant().equals("inventory")
? modelBakery.getItemModel(modelId)
: modelBakery.getBlockModel(modelId);

View file

@ -1,11 +1,12 @@
package org.betterx.bclib.client.gui.gridlayout;
import org.betterx.bclib.interfaces.TriConsumer;
import com.mojang.blaze3d.vertex.PoseStack;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import com.mojang.blaze3d.vertex.PoseStack;
import org.betterx.bclib.interfaces.TriConsumer;
import java.util.List;
import java.util.function.Function;
@ -15,11 +16,13 @@ class GridCell extends GridCellDefinition {
Function<GridTransform, Object> componentPlacer;
TriConsumer<PoseStack, GridTransform, Object> customRender;
GridCell(double width,
double height,
GridLayout.GridValueType widthType,
Function<GridTransform, Object> componentPlacer,
TriConsumer<PoseStack, GridTransform, Object> customRender) {
GridCell(
double width,
double height,
GridLayout.GridValueType widthType,
Function<GridTransform, Object> componentPlacer,
TriConsumer<PoseStack, GridTransform, Object> customRender
) {
super(width, widthType);
this.height = (float) height;
this.componentPlacer = componentPlacer;

View file

@ -12,13 +12,15 @@ import java.util.function.Consumer;
class SignalingCheckBox extends Checkbox {
private final Consumer<Boolean> onChange;
public SignalingCheckBox(int left,
int top,
int width,
int height,
Component component,
boolean checked,
Consumer<Boolean> onChange) {
public SignalingCheckBox(
int left,
int top,
int width,
int height,
Component component,
boolean checked,
Consumer<Boolean> onChange
) {
super(left, top, width, height, component, checked);
this.onChange = onChange;
if (onChange != null)
@ -40,22 +42,26 @@ public class GridCheckboxCell extends GridCell implements GridWidgetWithEnabledS
private boolean enabled;
private final float alpha;
GridCheckboxCell(Component text,
boolean checked,
float alpha,
double width,
GridLayout.GridValueType widthType,
double height) {
GridCheckboxCell(
Component text,
boolean checked,
float alpha,
double width,
GridLayout.GridValueType widthType,
double height
) {
this(text, checked, alpha, width, widthType, height, null);
}
GridCheckboxCell(Component text,
boolean checked,
float alpha,
double width,
GridLayout.GridValueType widthType,
double height,
Consumer<Boolean> onChange) {
GridCheckboxCell(
Component text,
boolean checked,
float alpha,
double width,
GridLayout.GridValueType widthType,
double height,
Consumer<Boolean> onChange
) {
super(width, height, widthType, null, null);
lastCheckbox = null;
enabled = true;

View file

@ -20,11 +20,13 @@ public class GridColumn extends GridContainer {
}
public GridRow addRow(GridLayout.VerticalAlignment align) {
GridRow row = new GridRow(1.0,
GridRow row = new GridRow(
1.0,
widthType == GridLayout.GridValueType.INHERIT
? GridLayout.GridValueType.INHERIT
: GridLayout.GridValueType.PERCENTAGE,
align);
align
);
this.cells.add(row);
return row;
}

View file

@ -1,11 +1,12 @@
package org.betterx.bclib.client.gui.gridlayout;
import org.betterx.bclib.client.gui.gridlayout.GridLayout.GridValueType;
import com.mojang.blaze3d.vertex.PoseStack;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import com.mojang.blaze3d.vertex.PoseStack;
import org.betterx.bclib.client.gui.gridlayout.GridLayout.GridValueType;
@Environment(EnvType.CLIENT)
public abstract class GridCustomRenderCell extends GridCell {

View file

@ -1,5 +1,7 @@
package org.betterx.bclib.client.gui.gridlayout;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.resources.ResourceLocation;
@ -7,30 +9,32 @@ import net.minecraft.resources.ResourceLocation;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
@Environment(EnvType.CLIENT)
public class GridImageCell extends GridCell {
GridImageCell(ResourceLocation location,
double width,
GridLayout.GridValueType widthType,
double height,
float alpha,
int uvLeft,
int uvTop,
int uvWidth,
int uvHeight,
int resourceWidth,
int resourceHeight) {
GridImageCell(
ResourceLocation location,
double width,
GridLayout.GridValueType widthType,
double height,
float alpha,
int uvLeft,
int uvTop,
int uvWidth,
int uvHeight,
int resourceWidth,
int resourceHeight
) {
super(width, height, widthType, null, (poseStack, transform, context) -> {
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, location);
RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA,
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.blendFunc(
GlStateManager.SourceFactor.SRC_ALPHA,
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA
);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, alpha);
GuiComponent.blit(poseStack,
GuiComponent.blit(
poseStack,
transform.left,
transform.top,
transform.width,
@ -40,7 +44,8 @@ public class GridImageCell extends GridCell {
uvWidth,
uvHeight,
resourceWidth,
resourceHeight);
resourceHeight
);
});
}
}

View file

@ -1,15 +1,15 @@
package org.betterx.bclib.client.gui.gridlayout;
import org.betterx.bclib.client.gui.gridlayout.GridLayout.GridValueType;
import org.betterx.bclib.interfaces.TriConsumer;
import org.betterx.bclib.util.Pair;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.components.AbstractWidget;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import com.mojang.blaze3d.vertex.PoseStack;
import org.betterx.bclib.client.gui.gridlayout.GridLayout.GridValueType;
import org.betterx.bclib.interfaces.TriConsumer;
import org.betterx.bclib.util.Pair;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Function;
@ -35,12 +35,14 @@ abstract class GridCellDefinition {
}
}
final GridElement buildElement(final int parentWidth,
final int autoWidth,
final float autoWidthSum,
int left,
final int top,
final List<GridElement> collector) {
final GridElement buildElement(
final int parentWidth,
final int autoWidth,
final float autoWidthSum,
int left,
final int top,
final List<GridElement> collector
) {
final int width = widthType == GridValueType.FILL
? (int) ((this.width / autoWidthSum) * autoWidth)
: calculateWidth(parentWidth);
@ -61,12 +63,14 @@ class GridElement extends GridTransform {
final TriConsumer<PoseStack, GridTransform, Object> customRender;
Object renderContext;
GridElement(int left,
int top,
int width,
int height,
Function<GridTransform, Object> componentPlacer,
TriConsumer<PoseStack, GridTransform, Object> customRender) {
GridElement(
int left,
int top,
int width,
int height,
Function<GridTransform, Object> componentPlacer,
TriConsumer<PoseStack, GridTransform, Object> customRender
) {
super(left, top, width, height);
this.componentPlacer = componentPlacer;
this.customRender = customRender;
@ -181,9 +185,11 @@ public class GridLayout extends GridColumn {
elements
.stream()
.filter(element -> element.customRender != null)
.forEach(element -> element.customRender.accept(poseStack,
.forEach(element -> element.customRender.accept(
poseStack,
element.transformWithPadding(sidePadding, topPadding),
element.renderContext));
element.renderContext
));
}

View file

@ -16,20 +16,24 @@ public class GridMessageCell extends GridCell {
private MultiLineLabel lastLabel;
private GridTransform lastTransform;
GridMessageCell(double width,
GridLayout.GridValueType widthType,
GridLayout.Alignment contentAlignment,
Font font,
Component text) {
GridMessageCell(
double width,
GridLayout.GridValueType widthType,
GridLayout.Alignment contentAlignment,
Font font,
Component text
) {
this(width, widthType, contentAlignment, font, text, GridLayout.COLOR_WHITE);
}
GridMessageCell(double width,
GridLayout.GridValueType widthType,
GridLayout.Alignment contentAlignment,
Font font,
Component text,
int color) {
GridMessageCell(
double width,
GridLayout.GridValueType widthType,
GridLayout.Alignment contentAlignment,
Font font,
Component text,
int color
) {
super(width, -1, widthType, null, null);
this.font = font;
this.text = text;
@ -37,11 +41,13 @@ public class GridMessageCell extends GridCell {
customRender = (poseStack, transform, context) -> {
//MultiLineLabel label = (MultiLineLabel) context;
if (contentAlignment == GridLayout.Alignment.CENTER) {
lastLabel.renderCentered(poseStack,
lastLabel.renderCentered(
poseStack,
transform.width / 2 + transform.left,
transform.top,
font.lineHeight,
color);
color
);
} else if (contentAlignment == GridLayout.Alignment.LEFT) {
lastLabel.renderLeftAligned(poseStack, transform.left, transform.top, font.lineHeight, color);
}

View file

@ -47,10 +47,12 @@ public class GridRow extends GridContainer {
return addComponent(1.0, GridLayout.GridValueType.PERCENTAGE, height, componentPlacer);
}
public GridCell addComponent(double width,
GridLayout.GridValueType widthType,
double height,
Function<GridTransform, Object> componentPlacer) {
public GridCell addComponent(
double width,
GridLayout.GridValueType widthType,
double height,
Function<GridTransform, Object> componentPlacer
) {
GridCell cell = new GridCell(width, height, widthType, componentPlacer, null);
this.cells.add(cell);
return cell;
@ -74,27 +76,33 @@ public class GridRow extends GridContainer {
return addButton(text, alpha, width, GridLayout.GridValueType.CONSTANT, height, onPress);
}
public GridCell addButton(Component text,
double width,
GridLayout.GridValueType widthType,
double height,
OnPress onPress) {
public GridCell addButton(
Component text,
double width,
GridLayout.GridValueType widthType,
double height,
OnPress onPress
) {
return addButton(text, 1.0f, width, widthType, height, onPress);
}
public GridCell addButton(Component text,
float alpha,
double width,
GridLayout.GridValueType widthType,
double height,
OnPress onPress) {
public GridCell addButton(
Component text,
float alpha,
double width,
GridLayout.GridValueType widthType,
double height,
OnPress onPress
) {
GridCell cell = new GridCell(width, height, widthType, (transform) -> {
Button customButton = new Button(transform.left,
Button customButton = new Button(
transform.left,
transform.top,
transform.width,
transform.height,
text,
onPress);
onPress
);
customButton.setAlpha(alpha);
return customButton;
}, null);
@ -107,8 +115,10 @@ public class GridRow extends GridContainer {
return addCheckbox(text, checked, width, widthType, onChange);
}
public GridCheckboxCell addCheckbox(Component text, boolean checked, double width,
GridLayout.GridValueType widthType, Consumer<Boolean> onChange) {
public GridCheckboxCell addCheckbox(
Component text, boolean checked, double width,
GridLayout.GridValueType widthType, Consumer<Boolean> onChange
) {
GridCheckboxCell cell = new GridCheckboxCell(text, checked, 1.0f, width, widthType, 20, onChange);
this.cells.add(cell);
@ -132,20 +142,24 @@ public class GridRow extends GridContainer {
return addCheckbox(text, checked, alpha, width, GridLayout.GridValueType.CONSTANT, height);
}
public GridCheckboxCell addCheckbox(Component text,
boolean checked,
double width,
GridLayout.GridValueType widthType,
int height) {
public GridCheckboxCell addCheckbox(
Component text,
boolean checked,
double width,
GridLayout.GridValueType widthType,
int height
) {
return addCheckbox(text, checked, 1.0f, width, widthType, height);
}
public GridCheckboxCell addCheckbox(Component text,
boolean checked,
float alpha,
double width,
GridLayout.GridValueType widthType,
int height) {
public GridCheckboxCell addCheckbox(
Component text,
boolean checked,
float alpha,
double width,
GridLayout.GridValueType widthType,
int height
) {
GridCheckboxCell cell = new GridCheckboxCell(text, checked, alpha, width, widthType, height);
this.cells.add(cell);
return cell;
@ -161,7 +175,8 @@ public class GridRow extends GridContainer {
}
public GridCell addImage(ResourceLocation location, float alpha, int width, int height) {
return addImage(location,
return addImage(
location,
alpha,
width,
GridLayout.GridValueType.CONSTANT,
@ -171,26 +186,32 @@ public class GridRow extends GridContainer {
width,
height,
width,
height);
height
);
}
public GridCell addImage(ResourceLocation location,
double width,
GridLayout.GridValueType widthType,
int height,
int resourceWidth,
int resourceHeight) {
public GridCell addImage(
ResourceLocation location,
double width,
GridLayout.GridValueType widthType,
int height,
int resourceWidth,
int resourceHeight
) {
return addImage(location, 1.0f, width, widthType, height, resourceWidth, resourceHeight);
}
public GridCell addImage(ResourceLocation location,
float alpha,
double width,
GridLayout.GridValueType widthType,
int height,
int resourceWidth,
int resourceHeight) {
return addImage(location,
public GridCell addImage(
ResourceLocation location,
float alpha,
double width,
GridLayout.GridValueType widthType,
int height,
int resourceWidth,
int resourceHeight
) {
return addImage(
location,
alpha,
width,
widthType,
@ -200,20 +221,24 @@ public class GridRow extends GridContainer {
resourceWidth,
resourceWidth,
resourceWidth,
resourceHeight);
resourceHeight
);
}
public GridCell addImage(ResourceLocation location,
double width,
GridLayout.GridValueType widthType,
int height,
int uvLeft,
int uvTop,
int uvWidth,
int uvHeight,
int resourceWidth,
int resourceHeight) {
return addImage(location,
public GridCell addImage(
ResourceLocation location,
double width,
GridLayout.GridValueType widthType,
int height,
int uvLeft,
int uvTop,
int uvWidth,
int uvHeight,
int resourceWidth,
int resourceHeight
) {
return addImage(
location,
1.0f,
width,
widthType,
@ -223,21 +248,25 @@ public class GridRow extends GridContainer {
uvWidth,
uvHeight,
resourceWidth,
resourceHeight);
resourceHeight
);
}
public GridCell addImage(ResourceLocation location,
float alpha,
double width,
GridLayout.GridValueType widthType,
int height,
int uvLeft,
int uvTop,
int uvWidth,
int uvHeight,
int resourceWidth,
int resourceHeight) {
GridCell cell = new GridImageCell(location,
public GridCell addImage(
ResourceLocation location,
float alpha,
double width,
GridLayout.GridValueType widthType,
int height,
int uvLeft,
int uvTop,
int uvWidth,
int uvHeight,
int resourceWidth,
int resourceHeight
) {
GridCell cell = new GridImageCell(
location,
width,
widthType,
height,
@ -247,7 +276,8 @@ public class GridRow extends GridContainer {
uvWidth,
uvHeight,
resourceWidth,
resourceHeight);
resourceHeight
);
this.cells.add(cell);
return cell;
}
@ -281,20 +311,24 @@ public class GridRow extends GridContainer {
return addMessage(text, 1.0, GridLayout.GridValueType.PERCENTAGE, font, color, contentAlignment);
}
public GridMessageCell addMessage(Component text,
double width,
GridLayout.GridValueType widthType,
Font font,
GridLayout.Alignment contentAlignment) {
public GridMessageCell addMessage(
Component text,
double width,
GridLayout.GridValueType widthType,
Font font,
GridLayout.Alignment contentAlignment
) {
return addMessage(text, width, widthType, font, GridLayout.COLOR_WHITE, contentAlignment);
}
public GridMessageCell addMessage(Component text,
double width,
GridLayout.GridValueType widthType,
Font font,
int color,
GridLayout.Alignment contentAlignment) {
public GridMessageCell addMessage(
Component text,
double width,
GridLayout.GridValueType widthType,
Font font,
int color,
GridLayout.Alignment contentAlignment
) {
GridMessageCell cell = new GridMessageCell(width, widthType, contentAlignment, font, text, color);
this.cells.add(cell);
return cell;
@ -307,46 +341,56 @@ public class GridRow extends GridContainer {
public GridStringCell addString(Component text, int color, GridScreen parent) {
final int width = parent.getWidth(text);
return this.addString(text,
return this.addString(
text,
width,
GridLayout.GridValueType.CONSTANT,
color,
GridLayout.Alignment.CENTER,
parent);
parent
);
}
public GridStringCell addString(Component text, GridLayout.Alignment contentAlignment, GridScreen parent) {
return this.addString(text, GridLayout.COLOR_WHITE, contentAlignment, parent);
}
public GridStringCell addString(Component text,
int color,
GridLayout.Alignment contentAlignment,
GridScreen parent) {
public GridStringCell addString(
Component text,
int color,
GridLayout.Alignment contentAlignment,
GridScreen parent
) {
return this.addString(text, 1.0, GridLayout.GridValueType.PERCENTAGE, color, contentAlignment, parent);
}
public GridStringCell addString(Component text,
double width,
GridLayout.GridValueType widthType,
GridLayout.Alignment contentAlignment,
GridScreen parent) {
public GridStringCell addString(
Component text,
double width,
GridLayout.GridValueType widthType,
GridLayout.Alignment contentAlignment,
GridScreen parent
) {
return addString(text, width, widthType, GridLayout.COLOR_WHITE, contentAlignment, parent);
}
public GridStringCell addString(Component text,
double width,
GridLayout.GridValueType widthType,
int color,
GridLayout.Alignment contentAlignment,
GridScreen parent) {
GridStringCell cell = new GridStringCell(width,
public GridStringCell addString(
Component text,
double width,
GridLayout.GridValueType widthType,
int color,
GridLayout.Alignment contentAlignment,
GridScreen parent
) {
GridStringCell cell = new GridStringCell(
width,
widthType,
parent.getFont().lineHeight,
contentAlignment,
parent,
text,
color);
color
);
this.cells.add(cell);
return cell;
}

View file

@ -1,5 +1,7 @@
package org.betterx.bclib.client.gui.gridlayout;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.components.Widget;
import net.minecraft.client.gui.components.events.GuiEventListener;
@ -12,9 +14,6 @@ import net.minecraft.util.Mth;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import org.jetbrains.annotations.Nullable;
@ -49,11 +48,13 @@ public abstract class GridScreen extends Screen {
this(null, title, topPadding, sidePadding, centerVertically);
}
public GridScreen(@Nullable Screen parent,
Component title,
int topPadding,
int sidePadding,
boolean centerVertically) {
public GridScreen(
@Nullable Screen parent,
Component title,
int topPadding,
int sidePadding,
boolean centerVertically
) {
super(title);
this.parent = parent;

View file

@ -10,33 +10,39 @@ import net.fabricmc.api.Environment;
public class GridStringCell extends GridCell {
private Component text;
GridStringCell(double width,
GridLayout.GridValueType widthType,
int height,
GridLayout.Alignment contentAlignment,
GridScreen parent,
Component text) {
GridStringCell(
double width,
GridLayout.GridValueType widthType,
int height,
GridLayout.Alignment contentAlignment,
GridScreen parent,
Component text
) {
this(width, widthType, height, contentAlignment, parent, text, GridLayout.COLOR_WHITE);
}
GridStringCell(double width,
GridLayout.GridValueType widthType,
int height,
GridLayout.Alignment contentAlignment,
GridScreen parent,
Component text,
int color) {
GridStringCell(
double width,
GridLayout.GridValueType widthType,
int height,
GridLayout.Alignment contentAlignment,
GridScreen parent,
Component text,
int color
) {
super(width, height, widthType, null, null);
this.text = text;
this.customRender = (poseStack, transform, context) -> {
if (contentAlignment == GridLayout.Alignment.CENTER) {
GuiComponent.drawCenteredString(poseStack,
GuiComponent.drawCenteredString(
poseStack,
parent.getFont(),
this.text,
transform.width / 2 + transform.left,
transform.top,
color);
color
);
} else if (contentAlignment == GridLayout.Alignment.LEFT) {
GuiComponent.drawString(poseStack, parent.getFont(), this.text, transform.left, transform.top, color);
}

View file

@ -1,9 +1,5 @@
package org.betterx.bclib.client.gui.modmenu;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import org.betterx.bclib.client.gui.gridlayout.*;
import org.betterx.bclib.config.ConfigKeeper;
import org.betterx.bclib.config.Configs;
@ -11,6 +7,10 @@ import org.betterx.bclib.config.NamedPathConfig;
import org.betterx.bclib.config.NamedPathConfig.ConfigTokenDescription;
import org.betterx.bclib.config.NamedPathConfig.DependendConfigToken;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
@ -50,13 +50,15 @@ public class MainScreen extends GridScreen {
if (option.leftPadding > 0) {
row.addSpacer(option.leftPadding);
}
GridCheckboxCell cb = row.addCheckbox(getComponent(config, option, "title"),
GridCheckboxCell cb = row.addCheckbox(
getComponent(config, option, "title"),
config.getRaw(option.token),
font,
(state) -> {
config.set(option.token, state);
updateEnabledState();
});
}
);
if (option.token instanceof DependendConfigToken) {
dependentWidgets.put(cb, () -> option.token.dependenciesTrue(config));

View file

@ -1,5 +1,10 @@
package org.betterx.bclib.client.gui.screens;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
import org.betterx.bclib.client.gui.gridlayout.GridRow;
import org.betterx.bclib.client.gui.gridlayout.GridScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
@ -7,11 +12,6 @@ import net.minecraft.resources.ResourceLocation;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
import org.betterx.bclib.client.gui.gridlayout.GridRow;
import org.betterx.bclib.client.gui.gridlayout.GridScreen;
import org.jetbrains.annotations.Nullable;
@Environment(EnvType.CLIENT)
@ -38,11 +38,13 @@ abstract class BCLibScreen extends GridScreen {
super(title, topPadding, sidePadding, centerVertically);
}
public BCLibScreen(@Nullable Screen parent,
Component title,
int topPadding,
int sidePadding,
boolean centerVertically) {
public BCLibScreen(
@Nullable Screen parent,
Component title,
int topPadding,
int sidePadding,
boolean centerVertically
) {
super(parent, title, topPadding, sidePadding, centerVertically);
}

View file

@ -1,6 +1,10 @@
package org.betterx.bclib.client.gui.screens;
import org.betterx.bclib.client.gui.gridlayout.GridCheckboxCell;
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
import org.betterx.bclib.client.gui.gridlayout.GridRow;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
@ -8,10 +12,6 @@ import net.minecraft.network.chat.Component;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.client.gui.gridlayout.GridCheckboxCell;
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
import org.betterx.bclib.client.gui.gridlayout.GridRow;
import org.jetbrains.annotations.Nullable;
@Environment(EnvType.CLIENT)
@ -34,18 +34,22 @@ public class ConfirmFixScreen extends BCLibScreen {
grid.addSpacerRow();
GridRow row = grid.addRow();
GridCheckboxCell backup = row.addCheckbox(Component.translatable("bclib.datafixer.backupWarning.backup"),
GridCheckboxCell backup = row.addCheckbox(
Component.translatable("bclib.datafixer.backupWarning.backup"),
true,
BUTTON_HEIGHT,
this.font);
this.font
);
grid.addSpacerRow(10);
row = grid.addRow();
GridCheckboxCell fix = row.addCheckbox(Component.translatable("bclib.datafixer.backupWarning.fix"),
GridCheckboxCell fix = row.addCheckbox(
Component.translatable("bclib.datafixer.backupWarning.fix"),
true,
BUTTON_HEIGHT,
this.font);
this.font
);
grid.addSpacerRow(20);

View file

@ -1,14 +1,14 @@
package org.betterx.bclib.client.gui.screens;
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
import org.betterx.bclib.client.gui.gridlayout.GridRow;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
import org.betterx.bclib.client.gui.gridlayout.GridRow;
@Environment(EnvType.CLIENT)
public class ConfirmRestartScreen extends BCLibScreen {

View file

@ -1,5 +1,9 @@
package org.betterx.bclib.client.gui.screens;
import org.betterx.bclib.client.gui.gridlayout.GridColumn;
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
import org.betterx.bclib.client.gui.gridlayout.GridRow;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
@ -7,10 +11,6 @@ import net.minecraft.network.chat.Component;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.client.gui.gridlayout.GridColumn;
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
import org.betterx.bclib.client.gui.gridlayout.GridRow;
@Environment(EnvType.CLIENT)
public class LevelFixErrorScreen extends BCLibScreen {
private final String[] errors;

View file

@ -1,13 +1,5 @@
package org.betterx.bclib.client.gui.screens;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.loader.api.metadata.ModEnvironment;
import org.betterx.bclib.api.v2.dataexchange.handler.autosync.HelloClient;
import org.betterx.bclib.client.gui.gridlayout.GridColumn;
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
@ -17,6 +9,14 @@ import org.betterx.bclib.util.ModUtil;
import org.betterx.bclib.util.PathUtil;
import org.betterx.bclib.util.Triple;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.loader.api.metadata.ModEnvironment;
import java.util.*;
import java.util.stream.Collectors;
@ -34,37 +34,45 @@ public class ModListScreen extends BCLibScreen {
return list;
}
public ModListScreen(Screen parent,
Component title,
Component description,
Map<String, ModUtil.ModInfo> mods,
HelloClient.IServerModMap serverInfo) {
public ModListScreen(
Screen parent,
Component title,
Component description,
Map<String, ModUtil.ModInfo> mods,
HelloClient.IServerModMap serverInfo
) {
this(parent, title, description, CommonComponents.GUI_BACK, mods, serverInfo);
}
public ModListScreen(Screen parent,
Component title,
Component description,
List<ModUtil.ModInfo> mods,
HelloClient.IServerModMap serverInfo) {
public ModListScreen(
Screen parent,
Component title,
Component description,
List<ModUtil.ModInfo> mods,
HelloClient.IServerModMap serverInfo
) {
this(parent, title, description, CommonComponents.GUI_BACK, mods, serverInfo);
}
public ModListScreen(Screen parent,
Component title,
Component description,
Component button,
Map<String, ModUtil.ModInfo> mods,
HelloClient.IServerModMap serverInfo) {
public ModListScreen(
Screen parent,
Component title,
Component description,
Component button,
Map<String, ModUtil.ModInfo> mods,
HelloClient.IServerModMap serverInfo
) {
this(parent, title, description, button, extractModList(mods), serverInfo);
}
public ModListScreen(Screen parent,
Component title,
Component description,
Component button,
List<ModUtil.ModInfo> mods,
HelloClient.IServerModMap serverInfo) {
public ModListScreen(
Screen parent,
Component title,
Component description,
Component button,
List<ModUtil.ModInfo> mods,
HelloClient.IServerModMap serverInfo
) {
super(parent, title, 10, true);
this.mods = mods;
this.serverInfo = serverInfo;
@ -96,10 +104,12 @@ public class ModListScreen extends BCLibScreen {
}
public static void addModDesc(GridColumn grid,
java.util.List<ModUtil.ModInfo> mods,
HelloClient.IServerModMap serverInfo,
GridScreen parent) {
public static void addModDesc(
GridColumn grid,
java.util.List<ModUtil.ModInfo> mods,
HelloClient.IServerModMap serverInfo,
GridScreen parent
) {
final int STATE_OK = 6;
final int STATE_SERVER_MISSING_CLIENT_MOD = 5;
final int STATE_MISSING_NOT_OFFERED = 4;
@ -128,9 +138,11 @@ public class ModListScreen extends BCLibScreen {
stateString += ", offered by server";
}
items.add(new Triple<>(modid,
items.add(new Triple<>(
modid,
nfo.canDownload() ? STATE_MISSING : STATE_MISSING_NOT_OFFERED,
stateString));
stateString
));
});
}

View file

@ -1,5 +1,11 @@
package org.betterx.bclib.client.gui.screens;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.client.gui.gridlayout.*;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.GameRenderer;
@ -7,12 +13,6 @@ import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ProgressListener;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.client.gui.gridlayout.*;
import java.util.concurrent.atomic.AtomicInteger;
import org.jetbrains.annotations.Nullable;
@ -78,7 +78,8 @@ class ProgressLogoRender extends GridCustomRenderCell {
}
if (percentage > 0 && percentage < 1.0) {
GuiComponent.fill(poseStack,
GuiComponent.fill(
poseStack,
transform.left,
yBar,
transform.left + transform.width,
@ -91,8 +92,10 @@ class ProgressLogoRender extends GridCustomRenderCell {
public class ProgressScreen extends GridScreen implements ProgressListener, AtomicProgressListener {
static final ResourceLocation BCLIB_LOGO_PIXELATED_LOCATION = new ResourceLocation(BCLib.MOD_ID,
"iconpixelated.png");
static final ResourceLocation BCLIB_LOGO_PIXELATED_LOCATION = new ResourceLocation(
BCLib.MOD_ID,
"iconpixelated.png"
);
public ProgressScreen(@Nullable Screen parent, Component title, Component description) {
super(parent, title, 20, true);
@ -155,9 +158,11 @@ public class ProgressScreen extends GridScreen implements ProgressListener, Atom
grid.addSpacerRow(20);
row = grid.addRow();
stage = row.addMessage(stageComponent != null ? stageComponent : Component.literal(""),
stage = row.addMessage(
stageComponent != null ? stageComponent : Component.literal(""),
font,
GridLayout.Alignment.CENTER);
GridLayout.Alignment.CENTER
);
}
@Override

View file

@ -1,5 +1,11 @@
package org.betterx.bclib.client.gui.screens;
import org.betterx.bclib.api.v2.dataexchange.handler.autosync.HelloClient;
import org.betterx.bclib.client.gui.gridlayout.GridCheckboxCell;
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
import org.betterx.bclib.client.gui.gridlayout.GridRow;
import org.betterx.bclib.util.ModUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
@ -7,12 +13,6 @@ import net.minecraft.network.chat.Component;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.api.v2.dataexchange.handler.autosync.HelloClient;
import org.betterx.bclib.client.gui.gridlayout.GridCheckboxCell;
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
import org.betterx.bclib.client.gui.gridlayout.GridRow;
import org.betterx.bclib.util.ModUtil;
@Environment(EnvType.CLIENT)
public class SyncFilesScreen extends BCLibScreen {
private final Component description;
@ -23,13 +23,15 @@ public class SyncFilesScreen extends BCLibScreen {
private final boolean shouldDelete;
private final HelloClient.IServerModMap serverInfo;
public SyncFilesScreen(int modFiles,
int configFiles,
int singleFiles,
int folderFiles,
int deleteFiles,
HelloClient.IServerModMap serverInfo,
Listener listener) {
public SyncFilesScreen(
int modFiles,
int configFiles,
int singleFiles,
int folderFiles,
int deleteFiles,
HelloClient.IServerModMap serverInfo,
Listener listener
) {
super(Component.translatable("title.bclib.syncfiles"));
this.serverInfo = serverInfo;
@ -55,10 +57,12 @@ public class SyncFilesScreen extends BCLibScreen {
final GridCheckboxCell mods;
row = grid.addRow();
mods = row.addCheckbox(Component.translatable("message.bclib.syncfiles.mods"),
mods = row.addCheckbox(
Component.translatable("message.bclib.syncfiles.mods"),
hasMods,
BUTTON_HEIGHT,
this.font);
this.font
);
mods.setEnabled(hasMods);
row.addSpacer();
@ -78,10 +82,12 @@ public class SyncFilesScreen extends BCLibScreen {
final GridCheckboxCell configs;
row = grid.addRow();
configs = row.addCheckbox(Component.translatable("message.bclib.syncfiles.configs"),
configs = row.addCheckbox(
Component.translatable("message.bclib.syncfiles.configs"),
hasConfigFiles,
BUTTON_HEIGHT,
this.font);
this.font
);
configs.setEnabled(hasConfigFiles);
grid.addSpacerRow();
@ -89,18 +95,22 @@ public class SyncFilesScreen extends BCLibScreen {
row = grid.addRow();
final GridCheckboxCell folder;
folder = row.addCheckbox(Component.translatable("message.bclib.syncfiles.folders"),
folder = row.addCheckbox(
Component.translatable("message.bclib.syncfiles.folders"),
hasFiles,
BUTTON_HEIGHT,
this.font);
this.font
);
folder.setEnabled(hasFiles);
row.addSpacer();
GridCheckboxCell delete;
delete = row.addCheckbox(Component.translatable("message.bclib.syncfiles.delete"),
delete = row.addCheckbox(
Component.translatable("message.bclib.syncfiles.delete"),
shouldDelete,
BUTTON_HEIGHT,
this.font);
this.font
);
delete.setEnabled(shouldDelete);

View file

@ -1,14 +1,14 @@
package org.betterx.bclib.client.gui.screens;
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
import org.betterx.bclib.client.gui.gridlayout.GridRow;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
import org.betterx.bclib.client.gui.gridlayout.GridRow;
@Environment(EnvType.CLIENT)
public class WarnBCLibVersionMismatch extends BCLibScreen {
private final Component description;

View file

@ -1,5 +1,11 @@
package org.betterx.bclib.client.gui.screens;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.generator.BCLBiomeSource;
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
import org.betterx.bclib.client.gui.gridlayout.GridCheckboxCell;
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
import net.minecraft.client.gui.screens.worldselection.WorldCreationContext;
import net.minecraft.network.chat.CommonComponents;
@ -12,12 +18,6 @@ import net.minecraft.world.level.dimension.LevelStem;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.generator.BCLBiomeSource;
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
import org.betterx.bclib.client.gui.gridlayout.GridCheckboxCell;
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
import org.jetbrains.annotations.Nullable;
@Environment(EnvType.CLIENT)
@ -70,20 +70,24 @@ public class WorldSetupScreen extends BCLibScreen {
colNether.addSpacerRow(2);
row = colNether.addRow();
row.addSpacer(20);
netherLegacy = row.addCheckbox(Component.translatable("title.screen.bclib.worldgen.legacy_square"),
netherLegacy = row.addCheckbox(
Component.translatable("title.screen.bclib.worldgen.legacy_square"),
endVersion == BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE,
1.0,
GridLayout.GridValueType.PERCENTAGE,
(state) -> {
});
bclibNether = mainSettingsRow.addCheckbox(Component.translatable(
}
);
bclibNether = mainSettingsRow.addCheckbox(
Component.translatable(
"title.screen.bclib.worldgen.custom_biome_source"),
netherVersion != BCLBiomeSource.BIOME_SOURCE_VERSION_VANILLA,
1.0,
GridLayout.GridValueType.PERCENTAGE,
(state) -> {
netherLegacy.setEnabled(state);
});
}
);
row = colEnd.addRow(GridLayout.VerticalAlignment.CENTER);
@ -96,21 +100,25 @@ public class WorldSetupScreen extends BCLibScreen {
row = colEnd.addRow();
row.addSpacer(20);
endLegacy = row.addCheckbox(Component.translatable("title.screen.bclib.worldgen.legacy_square"),
endLegacy = row.addCheckbox(
Component.translatable("title.screen.bclib.worldgen.legacy_square"),
endVersion == BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE,
1.0,
GridLayout.GridValueType.PERCENTAGE,
(state) -> {
});
}
);
bclibEnd = mainSettingsRow.addCheckbox(Component.translatable(
bclibEnd = mainSettingsRow.addCheckbox(
Component.translatable(
"title.screen.bclib.worldgen.custom_biome_source"),
endVersion != BCLBiomeSource.BIOME_SOURCE_VERSION_VANILLA,
1.0,
GridLayout.GridValueType.PERCENTAGE,
(state) -> {
endLegacy.setEnabled(state);
});
}
);
grid.addSpacerRow(36);
row = grid.addRow();

View file

@ -23,21 +23,21 @@ public class BaseChestBlockModel {
"partC",
CubeListBuilder.create().texOffs(0, 19).addBox(1.0f, 0.0f, 1.0f, 14.0f, 9.0f, 14.0f, deformation_partC),
PartPose.ZERO
);
);
CubeDeformation deformation_partA = new CubeDeformation(0.0f);
modelPartData.addOrReplaceChild(
"partA",
CubeListBuilder.create().texOffs(0, 0).addBox(1.0f, 0.0f, 0.0f, 14.0f, 5.0f, 14.0f, deformation_partA),
PartPose.offset(0.0f, 9.0f, 1.0f)
);
);
CubeDeformation deformation_partB = new CubeDeformation(0.0f);
modelPartData.addOrReplaceChild(
"partB",
CubeListBuilder.create().texOffs(0, 0).addBox(7.0f, -1.0f, 15.0f, 2.0f, 4.0f, 1.0f, deformation_partB),
PartPose.offset(0.0f, 8.0f, 0.0f)
);
);
CubeDeformation deformation_partRightC = new CubeDeformation(0.0f);
modelPartData.addOrReplaceChild(
@ -46,7 +46,7 @@ public class BaseChestBlockModel {
.texOffs(0, 19)
.addBox(1.0f, 0.0f, 1.0f, 15.0f, 9.0f, 14.0f, deformation_partRightC),
PartPose.ZERO
);
);
CubeDeformation deformation_partRightA = new CubeDeformation(0.0f);
modelPartData.addOrReplaceChild(
@ -55,7 +55,7 @@ public class BaseChestBlockModel {
.texOffs(0, 0)
.addBox(1.0f, 0.0f, 0.0f, 15.0f, 5.0f, 14.0f, deformation_partRightA),
PartPose.offset(0.0f, 9.0f, 1.0f)
);
);
CubeDeformation deformation_partRightB = new CubeDeformation(0.0f);
PartDefinition partRightB = modelPartData.addOrReplaceChild(
@ -64,7 +64,7 @@ public class BaseChestBlockModel {
.texOffs(0, 0)
.addBox(15.0f, -1.0f, 15.0f, 1.0f, 4.0f, 1.0f, deformation_partRightB),
PartPose.offset(0.0f, 8.0f, 0.0f)
);
);
CubeDeformation deformation_partLeftC = new CubeDeformation(0.0f);
modelPartData.addOrReplaceChild(
@ -73,7 +73,7 @@ public class BaseChestBlockModel {
.texOffs(0, 19)
.addBox(0.0f, 0.0f, 1.0f, 15.0f, 9.0f, 14.0f, deformation_partLeftC),
PartPose.ZERO
);
);
CubeDeformation deformation_partLeftA = new CubeDeformation(0.0f);
modelPartData.addOrReplaceChild(
@ -82,7 +82,7 @@ public class BaseChestBlockModel {
.texOffs(0, 0)
.addBox(0.0f, 0.0f, 0.0f, 15.0f, 5.0f, 14.0f, deformation_partLeftA),
PartPose.offset(0.0f, 9.0f, 1.0f)
);
);
CubeDeformation deformation_partLeftB = new CubeDeformation(0.0f);
modelPartData.addOrReplaceChild(
@ -91,7 +91,7 @@ public class BaseChestBlockModel {
.texOffs(0, 0)
.addBox(0.0f, -1.0f, 15.0f, 1.0f, 4.0f, 1.0f, deformation_partLeftB),
PartPose.offset(0.0f, 8.0f, 0.0f)
);
);
return LayerDefinition.create(modelData, 64, 64);
}

View file

@ -1,9 +1,9 @@
package org.betterx.bclib.client.models;
import net.minecraft.resources.ResourceLocation;
import org.betterx.bclib.BCLib;
import net.minecraft.resources.ResourceLocation;
public class BasePatterns {
//Block Models
public final static ResourceLocation BLOCK_EMPTY = BCLib.makeID("patterns/block/empty.json");

View file

@ -1,5 +1,11 @@
package org.betterx.bclib.client.models;
import org.betterx.bclib.api.v2.ModIntegrationAPI;
import org.betterx.bclib.client.render.EmissiveTextureInfo;
import org.betterx.bclib.interfaces.BlockModelProvider;
import org.betterx.bclib.interfaces.ItemModelProvider;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.renderer.block.BlockModelShaper;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.multipart.MultiPart;
@ -15,11 +21,6 @@ import net.minecraft.world.level.block.state.BlockState;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.mojang.datafixers.util.Pair;
import org.betterx.bclib.api.v2.ModIntegrationAPI;
import org.betterx.bclib.client.render.EmissiveTextureInfo;
import org.betterx.bclib.interfaces.BlockModelProvider;
import org.betterx.bclib.interfaces.ItemModelProvider;
import java.util.Collection;
import java.util.HashMap;
@ -34,16 +35,20 @@ public class CustomModelBakery {
}
public UnbakedModel getItemModel(ResourceLocation location) {
ResourceLocation storageID = new ResourceLocation(location.getNamespace(),
"models/item/" + location.getPath() + ".json");
ResourceLocation storageID = new ResourceLocation(
location.getNamespace(),
"models/item/" + location.getPath() + ".json"
);
return models.get(location);
}
public void loadCustomModels(ResourceManager resourceManager) {
Registry.BLOCK.stream().parallel().filter(block -> block instanceof BlockModelProvider).forEach(block -> {
ResourceLocation blockID = Registry.BLOCK.getKey(block);
ResourceLocation storageID = new ResourceLocation(blockID.getNamespace(),
"blockstates/" + blockID.getPath() + ".json");
ResourceLocation storageID = new ResourceLocation(
blockID.getNamespace(),
"blockstates/" + blockID.getPath() + ".json"
);
if (resourceManager.getResource(storageID).isEmpty()) {
addBlockModel(blockID, block);
}
@ -55,8 +60,10 @@ public class CustomModelBakery {
Registry.ITEM.stream().parallel().filter(item -> item instanceof ItemModelProvider).forEach(item -> {
ResourceLocation registryID = Registry.ITEM.getKey(item);
ResourceLocation storageID = new ResourceLocation(registryID.getNamespace(),
"models/item/" + registryID.getPath() + ".json");
ResourceLocation storageID = new ResourceLocation(
registryID.getNamespace(),
"models/item/" + registryID.getPath() + ".json"
);
if (resourceManager.getResource(storageID).isEmpty()) {
addItemModel(registryID, (ItemModelProvider) item);
}
@ -88,9 +95,11 @@ public class CustomModelBakery {
}
private void addItemModel(ResourceLocation itemID, ItemModelProvider provider) {
ModelResourceLocation modelLocation = new ModelResourceLocation(itemID.getNamespace(),
itemID.getPath(),
"inventory");
ModelResourceLocation modelLocation = new ModelResourceLocation(
itemID.getNamespace(),
itemID.getPath(),
"inventory"
);
if (models.containsKey(modelLocation)) {
return;
}

View file

@ -1,5 +1,6 @@
package org.betterx.bclib.client.models;
import com.mojang.math.Transformation;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.MultiVariant;
import net.minecraft.client.renderer.block.model.Variant;
@ -17,7 +18,6 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import com.google.common.collect.Lists;
import com.mojang.math.Transformation;
import java.util.List;
import java.util.Optional;
@ -47,9 +47,11 @@ public class ModelsHelper {
return fromPattern(pattern);
}
public static MultiVariant createMultiVariant(ResourceLocation resourceLocation,
Transformation transform,
boolean uvLock) {
public static MultiVariant createMultiVariant(
ResourceLocation resourceLocation,
Transformation transform,
boolean uvLock
) {
Variant variant = new Variant(resourceLocation, transform, uvLock, 1);
return new MultiVariant(Lists.newArrayList(variant));
}
@ -58,10 +60,12 @@ public class ModelsHelper {
return createMultiVariant(resourceLocation, Transformation.identity(), false);
}
public static MultiVariant createFacingModel(ResourceLocation resourceLocation,
Direction facing,
boolean uvLock,
boolean inverted) {
public static MultiVariant createFacingModel(
ResourceLocation resourceLocation,
Direction facing,
boolean uvLock,
boolean inverted
) {
if (inverted) {
facing = facing.getOpposite();
}
@ -90,7 +94,7 @@ public class ModelsHelper {
new Variant(resourceLocation, BlockModelRotation.X0_Y90.getRotation(), false, 1),
new Variant(resourceLocation, BlockModelRotation.X0_Y180.getRotation(), false, 1),
new Variant(resourceLocation, BlockModelRotation.X0_Y270.getRotation(), false, 1)
));
));
}
public static class MultiPartBuilder {

View file

@ -1,5 +1,11 @@
package org.betterx.bclib.client.models;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.util.BlocksHelper;
import org.betterx.bclib.util.MHelper;
import com.mojang.datafixers.util.Pair;
import com.mojang.math.Vector3f;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.ItemOverrides;
@ -18,11 +24,6 @@ import net.fabricmc.api.Environment;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.mojang.datafixers.util.Pair;
import com.mojang.math.Vector3f;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.util.BlocksHelper;
import org.betterx.bclib.util.MHelper;
import java.io.BufferedReader;
import java.io.IOException;
@ -50,12 +51,14 @@ public class OBJBlockModel implements UnbakedModel, BakedModel {
protected boolean useShading;
protected byte particleIndex;
public OBJBlockModel(ResourceLocation location,
Vector3f offset,
boolean useCulling,
boolean useShading,
byte particleIndex,
ResourceLocation... textureIDs) {
public OBJBlockModel(
ResourceLocation location,
Vector3f offset,
boolean useCulling,
boolean useShading,
byte particleIndex,
ResourceLocation... textureIDs
) {
for (Direction dir : BlocksHelper.DIRECTIONS) {
quadsUnbakedMap.put(dir, Lists.newArrayList());
quadsBakedMap.put(dir, Lists.newArrayList());
@ -83,17 +86,21 @@ public class OBJBlockModel implements UnbakedModel, BakedModel {
}
@Override
public Collection<Material> getMaterials(Function<ResourceLocation, UnbakedModel> function,
Set<Pair<String, String>> set) {
public Collection<Material> getMaterials(
Function<ResourceLocation, UnbakedModel> function,
Set<Pair<String, String>> set
) {
return materials;
}
@Nullable
@Override
public BakedModel bake(ModelBakery modelBakery,
Function<Material, TextureAtlasSprite> textureGetter,
ModelState modelState,
ResourceLocation resourceLocation) {
public BakedModel bake(
ModelBakery modelBakery,
Function<Material, TextureAtlasSprite> textureGetter,
ModelState modelState,
ResourceLocation resourceLocation
) {
for (int i = 0; i < sprites.length; i++) {
sprites[i] = textureGetter.apply(materials.get(i));
}
@ -111,9 +118,11 @@ public class OBJBlockModel implements UnbakedModel, BakedModel {
// Baked Model //
@Override
public List<BakedQuad> getQuads(@Nullable BlockState blockState,
@Nullable Direction direction,
RandomSource random) {
public List<BakedQuad> getQuads(
@Nullable BlockState blockState,
@Nullable Direction direction,
RandomSource random
) {
return direction == null ? quadsBaked : quadsBakedMap.get(direction);
}

View file

@ -1,12 +1,12 @@
package org.betterx.bclib.client.models;
import com.mojang.math.Vector3f;
import net.minecraft.resources.ResourceLocation;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import com.google.common.collect.Lists;
import com.mojang.math.Vector3f;
import java.util.List;

View file

@ -1,5 +1,8 @@
package org.betterx.bclib.client.models;
import com.mojang.math.Matrix4f;
import com.mojang.math.Vector3f;
import com.mojang.math.Vector4f;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.ModelState;
@ -8,10 +11,6 @@ import net.minecraft.core.Direction;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import com.mojang.math.Matrix4f;
import com.mojang.math.Vector3f;
import com.mojang.math.Vector4f;
@Environment(EnvType.CLIENT)
public class UnbakedQuad {
private static final Vector4f POS = new Vector4f();

View file

@ -1,5 +1,8 @@
package org.betterx.bclib.client.presets;
import org.betterx.bclib.client.gui.screens.WorldSetupScreen;
import org.betterx.bclib.presets.worldgen.BCLWorldPresets;
import net.minecraft.client.gui.screens.worldselection.PresetEditor;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.levelgen.presets.WorldPreset;
@ -7,9 +10,6 @@ import net.minecraft.world.level.levelgen.presets.WorldPreset;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.client.gui.screens.WorldSetupScreen;
import org.betterx.bclib.presets.worldgen.BCLWorldPresets;
import java.util.Optional;
@Environment(EnvType.CLIENT)

View file

@ -1,5 +1,11 @@
package org.betterx.bclib.client.render;
import org.betterx.bclib.blockentities.BaseChestBlockEntity;
import org.betterx.bclib.client.models.BaseChestBlockModel;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Vector3f;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
@ -20,13 +26,7 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import com.google.common.collect.Maps;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Vector3f;
import it.unimi.dsi.fastutil.floats.Float2FloatFunction;
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
import org.betterx.bclib.blockentities.BaseChestBlockEntity;
import org.betterx.bclib.client.models.BaseChestBlockModel;
import java.util.HashMap;
@ -46,19 +46,21 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
chestModel = new BaseChestBlockModel(BaseChestBlockModel.getTexturedModelData().bakeRoot());
}
public void render(BaseChestBlockEntity entity,
float tickDelta,
PoseStack matrices,
MultiBufferSource vertexConsumers,
int light,
int overlay) {
public void render(
BaseChestBlockEntity entity,
float tickDelta,
PoseStack matrices,
MultiBufferSource vertexConsumers,
int light,
int overlay
) {
Level world = entity.getLevel();
boolean worldExists = world != null;
BlockState blockState = worldExists ? entity.getBlockState() : Blocks.CHEST.defaultBlockState()
.setValue(
ChestBlock.FACING,
Direction.SOUTH
);
);
ChestType chestType = blockState.hasProperty(ChestBlock.TYPE)
? blockState.getValue(ChestBlock.TYPE)
: ChestType.SINGLE;
@ -102,7 +104,7 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
pitch,
blockLight,
overlay
);
);
} else {
renderParts(
matrices,
@ -113,7 +115,7 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
pitch,
blockLight,
overlay
);
);
}
} else {
renderParts(
@ -125,21 +127,23 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
pitch,
blockLight,
overlay
);
);
}
matrices.popPose();
}
}
private void renderParts(PoseStack matrices,
VertexConsumer vertices,
ModelPart modelPart,
ModelPart modelPart2,
ModelPart modelPart3,
float pitch,
int light,
int overlay) {
private void renderParts(
PoseStack matrices,
VertexConsumer vertices,
ModelPart modelPart,
ModelPart modelPart2,
ModelPart modelPart3,
float pitch,
int light,
int overlay
) {
modelPart.xRot = -(pitch * 1.5707964F);
modelPart2.xRot = modelPart.xRot;
modelPart.render(matrices, vertices, light, overlay);
@ -168,12 +172,16 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
block,
new RenderType[]{
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"))
RenderType.entityCutout(new ResourceLocation(
modId,
"textures/entity/chest/" + path + "_left.png"
)),
RenderType.entityCutout(new ResourceLocation(
modId,
"textures/entity/chest/" + path + "_right.png"
))
}
);
);
}
static {

View file

@ -1,5 +1,12 @@
package org.betterx.bclib.client.render;
import org.betterx.bclib.blockentities.BaseSignBlockEntity;
import org.betterx.bclib.blocks.BaseSignBlock;
import com.mojang.blaze3d.platform.NativeImage;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Vector3f;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.model.geom.ModelLayers;
@ -25,12 +32,6 @@ import net.minecraft.world.level.block.state.properties.WoodType;
import net.minecraft.world.phys.Vec3;
import com.google.common.collect.Maps;
import com.mojang.blaze3d.platform.NativeImage;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Vector3f;
import org.betterx.bclib.blockentities.BaseSignBlockEntity;
import org.betterx.bclib.blocks.BaseSignBlock;
import java.util.HashMap;
import java.util.List;
@ -49,12 +50,14 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
model = new SignRenderer.SignModel(ctx.bakeLayer(ModelLayers.createSignModelName(WoodType.OAK)));
}
public void render(BaseSignBlockEntity signBlockEntity,
float tickDelta,
PoseStack matrixStack,
MultiBufferSource provider,
int light,
int overlay) {
public void render(
BaseSignBlockEntity signBlockEntity,
float tickDelta,
PoseStack matrixStack,
MultiBufferSource provider,
int light,
int overlay
) {
BlockState state = signBlockEntity.getBlockState();
matrixStack.pushPose();
@ -94,7 +97,7 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
List<FormattedCharSequence> list = this.font.split(component, 90);
return list.isEmpty() ? FormattedCharSequence.EMPTY : list.get(0);
}
);
);
int drawColor;
boolean drawOutlined;
int drawLight;
@ -121,7 +124,7 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
matrixStack.last().pose(),
provider,
drawLight
);
);
} else {
this.font.drawInBatch(
formattedCharSequence,
@ -134,7 +137,7 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
false,
0,
drawLight
);
);
}
}
@ -179,8 +182,10 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
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"));
RenderType layer = RenderType.entitySolid(new ResourceLocation(
blockId.getNamespace(),
"textures/entity/sign/" + blockId.getPath() + ".png"
));
RENDER_TYPES.put(block, layer);
}

View file

@ -1,5 +1,12 @@
package org.betterx.bclib.client.render;
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
import org.betterx.bclib.config.Configs;
import org.betterx.bclib.util.BackgroundInfo;
import org.betterx.bclib.util.MHelper;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Camera;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.util.Mth;
@ -11,13 +18,6 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.material.FogType;
import com.mojang.blaze3d.systems.RenderSystem;
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
import org.betterx.bclib.config.Configs;
import org.betterx.bclib.util.BackgroundInfo;
import org.betterx.bclib.util.MHelper;
public class CustomFogRenderer {
private static final MutableBlockPos LAST_POS = new MutableBlockPos(0, -100, 0);
private static final MutableBlockPos MUT_POS = new MutableBlockPos();
@ -38,10 +38,12 @@ public class CustomFogRenderer {
}
Entity entity = camera.getEntity();
if (!isForcedDimension(entity.level) && shouldIgnoreArea(entity.level,
(int) entity.getX(),
(int) entity.getEyeY(),
(int) entity.getZ())) {
if (!isForcedDimension(entity.level) && shouldIgnoreArea(
entity.level,
(int) entity.getX(),
(int) entity.getEyeY(),
(int) entity.getZ()
)) {
BackgroundInfo.fogDensity = 1;
return false;
}