mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-29 00:16:27 +01:00
More porting, fix updateNeighbors and particle codecs
This commit is contained in:
parent
92a6e32b19
commit
74fadd94d6
7 changed files with 114 additions and 5 deletions
|
@ -66,10 +66,11 @@ public abstract class KineticBlock extends Block implements IRotate {
|
|||
@Override
|
||||
public abstract TileEntity createTileEntity(BlockState state, IBlockReader world);
|
||||
|
||||
// TODO 1.16 is this the right replacement for updateNeighbors?
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void updateNeighbors(BlockState stateIn, IWorld worldIn, BlockPos pos, int flags) {
|
||||
super.updateNeighbors(stateIn, worldIn, pos, flags);
|
||||
@Deprecated
|
||||
public void updateDiagonalNeighbors(BlockState stateIn, IWorld worldIn, BlockPos pos, int flags, int count) {
|
||||
super.updateDiagonalNeighbors(stateIn, worldIn, pos, flags, count);
|
||||
if (worldIn.isRemote())
|
||||
return;
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ import java.util.Locale;
|
|||
|
||||
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 net.minecraft.client.particle.ParticleManager.IParticleMetaFactory;
|
||||
|
@ -15,6 +17,13 @@ import net.minecraftforge.api.distmarker.Dist;
|
|||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class AirFlowParticleData implements IParticleData, ICustomParticle<AirFlowParticleData> {
|
||||
|
||||
public static final Codec<AirFlowParticleData> CODEC = RecordCodecBuilder.create(i ->
|
||||
i.group(
|
||||
Codec.INT.fieldOf("x").forGetter(p -> p.posX),
|
||||
Codec.INT.fieldOf("y").forGetter(p -> p.posY),
|
||||
Codec.INT.fieldOf("z").forGetter(p -> p.posZ))
|
||||
.apply(i, AirFlowParticleData::new));
|
||||
|
||||
public static final IParticleData.IDeserializer<AirFlowParticleData> DESERIALIZER = new IParticleData.IDeserializer<AirFlowParticleData>() {
|
||||
public AirFlowParticleData deserialize(ParticleType<AirFlowParticleData> particleTypeIn, StringReader reader)
|
||||
|
@ -72,6 +81,11 @@ public class AirFlowParticleData implements IParticleData, ICustomParticle<AirFl
|
|||
public IDeserializer<AirFlowParticleData> getDeserializer() {
|
||||
return DESERIALIZER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Codec<AirFlowParticleData> getCodec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
|
|
@ -4,6 +4,8 @@ import java.util.Locale;
|
|||
|
||||
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 net.minecraft.client.particle.ParticleManager.IParticleMetaFactory;
|
||||
|
@ -15,6 +17,12 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||
|
||||
public class AirParticleData implements IParticleData, ICustomParticle<AirParticleData> {
|
||||
|
||||
public static final Codec<AirParticleData> CODEC = RecordCodecBuilder.create(i ->
|
||||
i.group(
|
||||
Codec.FLOAT.fieldOf("drag").forGetter(p -> p.drag),
|
||||
Codec.FLOAT.fieldOf("speed").forGetter(p -> p.speed))
|
||||
.apply(i, AirParticleData::new));
|
||||
|
||||
public static final IParticleData.IDeserializer<AirParticleData> DESERIALIZER =
|
||||
new IParticleData.IDeserializer<AirParticleData>() {
|
||||
public AirParticleData deserialize(ParticleType<AirParticleData> particleTypeIn, StringReader reader)
|
||||
|
@ -64,6 +72,11 @@ public class AirParticleData implements IParticleData, ICustomParticle<AirPartic
|
|||
return DESERIALIZER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Codec<AirParticleData> getCodec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public IParticleMetaFactory<AirParticleData> getFactory() {
|
||||
|
|
|
@ -4,6 +4,8 @@ import java.util.Locale;
|
|||
|
||||
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 net.minecraft.client.particle.ParticleManager;
|
||||
|
@ -15,6 +17,16 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||
|
||||
public class CubeParticleData implements IParticleData, ICustomParticle<CubeParticleData> {
|
||||
|
||||
public static final Codec<CubeParticleData> CODEC = RecordCodecBuilder.create(i ->
|
||||
i.group(
|
||||
Codec.FLOAT.fieldOf("r").forGetter(p -> p.r),
|
||||
Codec.FLOAT.fieldOf("g").forGetter(p -> p.g),
|
||||
Codec.FLOAT.fieldOf("b").forGetter(p -> p.b),
|
||||
Codec.FLOAT.fieldOf("scale").forGetter(p -> p.scale),
|
||||
Codec.INT.fieldOf("avgAge").forGetter(p -> p.avgAge),
|
||||
Codec.BOOL.fieldOf("hot").forGetter(p -> p.hot))
|
||||
.apply(i, CubeParticleData::new));
|
||||
|
||||
public static final IParticleData.IDeserializer<CubeParticleData> DESERIALIZER = new IParticleData.IDeserializer<CubeParticleData>() {
|
||||
@Override
|
||||
public CubeParticleData deserialize(ParticleType<CubeParticleData> type, StringReader reader) throws CommandSyntaxException {
|
||||
|
@ -64,6 +76,11 @@ public class CubeParticleData implements IParticleData, ICustomParticle<CubePart
|
|||
return DESERIALIZER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Codec<CubeParticleData> getCodec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public ParticleManager.IParticleMetaFactory<CubeParticleData> getFactory() {
|
||||
|
|
|
@ -6,6 +6,8 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
|||
|
||||
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 mcp.MethodsReturnNonnullByDefault;
|
||||
|
@ -20,6 +22,13 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||
@MethodsReturnNonnullByDefault
|
||||
public class HeaterParticleData implements IParticleData, ICustomParticle<HeaterParticleData> {
|
||||
|
||||
public static final Codec<HeaterParticleData> CODEC = RecordCodecBuilder.create(i ->
|
||||
i.group(
|
||||
Codec.FLOAT.fieldOf("r").forGetter(p -> p.r),
|
||||
Codec.FLOAT.fieldOf("g").forGetter(p -> p.g),
|
||||
Codec.FLOAT.fieldOf("b").forGetter(p -> p.b))
|
||||
.apply(i, HeaterParticleData::new));
|
||||
|
||||
public static final IParticleData.IDeserializer<HeaterParticleData> DESERIALIZER =
|
||||
new IParticleData.IDeserializer<HeaterParticleData>() {
|
||||
@Override
|
||||
|
@ -59,6 +68,11 @@ public class HeaterParticleData implements IParticleData, ICustomParticle<Heater
|
|||
return DESERIALIZER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Codec<HeaterParticleData> getCodec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public IParticleMetaFactory<HeaterParticleData> getFactory() {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.simibubi.create.content.contraptions.particle;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
|
||||
import net.minecraft.client.particle.ParticleManager.IParticleMetaFactory;
|
||||
import net.minecraft.particles.IParticleData;
|
||||
import net.minecraft.particles.IParticleData.IDeserializer;
|
||||
|
@ -9,10 +11,18 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||
|
||||
public interface ICustomParticle<T extends IParticleData> {
|
||||
|
||||
public IDeserializer<T> getDeserializer();
|
||||
IDeserializer<T> getDeserializer();
|
||||
|
||||
Codec<T> getCodec();
|
||||
|
||||
public default ParticleType<T> createType() {
|
||||
return new ParticleType<T>(false, getDeserializer());
|
||||
return new ParticleType<T>(false, getDeserializer()) {
|
||||
|
||||
@Override
|
||||
public Codec<T> getCodec() {
|
||||
return ICustomParticle.this.getCodec();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
|
|
@ -4,6 +4,11 @@ import java.util.Locale;
|
|||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.DynamicOps;
|
||||
import com.mojang.serialization.codecs.PrimitiveCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import com.simibubi.create.AllParticleTypes;
|
||||
|
||||
import net.minecraft.client.particle.ParticleManager.IParticleMetaFactory;
|
||||
|
@ -16,6 +21,36 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||
|
||||
public class RotationIndicatorParticleData implements IParticleData, ICustomParticle<RotationIndicatorParticleData> {
|
||||
|
||||
// TODO 1.16 make this unnecessary
|
||||
public static final PrimitiveCodec<Character> CHAR = new PrimitiveCodec<Character>() {
|
||||
@Override
|
||||
public <T> DataResult<Character> read(final DynamicOps<T> ops, final T input) {
|
||||
return ops
|
||||
.getNumberValue(input)
|
||||
.map(n -> (char) n.shortValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T write(final DynamicOps<T> ops, final Character value) {
|
||||
return ops.createShort((short) value.charValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Bool";
|
||||
}
|
||||
};
|
||||
|
||||
public static final Codec<RotationIndicatorParticleData> CODEC = RecordCodecBuilder.create(i ->
|
||||
i.group(
|
||||
Codec.INT.fieldOf("color").forGetter(p -> p.color),
|
||||
Codec.FLOAT.fieldOf("speed").forGetter(p -> p.speed),
|
||||
Codec.FLOAT.fieldOf("radius1").forGetter(p -> p.radius1),
|
||||
Codec.FLOAT.fieldOf("radius2").forGetter(p -> p.radius2),
|
||||
Codec.INT.fieldOf("lifeSpan").forGetter(p -> p.lifeSpan),
|
||||
CHAR.fieldOf("axis").forGetter(p -> p.axis))
|
||||
.apply(i, RotationIndicatorParticleData::new));
|
||||
|
||||
public static final IParticleData.IDeserializer<RotationIndicatorParticleData> DESERIALIZER = new IParticleData.IDeserializer<RotationIndicatorParticleData>() {
|
||||
public RotationIndicatorParticleData deserialize(ParticleType<RotationIndicatorParticleData> particleTypeIn,
|
||||
StringReader reader) throws CommandSyntaxException {
|
||||
|
@ -92,6 +127,11 @@ public class RotationIndicatorParticleData implements IParticleData, ICustomPart
|
|||
return DESERIALIZER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Codec<RotationIndicatorParticleData> getCodec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public IParticleMetaFactory<RotationIndicatorParticleData> getFactory() {
|
||||
|
|
Loading…
Reference in a new issue