2019-07-11 19:55:11 +02:00
|
|
|
package com.simibubi.create;
|
|
|
|
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
2019-07-23 12:54:53 +02:00
|
|
|
import com.simibubi.create.modules.schematics.block.SchematicTableTileEntity;
|
|
|
|
import com.simibubi.create.modules.schematics.block.SchematicannonRenderer;
|
|
|
|
import com.simibubi.create.modules.schematics.block.SchematicannonTileEntity;
|
2019-07-11 19:55:11 +02:00
|
|
|
|
2019-07-13 12:55:28 +02:00
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
2019-07-11 19:55:11 +02:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.tileentity.TileEntityType;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
2019-07-15 12:10:57 +02:00
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
2019-07-11 19:55:11 +02:00
|
|
|
import net.minecraftforge.event.RegistryEvent;
|
|
|
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
2019-07-13 12:55:28 +02:00
|
|
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
2019-07-11 19:55:11 +02:00
|
|
|
import net.minecraftforge.fml.common.Mod;
|
|
|
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
|
|
|
|
|
|
|
@Mod.EventBusSubscriber(bus = Bus.MOD)
|
|
|
|
public enum AllTileEntities {
|
|
|
|
|
|
|
|
Schematicannon(SchematicannonTileEntity::new, AllBlocks.SCHEMATICANNON),
|
|
|
|
SchematicTable(SchematicTableTileEntity::new, AllBlocks.SCHEMATIC_TABLE);
|
|
|
|
|
|
|
|
private Supplier<? extends TileEntity> supplier;
|
|
|
|
public TileEntityType<?> type;
|
|
|
|
private AllBlocks block;
|
|
|
|
|
|
|
|
private AllTileEntities(Supplier<? extends TileEntity> supplier, AllBlocks block) {
|
|
|
|
this.supplier = supplier;
|
|
|
|
this.block = block;
|
|
|
|
}
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public static void onTileEntityRegistry(final RegistryEvent.Register<TileEntityType<?>> event) {
|
|
|
|
|
|
|
|
for (AllTileEntities tileEntity : values()) {
|
|
|
|
ResourceLocation resourceLocation = new ResourceLocation(Create.ID, tileEntity.name().toLowerCase());
|
|
|
|
tileEntity.type = TileEntityType.Builder.create(tileEntity.supplier, tileEntity.block.get()).build(null)
|
|
|
|
.setRegistryName(resourceLocation);
|
|
|
|
event.getRegistry().register(tileEntity.type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-15 12:10:57 +02:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
2019-07-11 19:55:11 +02:00
|
|
|
public static void registerRenderers() {
|
2019-07-13 12:55:28 +02:00
|
|
|
bind(SchematicannonTileEntity.class, new SchematicannonRenderer());
|
2019-07-11 19:55:11 +02:00
|
|
|
}
|
|
|
|
|
2019-07-15 12:10:57 +02:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
2019-07-13 12:55:28 +02:00
|
|
|
private static <T extends TileEntity> void bind(Class<T> clazz, TileEntityRenderer<? super T> renderer) {
|
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(clazz, renderer);
|
|
|
|
}
|
2019-07-11 19:55:11 +02:00
|
|
|
|
|
|
|
}
|