Utils ported
This commit is contained in:
@@ -64,15 +64,6 @@ public class ClientHelper extends ServerHelper {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
if (Platform.isClient()) {
|
||||
return MinecraftClient.getInstance().world;
|
||||
} else {
|
||||
return super.getWorld();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindTileEntitySpecialRenderer(final Class<? extends BlockEntity> tile, final AEBaseBlock blk) {
|
||||
|
||||
@@ -113,7 +104,7 @@ public class ClientHelper extends ServerHelper {
|
||||
|
||||
@Override
|
||||
public boolean shouldAddParticles(final Random r) {
|
||||
switch (MinecraftClient.getInstance().gameSettings.particles) {
|
||||
switch (MinecraftClient.getInstance().options.particles) {
|
||||
default:
|
||||
case ALL:
|
||||
return true;
|
||||
@@ -154,9 +145,9 @@ public class ClientHelper extends ServerHelper {
|
||||
|
||||
final PlayerEntity player = mc.player;
|
||||
|
||||
final int x = (int) player.getPosX();
|
||||
final int y = (int) player.getPosY();
|
||||
final int z = (int) player.getPosZ();
|
||||
final int x = (int) player.getX();
|
||||
final int y = (int) player.getY();
|
||||
final int z = (int) player.getZ();
|
||||
|
||||
final int range = 16 * 16;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.me.SlotME;
|
||||
@@ -63,7 +63,7 @@ public abstract class AEBaseMEScreen<T extends AEBaseContainer> extends AEBaseSc
|
||||
.format(myStack.getStackSize());
|
||||
final String format = String.format(local, formattedAmount);
|
||||
|
||||
currentToolTip.add(TextFormatting.GRAY + format);
|
||||
currentToolTip.add(Formatting.GRAY + format);
|
||||
}
|
||||
|
||||
if (myStack.getCountRequestable() > 0) {
|
||||
@@ -82,7 +82,7 @@ public abstract class AEBaseMEScreen<T extends AEBaseContainer> extends AEBaseSc
|
||||
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US).format(stack.getCount());
|
||||
final String format = String.format(local, formattedAmount);
|
||||
|
||||
currentToolTip.add(TextFormatting.GRAY + format);
|
||||
currentToolTip.add(Formatting.GRAY + format);
|
||||
|
||||
this.renderTooltip(currentToolTip, x, y, this.font);
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.util.Formatting;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -53,7 +54,6 @@ import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
@@ -198,11 +198,11 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
|
||||
lines = Lists.newArrayList(lines); // Make a copy
|
||||
|
||||
// Make the first line white
|
||||
lines.set(0, TextFormatting.WHITE + lines.get(0));
|
||||
lines.set(0, Formatting.WHITE + lines.get(0));
|
||||
|
||||
// All lines after the first are colored gray
|
||||
for (int i = 1; i < lines.size(); i++) {
|
||||
lines.set(i, TextFormatting.GRAY + lines.get(i));
|
||||
lines.set(i, Formatting.GRAY + lines.get(i));
|
||||
}
|
||||
|
||||
this.renderTooltip(lines, x, y, this.font);
|
||||
@@ -504,7 +504,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
|
||||
|
||||
if (getPlayer().inventory.getItemStack().isEmpty() && theSlot != null) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
if (getMinecraft().gameSettings.keyBindsHotbar[j].isActiveAndMatches(input)) {
|
||||
if (getMinecraft().options.keyBindsHotbar[j].isActiveAndMatches(input)) {
|
||||
final List<Slot> slots = this.getInventorySlots();
|
||||
for (final Slot s : slots) {
|
||||
if (s.getSlotIndex() == j && s.inventory == ((AEBaseContainer) this.container).getPlayerInv()) {
|
||||
|
||||
@@ -22,7 +22,7 @@ import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.CopyMode;
|
||||
@@ -118,9 +118,9 @@ public class CellWorkbenchScreen extends UpgradeableScreen<CellWorkbenchContaine
|
||||
this.copyMode.setState(this.container.getCopyMode() == CopyMode.CLEAR_ON_REMOVE);
|
||||
|
||||
boolean hasFuzzy = false;
|
||||
final ItemTransferable inv = this.container.getCellUpgradeInventory();
|
||||
for (int x = 0; x < inv.getSlots(); x++) {
|
||||
final ItemStack is = inv.getStackInSlot(x);
|
||||
final FixedItemInv inv = this.container.getCellUpgradeInventory();
|
||||
for (int x = 0; x < inv.getSlotCount(); x++) {
|
||||
final ItemStack is = inv.getInvStack(x);
|
||||
if (!is.isEmpty() && is.getItem() instanceof IUpgradeModule) {
|
||||
if (((IUpgradeModule) is.getItem()).getType(is) == Upgrades.FUZZY) {
|
||||
hasFuzzy = true;
|
||||
|
||||
@@ -223,7 +223,7 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
|
||||
for (int x = 0; x < current.getInventory().getSlots(); x++) {
|
||||
final String which = Integer.toString(x);
|
||||
if (invData.contains(which)) {
|
||||
current.getInventory().setStackInSlot(x, ItemStack.read(invData.getCompound(which)));
|
||||
current.getInventory().setStackInSlot(x, ItemStack.fromTag(invData.getCompound(which)));
|
||||
}
|
||||
}
|
||||
} catch (final NumberFormatException ignored) {
|
||||
@@ -319,7 +319,7 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
|
||||
|
||||
for (int i = 0; i < outTag.size(); i++) {
|
||||
|
||||
final ItemStack parsedItemStack = ItemStack.read(outTag.getCompound(i));
|
||||
final ItemStack parsedItemStack = ItemStack.fromTag(outTag.getCompound(i));
|
||||
if (!parsedItemStack.isEmpty()) {
|
||||
final String displayName = Platform.getItemDisplayName(AEApi.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createStack(parsedItemStack)).getString()
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.client.me;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -55,7 +56,7 @@ public class SlotDisconnected extends AppEngSlot {
|
||||
final ItemStack is = super.getStack();
|
||||
if (!is.isEmpty() && is.getItem() instanceof EncodedPatternItem) {
|
||||
final EncodedPatternItem iep = (EncodedPatternItem) is.getItem();
|
||||
final ItemStack out = iep.getOutput(is);
|
||||
final ItemStack out = iep.getOutput(MinecraftClient.getInstance().world, is);
|
||||
if (!out.isEmpty()) {
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -115,9 +115,9 @@ public class EncodedPatternBakedModel extends DelegateBakedModel {
|
||||
public BakedModel getModelWithOverrides(BakedModel originalModel, ItemStack stack, @Nullable World world,
|
||||
@Nullable LivingEntity entity) {
|
||||
boolean shiftHeld = Screen.hasShiftDown();
|
||||
if (shiftHeld) {
|
||||
if (shiftHeld && world != null) {
|
||||
EncodedPatternItem iep = (EncodedPatternItem) stack.getItem();
|
||||
ItemStack output = iep.getOutput(stack);
|
||||
ItemStack output = iep.getOutput(world, stack);
|
||||
if (!output.isEmpty()) {
|
||||
BakedModel realModel = MinecraftClient.getInstance().getItemRenderer().getItemModelMesher()
|
||||
.getItemModel(output);
|
||||
|
||||
@@ -62,9 +62,9 @@ public class EnergyFx extends SpriteTexturedParticle {
|
||||
|
||||
@Override
|
||||
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
|
||||
float x = (float) (this.prevPosX + (this.posX - this.prevPosX) * partialTicks);
|
||||
float y = (float) (this.prevPosY + (this.posY - this.prevPosY) * partialTicks);
|
||||
float z = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * partialTicks);
|
||||
float x = (float) (this.prevX + (this.posX - this.prevX) * partialTicks);
|
||||
float y = (float) (this.prevY + (this.posY - this.prevY) * partialTicks);
|
||||
float z = (float) (this.prevZ + (this.posZ - this.prevZ) * partialTicks);
|
||||
|
||||
final int blkX = MathHelper.floor(x);
|
||||
final int blkY = MathHelper.floor(y);
|
||||
|
||||
@@ -91,9 +91,9 @@ public class LightningFX extends SpriteTexturedParticle {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
this.prevX = this.posX;
|
||||
this.prevY = this.posY;
|
||||
this.prevZ = this.posZ;
|
||||
|
||||
if (this.age++ >= this.maxAge) {
|
||||
this.setExpired();
|
||||
@@ -109,9 +109,9 @@ public class LightningFX extends SpriteTexturedParticle {
|
||||
@Override
|
||||
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
|
||||
Vec3d vec3d = renderInfo.getProjectedView();
|
||||
float centerX = (float) (MathHelper.lerp(partialTicks, this.prevPosX, this.posX) - vec3d.getX());
|
||||
float centerY = (float) (MathHelper.lerp(partialTicks, this.prevPosY, this.posY) - vec3d.getY());
|
||||
float centerZ = (float) (MathHelper.lerp(partialTicks, this.prevPosZ, this.posZ) - vec3d.getZ());
|
||||
float centerX = (float) (MathHelper.lerp(partialTicks, this.prevX, this.posX) - vec3d.getX());
|
||||
float centerY = (float) (MathHelper.lerp(partialTicks, this.prevY, this.posY) - vec3d.getY());
|
||||
float centerZ = (float) (MathHelper.lerp(partialTicks, this.prevZ, this.posZ) - vec3d.getZ());
|
||||
|
||||
final float j = 1.0f;
|
||||
float red = this.particleRed * j * 0.9f;
|
||||
|
||||
@@ -54,9 +54,9 @@ public class MatterCannonFX extends SpriteTexturedParticle {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
this.prevX = this.posX;
|
||||
this.prevY = this.posY;
|
||||
this.prevZ = this.posZ;
|
||||
|
||||
if (this.age++ >= this.maxAge) {
|
||||
this.setExpired();
|
||||
|
||||
@@ -44,9 +44,9 @@ public class VibrantFX extends SpriteTexturedParticle {
|
||||
this.motionX = 0.0D;
|
||||
this.motionY = 0.0D;
|
||||
this.motionZ = 0.0D;
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
this.prevX = this.posX;
|
||||
this.prevY = this.posY;
|
||||
this.prevZ = this.posZ;
|
||||
this.maxAge = (int) (20.0D / (Math.random() * 0.8D + 0.1D));
|
||||
}
|
||||
|
||||
@@ -67,9 +67,9 @@ public class VibrantFX extends SpriteTexturedParticle {
|
||||
*/
|
||||
@Override
|
||||
public void tick() {
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
this.prevX = this.posX;
|
||||
this.prevY = this.posY;
|
||||
this.prevZ = this.posZ;
|
||||
// this.moveEntity(this.motionX, this.motionY, this.motionZ);
|
||||
this.particleScale *= 0.95;
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ public class SkyCompassBakedModel implements IDynamicBakedModel {
|
||||
if (world != null && entity instanceof ClientPlayerEntity) {
|
||||
PlayerEntity player = (PlayerEntity) entity;
|
||||
|
||||
float offRads = (float) (player.rotationYaw / 180.0f * (float) Math.PI + Math.PI);
|
||||
float offRads = (float) (player.yaw / 180.0f * (float) Math.PI + Math.PI);
|
||||
|
||||
SkyCompassBakedModel.this.fallbackRotation = offRads
|
||||
+ getAnimatedRotation(player.getPosition(), true);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
package appeng.client.render.tesr;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemTransferable;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||
@@ -126,16 +126,16 @@ public final class InscriberTESR extends BlockEntityRenderer<InscriberBlockEntit
|
||||
|
||||
// render items.
|
||||
|
||||
ItemTransferable tileInv = tile.getInternalInventory();
|
||||
FixedItemInv tileInv = tile.getInternalInventory();
|
||||
|
||||
int items = 0;
|
||||
if (!tileInv.getStackInSlot(0).isEmpty()) {
|
||||
if (!tileInv.getInvStack(0).isEmpty()) {
|
||||
items++;
|
||||
}
|
||||
if (!tileInv.getStackInSlot(1).isEmpty()) {
|
||||
if (!tileInv.getInvStack(1).isEmpty()) {
|
||||
items++;
|
||||
}
|
||||
if (!tileInv.getStackInSlot(2).isEmpty()) {
|
||||
if (!tileInv.getInvStack(2).isEmpty()) {
|
||||
items++;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public final class InscriberTESR extends BlockEntityRenderer<InscriberBlockEntit
|
||||
// consumed, see below)
|
||||
renderPresses = false;
|
||||
|
||||
ItemStack is = tileInv.getStackInSlot(3);
|
||||
ItemStack is = tileInv.getInvStack(3);
|
||||
|
||||
if (is.isEmpty()) {
|
||||
final InscriberRecipe ir = tile.getTask();
|
||||
@@ -160,12 +160,12 @@ public final class InscriberTESR extends BlockEntityRenderer<InscriberBlockEntit
|
||||
this.renderItem(ms, is, 0.0f, buffers, combinedLight, combinedOverlay);
|
||||
} else {
|
||||
renderPresses = true;
|
||||
this.renderItem(ms, tileInv.getStackInSlot(2), 0.0f, buffers, combinedLight, combinedOverlay);
|
||||
this.renderItem(ms, tileInv.getInvStack(2), 0.0f, buffers, combinedLight, combinedOverlay);
|
||||
}
|
||||
|
||||
if (renderPresses) {
|
||||
this.renderItem(ms, tileInv.getStackInSlot(0), press, buffers, combinedLight, combinedOverlay);
|
||||
this.renderItem(ms, tileInv.getStackInSlot(1), -press, buffers, combinedLight, combinedOverlay);
|
||||
this.renderItem(ms, tileInv.getInvStack(0), press, buffers, combinedLight, combinedOverlay);
|
||||
this.renderItem(ms, tileInv.getInvStack(1), -press, buffers, combinedLight, combinedOverlay);
|
||||
}
|
||||
|
||||
ms.pop();
|
||||
|
||||
Reference in New Issue
Block a user