mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-18 00:13:43 +01:00
b1a0f25f4b
- Stationary Contraption Entities no longer sync positions like normal entities - Flimsy attempts at making linear contraption movement smoother, especially at differing tick speeds between server and client - Added slot covers for the Mechanical Crafter - Added the Clockwork Bearing - Added the Rope Pulley - Server speed no longer tries to sync when game is paused - Fixed crash when moving block breakers are loaded in while stalled - Fixed Cuckoo Clock's angle interpolation when tps is low
90 lines
2.5 KiB
Java
90 lines
2.5 KiB
Java
package com.simibubi.create;
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
import com.simibubi.create.foundation.utility.Lang;
|
|
import com.simibubi.create.modules.contraptions.particle.AirFlowParticleData;
|
|
import com.simibubi.create.modules.contraptions.particle.ICustomParticle;
|
|
import com.simibubi.create.modules.contraptions.particle.RotationIndicatorParticleData;
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.particle.ParticleManager;
|
|
import net.minecraft.particles.IParticleData;
|
|
import net.minecraft.particles.ParticleType;
|
|
import net.minecraft.util.ResourceLocation;
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
|
|
import net.minecraftforge.event.RegistryEvent;
|
|
import net.minecraftforge.registries.IForgeRegistry;
|
|
|
|
public enum AllParticles {
|
|
|
|
ROTATION_INDICATOR(RotationIndicatorParticleData::new),
|
|
AIR_FLOW(AirFlowParticleData::new),
|
|
|
|
;
|
|
|
|
private ParticleEntry<?> entry;
|
|
|
|
private <D extends IParticleData> AllParticles(Supplier<? extends ICustomParticle<D>> typeFactory) {
|
|
String asId = Lang.asId(this.name());
|
|
entry = new ParticleEntry<D>(new ResourceLocation(Create.ID, asId), typeFactory);
|
|
}
|
|
|
|
public static void register(RegistryEvent.Register<ParticleType<?>> event) {
|
|
for (AllParticles particle : values())
|
|
particle.entry.register(event.getRegistry());
|
|
}
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
public static void registerFactories(ParticleFactoryRegisterEvent event) {
|
|
ParticleManager particles = Minecraft.getInstance().particles;
|
|
for (AllParticles particle : values())
|
|
particle.entry.registerFactory(particles);
|
|
}
|
|
|
|
public ParticleType<?> get() {
|
|
return entry.getType();
|
|
}
|
|
|
|
public String parameter() {
|
|
return Lang.asId(name());
|
|
}
|
|
|
|
private class ParticleEntry<D extends IParticleData> {
|
|
Supplier<? extends ICustomParticle<D>> typeFactory;
|
|
ParticleType<D> type;
|
|
ResourceLocation id;
|
|
|
|
public ParticleEntry(ResourceLocation id, Supplier<? extends ICustomParticle<D>> typeFactory) {
|
|
this.id = id;
|
|
this.typeFactory = typeFactory;
|
|
}
|
|
|
|
ParticleType<?> getType() {
|
|
makeType();
|
|
return type;
|
|
}
|
|
|
|
void register(IForgeRegistry<ParticleType<?>> registry) {
|
|
makeType();
|
|
registry.register(type);
|
|
}
|
|
|
|
void makeType() {
|
|
if (type == null) {
|
|
type = typeFactory.get().createType();
|
|
type.setRegistryName(id);
|
|
}
|
|
}
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
void registerFactory(ParticleManager particles) {
|
|
makeType();
|
|
particles.registerFactory(type, typeFactory.get().getFactory());
|
|
}
|
|
|
|
}
|
|
|
|
}
|