mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-08 06:26:43 +01:00
Upating to 1.21 (part 5)
This commit is contained in:
parent
de548235ca
commit
00bd1a65b9
29 changed files with 165 additions and 153 deletions
|
@ -56,13 +56,13 @@ public abstract class AbstractDisguiseSpell extends AbstractSpell implements Dis
|
|||
@Override
|
||||
public void toNBT(NbtCompound compound, WrapperLookup lookup) {
|
||||
super.toNBT(compound, lookup);
|
||||
disguise.toNBT(compound);
|
||||
disguise.toNBT(compound, lookup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromNBT(NbtCompound compound, WrapperLookup lookup) {
|
||||
super.fromNBT(compound, lookup);
|
||||
disguise.fromNBT(compound);
|
||||
disguise.fromNBT(compound, lookup);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,12 +19,12 @@ import com.minelittlepony.unicopia.item.AlicornAmuletItem;
|
|||
import com.minelittlepony.unicopia.item.UItems;
|
||||
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
|
||||
import com.minelittlepony.unicopia.projectile.ProjectileDelegate;
|
||||
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
||||
|
||||
import net.fabricmc.fabric.api.entity.FakePlayer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtElement;
|
||||
import net.minecraft.registry.RegistryWrapper.WrapperLookup;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.hit.EntityHitResult;
|
||||
|
@ -197,8 +197,9 @@ public class MindSwapSpell extends MimicSpell implements ProjectileDelegate.Enti
|
|||
super.toNBT(compound, lookup);
|
||||
compound.put("counterpart", counterpart.toNBT(lookup));
|
||||
compound.putBoolean("initialized", initialized);
|
||||
myStoredInventory.ifPresent(mine -> compound.put("myStoredInventory", mine.toNBT(new NbtCompound())));
|
||||
theirStoredInventory.ifPresent(mine -> compound.put("theirStoredInventory", mine.toNBT(new NbtCompound())));
|
||||
|
||||
myStoredInventory.ifPresent(mine -> compound.put("myStoredInventory", NbtSerialisable.encode(Inventory.CODEC, mine)));
|
||||
theirStoredInventory.ifPresent(theirs -> compound.put("theirStoredInventory", NbtSerialisable.encode(Inventory.CODEC, theirs)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -206,8 +207,8 @@ public class MindSwapSpell extends MimicSpell implements ProjectileDelegate.Enti
|
|||
super.fromNBT(compound, lookup);
|
||||
counterpart.fromNBT(compound.getCompound("counterpart"), lookup);
|
||||
initialized = compound.getBoolean("initialized");
|
||||
myStoredInventory = Optional.ofNullable(compound.contains("myStoredInventory", NbtElement.COMPOUND_TYPE) ? Inventory.fromNBT(compound.getCompound("myStoredInventory")) : null);
|
||||
theirStoredInventory = Optional.ofNullable(compound.contains("theirStoredInventory", NbtElement.COMPOUND_TYPE) ? Inventory.fromNBT(compound.getCompound("theirStoredInventory")) : null);
|
||||
myStoredInventory = NbtSerialisable.decode(Inventory.CODEC, compound.getCompound("myStoredInventory"));
|
||||
theirStoredInventory = NbtSerialisable.decode(Inventory.CODEC, compound.getCompound("theirStoredInventory"));
|
||||
}
|
||||
|
||||
private static void swapPlayerData(ServerPlayerEntity a, ServerPlayerEntity b) {
|
||||
|
|
|
@ -197,8 +197,6 @@ public interface URenderers {
|
|||
private static void renderJarItem(ItemStack stack, ModelTransformationMode mode, MatrixStack matrices, VertexConsumerProvider vertices, int light, int overlay) {
|
||||
ItemRenderer renderer = MinecraftClient.getInstance().getItemRenderer();
|
||||
|
||||
ChameleonItem item = (ChameleonItem)stack.getItem();
|
||||
|
||||
// Reset stuff done in the beforelands
|
||||
matrices.pop();
|
||||
|
||||
|
@ -209,7 +207,7 @@ public interface URenderers {
|
|||
VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
|
||||
ClientWorld world = MinecraftClient.getInstance().world;
|
||||
|
||||
if (item.hasAppearance(stack)) {
|
||||
if (ChameleonItem.hasAppearance(stack)) {
|
||||
matrices.push();
|
||||
if (mode.isFirstPerson()) {
|
||||
matrices.translate(0.05, 0.06, 0.06);
|
||||
|
@ -224,7 +222,7 @@ public interface URenderers {
|
|||
float scale = 0.5F;
|
||||
matrices.scale(scale, scale, scale);
|
||||
|
||||
ItemStack appearance = item.getAppearanceStack(stack);
|
||||
ItemStack appearance = ChameleonItem.getAppearanceStack(stack);
|
||||
renderer.renderItem(appearance, mode, light, overlay, matrices, immediate, world, 0);
|
||||
matrices.pop();
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ public class UnicopiaClient implements ClientModInitializer {
|
|||
|
||||
private void onWorldTick(ClientWorld world) {
|
||||
BlockPos pos = MinecraftClient.getInstance().getCameraEntity().getBlockPos();
|
||||
float tickDelta = MinecraftClient.getInstance().getTickDelta();
|
||||
float tickDelta = MinecraftClient.getInstance().getRenderTickCounter().getTickDelta(false);
|
||||
|
||||
Float targetRainGradient = getTargetRainGradient(world, pos, tickDelta);
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.minelittlepony.unicopia.particle.SphereParticleEffect;
|
|||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.math.*;
|
||||
|
||||
public class DiskParticle extends SphereParticle {
|
||||
|
@ -25,9 +26,9 @@ public class DiskParticle extends SphereParticle {
|
|||
protected void renderModel(MatrixStack matrices, VertexConsumer buffer, float scale, float tickDelta, int light) {
|
||||
matrices.multiply(rotation);
|
||||
float thickness = 0.2F;
|
||||
SphereModel.DISK.render(matrices, buffer, light, 1, scale, 1, 1, 1, 1);
|
||||
SphereModel.DISK.render(matrices, buffer, light, 1, scale, Colors.WHITE);
|
||||
matrices.translate(0, -thickness, 0);
|
||||
SphereModel.DISK.render(matrices, buffer, light, 1, scale, 1, 1, 1, 1);
|
||||
SphereModel.DISK.render(matrices, buffer, light, 1, scale, Colors.WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,10 +16,12 @@ import net.minecraft.client.texture.Sprite;
|
|||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.particle.BlockStateParticleEffect;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
import net.minecraft.util.math.ColorHelper.Argb;
|
||||
|
||||
public class DustCloudParticle extends AbstractBillboardParticle {
|
||||
protected static final int SEGMENTS = 20;
|
||||
|
@ -74,6 +76,7 @@ public class DustCloudParticle extends AbstractBillboardParticle {
|
|||
protected void renderQuads(Tessellator te, float x, float y, float z, float tickDelta) {
|
||||
float scale = getScale(tickDelta) * 0.5F;
|
||||
float alpha = this.alpha * (1 - ((float)age / maxAge));
|
||||
int color = Argb.withAlpha((int)(alpha * 255), Colors.WHITE);
|
||||
MatrixStack matrices = new MatrixStack();
|
||||
matrices.translate(x, y, z);
|
||||
matrices.scale(1, 0.5F, 1);
|
||||
|
@ -88,7 +91,7 @@ public class DustCloudParticle extends AbstractBillboardParticle {
|
|||
float ringScale = 1 + MathHelper.sin(((i * 10) + age + tickDelta) * 0.05F) * 0.1F;
|
||||
|
||||
BufferBuilder buffer = te.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR_LIGHT);
|
||||
model.render(matrices, buffer, 0, scale * ringScale, 1, 1, 1, alpha);
|
||||
model.render(matrices, buffer, 0, scale * ringScale, color);
|
||||
BufferRenderer.drawWithGlobalProgram(buffer.end());
|
||||
matrices.pop();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import net.minecraft.client.render.VertexConsumer;
|
|||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.math.ColorHelper.Argb;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import com.minelittlepony.unicopia.client.render.RenderLayers;
|
||||
import com.minelittlepony.unicopia.client.render.model.SphereModel;
|
||||
|
@ -17,6 +19,7 @@ import com.minelittlepony.unicopia.util.ColorHelper;
|
|||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
public class SphereParticle extends Particle {
|
||||
static final int TRANSLUCENT_WHITE = Argb.withAlpha((int)(0.8F * 255), Colors.WHITE);
|
||||
|
||||
protected float prevRadius;
|
||||
protected float radius;
|
||||
|
@ -100,8 +103,8 @@ public class SphereParticle extends Particle {
|
|||
|
||||
protected void renderModel(MatrixStack matrices, VertexConsumer buffer, float lerpedRad, float tickDelta, int light) {
|
||||
float thickness = 0.05F;
|
||||
SphereModel.SPHERE.render(matrices, buffer, light, 1, lerpedRad + thickness, 1, 1, 1, 0.8F);
|
||||
SphereModel.SPHERE.render(matrices, buffer, light, 1, lerpedRad - thickness, 1, 1, 1, 1);
|
||||
SphereModel.SPHERE.render(matrices, buffer, light, 1, lerpedRad + thickness, TRANSLUCENT_WHITE);
|
||||
SphereModel.SPHERE.render(matrices, buffer, light, 1, lerpedRad - thickness, Colors.WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,10 +27,12 @@ import net.minecraft.entity.vehicle.BoatEntity;
|
|||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.ColorHelper.Argb;
|
||||
|
||||
public class WorldRenderDelegate {
|
||||
public static final WorldRenderDelegate INSTANCE = new WorldRenderDelegate();
|
||||
private static final Optional<Vec3d> RED_SKY_COLOR = Optional.of(new Vec3d(1, 0, 0));
|
||||
private static final int DIVER_HELMET_COLOR = Argb.fromFloats(0.1F, 0.5F, 0.5F, 0.5F);
|
||||
|
||||
private final EntityReplacementManager disguiseLookup = new EntityReplacementManager();
|
||||
private final EntityDisguiseRenderer disguiseRenderer = new EntityDisguiseRenderer(this);
|
||||
|
@ -108,8 +110,8 @@ public class WorldRenderDelegate {
|
|||
RenderLayer layer = RenderLayers.getMagicColored();
|
||||
float scale = 0.9F;
|
||||
|
||||
SphereModel.SPHERE.render(matrices, immediate.getBuffer(layer), light, 0, scale, 0.5F, 0.5F, 0.5F, 0.1F);
|
||||
SphereModel.SPHERE.render(matrices, immediate.getBuffer(layer), light, 0, scale + 0.2F, 0.5F, 0.5F, 0.5F, 0.1F);
|
||||
SphereModel.SPHERE.render(matrices, immediate.getBuffer(layer), light, 0, scale, DIVER_HELMET_COLOR);
|
||||
SphereModel.SPHERE.render(matrices, immediate.getBuffer(layer), light, 0, scale + 0.2F, DIVER_HELMET_COLOR);
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.minelittlepony.unicopia.client.render.spell;
|
||||
|
||||
import com.minelittlepony.common.util.Color;
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.BubbleSpell;
|
||||
import com.minelittlepony.unicopia.client.gui.DrawableUtil;
|
||||
|
@ -14,6 +15,9 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.util.math.RotationAxis;
|
||||
|
||||
public class BubbleSpellRenderer extends SpellRenderer<BubbleSpell> {
|
||||
static final int BUBBLE_COLOR = Color.argbToHex(0.9F, 0.9F, 1, 0.25F);
|
||||
static final int BUBBLE_SHINE_COLOR = Color.argbToHex(0.9F, 0.9F, 1, 0.3F);
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider vertices, BubbleSpell spell, Caster<?> caster, int light, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
|
||||
super.render(matrices, vertices, spell, caster, light, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch);
|
||||
|
@ -36,10 +40,10 @@ public class BubbleSpellRenderer extends SpellRenderer<BubbleSpell> {
|
|||
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-cameraEntity.getPitch(tickDelta)));
|
||||
|
||||
|
||||
new SphereModel(40, 40, DrawableUtil.PI * 0.25F).render(matrices, buffer, light, 0, radius - 0.1F, 0.9F, 0.9F, 1, 0.3F);
|
||||
new SphereModel(40, 40, DrawableUtil.PI * 0.25F).render(matrices, buffer, light, 0, radius - 0.1F, BUBBLE_SHINE_COLOR);
|
||||
matrices.pop();
|
||||
|
||||
SphereModel.SPHERE.render(matrices, buffer, light, 0, radius, 0.9F, 0.9F, 1, 0.25F);
|
||||
SphereModel.SPHERE.render(matrices, buffer, light, 0, radius, BUBBLE_COLOR);
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
|
|
|
@ -14,14 +14,16 @@ import net.minecraft.client.render.RenderLayer;
|
|||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.ColorHelper.Argb;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class DarkVortexSpellRenderer extends SpellRenderer<DarkVortexSpell> {
|
||||
|
||||
private static final Identifier ACCRETION_DISK_TEXTURE = Unicopia.id("textures/spells/dark_vortex/accretion_disk.png");
|
||||
private static final int DISTORTION_ZONE_COLOR = Argb.withAlpha(Colors.BLACK, (int)(255 * 0.9F));
|
||||
|
||||
private static float cameraDistortion;
|
||||
|
||||
|
@ -52,10 +54,11 @@ public class DarkVortexSpellRenderer extends SpellRenderer<DarkVortexSpell> {
|
|||
|
||||
float visualRadius = Math.min(radius * 0.8F, absDistance - 1F);
|
||||
|
||||
SphereModel.SPHERE.render(matrices, vertices.getBuffer(RenderLayers.getSolid()), light, 1, visualRadius, 0, 0, 0, 1);
|
||||
SphereModel.SPHERE.render(matrices, vertices.getBuffer(RenderLayers.getMagicColored()), light, 1, visualRadius + 0.05F, 0, 0, 0, 0.9F);
|
||||
SphereModel.SPHERE.render(matrices, vertices.getBuffer(RenderLayers.getMagicColored()), light, 1, visualRadius + 0.1F, 0, 0, 0, 0.9F);
|
||||
SphereModel.SPHERE.render(matrices, vertices.getBuffer(RenderLayers.getMagicColored()), light, 1, visualRadius + 0.15F, 0, 0, 0, 0.9F);
|
||||
Argb.withAlpha(Colors.BLACK, (int)(255 * 0.9F));
|
||||
SphereModel.SPHERE.render(matrices, vertices.getBuffer(RenderLayers.getSolid()), light, 1, visualRadius, Colors.BLACK);
|
||||
SphereModel.SPHERE.render(matrices, vertices.getBuffer(RenderLayers.getMagicColored()), light, 1, visualRadius + 0.05F, DISTORTION_ZONE_COLOR);
|
||||
SphereModel.SPHERE.render(matrices, vertices.getBuffer(RenderLayers.getMagicColored()), light, 1, visualRadius + 0.1F, DISTORTION_ZONE_COLOR);
|
||||
SphereModel.SPHERE.render(matrices, vertices.getBuffer(RenderLayers.getMagicColored()), light, 1, visualRadius + 0.15F, DISTORTION_ZONE_COLOR);
|
||||
|
||||
matrices.push();
|
||||
|
||||
|
@ -65,7 +68,7 @@ public class DarkVortexSpellRenderer extends SpellRenderer<DarkVortexSpell> {
|
|||
cameraDistortion += distance;
|
||||
}
|
||||
|
||||
SphereModel.DISK.render(matrices, vertices.getBuffer(RenderLayers.getEndPortal()), light, 1, radius * 0.5F, 0, 0, 0, 0);
|
||||
SphereModel.DISK.render(matrices, vertices.getBuffer(RenderLayers.getEndPortal()), light, 1, radius * 0.5F, 0);
|
||||
|
||||
if (radius > 0.3F && absDistance > radius) {
|
||||
double g = Math.sqrt(ray.x * ray.x + ray.z * ray.z);
|
||||
|
@ -95,16 +98,16 @@ public class DarkVortexSpellRenderer extends SpellRenderer<DarkVortexSpell> {
|
|||
|
||||
VertexConsumer buffer = vertices.getBuffer(RenderLayer.getEntityTranslucent(ACCRETION_DISK_TEXTURE));
|
||||
|
||||
PlaneModel.INSTANCE.render(matrices, buffer, light, 0, 1, 1, 1, 1, 1);
|
||||
PlaneModel.INSTANCE.render(matrices, buffer, light, 0, 1, Colors.WHITE);
|
||||
float secondaryScale = 0.9F + cosProcession * 0.3F;
|
||||
matrices.translate(0, 0, 0.0001F);
|
||||
matrices.scale(secondaryScale, secondaryScale, secondaryScale);
|
||||
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(33));
|
||||
PlaneModel.INSTANCE.render(matrices, buffer, light, 0, 1, 1, 1, 1, 1);
|
||||
PlaneModel.INSTANCE.render(matrices, buffer, light, 0, 1, Colors.WHITE);
|
||||
matrices.translate(0, 0, 0.0001F);
|
||||
matrices.scale(0.9F, 0.9F, 0.9F);
|
||||
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(33));
|
||||
PlaneModel.INSTANCE.render(matrices, buffer, light, 0, 1, 1, 1, 1, 1);
|
||||
PlaneModel.INSTANCE.render(matrices, buffer, light, 0, 1, Colors.WHITE);
|
||||
}
|
||||
matrices.pop();
|
||||
matrices.pop();
|
||||
|
|
|
@ -5,12 +5,13 @@ import java.util.concurrent.ExecutionException;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Matrix4fStack;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.minelittlepony.common.util.Color;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.PortalSpell;
|
||||
|
@ -42,6 +43,7 @@ import net.minecraft.client.util.math.MatrixStack;
|
|||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.screen.PlayerScreenHandler;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
|
@ -94,22 +96,21 @@ class PortalFrameBuffer implements AutoCloseable {
|
|||
float uScale = (float)framebuffer.viewportWidth / (float)framebuffer.textureWidth;
|
||||
float vScale = (float)framebuffer.viewportHeight / (float)framebuffer.textureHeight;
|
||||
RenderSystem.setShader(UShaders.RENDER_TYPE_PORTAL_SURFACE);
|
||||
//RenderSystem.setShader(GameRenderer::getPositionTexColorProgram);
|
||||
RenderSystem._setShaderTexture(0, framebuffer.getColorAttachment());
|
||||
BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
|
||||
SphereModel.DISK.scaleUV(uScale, vScale);
|
||||
|
||||
RenderSystem.setTextureMatrix(SphereModel.DISK.getTextureMatrix());
|
||||
SphereModel.DISK.render(matrices, buffer, 1, 2F, 1, 1, 1, 1);
|
||||
tessellator.draw();
|
||||
SphereModel.DISK.render(matrices, buffer, 1, 2F, Colors.WHITE);
|
||||
buffer.end();
|
||||
|
||||
client.getTextureManager().bindTexture(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE);
|
||||
GlStateManager._enableCull();
|
||||
GlStateManager._colorMask(true, true, true, true);
|
||||
GlStateManager._depthMask(true);
|
||||
} else {
|
||||
Vec3d skyColor = client.world.getSkyColor(client.gameRenderer.getCamera().getPos(), client.getTickDelta());
|
||||
SphereModel.DISK.render(matrices, vertices.getBuffer(RenderLayers.getMagicShield()), 0, 0, 2, (float)skyColor.x, (float)skyColor.y, (float)skyColor.z, 1);
|
||||
Vec3d skyColor = client.world.getSkyColor(client.gameRenderer.getCamera().getPos(), client.getRenderTickCounter().getTickDelta(false));
|
||||
SphereModel.DISK.render(matrices, vertices.getBuffer(RenderLayers.getMagicShield()), 0, 0, 2, Color.argbToHex(1, (float)skyColor.x, (float)skyColor.y, (float)skyColor.z));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,10 +188,9 @@ class PortalFrameBuffer implements AutoCloseable {
|
|||
height = j;
|
||||
|
||||
Perspective perspective = client.options.getPerspective();
|
||||
MatrixStack view = RenderSystem.getModelViewStack();
|
||||
Matrix4fStack view = RenderSystem.getModelViewStack();
|
||||
|
||||
Matrix4f proj = RenderSystem.getProjectionMatrix();
|
||||
Matrix3f invView = RenderSystem.getInverseViewRotationMatrix();
|
||||
|
||||
int fbo = client.getFramebuffer().fbo;
|
||||
Camera camera = client.gameRenderer.getCamera();
|
||||
|
@ -206,8 +206,8 @@ class PortalFrameBuffer implements AutoCloseable {
|
|||
framebuffer.clear(MinecraftClient.IS_SYSTEM_MAC);
|
||||
}
|
||||
|
||||
view.push();
|
||||
view.loadIdentity();
|
||||
view.pushMatrix();
|
||||
view.identity();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
|
||||
window.setFramebufferWidth(width);
|
||||
|
@ -234,7 +234,7 @@ class PortalFrameBuffer implements AutoCloseable {
|
|||
|
||||
client.gameRenderer.setRenderHand(false);
|
||||
|
||||
client.gameRenderer.renderWorld(1, 0, new MatrixStack());
|
||||
client.gameRenderer.renderWorld(client.getRenderTickCounter());
|
||||
|
||||
// Strip transparency
|
||||
RenderSystem.colorMask(false, false, false, true);
|
||||
|
@ -249,10 +249,9 @@ class PortalFrameBuffer implements AutoCloseable {
|
|||
client.getFramebuffer().fbo = fbo;
|
||||
client.getFramebuffer().beginWrite(true);
|
||||
|
||||
view.pop();
|
||||
view.popMatrix();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
RenderSystem.setProjectionMatrix(proj, VertexSorter.BY_Z);
|
||||
RenderSystem.setInverseViewRotationMatrix(invView);
|
||||
|
||||
window.setFramebufferWidth(i);
|
||||
window.setFramebufferHeight(j);
|
||||
|
|
|
@ -11,6 +11,7 @@ import net.minecraft.client.render.VertexConsumer;
|
|||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
|
||||
public class PortalSpellRenderer extends SpellRenderer<PortalSpell> {
|
||||
|
@ -27,7 +28,7 @@ public class PortalSpellRenderer extends SpellRenderer<PortalSpell> {
|
|||
|
||||
matrices.push();
|
||||
matrices.translate(0, 0.02, 0);
|
||||
SphereModel.DISK.render(matrices, buff, light, 0, 2F * strength, 1, 1, 1, 1);
|
||||
SphereModel.DISK.render(matrices, buff, light, 0, 2F * strength, Colors.WHITE);
|
||||
matrices.pop();
|
||||
|
||||
EntityReference<Entity> destination = spell.getDestinationReference();
|
||||
|
@ -36,7 +37,7 @@ public class PortalSpellRenderer extends SpellRenderer<PortalSpell> {
|
|||
matrices.push();
|
||||
matrices.translate(0, -0.02, 0);
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(180));
|
||||
SphereModel.DISK.render(matrices, buff, light, 0, 2F * strength, 1, 1, 1, 1);
|
||||
SphereModel.DISK.render(matrices, buff, light, 0, 2F * strength, Colors.WHITE);
|
||||
matrices.pop();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.minelittlepony.unicopia.client.render.spell;
|
||||
|
||||
import com.minelittlepony.common.util.Color;
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.ShieldSpell;
|
||||
import com.minelittlepony.unicopia.client.gui.DrawableUtil;
|
||||
|
@ -13,6 +12,7 @@ import net.minecraft.client.option.Perspective;
|
|||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.math.ColorHelper.Argb;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
|
||||
|
@ -30,11 +30,12 @@ public class ShieldSpellRenderer extends SpellRenderer<ShieldSpell> {
|
|||
int typeColor = spell.getTypeAndTraits().type().getColor();
|
||||
int ponyColor = MineLPDelegate.getInstance().getMagicColor(caster.getOriginatingCaster().asEntity());
|
||||
|
||||
int color = ColorHelper.lerp(caster.getCorruption().getScaled(1) * (tickDelta / (1 + caster.asWorld().random.nextFloat())),
|
||||
ponyColor == 0 ? typeColor : ColorHelper.lerp(0.6F, ponyColor, typeColor),
|
||||
int color = ColorHelper.saturate(Argb.lerp(
|
||||
caster.getCorruption().getScaled(1) * (tickDelta / (1 + caster.asWorld().random.nextFloat())),
|
||||
ponyColor == 0 ? typeColor : Argb.lerp(0.6F, ponyColor, typeColor),
|
||||
0xFF000
|
||||
);
|
||||
float[] colors = ColorHelper.changeSaturation(Color.r(color), Color.g(color), Color.b(color), 2);
|
||||
), 2);
|
||||
|
||||
float radius = 0.35F + spell.getRadius(tickDelta) + MathHelper.sin(animationProgress / 30F) * 0.01F;
|
||||
|
||||
VertexConsumer buffer = vertices.getBuffer(RenderLayers.getMagicShield());
|
||||
|
@ -42,19 +43,18 @@ public class ShieldSpellRenderer extends SpellRenderer<ShieldSpell> {
|
|||
boolean firstPerson = caster.asEntity() == client.player && client.options.getPerspective() == Perspective.FIRST_PERSON;
|
||||
|
||||
float thickness = 0.02F * MathHelper.sin(animationProgress / 30F);
|
||||
float alpha = 1 - Math.abs(MathHelper.sin(animationProgress / 20F)) * 0.1F;
|
||||
alpha *= MathHelper.clamp(radius - 1, 0, 1);
|
||||
float alpha = (1 - Math.abs(MathHelper.sin(animationProgress / 20F)) * 0.1F) * MathHelper.clamp(radius - 1, 0, 1);
|
||||
|
||||
if (firstPerson) {
|
||||
matrices.translate(0, -1.75F, 0);
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(client.cameraEntity.getPitch(tickDelta)));
|
||||
model.render(matrices, buffer, light, 1, radius, colors[0], colors[1], colors[2], alpha * 0.2F);
|
||||
model.render(matrices, buffer, light, 1, radius, Argb.withAlpha((int)((alpha * 0.2F) * 255), color));
|
||||
} else {
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(180));
|
||||
matrices.scale(1, radius == 0 ? 1 : MathHelper.clamp(2.6F / radius, 0.7F, 1.8F), 1);
|
||||
SphereModel.SPHERE.render(matrices, buffer, light, 1, radius + thickness, colors[0], colors[1], colors[2], alpha * 0.08F);
|
||||
SphereModel.SPHERE.render(matrices, buffer, light, 1, radius - thickness, colors[0], colors[1], colors[2], alpha * 0.05F);
|
||||
SphereModel.SPHERE.render(matrices, buffer, light, 1, radius + thickness * 2, colors[0], colors[1], colors[2], alpha * 0.05F);
|
||||
SphereModel.SPHERE.render(matrices, buffer, light, 1, radius + thickness, Argb.withAlpha((int)((alpha * 0.08F) * 255), color));
|
||||
SphereModel.SPHERE.render(matrices, buffer, light, 1, radius - thickness, Argb.withAlpha((int)((alpha * 0.05F) * 255), color));
|
||||
SphereModel.SPHERE.render(matrices, buffer, light, 1, radius + thickness * 2, Argb.withAlpha((int)((alpha * 0.05F) * 255), color));
|
||||
}
|
||||
|
||||
matrices.pop();
|
||||
|
|
|
@ -9,14 +9,14 @@ import com.minelittlepony.unicopia.ability.magic.spell.TimedSpell;
|
|||
import com.minelittlepony.unicopia.client.gui.DrawableUtil;
|
||||
import com.minelittlepony.unicopia.entity.mob.CastSpellEntity;
|
||||
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
|
||||
import com.minelittlepony.unicopia.util.ColorHelper;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.model.json.ModelTransformationMode;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.EntityPose;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.math.ColorHelper.Argb;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class SpellRenderer<T extends Spell> {
|
|||
float timeRemaining = spell.getTimer().getPercentTimeRemaining(tickDelta);
|
||||
|
||||
DrawableUtil.drawArc(matrices, radius, radius + 0.3F, 0, DrawableUtil.TAU * timeRemaining,
|
||||
ColorHelper.lerp(MathHelper.clamp(timeRemaining * 4, 0, 1), 0xFF0000FF, 0xFFFFFFFF)
|
||||
Argb.lerp(MathHelper.clamp(timeRemaining * 4, 0, 1), Colors.BLUE, Colors.WHITE)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ public abstract class FadeOutSoundInstance extends MovingSoundInstance {
|
|||
}
|
||||
|
||||
private float getLerpedVolume() {
|
||||
float delta = MinecraftClient.getInstance().getTickDelta();
|
||||
float delta = MinecraftClient.getInstance().getRenderTickCounter().getTickDelta(false);
|
||||
float interpolate = MathHelper.clamp(MathHelper.lerp(delta, prevProgress, progress) / transitionTicks, 0, 1);
|
||||
return MathHelper.lerp(interpolate, sourceVolume, targetVolume);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.loot.LootTable;
|
|||
import net.minecraft.loot.LootTable.Builder;
|
||||
import net.minecraft.loot.context.LootContextTypes;
|
||||
import net.minecraft.loot.entry.ItemEntry;
|
||||
import net.minecraft.loot.function.EnchantedCountIncreaseLootFunction;
|
||||
import net.minecraft.loot.provider.number.ConstantLootNumberProvider;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
|
@ -20,8 +21,11 @@ import net.minecraft.registry.RegistryWrapper;
|
|||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class UEntityAdditionsLootTableProvider extends SimpleFabricLootTableProvider {
|
||||
private final CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup;
|
||||
|
||||
public UEntityAdditionsLootTableProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
|
||||
super(output, registryLookup, LootContextTypes.ENTITY);
|
||||
this.registryLookup = registryLookup;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,14 +35,14 @@ public class UEntityAdditionsLootTableProvider extends SimpleFabricLootTableProv
|
|||
|
||||
@Override
|
||||
public void accept(BiConsumer<RegistryKey<LootTable>, Builder> exporter) {
|
||||
generate((type, builder) -> exporter.accept(RegistryKey.of(RegistryKeys.LOOT_TABLE, Identifier.of("unicopiamc", EntityType.getId(type).withPrefixedPath("entities/").getPath())), builder));
|
||||
generate(registryLookup.join(), (type, builder) -> exporter.accept(RegistryKey.of(RegistryKeys.LOOT_TABLE, Identifier.of("unicopiamc", EntityType.getId(type).withPrefixedPath("entities/").getPath())), builder));
|
||||
}
|
||||
|
||||
protected void generate(BiConsumer<EntityType<?>, Builder> exporter) {
|
||||
protected void generate(RegistryWrapper.WrapperLookup registryLookup, BiConsumer<EntityType<?>, Builder> exporter) {
|
||||
exporter.accept(EntityType.FROG, LootTable.builder()
|
||||
.pool(LootPool.builder()
|
||||
.rolls(ConstantLootNumberProvider.create(1))
|
||||
.with(ItemEntry.builder(UItems.FROG_LEGS)
|
||||
.apply(LootingEnchantLootFunction.builder(ConstantLootNumberProvider.create(2))))));
|
||||
.apply(EnchantedCountIncreaseLootFunction.builder(registryLookup, ConstantLootNumberProvider.create(2))))));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.minelittlepony.unicopia.datagen.providers.loot;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import com.minelittlepony.unicopia.UTags;
|
||||
|
@ -16,47 +17,53 @@ import net.minecraft.loot.condition.RandomChanceLootCondition;
|
|||
import net.minecraft.loot.context.LootContextTypes;
|
||||
import net.minecraft.loot.entry.ItemEntry;
|
||||
import net.minecraft.loot.entry.TagEntry;
|
||||
import net.minecraft.loot.function.EnchantedCountIncreaseLootFunction;
|
||||
import net.minecraft.loot.function.SetCountLootFunction;
|
||||
import net.minecraft.loot.provider.number.ConstantLootNumberProvider;
|
||||
import net.minecraft.loot.provider.number.UniformLootNumberProvider;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
|
||||
public class UEntityLootTableProvider extends SimpleFabricLootTableProvider {
|
||||
public UEntityLootTableProvider(FabricDataOutput output) {
|
||||
super(output, LootContextTypes.ENTITY);
|
||||
private final CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup;
|
||||
|
||||
public UEntityLootTableProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
|
||||
super(output, registryLookup, LootContextTypes.ENTITY);
|
||||
this.registryLookup = registryLookup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(BiConsumer<Identifier, Builder> exporter) {
|
||||
generate((type, builder) -> exporter.accept(EntityType.getId(type).withPrefixedPath("entities/"), builder));
|
||||
public void accept(BiConsumer<RegistryKey<LootTable>, Builder> exporter) {
|
||||
generate(registryLookup.join(), (type, builder) -> exporter.accept(RegistryKey.of(RegistryKeys.LOOT_TABLE, EntityType.getId(type).withPrefixedPath("entities/")), builder));
|
||||
}
|
||||
|
||||
protected void generate(BiConsumer<EntityType<?>, Builder> exporter) {
|
||||
protected void generate(RegistryWrapper.WrapperLookup registryLookup, BiConsumer<EntityType<?>, Builder> exporter) {
|
||||
exporter.accept(UEntities.BUTTERFLY, LootTable.builder()
|
||||
.pool(LootPool.builder()
|
||||
.rolls(ConstantLootNumberProvider.create(1))
|
||||
.with(ItemEntry.builder(UItems.BUTTERFLY)
|
||||
.apply(LootingEnchantLootFunction.builder(UniformLootNumberProvider.create(0, 1))))));
|
||||
.apply(EnchantedCountIncreaseLootFunction.builder(registryLookup, UniformLootNumberProvider.create(0, 1))))));
|
||||
exporter.accept(UEntities.STORM_CLOUD, LootTable.builder()
|
||||
.pool(LootPool.builder()
|
||||
.rolls(ConstantLootNumberProvider.create(1))
|
||||
.with(ItemEntry.builder(UItems.CLOUD_LUMP)
|
||||
.apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(6, 12)))
|
||||
.apply(LootingEnchantLootFunction.builder(UniformLootNumberProvider.create(0, 1))))));
|
||||
.apply(EnchantedCountIncreaseLootFunction.builder(registryLookup, UniformLootNumberProvider.create(0, 1))))));
|
||||
exporter.accept(UEntities.LOOT_BUG, LootTable.builder()
|
||||
.pool(LootPool.builder()
|
||||
.rolls(ConstantLootNumberProvider.create(1))
|
||||
.with(TagEntry.builder(UTags.Items.LOOT_BUG_COMMON_DROPS)
|
||||
.apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(6, 12)))
|
||||
.apply(LootingEnchantLootFunction.builder(UniformLootNumberProvider.create(0, 3))))
|
||||
.apply(EnchantedCountIncreaseLootFunction.builder(registryLookup, UniformLootNumberProvider.create(0, 3))))
|
||||
.with(TagEntry.builder(UTags.Items.LOOT_BUG_RARE_DROPS)
|
||||
.conditionally(RandomChanceLootCondition.builder(0.25F))
|
||||
.apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 3)))
|
||||
.apply(LootingEnchantLootFunction.builder(UniformLootNumberProvider.create(0, 6))))
|
||||
.apply(EnchantedCountIncreaseLootFunction.builder(registryLookup, UniformLootNumberProvider.create(0, 6))))
|
||||
.with(TagEntry.builder(UTags.Items.LOOT_BUG_EPIC_DROPS)
|
||||
.conditionally(RandomChanceLootCondition.builder(0.1F))
|
||||
.apply(SetCountLootFunction.builder(ConstantLootNumberProvider.create(1)))
|
||||
.apply(LootingEnchantLootFunction.builder(UniformLootNumberProvider.create(0, 2))))
|
||||
.apply(EnchantedCountIncreaseLootFunction.builder(registryLookup, UniformLootNumberProvider.create(0, 2))))
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Map;
|
|||
import java.util.NoSuchElementException;
|
||||
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
||||
import com.minelittlepony.unicopia.item.component.UDataComponentTypes;
|
||||
import com.minelittlepony.unicopia.recipe.CloudShapingRecipe;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
|
||||
|
@ -15,7 +16,7 @@ import net.minecraft.data.server.recipe.StonecuttingRecipeJsonBuilder;
|
|||
import net.minecraft.data.server.recipe.VanillaRecipeProvider;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.predicate.ComponentPredicate;
|
||||
import net.minecraft.predicate.item.ItemPredicate;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.book.RecipeCategory;
|
||||
|
@ -71,11 +72,9 @@ public interface CraftingMaterialHelper {
|
|||
}
|
||||
|
||||
static AdvancementCriterion<?> conditionsFromSpell(ItemConvertible gem, SpellType<?> spell) {
|
||||
NbtCompound nbt = new NbtCompound();
|
||||
nbt.putString("spell", spell.getId().toString());
|
||||
return RecipeProvider.conditionsFromItemPredicates(ItemPredicate.Builder.create()
|
||||
.items(gem)
|
||||
.nbt(nbt)
|
||||
.component(ComponentPredicate.builder().add(UDataComponentTypes.STORED_SPELL, spell).build())
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -73,10 +73,10 @@ public class BlazeBehaviour extends EntityBehaviour<BlazeEntity> {
|
|||
Vec3d rot = player.asEntity().getRotationVec(1);
|
||||
|
||||
for (int i = 0; i < 1; ++i) {
|
||||
SmallFireballEntity proj = new SmallFireballEntity(entity.getWorld(), player.asEntity(),
|
||||
rot.getX() + entity.getRandom().nextGaussian(),
|
||||
rot.getY(),
|
||||
rot.getZ() + entity.getRandom().nextGaussian()
|
||||
SmallFireballEntity proj = new SmallFireballEntity(
|
||||
entity.getWorld(),
|
||||
player.asEntity(),
|
||||
rot.add(entity.getRandom().nextGaussian(), 0, entity.getRandom().nextGaussian())
|
||||
);
|
||||
proj.setPosition(proj.getX(), entity.getBodyY(0.5D) + 0.5D, proj.getZ());
|
||||
entity.getWorld().spawnEntity(proj);
|
||||
|
|
|
@ -17,7 +17,7 @@ import net.minecraft.util.math.MathHelper;
|
|||
|
||||
public interface EntitySwap {
|
||||
Swap<Entity> POSITION = Swap.of(Entity::getPos, (entity, pos) -> {
|
||||
entity.teleport(pos.getX(), pos.getY(), pos.getZ());
|
||||
entity.setPosition(pos.getX(), pos.getY(), pos.getZ());
|
||||
if (entity instanceof PathAwareEntity pae && !(entity instanceof PlayerEntity)) {
|
||||
pae.getNavigation().stop();
|
||||
}
|
||||
|
|
|
@ -28,10 +28,7 @@ public class GhastBehaviour extends MobBehaviour<GhastEntity> {
|
|||
|
||||
Vec3d rot = player.asEntity().getRotationVec(1);
|
||||
|
||||
FireballEntity proj = new FireballEntity(entity.getWorld(), player.asEntity(),
|
||||
rot.getX(),
|
||||
rot.getY(),
|
||||
rot.getZ(),
|
||||
FireballEntity proj = new FireballEntity(entity.getWorld(), player.asEntity(), rot,
|
||||
(int)player.getLevel().getScaled(entity.getFireballStrength())
|
||||
);
|
||||
proj.updatePosition(
|
||||
|
|
|
@ -3,18 +3,25 @@ package com.minelittlepony.unicopia.entity.behaviour;
|
|||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.minelittlepony.unicopia.util.CodecUtils;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
|
||||
public record Inventory (
|
||||
Map<EquipmentSlot, ItemStack> equipment,
|
||||
Optional<DefaultedList<ItemStack>> mainInventory
|
||||
) {
|
||||
public static final Codec<Inventory> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||
Codec.unboundedMap(EquipmentSlot.CODEC, ItemStack.CODEC).fieldOf("equipment").forGetter(Inventory::equipment),
|
||||
CodecUtils.defaultedList(ItemStack.CODEC, ItemStack.EMPTY).optionalFieldOf("main").forGetter(Inventory::mainInventory)
|
||||
).apply(instance, Inventory::new));
|
||||
|
||||
public static Optional<Inventory> of(LivingEntity entity) {
|
||||
Map<EquipmentSlot, ItemStack> equipment = new EnumMap<>(EquipmentSlot.class);
|
||||
|
@ -66,22 +73,6 @@ public record Inventory (
|
|||
return this;
|
||||
}
|
||||
|
||||
public NbtCompound toNBT(NbtCompound compound) {
|
||||
NbtCompound eq = new NbtCompound();
|
||||
equipment().forEach((slot, stack) -> {
|
||||
eq.put(slot.getName(), stack.writeNbt(new NbtCompound()));
|
||||
});
|
||||
compound.put("equipment", eq);
|
||||
mainInventory().ifPresent(main -> {
|
||||
NbtList list = new NbtList();
|
||||
main.forEach(stack -> {
|
||||
list.add(stack.writeNbt(new NbtCompound()));
|
||||
});
|
||||
compound.put("main", list);
|
||||
});
|
||||
return compound;
|
||||
}
|
||||
|
||||
public static void swapInventories(LivingEntity me, Optional<Inventory> myInv, LivingEntity them, Optional<Inventory> theirInv,
|
||||
Consumer<Inventory> outOverflowConsumer,
|
||||
Consumer<Inventory> inOverflowConsumer) {
|
||||
|
@ -95,23 +86,4 @@ public record Inventory (
|
|||
public static Optional<Inventory> copyInventoryInto(Optional<Inventory> inventory, LivingEntity to) {
|
||||
return inventory.map(inv -> inv.copyInto(to));
|
||||
}
|
||||
|
||||
public static Inventory fromNBT(NbtCompound compound) {
|
||||
Map<EquipmentSlot, ItemStack> equipment = new EnumMap<>(EquipmentSlot.class);
|
||||
NbtCompound eq = compound.getCompound("equipment");
|
||||
eq.getKeys().forEach(key -> {
|
||||
equipment.put(EquipmentSlot.byName(key), ItemStack.fromNbt(eq.getCompound(key)));
|
||||
});
|
||||
|
||||
if (!compound.contains("main", NbtElement.LIST_TYPE)) {
|
||||
return new Inventory(equipment, Optional.empty());
|
||||
}
|
||||
|
||||
NbtList list = compound.getList("main", NbtElement.COMPOUND_TYPE);
|
||||
DefaultedList<ItemStack> main = DefaultedList.ofSize(list.size(), ItemStack.EMPTY);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
main.set(i, ItemStack.fromNbt(list.getCompound(i)));
|
||||
}
|
||||
return new Inventory(equipment, Optional.of(main));
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.minelittlepony.unicopia.recipe;
|
|||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.item.ChameleonItem;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -44,14 +45,14 @@ public class JarExtractRecipe extends SpecialCraftingRecipe {
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (!UItems.FILLED_JAR.hasAppearance(stack)) {
|
||||
if (!ChameleonItem.hasAppearance(stack)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
jar = stack;
|
||||
}
|
||||
|
||||
return UItems.FILLED_JAR.getAppearanceStack(jar);
|
||||
return ChameleonItem.getAppearanceStack(jar);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.minelittlepony.unicopia.recipe;
|
||||
|
||||
import com.minelittlepony.unicopia.item.ChameleonItem;
|
||||
import com.minelittlepony.unicopia.item.EmptyJarItem;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
|
||||
|
@ -8,7 +9,6 @@ import net.minecraft.recipe.RecipeSerializer;
|
|||
import net.minecraft.recipe.book.CraftingRecipeCategory;
|
||||
import net.minecraft.recipe.input.CraftingRecipeInput;
|
||||
import net.minecraft.registry.RegistryWrapper.WrapperLookup;
|
||||
import net.minecraft.util.Pair;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
|
||||
public class JarInsertRecipe extends ItemCombinationRecipe {
|
||||
|
@ -19,9 +19,7 @@ public class JarInsertRecipe extends ItemCombinationRecipe {
|
|||
|
||||
@Override
|
||||
public final ItemStack craft(CraftingRecipeInput inventory, WrapperLookup registries) {
|
||||
Pair<ItemStack, ItemStack> pair = runMatch(inventory);
|
||||
|
||||
return UItems.FILLED_JAR.setAppearance(UItems.FILLED_JAR.getDefaultStack(), pair.getRight());
|
||||
return ChameleonItem.setAppearance(UItems.FILLED_JAR.getDefaultStack(), runMatch(inventory).getRight());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.recipe;
|
|||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import com.minelittlepony.unicopia.item.ChameleonItem;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -20,8 +21,8 @@ public class ZapAppleRecipe extends ShapelessRecipe {
|
|||
Codec.STRING.optionalFieldOf("group", "").forGetter(ZapAppleRecipe::getGroup),
|
||||
CraftingRecipeCategory.CODEC.optionalFieldOf("category", CraftingRecipeCategory.MISC).forGetter(ZapAppleRecipe::getCategory),
|
||||
Registries.ITEM.getCodec().xmap(
|
||||
item -> UItems.ZAP_APPLE.setAppearance(UItems.ZAP_APPLE.getDefaultStack(), item.getDefaultStack()),
|
||||
stack -> UItems.ZAP_APPLE.getAppearance(stack)
|
||||
item -> ChameleonItem.setAppearance(UItems.ZAP_APPLE.getDefaultStack(), item.getDefaultStack()),
|
||||
stack -> ChameleonItem.getAppearance(stack)
|
||||
).fieldOf("appearance").forGetter(recipe -> recipe.getResult(null)),
|
||||
URecipes.SHAPELESS_RECIPE_INGREDIENTS_CODEC.fieldOf("ingredients").forGetter(ZapAppleRecipe::getIngredients)
|
||||
).apply(instance, ZapAppleRecipe::new));
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.minelittlepony.unicopia.server.world;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -82,17 +81,10 @@ public class BlockDestructionManager implements Tickable {
|
|||
}
|
||||
});
|
||||
|
||||
MsgBlockDestruction msg = new MsgBlockDestruction(values);
|
||||
|
||||
if (msg.toBuffer().writerIndex() > 1048576) {
|
||||
throw new IllegalStateException("Payload may not be larger than 1048576 bytes. Here's what we were trying to send: ["
|
||||
+ values.size() + "]\n"
|
||||
+ Arrays.toString(values.values().stream().mapToDouble(Float::doubleValue).toArray()));
|
||||
}
|
||||
|
||||
var packet = Channel.SERVER_BLOCK_DESTRUCTION.toPacket(new MsgBlockDestruction(values));
|
||||
players.forEach(player -> {
|
||||
if (player instanceof ServerPlayerEntity) {
|
||||
Channel.SERVER_BLOCK_DESTRUCTION.sendToPlayer(msg, player);
|
||||
if (player instanceof ServerPlayerEntity spe) {
|
||||
spe.networkHandler.sendPacket(packet);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import com.minelittlepony.unicopia.block.UBlocks;
|
|||
|
||||
import net.fabricmc.fabric.api.biome.v1.*;
|
||||
import net.fabricmc.fabric.api.event.registry.DynamicRegistrySetupCallback;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -132,7 +131,7 @@ public record Tree (
|
|||
|
||||
public Tree build() {
|
||||
RegistryKey<ConfiguredFeature<?, ?>> configuredFeatureId = RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, id);
|
||||
Optional<Block> sapling = saplingId.map(id -> UBlocks.register(id, saplingConstructor.apply(new SaplingGenerator(id.toString(), Optional.of(configuredFeatureId), Optional.empty(), Optional.empty()), FabricBlockSettings.copy(Blocks.OAK_SAPLING)), ItemGroups.NATURAL));
|
||||
Optional<Block> sapling = saplingId.map(id -> UBlocks.register(id, saplingConstructor.apply(new SaplingGenerator(id.toString(), Optional.of(configuredFeatureId), Optional.empty(), Optional.empty()), Block.Settings.copy(Blocks.OAK_SAPLING)), ItemGroups.NATURAL));
|
||||
Tree tree = new Tree(id, configParameters.apply(new TreeFeatureConfig.Builder(
|
||||
BlockStateProvider.of(logType),
|
||||
trunkPlacer,
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|||
import net.fabricmc.fabric.api.util.TriState;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.util.dynamic.Codecs;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
@ -98,4 +99,8 @@ public interface CodecUtils {
|
|||
return Codec.BOOL.optionalFieldOf(fieldName)
|
||||
.<TriState>xmap(b -> b.map(TriState::of).orElse(TriState.DEFAULT), t -> Optional.ofNullable(t.get()));
|
||||
}
|
||||
|
||||
static <T> Codec<DefaultedList<T>> defaultedList(Codec<T> elementCodec, T empty) {
|
||||
return elementCodec.listOf().flatXmap(elements -> DataResult.success(new DefaultedList<>(elements, empty) {}), DataResult::success);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package com.minelittlepony.unicopia.util;
|
||||
|
||||
import com.minelittlepony.common.util.Color;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.passive.SheepEntity;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.ColorHelper.Argb;
|
||||
|
||||
public interface ColorHelper {
|
||||
|
@ -45,12 +42,37 @@ public interface ColorHelper {
|
|||
return new float[] {r, g, b};
|
||||
}
|
||||
|
||||
static int saturate(int color, float intensity) {
|
||||
float a = Argb.getAlpha(color) / 255F,
|
||||
red = Argb.getRed(color) / 255F,
|
||||
green = Argb.getGreen(color) / 255F,
|
||||
blue = Argb.getBlue(color) / 255F;
|
||||
float avg = (red + green + blue) / 3F;
|
||||
float r = avg + (red - avg) * intensity,
|
||||
g = avg + (green - avg) * intensity,
|
||||
b = avg + (blue - avg) * intensity;
|
||||
|
||||
if (r > 1) {
|
||||
g -= r - 1;
|
||||
b -= r - 1;
|
||||
r = 1;
|
||||
}
|
||||
if (g > 1) {
|
||||
r -= g - 1;
|
||||
b -= g - 1;
|
||||
g = 1;
|
||||
}
|
||||
if (b > 1) {
|
||||
r -= b - 1;
|
||||
g -= b - 1;
|
||||
b = 1;
|
||||
}
|
||||
|
||||
return Argb.fromFloats(a, r, g, b);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
static int lerp(float delta, int fromColor, int toColor) {
|
||||
return Color.argbToHex(
|
||||
MathHelper.lerp(delta, Color.a(fromColor), Color.a(toColor)),
|
||||
MathHelper.lerp(delta, Color.r(fromColor), Color.r(toColor)),
|
||||
MathHelper.lerp(delta, Color.g(fromColor), Color.g(toColor)),
|
||||
MathHelper.lerp(delta, Color.b(fromColor), Color.b(toColor))
|
||||
);
|
||||
return Argb.lerp(delta, fromColor, toColor);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue