Connected Custom Bogey Particle Types To CarriageParticles

This commit is contained in:
Rabbitminers 2023-05-01 10:09:03 +01:00
parent 9815f1490f
commit e5d7595822
3 changed files with 18 additions and 11 deletions

View file

@ -11,7 +11,7 @@ import com.simibubi.create.foundation.utility.Lang;
import com.tterrag.registrate.util.entry.BlockEntry; import com.tterrag.registrate.util.entry.BlockEntry;
import net.minecraft.core.particles.ParticleType; import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -54,7 +54,8 @@ public class AllBogeyStyles {
protected Component displayName = Lang.translateDirect("create.bogeys.invalid"); protected Component displayName = Lang.translateDirect("create.bogeys.invalid");
protected ResourceLocation soundType = AllSoundEvents.TRAIN2.getId(); protected ResourceLocation soundType = AllSoundEvents.TRAIN2.getId();
protected CompoundTag defaultData = new CompoundTag(); protected CompoundTag defaultData = new CompoundTag();
protected ParticleType<?> particleType = ParticleTypes.CRIT; protected ParticleOptions contactParticle = ParticleTypes.CRIT;
protected ParticleOptions smokeParticle = ParticleTypes.POOF;
protected Optional<CommonRenderer> commonRenderer = Optional.empty(); protected Optional<CommonRenderer> commonRenderer = Optional.empty();
public BogeyStyleBuilder(ResourceLocation name) { public BogeyStyleBuilder(ResourceLocation name) {
@ -88,8 +89,13 @@ public class AllBogeyStyles {
return this; return this;
} }
public BogeyStyleBuilder particle(ParticleType<?> particleType) { public BogeyStyleBuilder contactParticle(ParticleOptions contactParticle) {
this.particleType = particleType; this.contactParticle = contactParticle;
return this;
}
public BogeyStyleBuilder smokeParticle(ParticleOptions smokeParticle) {
this.smokeParticle = smokeParticle;
return this; return this;
} }
@ -100,7 +106,7 @@ public class AllBogeyStyles {
public BogeyStyle build() { public BogeyStyle build() {
BogeyStyle entry = BogeyStyle entry =
new BogeyStyle(name, displayName, soundType, particleType, defaultData, sizes, commonRenderer); new BogeyStyle(name, displayName, soundType, contactParticle, smokeParticle, defaultData, sizes, commonRenderer);
BOGEY_STYLES.put(name, entry); BOGEY_STYLES.put(name, entry);
return entry; return entry;
} }

View file

@ -7,7 +7,7 @@ import com.simibubi.create.content.logistics.trains.BogeyRenderer;
import com.simibubi.create.content.logistics.trains.BogeyRenderer.CommonRenderer; import com.simibubi.create.content.logistics.trains.BogeyRenderer.CommonRenderer;
import com.simibubi.create.content.logistics.trains.BogeySizes; import com.simibubi.create.content.logistics.trains.BogeySizes;
import net.minecraft.core.particles.ParticleType; import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -29,15 +29,17 @@ public class BogeyStyle {
private final Map<BogeySizes.BogeySize, SizeData> sizes; private final Map<BogeySizes.BogeySize, SizeData> sizes;
public final Component displayName; public final Component displayName;
public final ResourceLocation soundType; public final ResourceLocation soundType;
public final ParticleType<?> particleType; public final ParticleOptions contactParticle;
public final ParticleOptions smokeParticle;
public final CompoundTag defaultData; public final CompoundTag defaultData;
public BogeyStyle(ResourceLocation name, Component displayName, ResourceLocation soundType, ParticleType<?> particleType, public BogeyStyle(ResourceLocation name, Component displayName, ResourceLocation soundType, ParticleOptions contactParticle, ParticleOptions smokeParticle,
CompoundTag defaultData, Map<BogeySizes.BogeySize, SizeData> sizes, Optional<CommonRenderer> commonRenderer) { CompoundTag defaultData, Map<BogeySizes.BogeySize, SizeData> sizes, Optional<CommonRenderer> commonRenderer) {
this.name = name; this.name = name;
this.displayName = displayName; this.displayName = displayName;
this.soundType = soundType; this.soundType = soundType;
this.particleType = particleType; this.contactParticle = contactParticle;
this.smokeParticle = smokeParticle;
this.defaultData = defaultData; this.defaultData = defaultData;
this.sizes = sizes; this.sizes = sizes;

View file

@ -10,7 +10,6 @@ import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
@ -110,7 +109,7 @@ public class CarriageParticles {
m = m.add(contraptionMotion.scale(.75f)); m = m.add(contraptionMotion.scale(.75f));
level.addParticle(spark ? ParticleTypes.CRIT : ParticleTypes.POOF, v.x, v.y, v.z, m.x, m.y, m.z); level.addParticle(spark ? bogey.getStyle().contactParticle : bogey.getStyle().smokeParticle, v.x, v.y, v.z, m.x, m.y, m.z);
} }
} }
} }