Search in sources :

Example 91 with ResourceLocation

use of net.minecraft.util.ResourceLocation in project Railcraft by Railcraft.

the class MappingRegistry method read.

public void read(NBTTagCompound nbt) {
    NBTTagList blocksMapping = nbt.getTagList("blocksMapping", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < blocksMapping.tagCount(); ++i) {
        NBTTagCompound sub = blocksMapping.getCompoundTagAt(i);
        if (!sub.hasKey("name")) {
            // Keeping the order correct
            idToBlock.add(null);
            BCLog.logger.log(Level.WARN, "Can't load a block - corrupt blueprint!");
            continue;
        }
        String name = sub.getString("name");
        ResourceLocation location = new ResourceLocation(name);
        Block b = null;
        if (!Block.REGISTRY.containsKey(location) && name.contains(":")) {
            b = (Block) getMissingMappingFromFML(true, name, i);
            if (b != null) {
                BCLog.logger.info("Remapped " + name + " to " + Block.REGISTRY.getNameForObject(b));
            }
        }
        if (b == null && Block.REGISTRY.containsKey(location)) {
            b = (Block) Block.REGISTRY.getObject(location);
        }
        if (b != null) {
            registerBlock(b);
        } else {
            // Keeping the order correct
            idToBlock.add(null);
            BCLog.logger.log(Level.WARN, "Can't load block " + name);
        }
    }
    NBTTagList itemsMapping = nbt.getTagList("itemsMapping", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < itemsMapping.tagCount(); ++i) {
        NBTTagCompound sub = itemsMapping.getCompoundTagAt(i);
        if (!sub.hasKey("name")) {
            // Keeping the order correct
            idToItem.add(null);
            BCLog.logger.log(Level.WARN, "Can't load an item - corrupt blueprint!");
            continue;
        }
        String name = sub.getString("name");
        ResourceLocation location = new ResourceLocation(name);
        Item item = null;
        if (!Item.REGISTRY.containsKey(location) && name.contains(":")) {
            item = (Item) getMissingMappingFromFML(false, name, i);
            if (item != null) {
                BCLog.logger.info("Remapped " + name + " to " + Item.REGISTRY.getNameForObject(item));
            }
        }
        if (item == null && Item.REGISTRY.containsKey(location)) {
            item = (Item) Item.REGISTRY.getObject(location);
        }
        if (item != null) {
            registerItem(item);
        } else {
            // Keeping the order correct
            idToItem.add(null);
            BCLog.logger.log(Level.WARN, "Can't load item " + name);
        }
    }
    NBTTagList entitiesMapping = nbt.getTagList("entitiesMapping", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < entitiesMapping.tagCount(); ++i) {
        NBTTagCompound sub = entitiesMapping.getCompoundTagAt(i);
        String name = sub.getString("name");
        Class<? extends Entity> e = null;
        try {
            e = (Class<? extends Entity>) Class.forName(name);
        } catch (ClassNotFoundException e1) {
            e1.printStackTrace();
        }
        if (e != null) {
            registerEntity(e);
        } else {
            // Keeping the order correct
            idToEntity.add(null);
            BCLog.logger.log(Level.WARN, "Can't load entity " + name);
        }
    }
// System.out.println("[R] idToItem size : " + idToItem.size());
// for (Item i : idToItem) {
// System.out.println("- " + (i != null ? i.toString() : "null"));
// }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) Item(net.minecraft.item.Item) ResourceLocation(net.minecraft.util.ResourceLocation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Block(net.minecraft.block.Block)

Example 92 with ResourceLocation

use of net.minecraft.util.ResourceLocation in project Railcraft by Railcraft.

the class ClientProxy method initializeClient.

@Override
public void initializeClient() {
    ModelLoaderRegistry.registerLoader(OutfittedTrackModel.Loader.INSTANCE);
    ModelLoaderRegistry.registerLoader(OutfittedTrackItemModel.Loader.INSTANCE);
    ModelLoaderRegistry.registerLoader(ActuatorModel.Loader.INSTANCE);
    MinecraftForge.EVENT_BUS.register(RCSoundHandler.INSTANCE);
    MinecraftForge.EVENT_BUS.register(JSONModelRenderer.INSTANCE);
    MinecraftForge.EVENT_BUS.register(FluidModelRenderer.INSTANCE);
    MinecraftForge.EVENT_BUS.register(GoggleAuraWorldRenderer.INSTANCE);
    MinecraftForge.EVENT_BUS.register(new Object() {

        @SubscribeEvent
        public void textureStitch(TextureStitchEvent.Pre event) {
            //                CartContentRendererRedstoneFlux.instance().setRedstoneIcon(event.getMap().registerSprite(new ResourceLocation("railcraft:entities/carts/cart_redstone_flux")));
            //                CartContentRendererRedstoneFlux.instance().setFrameIcon(event.getMap().registerSprite(new ResourceLocation("railcraft:entities/carts/cart_redstone_flux_frame")));
            ParticleSpark.sprite = event.getMap().registerSprite(new ResourceLocation("railcraft:particle/spark"));
            ParticlePumpkin.sprite = event.getMap().registerSprite(new ResourceLocation("railcraft:particle/pumpkin"));
            for (RailcraftBlocks blockContainer : RailcraftBlocks.VALUES) {
                Block block = blockContainer.block();
                if (block instanceof IRailcraftBlock) {
                    IRailcraftBlock railcraftBlock = (IRailcraftBlock) block;
                    railcraftBlock.registerTextures(event.getMap());
                }
            }
        }
    });
    //        Set<IRailcraftObjectContainer<IRailcraftItemSimple>> items = new HashSet<>();
    //        items.addAll(Arrays.asList(RailcraftItems.VALUES));
    //        items.addAll(Arrays.asList(RailcraftCarts.VALUES));
    //        for (IRailcraftObjectContainer<IRailcraftItemSimple> itemContainer : items) {
    //            itemContainer.getObject().ifPresent(IRailcraftItemSimple::initializeClient);
    //        }
    RailcraftObjects.processItems(IRailcraftItemSimple::initializeClient);
    //        for (RailcraftBlocks blockContainer : RailcraftBlocks.VALUES) {
    //            ItemBlock item = blockContainer.item();
    //            blockContainer.getObject().ifPresent(block -> {
    //                block.initializeClient();
    //                if (item != null) {
    //                    ((IRailcraftObject) item).initializeClient();
    //                    IVariantEnum[] variants = block.getVariants();
    //                    if (variants != null) {
    //                        for (IVariantEnum variant : variants) {
    //                            ItemStack stack = blockContainer.getStack(variant);
    //                            if (stack != null)
    //                                block.registerItemModel(stack, variant);
    //                        }
    //                    } else {
    //                        ItemStack stack = blockContainer.getStack();
    //                        if (stack != null)
    //                            block.registerItemModel(stack, null);
    //                    }
    //                }
    //            });
    //        }
    RailcraftObjects.processBlocks((block, item) -> {
        block.initializeClient();
        if (item != null)
            item.initializeClient();
    }, (block, variant) -> {
        ItemStack stack = block.getStack(variant);
        if (stack != null)
            block.registerItemModel(stack, variant);
    });
    JSONModelRenderer.INSTANCE.registerModel(CartContentRendererRedstoneFlux.CORE_MODEL);
    JSONModelRenderer.INSTANCE.registerModel(CartContentRendererRedstoneFlux.FRAME_MODEL);
    JSONModelRenderer.INSTANCE.registerModel(TESRManipulatorFluid.PIPE_MODEL);
    RenderingRegistry.registerEntityRenderingHandler(EntityTunnelBore.class, RenderTunnelBore::new);
    RenderingRegistry.registerEntityRenderingHandler(EntityMinecart.class, RenderCart::new);
}
Also used : RailcraftBlocks(mods.railcraft.common.blocks.RailcraftBlocks) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) IRailcraftBlock(mods.railcraft.common.blocks.IRailcraftBlock) ResourceLocation(net.minecraft.util.ResourceLocation) TextureStitchEvent(net.minecraftforge.client.event.TextureStitchEvent) Block(net.minecraft.block.Block) IRailcraftBlock(mods.railcraft.common.blocks.IRailcraftBlock) IRailcraftItemSimple(mods.railcraft.common.items.IRailcraftItemSimple) ItemStack(net.minecraft.item.ItemStack)

Example 93 with ResourceLocation

use of net.minecraft.util.ResourceLocation in project Railcraft by Railcraft.

the class ItemTrackOutfitted method initializeClient.

@SideOnly(Side.CLIENT)
@Override
public void initializeClient() {
    ArrayList<ModelResourceLocation> textures = new ArrayList<>();
    for (TrackType trackType : TrackRegistry.TRACK_TYPE) {
        for (TrackKit trackKit : TrackRegistry.TRACK_KIT) {
            textures.add(new ModelResourceLocation(new ResourceLocation(RailcraftConstants.RESOURCE_DOMAIN, MODEL_PREFIX + trackType.getName() + "." + trackKit.getName()), "inventory"));
        }
    }
    ModelManager.registerComplexItemModel(this, (stack -> new ModelResourceLocation(new ResourceLocation(RailcraftConstants.RESOURCE_DOMAIN, MODEL_PREFIX + getSuffix(stack)), "inventory")), textures.toArray(new ModelResourceLocation[textures.size()]));
}
Also used : HashMap(java.util.HashMap) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) Block(net.minecraft.block.Block) Side(net.minecraftforge.fml.relauncher.Side) Map(java.util.Map) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) TrackRegistry(mods.railcraft.api.tracks.TrackRegistry) World(net.minecraft.world.World) ITrackItem(mods.railcraft.api.core.items.ITrackItem) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) ItemTrack(mods.railcraft.common.blocks.tracks.ItemTrack) TrackKit(mods.railcraft.api.tracks.TrackKit) LocalizationPlugin(mods.railcraft.common.plugins.forge.LocalizationPlugin) IBlockState(net.minecraft.block.state.IBlockState) ILocalizedObject(mods.railcraft.api.core.ILocalizedObject) ModelManager(mods.railcraft.client.render.models.resource.ModelManager) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TrackType(mods.railcraft.api.tracks.TrackType) ResourceLocation(net.minecraft.util.ResourceLocation) TileEntity(net.minecraft.tileentity.TileEntity) CreativePlugin(mods.railcraft.common.plugins.forge.CreativePlugin) RailcraftConstants(mods.railcraft.common.core.RailcraftConstants) TrackType(mods.railcraft.api.tracks.TrackType) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ArrayList(java.util.ArrayList) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) TrackKit(mods.railcraft.api.tracks.TrackKit) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 94 with ResourceLocation

use of net.minecraft.util.ResourceLocation in project Railcraft by Railcraft.

the class PipeDefinition_BC8 method registerSprites.

@SideOnly(Side.CLIENT)
public void registerSprites(TextureMap map) {
    sprites = new TextureAtlasSprite[maxSprites];
    for (int i = 0; i < spriteLocations.length; i++) {
        String string = spriteLocations[i];
        ResourceLocation location = new ResourceLocation(string);
        sprites[i] = map.registerSprite(location);
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 95 with ResourceLocation

use of net.minecraft.util.ResourceLocation in project Railcraft by Railcraft.

the class TileTradeStation method readPacketData.

@Override
public void readPacketData(RailcraftInputStream data) throws IOException {
    super.readPacketData(data);
    profession = VillagerRegistry.instance().getRegistry().getValue(new ResourceLocation(data.readUTF()));
    EnumFacing f = EnumFacing.getFront(data.readByte());
    if (direction != f) {
        direction = f;
        markBlockForUpdate();
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) EnumFacing(net.minecraft.util.EnumFacing)

Aggregations

ResourceLocation (net.minecraft.util.ResourceLocation)272 ItemStack (net.minecraft.item.ItemStack)51 Block (net.minecraft.block.Block)47 Item (net.minecraft.item.Item)32 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)31 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)30 IBlockState (net.minecraft.block.state.IBlockState)17 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)15 ArrayList (java.util.ArrayList)14 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)14 Map (java.util.Map)11 EntityPlayer (net.minecraft.entity.player.EntityPlayer)11 ShaderLayer (blusunrize.immersiveengineering.api.shader.ShaderCase.ShaderLayer)10 IOException (java.io.IOException)10 TileEntity (net.minecraft.tileentity.TileEntity)9 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)8 EnumFacing (net.minecraft.util.EnumFacing)8 BlockPos (net.minecraft.util.math.BlockPos)8 Random (java.util.Random)7 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)7