mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-15 06:54:21 +01:00
Port new changes to 1.16
This commit is contained in:
parent
0a98171384
commit
fb06dc5e72
@ -6,22 +6,22 @@ import com.simibubi.create.content.contraptions.processing.BasinTileEntity;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.Quaternion;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class BasinFluidParticle extends FluidStackParticle {
|
||||
|
||||
BlockPos basinPos;
|
||||
Vec3d targetPos;
|
||||
Vec3d centerOfBasin;
|
||||
Vector3d targetPos;
|
||||
Vector3d centerOfBasin;
|
||||
float yOffset;
|
||||
|
||||
public BasinFluidParticle(World world, FluidStack fluid, double x, double y, double z, double vx, double vy,
|
||||
public BasinFluidParticle(ClientWorld world, FluidStack fluid, double x, double y, double z, double vx, double vy,
|
||||
double vz) {
|
||||
super(world, fluid, x, y, z, vx, vy, vz);
|
||||
particleGravity = 0;
|
||||
@ -32,14 +32,14 @@ public class BasinFluidParticle extends FluidStackParticle {
|
||||
posY += yOffset;
|
||||
particleScale = 0;
|
||||
maxAge = 60;
|
||||
Vec3d currentPos = new Vec3d(posX, posY, posZ);
|
||||
Vector3d currentPos = new Vector3d(posX, posY, posZ);
|
||||
basinPos = new BlockPos(currentPos);
|
||||
centerOfBasin = VecHelper.getCenterOf(basinPos);
|
||||
|
||||
if (vx != 0) {
|
||||
maxAge = 20;
|
||||
Vec3d centerOf = VecHelper.getCenterOf(basinPos);
|
||||
Vec3d diff = currentPos.subtract(centerOf)
|
||||
Vector3d centerOf = VecHelper.getCenterOf(basinPos);
|
||||
Vector3d diff = currentPos.subtract(centerOf)
|
||||
.mul(1, 0, 1)
|
||||
.normalize()
|
||||
.scale(.375);
|
||||
@ -74,7 +74,7 @@ public class BasinFluidParticle extends FluidStackParticle {
|
||||
|
||||
if (targetPos != null) {
|
||||
float progess = (1f * age) / maxAge;
|
||||
Vec3d currentPos = centerOfBasin.add(targetPos.subtract(centerOfBasin)
|
||||
Vector3d currentPos = centerOfBasin.add(targetPos.subtract(centerOfBasin)
|
||||
.scale(progess));
|
||||
posX = currentPos.x;
|
||||
posZ = currentPos.z;
|
||||
|
@ -1,14 +1,21 @@
|
||||
package com.simibubi.create.content.contraptions.fluids.particle;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import com.simibubi.create.AllParticleTypes;
|
||||
import com.simibubi.create.content.contraptions.particle.ICustomParticleData;
|
||||
|
||||
import net.minecraft.client.particle.IParticleFactory;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.particles.IParticleData;
|
||||
import net.minecraft.particles.ParticleType;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@ -50,6 +57,32 @@ public class FluidParticleData implements IParticleData, ICustomParticleData<Flu
|
||||
.getRegistryName();
|
||||
}
|
||||
|
||||
public static final Codec<FluidStack> FLUID_CODEC = RecordCodecBuilder.create(i -> i.group(
|
||||
Registry.FLUID.fieldOf("FluidName")
|
||||
.forGetter(FluidStack::getFluid),
|
||||
Codec.INT.fieldOf("Amount")
|
||||
.forGetter(FluidStack::getAmount),
|
||||
CompoundNBT.CODEC.optionalFieldOf("tag")
|
||||
.forGetter((fs) -> {
|
||||
return Optional.ofNullable(fs.getTag());
|
||||
}))
|
||||
.apply(i, (f, a, t) -> new FluidStack(f, a, t.orElse(null))));
|
||||
|
||||
public static final Codec<FluidParticleData> CODEC = RecordCodecBuilder.create(i -> i
|
||||
.group(FLUID_CODEC.fieldOf("fluid")
|
||||
.forGetter(p -> p.fluid))
|
||||
.apply(i, fs -> new FluidParticleData(AllParticleTypes.FLUID_PARTICLE.get(), fs)));
|
||||
|
||||
public static final Codec<FluidParticleData> BASIN_CODEC = RecordCodecBuilder.create(i -> i
|
||||
.group(FLUID_CODEC.fieldOf("fluid")
|
||||
.forGetter(p -> p.fluid))
|
||||
.apply(i, fs -> new FluidParticleData(AllParticleTypes.BASIN_FLUID.get(), fs)));
|
||||
|
||||
public static final Codec<FluidParticleData> DRIP_CODEC = RecordCodecBuilder.create(i -> i
|
||||
.group(FLUID_CODEC.fieldOf("fluid")
|
||||
.forGetter(p -> p.fluid))
|
||||
.apply(i, fs -> new FluidParticleData(AllParticleTypes.FLUID_DRIP.get(), fs)));
|
||||
|
||||
public static final IParticleData.IDeserializer<FluidParticleData> DESERIALIZER =
|
||||
new IParticleData.IDeserializer<FluidParticleData>() {
|
||||
|
||||
@ -69,4 +102,13 @@ public class FluidParticleData implements IParticleData, ICustomParticleData<Flu
|
||||
return DESERIALIZER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Codec<FluidParticleData> getCodec(ParticleType<FluidParticleData> type) {
|
||||
if (type == AllParticleTypes.BASIN_FLUID.get())
|
||||
return BASIN_CODEC;
|
||||
if (type == AllParticleTypes.FLUID_DRIP.get())
|
||||
return DRIP_CODEC;
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,11 +7,11 @@ import com.simibubi.create.foundation.utility.ColorHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.IParticleRenderType;
|
||||
import net.minecraft.client.particle.SpriteTexturedParticle;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.inventory.container.PlayerContainer;
|
||||
import net.minecraft.particles.ParticleType;
|
||||
import net.minecraft.particles.ParticleTypes;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class FluidStackParticle extends SpriteTexturedParticle {
|
||||
@ -19,14 +19,14 @@ public class FluidStackParticle extends SpriteTexturedParticle {
|
||||
private final float field_217588_H;
|
||||
private FluidStack fluid;
|
||||
|
||||
public static FluidStackParticle create(ParticleType<FluidParticleData> type, World world, FluidStack fluid, double x,
|
||||
public static FluidStackParticle create(ParticleType<FluidParticleData> type, ClientWorld world, FluidStack fluid, double x,
|
||||
double y, double z, double vx, double vy, double vz) {
|
||||
if (type == AllParticleTypes.BASIN_FLUID.get())
|
||||
return new BasinFluidParticle(world, fluid, x, y, z, vx, vy, vz);
|
||||
return new FluidStackParticle(world, fluid, x, y, z, vx, vy, vz);
|
||||
}
|
||||
|
||||
public FluidStackParticle(World world, FluidStack fluid, double x, double y, double z, double vx, double vy,
|
||||
public FluidStackParticle(ClientWorld world, FluidStack fluid, double x, double y, double z, double vx, double vy,
|
||||
double vz) {
|
||||
super(world, x, y, z, vx, vy, vz);
|
||||
this.fluid = fluid;
|
||||
@ -98,7 +98,7 @@ public class FluidStackParticle extends SpriteTexturedParticle {
|
||||
if (!onGround && world.rand.nextFloat() < 1 / 8f)
|
||||
return;
|
||||
|
||||
Vec3d rgb = ColorHelper.getRGB(fluid.getFluid()
|
||||
Vector3d rgb = ColorHelper.getRGB(fluid.getFluid()
|
||||
.getAttributes()
|
||||
.getColor(fluid));
|
||||
world.addParticle(ParticleTypes.ENTITY_EFFECT, posX, posY, posZ, rgb.x, rgb.y, rgb.z);
|
||||
|
@ -29,7 +29,7 @@ public class BracketBlock extends ProperDirectionalBlock {
|
||||
PIPE, COG, SHAFT;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String getString() {
|
||||
return Lang.asId(name());
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class BracketGenerator extends DirectionalAxisBlockStateGen {
|
||||
public <T extends Block> ModelFile getModel(DataGenContext<Block, T> ctx, RegistrateBlockstateProvider prov,
|
||||
BlockState state) {
|
||||
String type = state.get(BracketBlock.TYPE)
|
||||
.getName();
|
||||
.getString();
|
||||
boolean vertical = state.get(BracketBlock.FACING)
|
||||
.getAxis()
|
||||
.isVertical();
|
||||
|
@ -73,7 +73,7 @@ public class AirParticleData implements IParticleData, ICustomParticleDataWithSp
|
||||
}
|
||||
|
||||
@Override
|
||||
public Codec<AirParticleData> getCodec() {
|
||||
public Codec<AirParticleData> getCodec(ParticleType<AirParticleData> type) {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class CubeParticleData implements IParticleData, ICustomParticleData<Cube
|
||||
}
|
||||
|
||||
@Override
|
||||
public Codec<CubeParticleData> getCodec() {
|
||||
public Codec<CubeParticleData> getCodec(ParticleType<CubeParticleData> type) {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class HeaterParticleData implements IParticleData, ICustomParticleDataWit
|
||||
}
|
||||
|
||||
@Override
|
||||
public Codec<HeaterParticleData> getCodec() {
|
||||
public Codec<HeaterParticleData> getCodec(ParticleType<HeaterParticleData> type) {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.simibubi.create.content.contraptions.particle;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
|
||||
import net.minecraft.client.particle.IParticleFactory;
|
||||
import net.minecraft.client.particle.ParticleManager;
|
||||
import net.minecraft.client.particle.ParticleManager.IParticleMetaFactory;
|
||||
@ -11,13 +13,20 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public interface ICustomParticleDataWithSprite<T extends IParticleData> extends ICustomParticleData<T> {
|
||||
|
||||
public IDeserializer<T> getDeserializer();
|
||||
IDeserializer<T> getDeserializer();
|
||||
|
||||
public default ParticleType<T> createType() {
|
||||
return new ParticleType<T>(false, getDeserializer());
|
||||
return new ParticleType<T>(false, getDeserializer()) {
|
||||
|
||||
@Override
|
||||
public Codec<T> getCodec() {
|
||||
return ICustomParticleDataWithSprite.this.getCodec(this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
default IParticleFactory<T> getFactory() {
|
||||
throw new IllegalAccessError("This particle type uses a metaFactory!");
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ILightReader;
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
@ -28,7 +28,7 @@ public class BracketedKineticBlockModel extends WrappedBakedModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelData getModelData(ILightReader world, BlockPos pos, BlockState state, IModelData tileData) {
|
||||
public IModelData getModelData(IBlockDisplayReader world, BlockPos pos, BlockState state, IModelData tileData) {
|
||||
if (tileData == VirtualEmptyModelData.INSTANCE)
|
||||
return tileData;
|
||||
BracketedModelData data = new BracketedModelData();
|
||||
|
Loading…
Reference in New Issue
Block a user