1.16 port

This commit is contained in:
yueh
2020-07-22 16:44:42 +02:00
parent 662dbca3e1
commit 56ecda5173
225 changed files with 1214 additions and 969 deletions
@@ -25,11 +25,14 @@ import java.util.List;
import java.util.Map;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.client.gui.HoverChecker;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.IRecipeLayout;
@@ -40,6 +43,7 @@ import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.category.IRecipeCategory;
import mezz.jei.gui.HoverChecker;
import appeng.api.config.CondenserOutput;
import appeng.api.definitions.IMaterials;
@@ -90,7 +94,7 @@ class CondenserCategory implements IRecipeCategory<CondenserOutput> {
guiHelper.drawableBuilder(statesLocation, 16, 112, 14, 14).addPadding(28, 0, 78, 0).build());
this.buttonIcons.put(CondenserOutput.SINGULARITY,
guiHelper.drawableBuilder(statesLocation, 32, 112, 14, 14).addPadding(28, 0, 78, 0).build());
this.buttonHoverChecker = new HoverChecker(28, 28 + 16, 78, 78 + 16, 0);
this.buttonHoverChecker = new HoverChecker(28, 28 + 16, 78, 78 + 16);
}
private ItemStack getOutput(CondenserOutput recipe) {
@@ -135,14 +139,14 @@ class CondenserCategory implements IRecipeCategory<CondenserOutput> {
}
@Override
public void draw(CondenserOutput recipe, double mouseX, double mouseY) {
this.progress.draw();
this.iconTrash.draw();
this.iconButton.draw();
public void draw(CondenserOutput recipe, MatrixStack matrixStack, double mouseX, double mouseY) {
this.progress.draw(matrixStack);
this.iconTrash.draw(matrixStack);
this.iconButton.draw(matrixStack);
IDrawable buttonIcon = this.buttonIcons.get(recipe);
if (buttonIcon != null) {
buttonIcon.draw();
buttonIcon.draw(matrixStack);
}
}
@@ -183,7 +187,7 @@ class CondenserCategory implements IRecipeCategory<CondenserOutput> {
}
@Override
public List<String> getTooltipStrings(CondenserOutput output, double mouseX, double mouseY) {
public List<ITextComponent> getTooltipStrings(CondenserOutput output, double mouseX, double mouseY) {
if (this.buttonHoverChecker.checkHover((int) mouseX, (int) mouseY)) {
String key;
@@ -199,7 +203,7 @@ class CondenserCategory implements IRecipeCategory<CondenserOutput> {
return Collections.emptyList();
}
return Splitter.on("\\n").splitToList(I18n.format(key, output.requiredPower));
return Lists.newArrayList(new TranslationTextComponent(key));
}
return Collections.emptyList();
}
@@ -21,6 +21,7 @@ package appeng.integration.modules.theoneprobe.part;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.IProbeHitData;
@@ -49,7 +50,7 @@ public class ChannelInfoProvider implements IPartProbInfoProvider {
usedChannels = 0;
}
final String formattedChannelString = TheOneProbeText.CHANNELS.getTranslationString(usedChannels,
final ITextComponent formattedChannelString = TheOneProbeText.CHANNELS.getTranslationComponent(usedChannels,
maxChannels);
probeInfo.text(formattedChannelString);
@@ -22,6 +22,8 @@ import com.google.common.collect.Iterators;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.IProbeHitData;
@@ -69,10 +71,10 @@ public class P2PStateInfoProvider implements IPartProbInfoProvider {
switch (state) {
case STATE_UNLINKED:
probeInfo.text(TheOneProbeText.P2P_UNLINKED.getTranslationString());
probeInfo.text(TheOneProbeText.P2P_UNLINKED.getTranslationComponent());
break;
case STATE_OUTPUT:
probeInfo.text(TheOneProbeText.P2P_OUTPUT.getTranslationString());
probeInfo.text(TheOneProbeText.P2P_OUTPUT.getTranslationComponent());
break;
case STATE_INPUT:
probeInfo.text(getOutputText(outputCount));
@@ -80,7 +82,7 @@ public class P2PStateInfoProvider implements IPartProbInfoProvider {
}
final short freq = tunnel.getFrequency();
final String freqTooltip = Platform.p2p().toHexString(freq);
final ITextComponent freqTooltip = new StringTextComponent(Platform.p2p().toHexString(freq));
probeInfo.text(freqTooltip);
}
@@ -95,11 +97,11 @@ public class P2PStateInfoProvider implements IPartProbInfoProvider {
}
}
private static String getOutputText(int outputs) {
private static ITextComponent getOutputText(int outputs) {
if (outputs <= 1) {
return TheOneProbeText.P2P_INPUT_ONE_OUTPUT.getTranslationString();
return TheOneProbeText.P2P_INPUT_ONE_OUTPUT.getTranslationComponent();
} else {
return TheOneProbeText.P2P_INPUT_MANY_OUTPUTS.getTranslationString(outputs);
return TheOneProbeText.P2P_INPUT_MANY_OUTPUTS.getTranslationComponent(outputs);
}
}
@@ -22,7 +22,7 @@ import java.util.Optional;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.vector.Vector3d;
import mcjty.theoneprobe.api.IProbeHitData;
@@ -35,7 +35,7 @@ public final class PartAccessor {
public Optional<IPart> getMaybePart(final TileEntity te, final IProbeHitData data) {
if (te instanceof IPartHost) {
BlockPos pos = data.getPos();
final Vec3d position = data.getHitVec().add(-pos.getX(), -pos.getY(), -pos.getZ());
final Vector3d position = data.getHitVec().add(-pos.getX(), -pos.getY(), -pos.getZ());
final IPartHost host = (IPartHost) te;
final SelectedPart sp = host.selectPart(position);
@@ -20,6 +20,7 @@ package appeng.integration.modules.theoneprobe.part;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.IProbeHitData;
@@ -37,22 +38,22 @@ public class PowerStateInfoProvider implements IPartProbInfoProvider {
BlockState blockState, IProbeHitData data) {
if (part instanceof IPowerChannelState) {
final IPowerChannelState state = (IPowerChannelState) part;
final String tooltip = this.getToolTip(state.isActive(), state.isPowered());
final ITextComponent tooltip = this.getToolTip(state.isActive(), state.isPowered());
probeInfo.text(tooltip);
}
}
private String getToolTip(final boolean isActive, final boolean isPowered) {
final String result;
private ITextComponent getToolTip(final boolean isActive, final boolean isPowered) {
final ITextComponent result;
if (isActive && isPowered) {
result = TheOneProbeText.DEVICE_ONLINE.getTranslationString();
result = TheOneProbeText.DEVICE_ONLINE.getTranslationComponent();
} else if (isPowered) {
result = TheOneProbeText.DEVICE_MISSING_CHANNEL.getTranslationString();
result = TheOneProbeText.DEVICE_MISSING_CHANNEL.getTranslationComponent();
} else {
result = TheOneProbeText.DEVICE_OFFLINE.getTranslationString();
result = TheOneProbeText.DEVICE_OFFLINE.getTranslationComponent();
}
return result;
@@ -21,6 +21,7 @@ package appeng.integration.modules.theoneprobe.part;
import net.minecraft.block.BlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.IProbeHitData;
@@ -48,18 +49,18 @@ public class StorageMonitorInfoProvider implements IPartProbInfoProvider {
// TODO: generalize
if (displayed instanceof IAEItemStack) {
final IAEItemStack ais = (IAEItemStack) displayed;
probeInfo.text(TheOneProbeText.SHOWING.getTranslationComponent() + ": "
+ ais.asItemStackRepresentation().getDisplayName());
probeInfo.text(TheOneProbeText.SHOWING
.getTranslationComponent(ais.asItemStackRepresentation().getDisplayName()));
} else if (displayed instanceof IAEFluidStack) {
final IAEFluidStack ais = (IAEFluidStack) displayed;
final String fluidName = I18n.format(ais.getFluidStack().getTranslationKey());
final String text = TheOneProbeText.SHOWING.getTranslationComponent() + ": " + fluidName;
final ITextComponent text = TheOneProbeText.SHOWING.getTranslationComponent(fluidName);
probeInfo.text(text);
}
probeInfo.text(isLocked ? TheOneProbeText.LOCKED.getTranslationString()
: TheOneProbeText.UNLOCKED.getTranslationString());
probeInfo.text(isLocked ? TheOneProbeText.LOCKED.getTranslationComponent()
: TheOneProbeText.UNLOCKED.getTranslationComponent());
}
}
@@ -21,6 +21,7 @@ package appeng.integration.modules.theoneprobe.tile;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
@@ -43,7 +44,7 @@ public class ChargerInfoProvider implements ITileProbInfoProvider {
final ItemStack chargingItem = chargerInventory.getStackInSlot(0);
if (!chargingItem.isEmpty()) {
final String currentInventory = chargingItem.getDisplayName().getString();
final ITextComponent currentInventory = chargingItem.getDisplayName();
final IProbeInfo centerAlignedHorizontalLayout = probeInfo
.horizontal(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER));
@@ -21,6 +21,7 @@ package appeng.integration.modules.theoneprobe.tile;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.ElementAlignment;
@@ -46,8 +47,7 @@ public class CraftingMonitorInfoProvider implements ITileProbInfoProvider {
// TODO: check if OK
final ItemStack itemStack = displayStack.asItemStackRepresentation();
final String itemName = itemStack.getDisplayName().getString();
final String formattedCrafting = TheOneProbeText.CRAFTING.getTranslationComponent(itemName)
.getFormattedText();
final ITextComponent formattedCrafting = TheOneProbeText.CRAFTING.getTranslationComponent(itemName);
final IProbeInfo centerAlignedHorizontalLayout = probeInfo
.horizontal(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER));
@@ -42,11 +42,11 @@ public class PowerStateInfoProvider implements ITileProbInfoProvider {
final boolean isPowered = state.isPowered();
if (isActive && isPowered) {
probeInfo.text(TheOneProbeText.DEVICE_ONLINE.getTranslationString());
probeInfo.text(TheOneProbeText.DEVICE_ONLINE.getTranslationComponent());
} else if (isPowered) {
probeInfo.text(TheOneProbeText.DEVICE_MISSING_CHANNEL.getTranslationString());
probeInfo.text(TheOneProbeText.DEVICE_MISSING_CHANNEL.getTranslationComponent());
} else {
probeInfo.text(TheOneProbeText.DEVICE_OFFLINE.getTranslationString());
probeInfo.text(TheOneProbeText.DEVICE_OFFLINE.getTranslationComponent());
}
}
@@ -20,6 +20,7 @@ package appeng.integration.modules.theoneprobe.tile;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import mcjty.theoneprobe.api.IProbeHitData;
@@ -48,8 +49,8 @@ public class PowerStorageInfoProvider implements ITileProbInfoProvider {
final String formatCurrentPower = Platform.formatPowerLong(internalCurrentPower, false);
final String formatMaxPower = Platform.formatPowerLong(internalMaxPower, false);
final String formattedString = TheOneProbeText.STORED_ENERGY
.getTranslationComponent(formatCurrentPower, formatMaxPower).getFormattedText();
final ITextComponent formattedString = TheOneProbeText.STORED_ENERGY
.getTranslationComponent(formatCurrentPower, formatMaxPower);
probeInfo.text(formattedString);
}