Whoops missed some classes

This commit is contained in:
JozsefA 2021-06-23 00:16:24 -07:00
parent 312b327161
commit d189efd987
2 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,57 @@
package com.simibubi.create.foundation.data;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
import com.jozufozu.flywheel.backend.instancing.entity.IEntityInstanceFactory;
import com.jozufozu.flywheel.backend.instancing.tile.ITileInstanceFactory;
import com.tterrag.registrate.AbstractRegistrate;
import com.tterrag.registrate.builders.BuilderCallback;
import com.tterrag.registrate.builders.EntityBuilder;
import com.tterrag.registrate.util.OneTimeEventReceiver;
import com.tterrag.registrate.util.nullness.NonNullSupplier;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
@ParametersAreNonnullByDefault
public class CreateEntityBuilder<T extends Entity, P> extends EntityBuilder<T, P> {
@Nullable
private NonNullSupplier<IEntityInstanceFactory<? super T>> instanceFactory;
public static <T extends Entity, P> EntityBuilder<T, P> create(AbstractRegistrate<?> owner, P parent, String name, BuilderCallback callback, EntityType.IFactory<T> factory, EntityClassification classification) {
return (new CreateEntityBuilder<>(owner, parent, name, callback, factory, classification)).defaultLang();
}
public CreateEntityBuilder(AbstractRegistrate<?> owner, P parent, String name, BuilderCallback callback, EntityType.IFactory<T> factory, EntityClassification classification) {
super(owner, parent, name, callback, factory, classification);
}
public CreateEntityBuilder<T, P> instance(NonNullSupplier<IEntityInstanceFactory<? super T>> instanceFactory) {
if (this.instanceFactory == null) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> this::registerInstance);
}
this.instanceFactory = instanceFactory;
return this;
}
protected void registerInstance() {
OneTimeEventReceiver.addModListener(FMLClientSetupEvent.class, $ -> {
NonNullSupplier<IEntityInstanceFactory<? super T>> instanceFactory = this.instanceFactory;
if (instanceFactory != null) {
InstancedRenderRegistry.getInstance().register(getEntry(), instanceFactory.get());
}
});
}
}

View File

@ -0,0 +1,27 @@
package com.simibubi.create.foundation.render;
import com.jozufozu.flywheel.core.shader.spec.IBooleanStateProvider;
import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.KineticDebugger;
import net.minecraft.util.ResourceLocation;
public class RainbowDebugStateProvider implements IBooleanStateProvider {
public static final RainbowDebugStateProvider INSTANCE = new RainbowDebugStateProvider();
public static final ResourceLocation NAME = new ResourceLocation(Create.ID, "rainbow_debug");
protected RainbowDebugStateProvider() {
}
@Override
public boolean isTrue() {
return KineticDebugger.isActive();
}
@Override
public ResourceLocation getID() {
return NAME;
}
}