Search in sources :

Example 6 with TileEntityType

use of org.spongepowered.api.block.tileentity.TileEntityType in project SpongeCommon by SpongePowered.

the class TileEntityTypeRegistryModule method doTileEntityRegistration.

@SuppressWarnings("unchecked")
public void doTileEntityRegistration(Class<?> clazz, String name) {
    final String id = TileEntityTypeRegistryModule.getInstance().getIdForName(name);
    boolean canTick = true;
    try {
        if (ITickable.class.isAssignableFrom(clazz)) {
            String mapping = SpongeImplHooks.isDeobfuscatedEnvironment() ? "update" : "func_73660_a";
            Class<?> declaringClazz = clazz.getMethod(mapping).getDeclaringClass();
            if (declaringClazz.equals(TileEntityChest.class) || declaringClazz.equals(TileEntityEnderChest.class)) {
                canTick = false;
            }
        }
    } catch (Throwable e) {
    // ignore
    }
    final String modId = SpongeImplHooks.getModIdFromClass(clazz);
    final String tileId = modId + ":" + id;
    final TileEntityType tileEntityType = new SpongeTileEntityType((Class<? extends org.spongepowered.api.block.tileentity.TileEntity>) clazz, name, tileId, canTick, modId);
    TileEntityTypeRegistryModule.getInstance().registerAdditionalCatalog(tileEntityType);
}
Also used : TileEntityChest(net.minecraft.tileentity.TileEntityChest) SpongeTileEntityType(org.spongepowered.common.data.type.SpongeTileEntityType) SpongeTileEntityType(org.spongepowered.common.data.type.SpongeTileEntityType) TileEntityType(org.spongepowered.api.block.tileentity.TileEntityType) TileEntityEnderChest(net.minecraft.tileentity.TileEntityEnderChest)

Aggregations

TileEntityType (org.spongepowered.api.block.tileentity.TileEntityType)6 ResourceLocation (net.minecraft.util.ResourceLocation)3 TileEntityArchetype (org.spongepowered.api.block.tileentity.TileEntityArchetype)3 Vector3i (com.flowpowered.math.vector.Vector3i)2 BlockState (org.spongepowered.api.block.BlockState)2 DataView (org.spongepowered.api.data.DataView)2 InvalidDataException (org.spongepowered.api.data.persistence.InvalidDataException)2 BlockPalette (org.spongepowered.api.world.schematic.BlockPalette)2 SpongeTileEntityArchetypeBuilder (org.spongepowered.common.block.SpongeTileEntityArchetypeBuilder)2 SpongeTileEntityType (org.spongepowered.common.data.type.SpongeTileEntityType)2 ArrayMutableBlockBuffer (org.spongepowered.common.util.gen.ArrayMutableBlockBuffer)2 SpongeSchematic (org.spongepowered.common.world.schematic.SpongeSchematic)2 ITileEntityProvider (net.minecraft.block.ITileEntityProvider)1 TileEntity (net.minecraft.tileentity.TileEntity)1 TileEntityChest (net.minecraft.tileentity.TileEntityChest)1 TileEntityEnderChest (net.minecraft.tileentity.TileEntityEnderChest)1 ITickable (net.minecraft.util.ITickable)1 BlockType (org.spongepowered.api.block.BlockType)1 DataQuery (org.spongepowered.api.data.DataQuery)1 MutableBlockVolume (org.spongepowered.api.world.extent.MutableBlockVolume)1