Java 类net.minecraftforge.common.model.animation.CapabilityAnimation 实例源码

项目:CustomWorldGen    文件:AnimationItemOverrideList.java   
@Override
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity)
{
    if(stack.hasCapability(net.minecraftforge.common.model.animation.CapabilityAnimation.ANIMATION_CAPABILITY, null))
    {
        // TODO: caching?
        IAnimationStateMachine asm = stack.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null);
        if(world == null)
        {
            world = entity.worldObj;
        }
        if(world == null)
        {
            world = Minecraft.getMinecraft().theWorld;
        }
        IModelState state = asm.apply(Animation.getWorldTime(world, Animation.getPartialTickTime())).getLeft();
        return model.bake(new ModelStateComposition(state, this.state), format, bakedTextureGetter);
    }
    return super.handleItemState(originalModel, stack, world, entity);
}
项目:CustomWorldGen    文件:ForgeModContainer.java   
@Subscribe
public void preInit(FMLPreInitializationEvent evt)
{
    CapabilityItemHandler.register();
    CapabilityFluidHandler.register();
    CapabilityAnimation.register();
    CapabilityEnergy.register();
    MinecraftForge.EVENT_BUS.register(MinecraftForge.INTERNAL_HANDLER);
    ForgeChunkManager.captureConfig(evt.getModConfigurationDirectory());
    MinecraftForge.EVENT_BUS.register(this);

    if (!ForgeModContainer.disableVersionCheck)
    {
        ForgeVersion.startVersionCheck();
    }

    // Add and register the forge universal bucket, if it's enabled
    if(FluidRegistry.isUniversalBucketEnabled())
    {
        universalBucket = new UniversalBucket();
        universalBucket.setUnlocalizedName("forge.bucketFilled");
        GameRegistry.registerItem(universalBucket, "bucketFilled");
        MinecraftForge.EVENT_BUS.register(universalBucket);
    }
}
项目:CustomWorldGen    文件:AnimationTESR.java   
public void renderTileEntityFast(T te, double x, double y, double z, float partialTick, int breakStage, VertexBuffer renderer)
{
    if(!te.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null))
    {
        return;
    }
    if(blockRenderer == null) blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockPos pos = te.getPos();
    IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos);
    IBlockState state = world.getBlockState(pos);
    if(state.getPropertyNames().contains(Properties.StaticProperty))
    {
        state = state.withProperty(Properties.StaticProperty, false);
    }
    if(state instanceof IExtendedBlockState)
    {
        IExtendedBlockState exState = (IExtendedBlockState)state;
        if(exState.getUnlistedNames().contains(Properties.AnimationProperty))
        {
            float time = Animation.getWorldTime(getWorld(), partialTick);
            Pair<IModelState, Iterable<Event>> pair = te.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null).apply(time);
            handleEvents(te, time, pair.getRight());

            // TODO: caching?
            IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean());
            exState = exState.withProperty(Properties.AnimationProperty, pair.getLeft());

            renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());

            blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, renderer, false);
        }
    }
}
项目:OpenBlocks    文件:TileEntityPaintMixerRenderer.java   
@Override
public void renderTileEntityFast(TileEntityPaintMixer te, double x, double y, double z, float partialTick, int breakStage, float alpha, BufferBuilder renderer) {
    if (te.hasPaint()) {
        if (!te.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null)) { return; }
        if (blockRenderer == null) blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();

        final BlockPos pos = te.getPos();
        final IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos);
        IBlockState state = world.getBlockState(pos);

        if (state.getPropertyKeys().contains(Properties.StaticProperty)) {
            state = state.withProperty(Properties.StaticProperty, false);
        }

        if (state instanceof IExtendedBlockState) {
            state = state.getBlock().getExtendedState(state, world, pos); // difference between this and AnimationTESR

            IExtendedBlockState exState = (IExtendedBlockState)state;
            if (exState.getUnlistedNames().contains(Properties.AnimationProperty)) {
                float time = Animation.getWorldTime(getWorld(), partialTick);
                Pair<IModelState, Iterable<Event>> pair = te.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null).apply(time);

                IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean());
                exState = exState.withProperty(Properties.AnimationProperty, pair.getLeft());

                renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());

                blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, renderer, false);
            }
        }
    }
}
项目:OpenBlocks    文件:TileEntityPaintMixer.java   
@Override
@SuppressWarnings("unchecked")
public <T> T getCapability(Capability<T> capability, EnumFacing side) {
    if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
        return (T)asm;

    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return (T)inventory.getHandler();

    return super.getCapability(capability, side);
}
项目:OpenBlocks    文件:TileEntityProjector.java   
@Override
@SuppressWarnings("unchecked")
public <T> T getCapability(Capability<T> capability, EnumFacing side) {
    if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
        return (T)asm;

    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return (T)inventory.getHandler();

    return super.getCapability(capability, side);
}
项目:Solar    文件:TilePhenomena.java   
@Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
    return capability == CapabilityAnimation.ANIMATION_CAPABILITY;
}
项目:Solar    文件:TilePhenomena.java   
@Nullable
@Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
    return capability == CapabilityAnimation.ANIMATION_CAPABILITY ? CapabilityAnimation.ANIMATION_CAPABILITY.cast(animation) : null;
}
项目:OpenBlocks    文件:TileEntityProjectorRenderer.java   
private void renderProjector(TileEntityProjector projector, float partialTickTime, double x, double y, double z) {
    if (bakedSpinnerModel == null) return;
    if (!projector.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null)) return;

    if (blockModelRenderer == null) {
        blockModelRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer();
    }

    final BlockPos pos = projector.getPos();
    final IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(projector.getWorld(), pos);
    final IBlockState state = world.getBlockState(pos);

    if (state instanceof IExtendedBlockState) {
        IExtendedBlockState exState = (IExtendedBlockState)state;
        if (exState.getUnlistedNames().contains(Properties.AnimationProperty)) {
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder vb = tessellator.getBuffer();
            bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            RenderHelper.disableStandardItemLighting();
            GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            GlStateManager.enableBlend();
            GlStateManager.disableCull();

            if (Minecraft.isAmbientOcclusionEnabled()) {
                GlStateManager.shadeModel(GL11.GL_SMOOTH);
            } else {
                GlStateManager.shadeModel(GL11.GL_FLAT);
            }

            vb.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);

            float time = Animation.getWorldTime(getWorld(), partialTickTime);
            final Pair<IModelState, Iterable<Event>> pair = projector.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null).apply(time);
            exState = exState.withProperty(Properties.AnimationProperty, pair.getLeft());

            vb.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());

            blockModelRenderer.renderModel(world, bakedSpinnerModel, exState, pos, vb, false);

            vb.setTranslation(0, 0, 0);

            tessellator.draw();

            RenderHelper.enableStandardItemLighting();
        }
    }
}
项目:OpenBlocks    文件:TileEntityPaintMixer.java   
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing side) {
    return capability == CapabilityAnimation.ANIMATION_CAPABILITY ||
            capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ||
            super.hasCapability(capability, side);
}
项目:OpenBlocks    文件:TileEntityProjector.java   
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing side) {
    return capability == CapabilityAnimation.ANIMATION_CAPABILITY ||
            capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ||
            super.hasCapability(capability, side);
}