1.19-pre1

This commit is contained in:
modmuss50 2022-05-18 20:20:44 +01:00
parent 05d443c51d
commit 3cb62b0291
95 changed files with 451 additions and 403 deletions

View file

@ -29,7 +29,6 @@ import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerBlockEntityEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents;
import net.fabricmc.fabric.api.event.world.WorldTickCallback;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.util.Identifier;
@ -95,7 +94,7 @@ public class RebornCore implements ModInitializer {
each game loop. SERVER and WORLD ticks only run on the server. WORLDLOAD
ticks run only on the server, and only when worlds are loaded.
*/
WorldTickCallback.EVENT.register(MultiblockRegistry::tickStart);
ServerTickEvents.START_WORLD_TICK.register(MultiblockRegistry::tickStart);
// packets
ServerBoundPackets.init();

View file

@ -25,7 +25,7 @@
package reborncore.client;
import com.mojang.blaze3d.systems.RenderSystem;
import net.fabricmc.fabric.api.client.rendereregistry.v1.LivingEntityFeatureRendererRegistrationCallback;
import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;

View file

@ -34,7 +34,6 @@ import net.minecraft.client.resource.language.I18n;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@ -59,7 +58,7 @@ public class StackToolTipHandler implements ItemTooltipCallback {
((IListInfoProvider) item).addInfo(tooltipLines, false, false);
}
else if (item instanceof RcEnergyItem energyItem) {
LiteralText line1 = new LiteralText(PowerSystem.getLocalizedPowerNoSuffix(energyItem.getStoredEnergy(itemStack)));
MutableText line1 = Text.literal(PowerSystem.getLocalizedPowerNoSuffix(energyItem.getStoredEnergy(itemStack)));
line1.append("/");
line1.append(PowerSystem.getLocalizedPower(energyItem.getEnergyCapacity()));
line1.formatted(Formatting.GOLD);
@ -76,7 +75,8 @@ public class StackToolTipHandler implements ItemTooltipCallback {
double inputRate = energyItem.getEnergyMaxInput();
double outputRate = energyItem.getEnergyMaxOutput();
LiteralText line3 = new LiteralText("");
MutableText line3 = Text.literal("");
if (inputRate != 0 && inputRate == outputRate){
line3.append(I18n.translate("techreborn.tooltip.transferRate"));
line3.append(" : ");
@ -111,7 +111,7 @@ public class StackToolTipHandler implements ItemTooltipCallback {
if (blockEntity != null) {
blockEntity.readNbt(blockEntityData);
hasData = true;
tooltipLines.add(new LiteralText(I18n.translate("reborncore.tooltip.has_data")).formatted(Formatting.DARK_GREEN));
tooltipLines.add(Text.literal(I18n.translate("reborncore.tooltip.has_data")).formatted(Formatting.DARK_GREEN));
}
}
if (blockEntity instanceof IListInfoProvider) {

View file

@ -29,7 +29,6 @@ import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import reborncore.common.util.Color;
@ -50,7 +49,7 @@ public class GuiButtonCustomTexture extends ButtonWidget {
public GuiButtonCustomTexture(int xPos, int yPos, int u, int v, int buttonWidth, int buttonHeight,
String textureName, String linkedPage, Text name, int buttonU, int buttonV, int textureH, int textureW, ButtonWidget.PressAction pressAction) {
super(xPos, yPos, buttonWidth, buttonHeight, LiteralText.EMPTY, pressAction);
super(xPos, yPos, buttonWidth, buttonHeight, Text.empty(), pressAction);
this.textureU = u;
this.textureV = v;
this.textureName = textureName;

View file

@ -30,7 +30,6 @@ import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import reborncore.common.util.Color;
@ -44,7 +43,7 @@ public class GuiButtonItemTexture extends ButtonWidget {
public GuiButtonItemTexture(int xPos, int yPos, int u, int v, int width, int height, ItemStack stack,
String linkedPage, Text name, ButtonWidget.PressAction pressAction) {
super(xPos, yPos, width, height, LiteralText.EMPTY, pressAction);
super(xPos, yPos, width, height, Text.empty(), pressAction);
textureU = u;
textureV = v;
itemstack = stack;

View file

@ -42,9 +42,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Util;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.glfw.GLFW;
@ -136,7 +134,7 @@ public class GuiBase<T extends ScreenHandler> extends HandledScreen<T> {
public boolean upgrades;
public GuiBase(PlayerEntity player, BlockEntity blockEntity, T screenHandler) {
super(screenHandler, player.getInventory(), new LiteralText(I18n.translate(blockEntity.getCachedState().getBlock().getTranslationKey())));
super(screenHandler, player.getInventory(), Text.literal(I18n.translate(blockEntity.getCachedState().getBlock().getTranslationKey())));
this.be = blockEntity;
this.builtScreenHandler = (BuiltScreenHandler) screenHandler;
selectedTab = null;
@ -266,13 +264,13 @@ public class GuiBase<T extends ScreenHandler> extends HandledScreen<T> {
if (isPointWithinBounds(-25, 6, 24, 80, mouseX, mouseY) && upgrades
&& this.focusedSlot != null && !this.focusedSlot.hasStack()) {
List<Text> list = new ArrayList<>();
list.add(new TranslatableText("reborncore.gui.tooltip.upgrades"));
list.add(Text.translatable("reborncore.gui.tooltip.upgrades"));
renderTooltip(matrixStack, list, mouseX, mouseY);
}
int offset = upgrades ? 82 : 0;
for (GuiTab tab : tabs) {
if (isPointWithinBounds(-26, 6 + offset, 24, 23, mouseX, mouseY)) {
renderTooltip(matrixStack, Collections.singletonList(new TranslatableText(tab.name())), mouseX, mouseY);
renderTooltip(matrixStack, Collections.singletonList(Text.translatable(tab.name())), mouseX, mouseY);
}
offset += 24;
}
@ -290,7 +288,7 @@ public class GuiBase<T extends ScreenHandler> extends HandledScreen<T> {
}
protected void drawTitle(MatrixStack matrixStack) {
drawCentredText(matrixStack, new TranslatableText(be.getCachedState().getBlock().getTranslationKey()), 6, 4210752, Layer.FOREGROUND);
drawCentredText(matrixStack, Text.translatable(be.getCachedState().getBlock().getTranslationKey()), 6, 4210752, Layer.FOREGROUND);
}
public void drawCentredText(MatrixStack matrixStack, Text text, int y, int colour, Layer layer) {

View file

@ -27,7 +27,7 @@ package reborncore.client.gui.builder;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.text.Text;
import reborncore.client.RenderUtil;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.blockentity.RedstoneConfiguration;
@ -53,13 +53,13 @@ public class RedstoneConfigGui {
for (RedstoneConfiguration.Element element : configuration.getElements()) {
itemRenderer.renderInGuiWithOverrides(element.getIcon(), x - 3, y + (i * spread) - 5);
guiBase.getTextRenderer().draw(matrixStack, new TranslatableText("reborncore.gui.fluidconfig." + element.getName()), x + 15, y + (i * spread), -1);
guiBase.getTextRenderer().draw(matrixStack, Text.translatable("reborncore.gui.fluidconfig." + element.getName()), x + 15, y + (i * spread), -1);
boolean hovered = withinBounds(guiBase, mouseX, mouseY, x + 92, y + (i * spread) - 2, 63, 15);
int color = hovered ? 0xFF8b8b8b : 0x668b8b8b;
RenderUtil.drawGradientRect(matrixStack, 0, x + 91, y + (i * spread) - 2, x + 93 + 65, y + (i * spread) + 10, color, color);
Text name = new TranslatableText("reborncore.gui.fluidconfig." + configuration.getState(element).name().toLowerCase(Locale.ROOT));
Text name = Text.translatable("reborncore.gui.fluidconfig." + configuration.getState(element).name().toLowerCase(Locale.ROOT));
guiBase.drawCentredText(matrixStack, name, y + (i * spread), -1, x + 37, GuiBase.Layer.FOREGROUND);
//guiBase.getTextRenderer().drawWithShadow(name, x + 92, y + (i * spread), -1);
i++;

View file

@ -28,10 +28,13 @@ import com.google.common.collect.Lists;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.network.MessageType;
import net.minecraft.screen.slot.Slot;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.Util;
import net.minecraft.util.registry.Registry;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Unique;
import reborncore.client.gui.GuiUtil;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.slot.elements.ConfigSlotElement;
@ -41,6 +44,7 @@ import reborncore.common.screen.BuiltScreenHandler;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.network.NetworkManager;
import reborncore.common.network.ServerBoundPackets;
import reborncore.common.util.ClientChatUtils;
import reborncore.common.util.Color;
import java.util.Collections;
@ -108,7 +112,7 @@ public class SlotConfigGui {
}
String json = machine.getSlotConfiguration().toJson(machine.getClass().getCanonicalName());
MinecraftClient.getInstance().keyboard.setClipboard(json);
MinecraftClient.getInstance().player.sendSystemMessage(new LiteralText("Slot configuration copied to clipboard"), Util.NIL_UUID);
ClientChatUtils.addHudMessage(Text.literal("Slot configuration copied to clipboard"));
}
public static void pasteFromClipboard() {
@ -120,9 +124,9 @@ public class SlotConfigGui {
try {
machine.getSlotConfiguration().readJson(json, machine.getClass().getCanonicalName());
NetworkManager.sendToServer(ServerBoundPackets.createPacketConfigSave(machine.getPos(), machine.getSlotConfiguration()));
MinecraftClient.getInstance().player.sendSystemMessage(new LiteralText("Slot configuration loaded from clipboard"), Util.NIL_UUID);
ClientChatUtils.addHudMessage(Text.literal("Slot configuration loaded from clipboard"));
} catch (UnsupportedOperationException e) {
MinecraftClient.getInstance().player.sendSystemMessage(new LiteralText(e.getMessage()), Util.NIL_UUID);
ClientChatUtils.addHudMessage(Text.literal(e.getMessage()));
}
}

View file

@ -25,7 +25,7 @@
package reborncore.client.gui.builder.slot.elements;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.TranslatableText;
import net.minecraft.text.Text;
import reborncore.client.gui.builder.GuiBase;
import reborncore.common.util.Tank;
@ -51,12 +51,12 @@ public class ConfigFluidElement extends ElementBase {
return true;
}));
elements.add(new CheckBoxElement(new TranslatableText("reborncore.gui.fluidconfig.pullin"), 0xFFFFFFFF, x - 26, y + 42, "input", 0, Sprite.LIGHT_CHECK_BOX, gui.getMachine(),
elements.add(new CheckBoxElement(Text.translatable("reborncore.gui.fluidconfig.pullin"), 0xFFFFFFFF, x - 26, y + 42, "input", 0, Sprite.LIGHT_CHECK_BOX, gui.getMachine(),
checkBoxElement -> checkBoxElement.machineBase.fluidConfiguration.autoInput()).addPressAction((element, gui12, provider, mouseX, mouseY) -> {
popupElement.updateCheckBox((CheckBoxElement) element, "input", gui12);
return true;
}));
elements.add(new CheckBoxElement(new TranslatableText("reborncore.gui.fluidconfig.pumpout"), 0xFFFFFFFF, x - 26, y + 57, "output", 0, Sprite.LIGHT_CHECK_BOX, gui.getMachine(),
elements.add(new CheckBoxElement(Text.translatable("reborncore.gui.fluidconfig.pumpout"), 0xFFFFFFFF, x - 26, y + 57, "output", 0, Sprite.LIGHT_CHECK_BOX, gui.getMachine(),
checkBoxElement -> checkBoxElement.machineBase.fluidConfiguration.autoOutput()).addPressAction((element, gui13, provider, mouseX, mouseY) -> {
popupElement.updateCheckBox((CheckBoxElement) element, "output", gui13);
return true;

View file

@ -31,7 +31,7 @@ import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.text.TranslatableText;
import net.minecraft.text.Text;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.slot.SlotConfigGui;
import reborncore.client.gui.slots.BaseSlot;
@ -74,14 +74,14 @@ public class ConfigSlotElement extends ElementBase {
}));
if (inputEnabled) {
elements.add(new CheckBoxElement(new TranslatableText("reborncore.gui.slotconfig.autoinput"), 0xFFFFFFFF, x - 26, y + 42, "input", slotId, Sprite.LIGHT_CHECK_BOX, gui.getMachine(),
elements.add(new CheckBoxElement(Text.translatable("reborncore.gui.slotconfig.autoinput"), 0xFFFFFFFF, x - 26, y + 42, "input", slotId, Sprite.LIGHT_CHECK_BOX, gui.getMachine(),
checkBoxElement -> checkBoxElement.machineBase.getSlotConfiguration().getSlotDetails(checkBoxElement.slotID).autoInput()).addPressAction((element, gui12, provider, mouseX, mouseY) -> {
popupElement.updateCheckBox((CheckBoxElement) element, "input", gui12);
return true;
}));
}
elements.add(new CheckBoxElement(new TranslatableText("reborncore.gui.slotconfig.autooutput"), 0xFFFFFFFF, x - 26, y + 57, "output", slotId, Sprite.LIGHT_CHECK_BOX, gui.getMachine(),
elements.add(new CheckBoxElement(Text.translatable("reborncore.gui.slotconfig.autooutput"), 0xFFFFFFFF, x - 26, y + 57, "output", slotId, Sprite.LIGHT_CHECK_BOX, gui.getMachine(),
checkBoxElement -> checkBoxElement.machineBase.getSlotConfiguration().getSlotDetails(checkBoxElement.slotID).autoOutput()).addPressAction((element, gui13, provider, mouseX, mouseY) -> {
popupElement.updateCheckBox((CheckBoxElement) element, "output", gui13);
return true;
@ -89,7 +89,7 @@ public class ConfigSlotElement extends ElementBase {
if (gui.getMachine() instanceof SlotConfiguration.SlotFilter slotFilter) {
if (Arrays.stream(slotFilter.getInputSlots()).anyMatch(value -> value == slotId)) {
elements.add(new CheckBoxElement(new TranslatableText("reborncore.gui.slotconfig.filter_input"), 0xFFFFFFFF, x - 26, y + 72, "filter", slotId, Sprite.LIGHT_CHECK_BOX, gui.getMachine(),
elements.add(new CheckBoxElement(Text.translatable("reborncore.gui.slotconfig.filter_input"), 0xFFFFFFFF, x - 26, y + 72, "filter", slotId, Sprite.LIGHT_CHECK_BOX, gui.getMachine(),
checkBoxElement -> checkBoxElement.machineBase.getSlotConfiguration().getSlotDetails(checkBoxElement.slotID).filter()).addPressAction((element, gui13, provider, mouseX, mouseY) -> {
popupElement.updateCheckBox((CheckBoxElement) element, "filter", gui13);
return true;

View file

@ -26,7 +26,7 @@ package reborncore.client.gui.builder.widget;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import reborncore.client.gui.builder.GuiBase;
/**
@ -38,7 +38,7 @@ public class GuiButtonHologram extends GuiButtonExtended {
GuiBase<?> gui;
public GuiButtonHologram(int x, int y, GuiBase<?> gui, GuiBase.Layer layer, ButtonWidget.PressAction pressAction) {
super(x, y, 20, 12, LiteralText.EMPTY, pressAction);
super(x, y, 20, 12, Text.empty(), pressAction);
this.layer = layer;
this.gui = gui;
}

View file

@ -27,7 +27,7 @@ package reborncore.client.gui.builder.widget;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import reborncore.client.gui.builder.GuiBase;
/**
@ -39,7 +39,7 @@ public class GuiButtonUpDown extends GuiButtonExtended {
UpDownButtonType type;
public GuiButtonUpDown(int x, int y, GuiBase<?> gui, ButtonWidget.PressAction pressAction, UpDownButtonType type) {
super(x, y, 12, 12, LiteralText.EMPTY, pressAction);
super(x, y, 12, 12, Text.empty(), pressAction);
this.gui = gui;
this.type = type;
}

View file

@ -42,9 +42,8 @@ import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import reborncore.api.IListInfoProvider;
@ -67,7 +66,7 @@ import java.util.stream.Collectors;
*/
public class GuiBuilder {
public static final Identifier defaultTextureSheet = new Identifier("reborncore", "textures/gui/guielements.png");
private static final Text SPACE_TEXT = new LiteralText(" ");
private static final Text SPACE_TEXT = Text.literal(" ");
static Identifier resourceLocation;
public GuiBuilder() {
@ -175,9 +174,9 @@ public class GuiBuilder {
if (gui.isPointInRect(x, y, 20, 12, mouseX, mouseY)) {
List<Text> list = new ArrayList<>();
if (locked) {
list.add(new TranslatableText("reborncore.gui.tooltip.unlock_items"));
list.add(Text.translatable("reborncore.gui.tooltip.unlock_items"));
} else {
list.add(new TranslatableText("reborncore.gui.tooltip.lock_items"));
list.add(Text.translatable("reborncore.gui.tooltip.lock_items"));
}
matrixStack.push();
gui.renderTooltip(matrixStack, list, mouseX, mouseY);
@ -209,7 +208,7 @@ public class GuiBuilder {
}
if (gui.isPointInRect(x, y, 20, 12, mouseX, mouseY)) {
List<Text> list = new ArrayList<>();
list.add(new TranslatableText("reborncore.gui.tooltip.hologram"));
list.add(Text.translatable("reborncore.gui.tooltip.hologram"));
matrixStack.push();
if (layer == GuiBase.Layer.FOREGROUND) {
mouseX -= gui.getGuiLeft();
@ -245,8 +244,8 @@ public class GuiBuilder {
}
gui.drawTexture(matrixStack, x + 4, y + 4, 26, 246, j, 10);
Text text = new LiteralText(String.valueOf(value))
.append(new TranslatableText("reborncore.gui.heat"));
Text text = Text.literal(String.valueOf(value))
.append(Text.translatable("reborncore.gui.heat"));
gui.drawCentredText(matrixStack, text, y + 5, 0xFFFFFF, layer);
}
@ -282,13 +281,13 @@ public class GuiBuilder {
if (!suffix.equals("")) {
suffix = " " + suffix;
}
gui.drawCentredText(matrixStack, new LiteralText(format).append(suffix), y + 5, 0xFFFFFF, layer);
gui.drawCentredText(matrixStack, Text.literal(format).append(suffix), y + 5, 0xFFFFFF, layer);
if (gui.isPointInRect(x, y, 114, 18, mouseX, mouseY)) {
int percentage = percentage(max, value);
List<Text> list = new ArrayList<>();
list.add(
new LiteralText(String.valueOf(value))
Text.literal(String.valueOf(value))
.formatted(Formatting.GOLD)
.append("/")
.append(String.valueOf(max))
@ -296,11 +295,11 @@ public class GuiBuilder {
);
list.add(
new LiteralText(String.valueOf(percentage))
Text.literal(String.valueOf(percentage))
.formatted(StringUtils.getPercentageColour(percentage))
.append("%")
.append(
new TranslatableText("reborncore.gui.tooltip.dsu_fullness")
Text.translatable("reborncore.gui.tooltip.dsu_fullness")
.formatted(Formatting.GRAY)
)
);
@ -309,15 +308,15 @@ public class GuiBuilder {
if (value > max) {
list.add(
new LiteralText("Yo this is storing more than it should be able to")
Text.literal("Yo this is storing more than it should be able to")
.formatted(Formatting.GRAY)
);
list.add(
new LiteralText("prolly a bug")
Text.literal("prolly a bug")
.formatted(Formatting.GRAY)
);
list.add(
new LiteralText("pls report and tell how tf you did this")
Text.literal("pls report and tell how tf you did this")
.formatted(Formatting.GRAY)
);
}
@ -332,12 +331,12 @@ public class GuiBuilder {
}
public void drawBigBlueBar(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, int value, int max, int mouseX, int mouseY, String suffix, GuiBase.Layer layer) {
drawBigBlueBar(matrixStack, gui, x, y, value, max, mouseX, mouseY, suffix, LiteralText.EMPTY, Integer.toString(value), layer);
drawBigBlueBar(matrixStack, gui, x, y, value, max, mouseX, mouseY, suffix, Text.empty(), Integer.toString(value), layer);
}
public void drawBigBlueBar(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, int value, int max, int mouseX, int mouseY, GuiBase.Layer layer) {
drawBigBlueBar(matrixStack, gui, x, y, value, max, mouseX, mouseY, "", LiteralText.EMPTY, "", layer);
drawBigBlueBar(matrixStack, gui, x, y, value, max, mouseX, mouseY, "", Text.empty(), "", layer);
}
/**
@ -362,7 +361,7 @@ public class GuiBuilder {
RenderUtil.drawGradientRect(matrixStack, 0, x, y + 68, x + 176, y + 70 + 20, 0xC0000000, 0x00000000);
RenderSystem.colorMask(true, true, true, true);
RenderSystem.disableDepthTest();
gui.drawCentredText(matrixStack, new TranslatableText("reborncore.gui.missingmultiblock"), 43, 0xFFFFFF, layer);
gui.drawCentredText(matrixStack, Text.translatable("reborncore.gui.missingmultiblock"), 43, 0xFFFFFF, layer);
}
/**
@ -404,7 +403,7 @@ public class GuiBuilder {
*/
public void drawSlotConfigTips(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, int mouseX, int mouseY, GuiTab guiTab) {
List<Text> tips = guiTab.getTips().stream()
.map(TranslatableText::new)
.map(Text::translatable)
.collect(Collectors.toList());
TipsListWidget explanation = new TipsListWidget(gui, gui.getScreenWidth() - 14, 54, y, y + 76, 9 + 2, tips);
@ -481,7 +480,7 @@ public class GuiBuilder {
*/
public void drawEnergyOutput(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, int maxOutput, GuiBase.Layer layer) {
if (gui.hideGuiElements()) return;
Text text = new LiteralText(PowerSystem.getLocalizedPowerNoSuffix(maxOutput))
Text text = Text.literal(PowerSystem.getLocalizedPowerNoSuffix(maxOutput))
.append(SPACE_TEXT)
.append(PowerSystem.getDisplayPower().abbreviation)
.append("\t");
@ -544,7 +543,7 @@ public class GuiBuilder {
int percentage = percentage(maxProgress, progress);
List<Text> list = new ArrayList<>();
list.add(
new LiteralText(String.valueOf(percentage))
Text.literal(String.valueOf(percentage))
.formatted(StringUtils.getPercentageColour(percentage))
.append("%")
);
@ -592,14 +591,14 @@ public class GuiBuilder {
List<Text> list = Lists.newArrayList();
if (Screen.hasShiftDown()) {
list.add(
new LiteralText(PowerSystem.getLocalizedPowerFullNoSuffix(energyStored))
Text.literal(PowerSystem.getLocalizedPowerFullNoSuffix(energyStored))
.formatted(Formatting.GOLD)
.append("/")
.append(PowerSystem.getLocalizedPowerFull(maxEnergyStored))
);
} else {
list.add(
new LiteralText(PowerSystem.getLocalizedPowerNoSuffix(energyStored))
Text.literal(PowerSystem.getLocalizedPowerNoSuffix(energyStored))
.formatted(Formatting.GOLD)
.append("/")
.append(PowerSystem.getLocalizedPower(maxEnergyStored))
@ -609,7 +608,7 @@ public class GuiBuilder {
StringUtils.getPercentageText(percentage)
.append(SPACE_TEXT)
.append(
new TranslatableText("reborncore.gui.tooltip.power_charged")
Text.translatable("reborncore.gui.tooltip.power_charged")
.formatted(Formatting.GRAY)
)
);
@ -618,14 +617,14 @@ public class GuiBuilder {
if (Screen.hasShiftDown()) {
((IListInfoProvider) gui.be).addInfo(list, true, true);
} else {
list.add(LiteralText.EMPTY);
list.add(Text.empty());
list.add(
new LiteralText("Shift")
Text.literal("Shift")
.formatted(Formatting.BLUE)
.append(SPACE_TEXT)
.formatted(Formatting.GRAY)
.append(new TranslatableText("reborncore.gui.tooltip.power_moreinfo"))
.append(Text.translatable("reborncore.gui.tooltip.power_moreinfo"))
);
}
}
@ -675,10 +674,10 @@ public class GuiBuilder {
if (gui.isPointInRect(x, y, 22, 56, mouseX, mouseY)) {
List<Text> list = new ArrayList<>();
if (isTankEmpty) {
list.add(new TranslatableText("reborncore.gui.tooltip.tank_empty").formatted(Formatting.GOLD));
list.add(Text.translatable("reborncore.gui.tooltip.tank_empty").formatted(Formatting.GOLD));
} else {
list.add(
new LiteralText(String.format("%s / %s", amount, maxCapacity))
Text.literal(String.format("%s / %s", amount, maxCapacity))
.formatted(Formatting.GOLD)
.append(SPACE_TEXT)
.append(FluidUtils.getFluidName(fluid))
@ -689,7 +688,7 @@ public class GuiBuilder {
StringUtils.getPercentageText(percentage)
.formatted(Formatting.GRAY)
.append(SPACE_TEXT)
.append(new TranslatableText("reborncore.gui.tooltip.tank_fullness"))
.append(Text.translatable("reborncore.gui.tooltip.tank_fullness"))
);
if (layer == GuiBase.Layer.FOREGROUND) {

View file

@ -15,6 +15,7 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.fluid.FluidState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.AbstractRandom;
import net.minecraft.world.BlockRenderView;
import net.minecraft.world.BlockView;
import reborncore.common.blockentity.MultiblockWriter;
@ -46,7 +47,7 @@ record HologramRenderer(BlockRenderView view, MatrixStack matrix, VertexConsumer
} else {
matrix.translate(-0.5, -0.5, -0.5);
VertexConsumer consumer = vertexConsumerProvider.getBuffer(RenderLayers.getBlockLayer(state));
blockRenderManager.renderBlock(state, OUT_OF_WORLD_POS, view, matrix, consumer, false, new Random());
blockRenderManager.renderBlock(state, OUT_OF_WORLD_POS, view, matrix, consumer, false, AbstractRandom.create());
}
matrix.pop();

View file

@ -43,7 +43,7 @@ import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerChunkManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.chunk.ChunkStatus;
import reborncore.common.network.ClientBoundPackets;
@ -108,13 +108,14 @@ public class RebornCoreCommands {
.executes(RebornCoreCommands::renderMod)
)
)
.then(
literal("item")
.then(
argument("item", ItemStackArgumentType.itemStack())
.executes(RebornCoreCommands::itemRenderer)
)
)
// TODO 1.19: Waiting on https://github.com/FabricMC/fabric/pull/2227
// .then(
// literal("item")
// .then(
// argument("item", ItemStackArgumentType.itemStack())
// .executes(RebornCoreCommands::itemRenderer)
// )
// )
.then(
literal("hand")
.executes(RebornCoreCommands::handRenderer)
@ -137,7 +138,7 @@ public class RebornCoreCommands {
CompletableFuture.supplyAsync(() -> serverChunkManager.getChunk(chunkPosX, chunkPosZ, ChunkStatus.FULL, true), EXECUTOR_SERVICE)
.whenComplete((chunk, throwable) -> {
int max = (int) Math.pow(size, 2);
ctx.getSource().sendFeedback(new LiteralText(String.format("Finished generating %d:%d (%d/%d %d%%)", chunk.getPos().x, chunk.getPos().z, completed.getAndIncrement(), max, completed.get() == 0 ? 0 : (int) ((completed.get() * 100.0f) / max))), true);
ctx.getSource().sendFeedback(Text.literal(String.format("Finished generating %d:%d (%d/%d %d%%)", chunk.getPos().x, chunk.getPos().z, completed.getAndIncrement(), max, completed.get() == 0 ? 0 : (int) ((completed.get() * 100.0f) / max))), true);
}
);
}
@ -175,23 +176,13 @@ public class RebornCoreCommands {
}
private static int handRenderer(CommandContext<ServerCommandSource> ctx) {
try {
queueRender(Collections.singletonList(ctx.getSource().getPlayer().getInventory().getMainHandStack()), ctx);
} catch (CommandSyntaxException e) {
e.printStackTrace();
return 0;
}
queueRender(Collections.singletonList(ctx.getSource().getPlayer().getInventory().getMainHandStack()), ctx);
return Command.SINGLE_SUCCESS;
}
private static void queueRender(List<ItemStack> stacks, CommandContext<ServerCommandSource> ctx) {
IdentifiedPacket packet = ClientBoundPackets.createPacketQueueItemStacksToRender(stacks);
try {
NetworkManager.sendToPlayer(packet, ctx.getSource().getPlayer());
} catch (CommandSyntaxException e) {
e.printStackTrace();
}
NetworkManager.sendToPlayer(packet, ctx.getSource().getPlayer());
}
}

View file

@ -36,7 +36,6 @@ import net.minecraft.inventory.SidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;
@ -405,10 +404,10 @@ public class MachineBaseBlockEntity extends BlockEntity implements BlockEntityTi
public void addInfo(List<Text> info, boolean isReal, boolean hasData) {
if (hasData) {
if (getOptionalInventory().isPresent()) {
info.add(new LiteralText(Formatting.GOLD + "" + getOptionalInventory().get().getContents() + Formatting.GRAY + " items"));
info.add(Text.literal(Formatting.GOLD + "" + getOptionalInventory().get().getContents() + Formatting.GRAY + " items"));
}
if (!upgradeInventory.isEmpty()) {
info.add(new LiteralText(Formatting .GOLD + "" + upgradeInventory.getContents() + Formatting .GRAY + " upgrades"));
info.add(Text.literal(Formatting .GOLD + "" + upgradeInventory.getContents() + Formatting .GRAY + " upgrades"));
}
}
}

View file

@ -32,13 +32,11 @@ import net.minecraft.advancement.Advancement;
import net.minecraft.advancement.AdvancementRewards;
import net.minecraft.advancement.CriterionMerger;
import net.minecraft.advancement.criterion.RecipeUnlockedCriterion;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtOps;
import net.minecraft.recipe.Recipe;
import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper;
import net.minecraft.util.collection.DefaultedList;
@ -48,16 +46,12 @@ import org.jetbrains.annotations.NotNull;
import reborncore.common.util.DefaultedListCollector;
import reborncore.common.util.serialization.SerializationUtil;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
public class RecipeUtils {
@SuppressWarnings("unchecked")
public static <T extends RebornRecipe> List<T> getRecipes(World world, RebornRecipeType<T> type) {
final Collection<Recipe<Inventory>> recipes = world.getRecipeManager().getAllOfType(type).values().stream().toList();
//noinspection unchecked
return (List<T>) (Object) recipes;
return (List<T>) world.getRecipeManager().getAllOfType(type).values().stream().toList();
}
public static DefaultedList<ItemStack> deserializeItems(JsonElement jsonObject) {

View file

@ -29,7 +29,6 @@ import com.google.gson.JsonObject;
import net.minecraft.item.Item;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.ShapedRecipe;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagKey;
import net.minecraft.util.JsonHelper;
import net.minecraft.util.registry.Registry;

View file

@ -41,7 +41,7 @@ import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.text.TranslatableText;
import net.minecraft.text.Text;
import net.minecraft.util.Hand;
import net.minecraft.util.registry.Registry;
import org.jetbrains.annotations.NotNull;
@ -78,7 +78,7 @@ public class FluidUtils {
// Just extract as much as we can
try (Transaction tx = Transaction.openOuter()) {
boolean didSomething = false;
for (var view : itemStorage.iterable(tx)) {
for (var view : itemStorage) {
if (view.isResourceBlank()) continue;
didSomething = didSomething | view.extract(view.getResource(), Long.MAX_VALUE, tx) > 0;
@ -145,7 +145,7 @@ public class FluidUtils {
// Use current transaction in case this check is nested in a transfer operation.
try (var tx = Transaction.openNested(Transaction.getCurrentUnsafe())) {
for (var view : fluidStorage.iterable(tx)) {
for (var view : fluidStorage) {
if (!view.isResourceBlank() && view.getAmount() > 0) {
return false;
}
@ -161,7 +161,7 @@ public class FluidUtils {
// Use current transaction in case this check is nested in a transfer operation.
try (var tx = Transaction.openNested(Transaction.getCurrentUnsafe())) {
for (var view : fluidStorage.iterable(tx)) {
for (var view : fluidStorage) {
if (!view.isResourceBlank() && view.getAmount() > 0 && predicate.test(view.getResource().getFluid())) {
return true;
}
@ -183,6 +183,6 @@ public class FluidUtils {
}
public static String getFluidName(@NotNull Fluid fluid) {
return new TranslatableText(fluid.getDefaultState().getBlockState().getBlock().getTranslationKey()).getString();
return Text.translatable(fluid.getDefaultState().getBlockState().getBlock().getTranslationKey()).getString();
}
}

View file

@ -32,7 +32,6 @@ import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.inventory.Inventory;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
@ -456,7 +455,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
public void addInfo(List<Text> info, boolean isReal, boolean hasData) {
if (!isReal && hasData) {
info.add(
new TranslatableText("reborncore.tooltip.energy")
Text.translatable("reborncore.tooltip.energy")
.formatted(Formatting.GRAY)
.append(": ")
.append(PowerSystem.getLocalizedPower(getStored()))
@ -465,7 +464,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
}
info.add(
new TranslatableText("reborncore.tooltip.energy.maxEnergy")
Text.translatable("reborncore.tooltip.energy.maxEnergy")
.formatted(Formatting.GRAY)
.append(": ")
.append(PowerSystem.getLocalizedPower(getMaxStoredPower()))
@ -474,7 +473,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
if (getMaxInput(null) != 0) {
info.add(
new TranslatableText("reborncore.tooltip.energy.inputRate")
Text.translatable("reborncore.tooltip.energy.inputRate")
.formatted(Formatting.GRAY)
.append(": ")
.append(PowerSystem.getLocalizedPower(getMaxInput(null)))
@ -483,7 +482,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
}
if (getMaxOutput(null) > 0) {
info.add(
new TranslatableText("reborncore.tooltip.energy.outputRate")
Text.translatable("reborncore.tooltip.energy.outputRate")
.formatted(Formatting.GRAY)
.append(": ")
.append(PowerSystem.getLocalizedPower(getMaxOutput(null)))
@ -492,7 +491,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
}
info.add(
new TranslatableText("reborncore.tooltip.energy.tier")
Text.translatable("reborncore.tooltip.energy.tier")
.formatted(Formatting.GRAY)
.append(": ")
.append(StringUtils.toFirstCapitalAllLowercase(getTier().toString()))
@ -501,7 +500,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
if (isReal) {
info.add(
new TranslatableText("reborncore.tooltip.energy.change")
Text.translatable("reborncore.tooltip.energy.change")
.formatted(Formatting.GRAY)
.append(": ")
.append(PowerSystem.getLocalizedPower(powerChange))

View file

@ -0,0 +1,43 @@
/*
* This file is part of RebornCore, licensed under the MIT License (MIT).
*
* Copyright (c) 2021 TeamReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package reborncore.common.util;
import net.minecraft.client.MinecraftClient;
import net.minecraft.network.MessageSender;
import net.minecraft.network.MessageType;
import net.minecraft.text.Text;
import net.minecraft.util.Util;
import net.minecraft.util.registry.Registry;
public class ClientChatUtils {
public static void addHudMessage(Text text) {
MinecraftClient.getInstance().inGameHud.onChatMessage(getSystemMessageType(), text, new MessageSender(Util.NIL_UUID, text));
}
private static MessageType getSystemMessageType() {
Registry<MessageType> registry = MinecraftClient.getInstance().world.getRegistryManager().get(Registry.MESSAGE_TYPE_KEY);
return registry.get(MessageType.SYSTEM);
}
}

View file

@ -34,7 +34,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import reborncore.common.powerSystem.RcEnergyItem;
import reborncore.common.recipes.IRecipeInput;
@ -172,11 +172,11 @@ public class ItemUtils {
}
if (player instanceof ServerPlayerEntity serverPlayerEntity) {
ChatUtils.sendNoSpamMessage(serverPlayerEntity, messageId, new TranslatableText("reborncore.message.energyError")
ChatUtils.sendNoSpamMessage(serverPlayerEntity, messageId, Text.translatable("reborncore.message.energyError")
.formatted(Formatting.GRAY)
.append(" ")
.append(
new TranslatableText("reborncore.message.deactivating")
Text.translatable("reborncore.message.deactivating")
.formatted(Formatting.GOLD)
)
);
@ -199,11 +199,11 @@ public class ItemUtils {
stack.getOrCreateNbt().putBoolean("isActive", true);
if (entity instanceof ServerPlayerEntity serverPlayerEntity) {
ChatUtils.sendNoSpamMessage(serverPlayerEntity, messageId, new TranslatableText("reborncore.message.setTo")
ChatUtils.sendNoSpamMessage(serverPlayerEntity, messageId, Text.translatable("reborncore.message.setTo")
.formatted(Formatting.GRAY)
.append(" ")
.append(
new TranslatableText("reborncore.message.active")
Text.translatable("reborncore.message.active")
.formatted(Formatting.GOLD)
)
);
@ -211,11 +211,11 @@ public class ItemUtils {
} else {
stack.getOrCreateNbt().putBoolean("isActive", false);
if (entity instanceof ServerPlayerEntity serverPlayerEntity) {
ChatUtils.sendNoSpamMessage(serverPlayerEntity, messageId, new TranslatableText("reborncore.message.setTo")
ChatUtils.sendNoSpamMessage(serverPlayerEntity, messageId, Text.translatable("reborncore.message.setTo")
.formatted(Formatting.GRAY)
.append(" ")
.append(
new TranslatableText("reborncore.message.inactive")
Text.translatable("reborncore.message.inactive")
.formatted(Formatting.GOLD)
)
);
@ -231,9 +231,9 @@ public class ItemUtils {
*/
public static void buildActiveTooltip(ItemStack stack, List<Text> tooltip) {
if (!ItemUtils.isActive(stack)) {
tooltip.add(new TranslatableText("reborncore.message.inactive").formatted(Formatting.RED));
tooltip.add(Text.translatable("reborncore.message.inactive").formatted(Formatting.RED));
} else {
tooltip.add(new TranslatableText("reborncore.message.active").formatted(Formatting.GREEN));
tooltip.add(Text.translatable("reborncore.message.active").formatted(Formatting.GREEN));
}
}

View file

@ -24,8 +24,8 @@
package reborncore.common.util;
import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.util.Locale;
@ -68,7 +68,7 @@ public class StringUtils {
}
public static MutableText getPercentageText(int percentage) {
return new LiteralText(String.valueOf(percentage))
return Text.literal(String.valueOf(percentage))
.formatted(getPercentageColour(percentage))
.append("%");
}

View file

@ -7,6 +7,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.math.random.AbstractRandom;
import net.minecraft.village.TradeOffer;
import net.minecraft.village.TradeOffers;
import net.minecraft.village.VillagerProfession;
@ -56,7 +57,7 @@ public final class TradeUtils {
@Nullable
@Override
public TradeOffer create(Entity entity, Random random) {
public TradeOffer create(Entity entity, AbstractRandom random) {
return copy(offer);
}
};

View file

@ -25,11 +25,11 @@
"reborncore.common.mixins.json"
],
"depends": {
"fabricloader": ">=0.13.3",
"fabric": ">=0.50.0",
"fabricloader": ">=0.14.5",
"fabric": ">=0.52.4",
"team_reborn_energy": ">=2.2.0",
"fabric-biome-api-v1": ">=3.0.0",
"minecraft": "~1.18.2-beta.1"
"minecraft": "~1.19-beta.1"
},
"authors": [
"Team Reborn",