Java 类net.minecraft.entity.item.EntityMinecart 实例源码

项目:DecompiledMinecraft    文件:BlockRailDetector.java   
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
    if (((Boolean)worldIn.getBlockState(pos).getValue(POWERED)).booleanValue())
    {
        List<EntityMinecartCommandBlock> list = this.<EntityMinecartCommandBlock>findMinecarts(worldIn, pos, EntityMinecartCommandBlock.class, new Predicate[0]);

        if (!list.isEmpty())
        {
            return ((EntityMinecartCommandBlock)list.get(0)).getCommandBlockLogic().getSuccessCount();
        }

        List<EntityMinecart> list1 = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[] {EntitySelectors.selectInventories});

        if (!list1.isEmpty())
        {
            return Container.calcRedstoneFromInventory((IInventory)list1.get(0));
        }
    }

    return 0;
}
项目:DecompiledMinecraft    文件:MobSpawnerBaseLogic.java   
private WeightedRandomMinecart(NBTTagCompound tagCompound, String type, int weight)
{
    super(weight);

    if (type.equals("Minecart"))
    {
        if (tagCompound != null)
        {
            type = EntityMinecart.EnumMinecartType.byNetworkID(tagCompound.getInteger("Type")).getName();
        }
        else
        {
            type = "MinecartRideable";
        }
    }

    this.nbtData = tagCompound;
    this.entityType = type;
}
项目:DecompiledMinecraft    文件:BlockRailDetector.java   
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
    if (((Boolean)worldIn.getBlockState(pos).getValue(POWERED)).booleanValue())
    {
        List<EntityMinecartCommandBlock> list = this.<EntityMinecartCommandBlock>findMinecarts(worldIn, pos, EntityMinecartCommandBlock.class, new Predicate[0]);

        if (!list.isEmpty())
        {
            return ((EntityMinecartCommandBlock)list.get(0)).getCommandBlockLogic().getSuccessCount();
        }

        List<EntityMinecart> list1 = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[] {EntitySelectors.selectInventories});

        if (!list1.isEmpty())
        {
            return Container.calcRedstoneFromInventory((IInventory)list1.get(0));
        }
    }

    return 0;
}
项目:DecompiledMinecraft    文件:WorldClient.java   
/**
 * Called when an entity is spawned in the world. This includes players.
 */
public boolean spawnEntityInWorld(Entity entityIn)
{
    boolean flag = super.spawnEntityInWorld(entityIn);
    this.entityList.add(entityIn);

    if (!flag)
    {
        this.entitySpawnQueue.add(entityIn);
    }
    else if (entityIn instanceof EntityMinecart)
    {
        this.mc.getSoundHandler().playSound(new MovingSoundMinecart((EntityMinecart)entityIn));
    }

    return flag;
}
项目:DecompiledMinecraft    文件:MobSpawnerBaseLogic.java   
private WeightedRandomMinecart(NBTTagCompound tagCompound, String type, int weight)
{
    super(weight);

    if (type.equals("Minecart"))
    {
        if (tagCompound != null)
        {
            type = EntityMinecart.EnumMinecartType.byNetworkID(tagCompound.getInteger("Type")).getName();
        }
        else
        {
            type = "MinecartRideable";
        }
    }

    this.nbtData = tagCompound;
    this.entityType = type;
}
项目:BaseClient    文件:BlockRailDetector.java   
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
    if (((Boolean)worldIn.getBlockState(pos).getValue(POWERED)).booleanValue())
    {
        List<EntityMinecartCommandBlock> list = this.<EntityMinecartCommandBlock>findMinecarts(worldIn, pos, EntityMinecartCommandBlock.class, new Predicate[0]);

        if (!list.isEmpty())
        {
            return ((EntityMinecartCommandBlock)list.get(0)).getCommandBlockLogic().getSuccessCount();
        }

        List<EntityMinecart> list1 = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[] {EntitySelectors.selectInventories});

        if (!list1.isEmpty())
        {
            return Container.calcRedstoneFromInventory((IInventory)list1.get(0));
        }
    }

    return 0;
}
项目:BaseClient    文件:WorldClient.java   
/**
 * Called when an entity is spawned in the world. This includes players.
 */
public boolean spawnEntityInWorld(Entity entityIn)
{
    boolean flag = super.spawnEntityInWorld(entityIn);
    this.entityList.add(entityIn);

    if (!flag)
    {
        this.entitySpawnQueue.add(entityIn);
    }
    else if (entityIn instanceof EntityMinecart)
    {
        this.mc.getSoundHandler().playSound(new MovingSoundMinecart((EntityMinecart)entityIn));
    }

    return flag;
}
项目:BaseClient    文件:MobSpawnerBaseLogic.java   
private WeightedRandomMinecart(NBTTagCompound tagCompound, String type, int weight)
{
    super(weight);

    if (type.equals("Minecart"))
    {
        if (tagCompound != null)
        {
            type = EntityMinecart.EnumMinecartType.byNetworkID(tagCompound.getInteger("Type")).getName();
        }
        else
        {
            type = "MinecartRideable";
        }
    }

    this.nbtData = tagCompound;
    this.entityType = type;
}
项目:BaseClient    文件:BlockRailDetector.java   
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
    if (((Boolean)worldIn.getBlockState(pos).getValue(POWERED)).booleanValue())
    {
        List<EntityMinecartCommandBlock> list = this.<EntityMinecartCommandBlock>findMinecarts(worldIn, pos, EntityMinecartCommandBlock.class, new Predicate[0]);

        if (!list.isEmpty())
        {
            return ((EntityMinecartCommandBlock)list.get(0)).getCommandBlockLogic().getSuccessCount();
        }

        List<EntityMinecart> list1 = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[] {EntitySelectors.selectInventories});

        if (!list1.isEmpty())
        {
            return Container.calcRedstoneFromInventory((IInventory)list1.get(0));
        }
    }

    return 0;
}
项目:BaseClient    文件:WorldClient.java   
/**
 * Called when an entity is spawned in the world. This includes players.
 */
public boolean spawnEntityInWorld(Entity entityIn)
{
    boolean flag = super.spawnEntityInWorld(entityIn);
    this.entityList.add(entityIn);

    if (!flag)
    {
        this.entitySpawnQueue.add(entityIn);
    }
    else if (entityIn instanceof EntityMinecart)
    {
        this.mc.getSoundHandler().playSound(new MovingSoundMinecart((EntityMinecart)entityIn));
    }

    return flag;
}
项目:BaseClient    文件:MobSpawnerBaseLogic.java   
private WeightedRandomMinecart(NBTTagCompound tagCompound, String type, int weight)
{
    super(weight);

    if (type.equals("Minecart"))
    {
        if (tagCompound != null)
        {
            type = EntityMinecart.EnumMinecartType.byNetworkID(tagCompound.getInteger("Type")).getName();
        }
        else
        {
            type = "MinecartRideable";
        }
    }

    this.nbtData = tagCompound;
    this.entityType = type;
}
项目:Zombe-Modpack    文件:EntityPlayerSP.java   
public boolean startRiding(Entity entityIn, boolean force)
{
    if (!super.startRiding(entityIn, force))
    {
        return false;
    }
    else
    {
        if (entityIn instanceof EntityMinecart)
        {
            this.mc.getSoundHandler().playSound(new MovingSoundMinecartRiding(this, (EntityMinecart)entityIn));
        }

        if (entityIn instanceof EntityBoat)
        {
            this.prevRotationYaw = entityIn.rotationYaw;
            this.rotationYaw = entityIn.rotationYaw;
            this.setRotationYawHead(entityIn.rotationYaw);
        }

        return true;
    }
}
项目:Backmemed    文件:BlockRailDetector.java   
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos)
{
    if (((Boolean)blockState.getValue(POWERED)).booleanValue())
    {
        List<EntityMinecartCommandBlock> list = this.<EntityMinecartCommandBlock>findMinecarts(worldIn, pos, EntityMinecartCommandBlock.class, new Predicate[0]);

        if (!list.isEmpty())
        {
            return ((EntityMinecartCommandBlock)list.get(0)).getCommandBlockLogic().getSuccessCount();
        }

        List<EntityMinecart> list1 = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[] {EntitySelectors.HAS_INVENTORY});

        if (!list1.isEmpty())
        {
            return Container.calcRedstoneFromInventory((IInventory)list1.get(0));
        }
    }

    return 0;
}
项目:Backmemed    文件:EntityPlayerSP.java   
public boolean startRiding(Entity entityIn, boolean force)
{
    if (!super.startRiding(entityIn, force))
    {
        return false;
    }
    else
    {
        if (entityIn instanceof EntityMinecart)
        {
            this.mc.getSoundHandler().playSound(new MovingSoundMinecartRiding(this, (EntityMinecart)entityIn));
        }

        if (entityIn instanceof EntityBoat)
        {
            this.prevRotationYaw = entityIn.rotationYaw;
            this.rotationYaw = entityIn.rotationYaw;
            this.setRotationYawHead(entityIn.rotationYaw);
        }

        return true;
    }
}
项目:Backmemed    文件:WorldClient.java   
/**
 * Called when an entity is spawned in the world. This includes players.
 */
public boolean spawnEntityInWorld(Entity entityIn)
{
    boolean flag = super.spawnEntityInWorld(entityIn);
    this.entityList.add(entityIn);

    if (flag)
    {
        if (entityIn instanceof EntityMinecart)
        {
            this.mc.getSoundHandler().playSound(new MovingSoundMinecart((EntityMinecart)entityIn));
        }
    }
    else
    {
        this.entitySpawnQueue.add(entityIn);
    }

    return flag;
}
项目:CustomWorldGen    文件:WorldClient.java   
/**
 * Called when an entity is spawned in the world. This includes players.
 */
public boolean spawnEntityInWorld(Entity entityIn)
{
    boolean flag = super.spawnEntityInWorld(entityIn);
    this.entityList.add(entityIn);

    if (flag)
    {
        if (entityIn instanceof EntityMinecart)
        {
            this.mc.getSoundHandler().playSound(new MovingSoundMinecart((EntityMinecart)entityIn));
        }
    }
    else
    {
        this.entitySpawnQueue.add(entityIn);
    }

    return flag;
}
项目:CustomWorldGen    文件:EntityPlayerSP.java   
public boolean startRiding(Entity entityIn, boolean force)
{
    if (!super.startRiding(entityIn, force))
    {
        return false;
    }
    else
    {
        if (entityIn instanceof EntityMinecart)
        {
            this.mc.getSoundHandler().playSound(new MovingSoundMinecartRiding(this, (EntityMinecart)entityIn));
        }

        if (entityIn instanceof EntityBoat)
        {
            this.prevRotationYaw = entityIn.rotationYaw;
            this.rotationYaw = entityIn.rotationYaw;
            this.setRotationYawHead(entityIn.rotationYaw);
        }

        return true;
    }
}
项目:pnc-repressurized    文件:PneumaticCraftUtils.java   
private static boolean isEntityValidForName(String filter, Entity entity) throws IllegalArgumentException {
    if (filter.equals("")) {
        return true;
    } else if (filter.startsWith("@")) {//entity type selection
        filter = filter.substring(1); //cut off the '@'.
        Class typeClass = null;
        if (filter.equals("mob")) {
            typeClass = EntityMob.class;
        } else if (filter.equals("animal")) {
            typeClass = EntityAnimal.class;
        } else if (filter.equals("living")) {
            typeClass = EntityLivingBase.class;
        } else if (filter.equals("player")) {
            typeClass = EntityPlayer.class;
        } else if (filter.equals("item")) {
            typeClass = EntityItem.class;
        } else if (filter.equals("minecart")) {
            typeClass = EntityMinecart.class;
        } else if (filter.equals("drone")) {
            typeClass = EntityDrone.class;
        }
        if (typeClass != null) {
            return typeClass.isAssignableFrom(entity.getClass());
        } else {
            throw new IllegalArgumentException(filter + " is not a valid entity type.");
        }
    } else {
        try {
            String regex = filter.toLowerCase().replaceAll(".", "[$0]").replace("[*]", ".*");//Wildcard regex
            return entity.getName().toLowerCase().matches(regex);//TODO when player, check if entity is tamed by the player (see EntityAIAvoidEntity for example)
        } catch (PatternSyntaxException e) {
            return entity.getName().toLowerCase().equals(filter.toLowerCase());
        }
    }
}
项目:DecompiledMinecraft    文件:EntityList.java   
/**
 * create a new instance of an entity from NBT store
 */
public static Entity createEntityFromNBT(NBTTagCompound nbt, World worldIn)
{
    Entity entity = null;

    if ("Minecart".equals(nbt.getString("id")))
    {
        nbt.setString("id", EntityMinecart.EnumMinecartType.byNetworkID(nbt.getInteger("Type")).getName());
        nbt.removeTag("Type");
    }

    try
    {
        Class <? extends Entity > oclass = (Class)stringToClassMapping.get(nbt.getString("id"));

        if (oclass != null)
        {
            entity = (Entity)oclass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {worldIn});
        }
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }

    if (entity != null)
    {
        entity.readFromNBT(nbt);
    }
    else
    {
        logger.warn("Skipping Entity with id " + nbt.getString("id"));
    }

    return entity;
}
项目:DecompiledMinecraft    文件:EntityPlayer.java   
/**
 * Adds a value to a mounted movement statistic field - by minecart, boat, or pig.
 */
private void addMountedMovementStat(double p_71015_1_, double p_71015_3_, double p_71015_5_)
{
    if (this.ridingEntity != null)
    {
        int i = Math.round(MathHelper.sqrt_double(p_71015_1_ * p_71015_1_ + p_71015_3_ * p_71015_3_ + p_71015_5_ * p_71015_5_) * 100.0F);

        if (i > 0)
        {
            if (this.ridingEntity instanceof EntityMinecart)
            {
                this.addStat(StatList.distanceByMinecartStat, i);

                if (this.startMinecartRidingCoordinate == null)
                {
                    this.startMinecartRidingCoordinate = new BlockPos(this);
                }
                else if (this.startMinecartRidingCoordinate.distanceSq((double)MathHelper.floor_double(this.posX), (double)MathHelper.floor_double(this.posY), (double)MathHelper.floor_double(this.posZ)) >= 1000000.0D)
                {
                    this.triggerAchievement(AchievementList.onARail);
                }
            }
            else if (this.ridingEntity instanceof EntityBoat)
            {
                this.addStat(StatList.distanceByBoatStat, i);
            }
            else if (this.ridingEntity instanceof EntityPig)
            {
                this.addStat(StatList.distanceByPigStat, i);
            }
            else if (this.ridingEntity instanceof EntityHorse)
            {
                this.addStat(StatList.distanceByHorseStat, i);
            }
        }
    }
}
项目:DecompiledMinecraft    文件:ItemMinecart.java   
public ItemMinecart(EntityMinecart.EnumMinecartType type)
{
    this.maxStackSize = 1;
    this.minecartType = type;
    this.setCreativeTab(CreativeTabs.tabTransport);
    BlockDispenser.dispenseBehaviorRegistry.putObject(this, dispenserMinecartBehavior);
}
项目:DecompiledMinecraft    文件:ItemMinecart.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (BlockRailBase.isRailBlock(iblockstate))
    {
        if (!worldIn.isRemote)
        {
            BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
            double d0 = 0.0D;

            if (blockrailbase$enumraildirection.isAscending())
            {
                d0 = 0.5D;
            }

            EntityMinecart entityminecart = EntityMinecart.func_180458_a(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.0625D + d0, (double)pos.getZ() + 0.5D, this.minecartType);

            if (stack.hasDisplayName())
            {
                entityminecart.setCustomNameTag(stack.getDisplayName());
            }

            worldIn.spawnEntityInWorld(entityminecart);
        }

        --stack.stackSize;
        return true;
    }
    else
    {
        return false;
    }
}
项目:DecompiledMinecraft    文件:BlockRailDetector.java   
private void updatePoweredState(World worldIn, BlockPos pos, IBlockState state)
{
    boolean flag = ((Boolean)state.getValue(POWERED)).booleanValue();
    boolean flag1 = false;
    List<EntityMinecart> list = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[0]);

    if (!list.isEmpty())
    {
        flag1 = true;
    }

    if (flag1 && !flag)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)), 3);
        worldIn.notifyNeighborsOfStateChange(pos, this);
        worldIn.notifyNeighborsOfStateChange(pos.down(), this);
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
    }

    if (!flag1 && flag)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)), 3);
        worldIn.notifyNeighborsOfStateChange(pos, this);
        worldIn.notifyNeighborsOfStateChange(pos.down(), this);
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
    }

    if (flag1)
    {
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
    }

    worldIn.updateComparatorOutputLevel(pos, this);
}
项目:DecompiledMinecraft    文件:EntityList.java   
/**
 * create a new instance of an entity from NBT store
 */
public static Entity createEntityFromNBT(NBTTagCompound nbt, World worldIn)
{
    Entity entity = null;

    if ("Minecart".equals(nbt.getString("id")))
    {
        nbt.setString("id", EntityMinecart.EnumMinecartType.byNetworkID(nbt.getInteger("Type")).getName());
        nbt.removeTag("Type");
    }

    try
    {
        Class <? extends Entity > oclass = (Class)stringToClassMapping.get(nbt.getString("id"));

        if (oclass != null)
        {
            entity = (Entity)oclass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {worldIn});
        }
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }

    if (entity != null)
    {
        entity.readFromNBT(nbt);
    }
    else
    {
        logger.warn("Skipping Entity with id " + nbt.getString("id"));
    }

    return entity;
}
项目:DecompiledMinecraft    文件:EntityPlayer.java   
/**
 * Adds a value to a mounted movement statistic field - by minecart, boat, or pig.
 */
private void addMountedMovementStat(double p_71015_1_, double p_71015_3_, double p_71015_5_)
{
    if (this.ridingEntity != null)
    {
        int i = Math.round(MathHelper.sqrt_double(p_71015_1_ * p_71015_1_ + p_71015_3_ * p_71015_3_ + p_71015_5_ * p_71015_5_) * 100.0F);

        if (i > 0)
        {
            if (this.ridingEntity instanceof EntityMinecart)
            {
                this.addStat(StatList.distanceByMinecartStat, i);

                if (this.startMinecartRidingCoordinate == null)
                {
                    this.startMinecartRidingCoordinate = new BlockPos(this);
                }
                else if (this.startMinecartRidingCoordinate.distanceSq((double)MathHelper.floor_double(this.posX), (double)MathHelper.floor_double(this.posY), (double)MathHelper.floor_double(this.posZ)) >= 1000000.0D)
                {
                    this.triggerAchievement(AchievementList.onARail);
                }
            }
            else if (this.ridingEntity instanceof EntityBoat)
            {
                this.addStat(StatList.distanceByBoatStat, i);
            }
            else if (this.ridingEntity instanceof EntityPig)
            {
                this.addStat(StatList.distanceByPigStat, i);
            }
            else if (this.ridingEntity instanceof EntityHorse)
            {
                this.addStat(StatList.distanceByHorseStat, i);
            }
        }
    }
}
项目:DecompiledMinecraft    文件:ItemMinecart.java   
public ItemMinecart(EntityMinecart.EnumMinecartType type)
{
    this.maxStackSize = 1;
    this.minecartType = type;
    this.setCreativeTab(CreativeTabs.tabTransport);
    BlockDispenser.dispenseBehaviorRegistry.putObject(this, dispenserMinecartBehavior);
}
项目:DecompiledMinecraft    文件:ItemMinecart.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (BlockRailBase.isRailBlock(iblockstate))
    {
        if (!worldIn.isRemote)
        {
            BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
            double d0 = 0.0D;

            if (blockrailbase$enumraildirection.isAscending())
            {
                d0 = 0.5D;
            }

            EntityMinecart entityminecart = EntityMinecart.func_180458_a(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.0625D + d0, (double)pos.getZ() + 0.5D, this.minecartType);

            if (stack.hasDisplayName())
            {
                entityminecart.setCustomNameTag(stack.getDisplayName());
            }

            worldIn.spawnEntityInWorld(entityminecart);
        }

        --stack.stackSize;
        return true;
    }
    else
    {
        return false;
    }
}
项目:DecompiledMinecraft    文件:BlockRailDetector.java   
private void updatePoweredState(World worldIn, BlockPos pos, IBlockState state)
{
    boolean flag = ((Boolean)state.getValue(POWERED)).booleanValue();
    boolean flag1 = false;
    List<EntityMinecart> list = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[0]);

    if (!list.isEmpty())
    {
        flag1 = true;
    }

    if (flag1 && !flag)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)), 3);
        worldIn.notifyNeighborsOfStateChange(pos, this);
        worldIn.notifyNeighborsOfStateChange(pos.down(), this);
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
    }

    if (!flag1 && flag)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)), 3);
        worldIn.notifyNeighborsOfStateChange(pos, this);
        worldIn.notifyNeighborsOfStateChange(pos.down(), this);
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
    }

    if (flag1)
    {
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
    }

    worldIn.updateComparatorOutputLevel(pos, this);
}
项目:DecompiledMinecraft    文件:EntityPlayerSP.java   
/**
 * Called when a player mounts an entity. e.g. mounts a pig, mounts a boat.
 */
public void mountEntity(Entity entityIn)
{
    super.mountEntity(entityIn);

    if (entityIn instanceof EntityMinecart)
    {
        this.mc.getSoundHandler().playSound(new MovingSoundMinecartRiding(this, (EntityMinecart)entityIn));
    }
}
项目:DecompiledMinecraft    文件:MovingSoundMinecartRiding.java   
public MovingSoundMinecartRiding(EntityPlayer playerRiding, EntityMinecart minecart)
{
    super(new ResourceLocation("minecraft:minecart.inside"));
    this.player = playerRiding;
    this.minecart = minecart;
    this.attenuationType = ISound.AttenuationType.NONE;
    this.repeat = true;
    this.repeatDelay = 0;
}
项目:DecompiledMinecraft    文件:MovingSoundMinecart.java   
public MovingSoundMinecart(EntityMinecart minecartIn)
{
    super(new ResourceLocation("minecraft:minecart.base"));
    this.minecart = minecartIn;
    this.repeat = true;
    this.repeatDelay = 0;
}
项目:chesttransporter    文件:ChestRegistry.java   
public static EntityMinecart createMinecart(World world, TransportableChest chest)
{
    try
    {
        return getMinecartClass(chest).getConstructor(World.class).newInstance(world);
    } catch (Exception e)
    {
        e.printStackTrace();
    }

    return null;
}
项目:BaseClient    文件:EntityList.java   
/**
 * create a new instance of an entity from NBT store
 */
public static Entity createEntityFromNBT(NBTTagCompound nbt, World worldIn)
{
    Entity entity = null;

    if ("Minecart".equals(nbt.getString("id")))
    {
        nbt.setString("id", EntityMinecart.EnumMinecartType.byNetworkID(nbt.getInteger("Type")).getName());
        nbt.removeTag("Type");
    }

    try
    {
        Class <? extends Entity > oclass = (Class)stringToClassMapping.get(nbt.getString("id"));

        if (oclass != null)
        {
            entity = (Entity)oclass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {worldIn});
        }
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }

    if (entity != null)
    {
        entity.readFromNBT(nbt);
    }
    else
    {
        logger.warn("Skipping Entity with id " + nbt.getString("id"));
    }

    return entity;
}
项目:BaseClient    文件:EntityPlayer.java   
/**
 * Adds a value to a mounted movement statistic field - by minecart, boat, or pig.
 */
private void addMountedMovementStat(double p_71015_1_, double p_71015_3_, double p_71015_5_)
{
    if (this.ridingEntity != null)
    {
        int i = Math.round(MathHelper.sqrt_double(p_71015_1_ * p_71015_1_ + p_71015_3_ * p_71015_3_ + p_71015_5_ * p_71015_5_) * 100.0F);

        if (i > 0)
        {
            if (this.ridingEntity instanceof EntityMinecart)
            {
                this.addStat(StatList.distanceByMinecartStat, i);

                if (this.startMinecartRidingCoordinate == null)
                {
                    this.startMinecartRidingCoordinate = new BlockPos(this);
                }
                else if (this.startMinecartRidingCoordinate.distanceSq((double)MathHelper.floor_double(this.posX), (double)MathHelper.floor_double(this.posY), (double)MathHelper.floor_double(this.posZ)) >= 1000000.0D)
                {
                    this.triggerAchievement(AchievementList.onARail);
                }
            }
            else if (this.ridingEntity instanceof EntityBoat)
            {
                this.addStat(StatList.distanceByBoatStat, i);
            }
            else if (this.ridingEntity instanceof EntityPig)
            {
                this.addStat(StatList.distanceByPigStat, i);
            }
            else if (this.ridingEntity instanceof EntityHorse)
            {
                this.addStat(StatList.distanceByHorseStat, i);
            }
        }
    }
}
项目:BaseClient    文件:ItemMinecart.java   
public ItemMinecart(EntityMinecart.EnumMinecartType type)
{
    this.maxStackSize = 1;
    this.minecartType = type;
    this.setCreativeTab(CreativeTabs.tabTransport);
    BlockDispenser.dispenseBehaviorRegistry.putObject(this, dispenserMinecartBehavior);
}
项目:BaseClient    文件:ItemMinecart.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (BlockRailBase.isRailBlock(iblockstate))
    {
        if (!worldIn.isRemote)
        {
            BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
            double d0 = 0.0D;

            if (blockrailbase$enumraildirection.isAscending())
            {
                d0 = 0.5D;
            }

            EntityMinecart entityminecart = EntityMinecart.func_180458_a(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.0625D + d0, (double)pos.getZ() + 0.5D, this.minecartType);

            if (stack.hasDisplayName())
            {
                entityminecart.setCustomNameTag(stack.getDisplayName());
            }

            worldIn.spawnEntityInWorld(entityminecart);
        }

        --stack.stackSize;
        return true;
    }
    else
    {
        return false;
    }
}
项目:BaseClient    文件:BlockRailDetector.java   
private void updatePoweredState(World worldIn, BlockPos pos, IBlockState state)
{
    boolean flag = ((Boolean)state.getValue(POWERED)).booleanValue();
    boolean flag1 = false;
    List<EntityMinecart> list = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[0]);

    if (!list.isEmpty())
    {
        flag1 = true;
    }

    if (flag1 && !flag)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)), 3);
        worldIn.notifyNeighborsOfStateChange(pos, this);
        worldIn.notifyNeighborsOfStateChange(pos.down(), this);
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
    }

    if (!flag1 && flag)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)), 3);
        worldIn.notifyNeighborsOfStateChange(pos, this);
        worldIn.notifyNeighborsOfStateChange(pos.down(), this);
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
    }

    if (flag1)
    {
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
    }

    worldIn.updateComparatorOutputLevel(pos, this);
}
项目:BaseClient    文件:EntityPlayerSP.java   
/**
 * Called when a player mounts an entity. e.g. mounts a pig, mounts a boat.
 */
public void mountEntity(Entity entityIn)
{
    super.mountEntity(entityIn);

    if (entityIn instanceof EntityMinecart)
    {
        this.mc.getSoundHandler().playSound(new MovingSoundMinecartRiding(this, (EntityMinecart)entityIn));
    }
}
项目:BaseClient    文件:MovingSoundMinecartRiding.java   
public MovingSoundMinecartRiding(EntityPlayer playerRiding, EntityMinecart minecart)
{
    super(new ResourceLocation("minecraft:minecart.inside"));
    this.player = playerRiding;
    this.minecart = minecart;
    this.attenuationType = ISound.AttenuationType.NONE;
    this.repeat = true;
    this.repeatDelay = 0;
}
项目:BaseClient    文件:MovingSoundMinecart.java   
public MovingSoundMinecart(EntityMinecart minecartIn)
{
    super(new ResourceLocation("minecraft:minecart.base"));
    this.minecart = minecartIn;
    this.repeat = true;
    this.repeatDelay = 0;
}