2019-07-11 19:55:11 +02:00
|
|
|
package com.simibubi.create;
|
|
|
|
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
2019-08-06 18:13:33 +02:00
|
|
|
import com.simibubi.create.modules.kinetics.base.KineticTileEntityRenderer;
|
|
|
|
import com.simibubi.create.modules.kinetics.generators.MotorTileEntity;
|
|
|
|
import com.simibubi.create.modules.kinetics.generators.MotorTileEntityRenderer;
|
|
|
|
import com.simibubi.create.modules.kinetics.receivers.TurntableTileEntity;
|
|
|
|
import com.simibubi.create.modules.kinetics.relays.AxisTileEntity;
|
|
|
|
import com.simibubi.create.modules.kinetics.relays.AxisTunnelTileEntity;
|
|
|
|
import com.simibubi.create.modules.kinetics.relays.AxisTunnelTileEntityRenderer;
|
2019-08-10 01:00:36 +02:00
|
|
|
import com.simibubi.create.modules.kinetics.relays.BeltTileEntity;
|
|
|
|
import com.simibubi.create.modules.kinetics.relays.BeltTileEntityRenderer;
|
2019-08-06 18:13:33 +02:00
|
|
|
import com.simibubi.create.modules.kinetics.relays.GearboxTileEntity;
|
|
|
|
import com.simibubi.create.modules.kinetics.relays.GearboxTileEntityRenderer;
|
|
|
|
import com.simibubi.create.modules.kinetics.relays.GearshifterTileEntity;
|
|
|
|
import com.simibubi.create.modules.kinetics.relays.GearshifterTileEntityRenderer;
|
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-08-06 18:13:33 +02:00
|
|
|
import net.minecraft.block.Block;
|
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 {
|
|
|
|
|
2019-08-06 18:13:33 +02:00
|
|
|
// Schematics
|
|
|
|
SCHEMATICANNON(SchematicannonTileEntity::new, AllBlocks.SCHEMATICANNON),
|
|
|
|
SCHEMATICTABLE(SchematicTableTileEntity::new, AllBlocks.SCHEMATIC_TABLE),
|
2019-07-11 19:55:11 +02:00
|
|
|
|
2019-08-06 18:13:33 +02:00
|
|
|
// Kinetics
|
|
|
|
AXIS(AxisTileEntity::new, AllBlocks.AXIS, AllBlocks.GEAR, AllBlocks.LARGE_GEAR, AllBlocks.AXIS_TUNNEL),
|
|
|
|
MOTOR(MotorTileEntity::new, AllBlocks.MOTOR),
|
|
|
|
GEARBOX(GearboxTileEntity::new, AllBlocks.GEARBOX),
|
|
|
|
TURNTABLE(TurntableTileEntity::new, AllBlocks.TURNTABLE),
|
|
|
|
AXIS_TUNNEL(AxisTunnelTileEntity::new, AllBlocks.AXIS_TUNNEL),
|
|
|
|
GEARSHIFTER(GearshifterTileEntity::new, AllBlocks.GEARSHIFTER),
|
2019-08-10 01:00:36 +02:00
|
|
|
BELT(BeltTileEntity::new, AllBlocks.BELT),
|
2019-08-06 18:13:33 +02:00
|
|
|
|
|
|
|
;
|
|
|
|
|
2019-07-11 19:55:11 +02:00
|
|
|
private Supplier<? extends TileEntity> supplier;
|
|
|
|
public TileEntityType<?> type;
|
2019-08-06 18:13:33 +02:00
|
|
|
private AllBlocks[] blocks;
|
2019-07-11 19:55:11 +02:00
|
|
|
|
2019-08-06 18:13:33 +02:00
|
|
|
private AllTileEntities(Supplier<? extends TileEntity> supplier, AllBlocks... blocks) {
|
2019-07-11 19:55:11 +02:00
|
|
|
this.supplier = supplier;
|
2019-08-06 18:13:33 +02:00
|
|
|
this.blocks = blocks;
|
2019-07-11 19:55:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public static void onTileEntityRegistry(final RegistryEvent.Register<TileEntityType<?>> event) {
|
|
|
|
|
|
|
|
for (AllTileEntities tileEntity : values()) {
|
2019-08-06 18:13:33 +02:00
|
|
|
Block[] blocks = new Block[tileEntity.blocks.length];
|
|
|
|
for (int i = 0; i < blocks.length; i++)
|
|
|
|
blocks[i] = tileEntity.blocks[i].block;
|
|
|
|
|
2019-07-11 19:55:11 +02:00
|
|
|
ResourceLocation resourceLocation = new ResourceLocation(Create.ID, tileEntity.name().toLowerCase());
|
2019-08-06 18:13:33 +02:00
|
|
|
tileEntity.type = TileEntityType.Builder.create(tileEntity.supplier, blocks).build(null)
|
2019-07-11 19:55:11 +02:00
|
|
|
.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-08-06 18:13:33 +02:00
|
|
|
bind(AxisTileEntity.class, new KineticTileEntityRenderer());
|
|
|
|
bind(TurntableTileEntity.class, new KineticTileEntityRenderer());
|
|
|
|
bind(MotorTileEntity.class, new MotorTileEntityRenderer());
|
|
|
|
bind(AxisTunnelTileEntity.class, new AxisTunnelTileEntityRenderer());
|
|
|
|
bind(GearboxTileEntity.class, new GearboxTileEntityRenderer());
|
|
|
|
bind(GearshifterTileEntity.class, new GearshifterTileEntityRenderer());
|
2019-08-10 01:00:36 +02:00
|
|
|
bind(BeltTileEntity.class, new BeltTileEntityRenderer());
|
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
|
|
|
|
|
|
|
}
|