Fix build and dist issues

- Fixed javac not inferring type vars correctly
- Fixed client particle classes being loaded on server dist
This commit is contained in:
simibubi 2020-07-19 13:53:27 +02:00
parent 6076dc22a2
commit 19ca9dd7d6
4 changed files with 26 additions and 10 deletions

View file

@ -467,7 +467,7 @@ public class AllBlocks {
.onRegister(CreateRegistrate.blockModel(() -> FluidTankModel::new)) .onRegister(CreateRegistrate.blockModel(() -> FluidTankModel::new))
.addLayer(() -> RenderType::getCutoutMipped) .addLayer(() -> RenderType::getCutoutMipped)
.item(FluidTankItem::new) .item(FluidTankItem::new)
.model(AssetLookup.customItemModel("_", "block_single_window")) .model(AssetLookup.<FluidTankItem>customItemModel("_", "block_single_window"))
.build() .build()
.register(); .register();

View file

@ -2,7 +2,12 @@ package com.simibubi.create;
import java.util.function.Supplier; import java.util.function.Supplier;
import com.simibubi.create.content.contraptions.particle.*; import com.simibubi.create.content.contraptions.particle.AirFlowParticleData;
import com.simibubi.create.content.contraptions.particle.CubeParticle;
import com.simibubi.create.content.contraptions.particle.CubeParticleData;
import com.simibubi.create.content.contraptions.particle.HeaterParticleData;
import com.simibubi.create.content.contraptions.particle.ICustomParticle;
import com.simibubi.create.content.contraptions.particle.RotationIndicatorParticleData;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -22,7 +27,7 @@ public enum AllParticleTypes {
ROTATION_INDICATOR(RotationIndicatorParticleData::new), ROTATION_INDICATOR(RotationIndicatorParticleData::new),
AIR_FLOW(AirFlowParticleData::new), AIR_FLOW(AirFlowParticleData::new),
HEATER_PARTICLE(HeaterParticleData::new), HEATER_PARTICLE(HeaterParticleData::new),
CUBE(CubeParticleData::dummy, CubeParticle.Factory::new) CUBE(CubeParticleData::dummy, () -> CubeParticle.Factory::new)
; ;
@ -33,7 +38,8 @@ public enum AllParticleTypes {
entry = new ParticleEntry<>(new ResourceLocation(Create.ID, asId), typeFactory); entry = new ParticleEntry<>(new ResourceLocation(Create.ID, asId), typeFactory);
} }
<D extends IParticleData> AllParticleTypes(Supplier<? extends ICustomParticle<D>> typeFactory, Supplier<IParticleFactory<D>> particleMetaFactory) { <D extends IParticleData> AllParticleTypes(Supplier<? extends ICustomParticle<D>> typeFactory,
Supplier<Supplier<IParticleFactory<D>>> particleMetaFactory) {
String asId = Lang.asId(this.name()); String asId = Lang.asId(this.name());
entry = new ParticleEntry<>(new ResourceLocation(Create.ID, asId), typeFactory, particleMetaFactory); entry = new ParticleEntry<>(new ResourceLocation(Create.ID, asId), typeFactory, particleMetaFactory);
} }
@ -60,11 +66,12 @@ public enum AllParticleTypes {
private class ParticleEntry<D extends IParticleData> { private class ParticleEntry<D extends IParticleData> {
Supplier<? extends ICustomParticle<D>> typeFactory; Supplier<? extends ICustomParticle<D>> typeFactory;
Supplier<IParticleFactory<D>> particleMetaFactory; Supplier<Supplier<IParticleFactory<D>>> particleMetaFactory;
ParticleType<D> type; ParticleType<D> type;
ResourceLocation id; ResourceLocation id;
public ParticleEntry(ResourceLocation id, Supplier<? extends ICustomParticle<D>> typeFactory, Supplier<IParticleFactory<D>> particleMetaFactory) { public ParticleEntry(ResourceLocation id, Supplier<? extends ICustomParticle<D>> typeFactory,
Supplier<Supplier<IParticleFactory<D>>> particleMetaFactory) {
this.id = id; this.id = id;
this.typeFactory = typeFactory; this.typeFactory = typeFactory;
this.particleMetaFactory = particleMetaFactory; this.particleMetaFactory = particleMetaFactory;
@ -96,9 +103,10 @@ public enum AllParticleTypes {
void registerFactory(ParticleManager particles) { void registerFactory(ParticleManager particles) {
makeType(); makeType();
if (particleMetaFactory == null) if (particleMetaFactory == null)
particles.registerFactory(type, typeFactory.get().getFactory()); particles.registerFactory(type, typeFactory.get()
.getFactory());
else else
particles.registerFactory(type, particleMetaFactory.get()); particles.registerFactory(type, particleMetaFactory.get().get());
} }
} }

View file

@ -1,14 +1,17 @@
package com.simibubi.create.content.contraptions.particle; package com.simibubi.create.content.contraptions.particle;
import java.util.Locale;
import com.mojang.brigadier.StringReader; import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.simibubi.create.AllParticleTypes; import com.simibubi.create.AllParticleTypes;
import net.minecraft.client.particle.ParticleManager; import net.minecraft.client.particle.ParticleManager;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.particles.IParticleData; import net.minecraft.particles.IParticleData;
import net.minecraft.particles.ParticleType; import net.minecraft.particles.ParticleType;
import net.minecraftforge.api.distmarker.Dist;
import java.util.Locale; import net.minecraftforge.api.distmarker.OnlyIn;
public class CubeParticleData implements IParticleData, ICustomParticle<CubeParticleData> { public class CubeParticleData implements IParticleData, ICustomParticle<CubeParticleData> {
@ -58,6 +61,7 @@ public class CubeParticleData implements IParticleData, ICustomParticle<CubePart
} }
@Override @Override
@OnlyIn(Dist.CLIENT)
public ParticleManager.IParticleMetaFactory<CubeParticleData> getFactory() { public ParticleManager.IParticleMetaFactory<CubeParticleData> getFactory() {
return null; return null;
} }

View file

@ -13,10 +13,13 @@ import net.minecraft.client.particle.ParticleManager.IParticleMetaFactory;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.particles.IParticleData; import net.minecraft.particles.IParticleData;
import net.minecraft.particles.ParticleType; import net.minecraft.particles.ParticleType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault @MethodsReturnNonnullByDefault
public class HeaterParticleData implements IParticleData, ICustomParticle<HeaterParticleData> { public class HeaterParticleData implements IParticleData, ICustomParticle<HeaterParticleData> {
public static final IParticleData.IDeserializer<HeaterParticleData> DESERIALIZER = public static final IParticleData.IDeserializer<HeaterParticleData> DESERIALIZER =
new IParticleData.IDeserializer<HeaterParticleData>() { new IParticleData.IDeserializer<HeaterParticleData>() {
@Override @Override
@ -57,6 +60,7 @@ public class HeaterParticleData implements IParticleData, ICustomParticle<Heater
} }
@Override @Override
@OnlyIn(Dist.CLIENT)
public IParticleMetaFactory<HeaterParticleData> getFactory() { public IParticleMetaFactory<HeaterParticleData> getFactory() {
return HeaterParticle.Factory::new; return HeaterParticle.Factory::new;
} }