net.minecraft.entity.item.EntityMinecartContainer Java Examples

The following examples show how to use net.minecraft.entity.item.EntityMinecartContainer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TracersModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
private boolean checkFilter(Entity entity) {
    boolean ret = false;

    if (this.players.getValue() && entity instanceof EntityPlayer && entity != Minecraft.getMinecraft().player) {
        ret = true;
    }

    if (this.mobs.getValue() && entity instanceof IMob) {
        ret = true;
    }

    if (this.animals.getValue() && entity instanceof IAnimals && !(entity instanceof IMob)) {
        ret = true;
    }

    if (this.vehicles.getValue() && (entity instanceof EntityBoat || entity instanceof EntityMinecart || entity instanceof EntityMinecartContainer)) {
        ret = true;
    }

    if (this.items.getValue() && entity instanceof EntityItem) {
        ret = true;
    }

    return ret;
}
 
Example #2
Source File: KillAuraModule.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
private boolean checkFilter(Entity entity) {
    boolean ret = false;

    if (this.players.getValue() && entity instanceof EntityPlayer && entity != Minecraft.getMinecraft().player && Seppuku.INSTANCE.getFriendManager().isFriend(entity) == null && !entity.getName().equals(Minecraft.getMinecraft().player.getName())) {
        ret = true;
    }

    if (this.mobs.getValue() && entity instanceof IMob) {
        ret = true;
    }

    if (this.animals.getValue() && entity instanceof IAnimals && !(entity instanceof IMob)) {
        ret = true;
    }

    if (this.vehicles.getValue() && (entity instanceof EntityBoat || entity instanceof EntityMinecart || entity instanceof EntityMinecartContainer)) {
        ret = true;
    }

    if (this.projectiles.getValue() && (entity instanceof EntityShulkerBullet || entity instanceof EntityFireball)) {
        ret = true;
    }

    if (entity instanceof EntityLivingBase) {
        final EntityLivingBase entityLivingBase = (EntityLivingBase) entity;
        if (entityLivingBase.getHealth() <= 0) {
            ret = false;
        }
    }

    return ret;
}
 
Example #3
Source File: TracersModule.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
private int getColor(Entity entity) {
    int ret = -1;

    if (entity instanceof IAnimals && !(entity instanceof IMob)) {
        ret = 0xFF00FF44;
    }

    if (entity instanceof IMob) {
        ret = 0xFFFFAA00;
    }

    if (entity instanceof EntityBoat || entity instanceof EntityMinecart || entity instanceof EntityMinecartContainer) {
        ret = 0xFF00FFAA;
    }

    if (entity instanceof EntityItem) {
        ret = 0xFF00FFAA;
    }

    if (entity instanceof EntityPlayer) {
        ret = 0xFFFF4444;

        if (Seppuku.INSTANCE.getFriendManager().isFriend(entity) != null) {
            ret = 0xFF9900EE;
        }
    }

    return ret;
}
 
Example #4
Source File: ChamsModule.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
private boolean checkFilter(Entity entity) {
    boolean ret = false;

    if (entity == Minecraft.getMinecraft().player) {
        ret = false;
    }

    final Entity riding = Minecraft.getMinecraft().player.getRidingEntity();

    if (riding != null && entity == riding) {
        ret = false;
    }

    if (this.players.getValue() && entity instanceof EntityPlayer && entity != Minecraft.getMinecraft().player) {
        ret = true;
    }

    if (this.animals.getValue() && entity instanceof IAnimals) {
        ret = true;
    }

    if (this.mobs.getValue() && entity instanceof IMob) {
        ret = true;
    }

    if (this.vehicles.getValue() && (entity instanceof EntityBoat || entity instanceof EntityMinecart || entity instanceof EntityMinecartContainer)) {
        ret = true;
    }

    if (this.crystals.getValue() && entity instanceof EntityEnderCrystal) {
        ret = true;
    }

    if (entity instanceof EntityLivingBase) {
        final EntityLivingBase entityLiving = (EntityLivingBase) entity;

        if (entityLiving.ticksExisted <= 0) {
            ret = false;
        }
    }

    return ret;
}
 
Example #5
Source File: BlockTeleportRail.java    From Signals with GNU General Public License v3.0 4 votes vote down vote up
private void teleport(EntityMinecart cart, MCPos destination){
    if(cart instanceof EntityMinecartContainer) {
        ((EntityMinecartContainer)cart).dropContentsWhenDead = false;
    }

    int dimensionIn = destination.getDimID();
    BlockPos destPos = destination.getPos();
    if(!ForgeHooks.onTravelToDimension(cart, destination.getDimID())) return;

    MinecraftServer minecraftserver = cart.getServer();
    int i = cart.dimension;
    WorldServer worldserver = minecraftserver.getWorld(i);
    WorldServer worldserver1 = minecraftserver.getWorld(dimensionIn);
    cart.dimension = dimensionIn;

    /*if (i == 1 && dimensionIn == 1)
    {
        worldserver1 = minecraftserver.getWorld(0);
        this.dimension = 0;
    }*/

    cart.world.removeEntity(cart);
    cart.isDead = false;
    BlockPos blockpos = destination.getPos();

    /* double moveFactor = worldserver.provider.getMovementFactor() / worldserver1.provider.getMovementFactor();
    double d0 = MathHelper.clamp(this.posX * moveFactor, worldserver1.getWorldBorder().minX() + 16.0D, worldserver1.getWorldBorder().maxX() - 16.0D);
    double d1 = MathHelper.clamp(this.posZ * moveFactor, worldserver1.getWorldBorder().minZ() + 16.0D, worldserver1.getWorldBorder().maxZ() - 16.0D);
    double d2 = 8.0D;*/

    cart.moveToBlockPosAndAngles(destPos, 90.0F, 0.0F);
    /*Teleporter teleporter = worldserver1.getDefaultTeleporter();
    teleporter.placeInExistingPortal(this, f);
    blockpos = new BlockPos(this);*/

    worldserver.updateEntityWithOptionalForce(cart, false);
    Entity entity = EntityList.newEntity(cart.getClass(), worldserver1);

    if(entity != null) {
        copyDataFromOld(entity, cart);

        entity.moveToBlockPosAndAngles(blockpos, entity.rotationYaw, entity.rotationPitch);

        IBlockState state = destination.getLoadedBlockState();
        if(state.getBlock() == ModBlocks.TELEPORT_RAIL) { //If the destination is a teleport track, use its rail direction to push the cart the right direction
            EnumFacing teleportDir = getTeleportDirection(state);
            double speed = 0.2;
            entity.motionX = teleportDir.getFrontOffsetX() * speed;
            entity.motionY = teleportDir.getFrontOffsetY() * speed;
            entity.motionZ = teleportDir.getFrontOffsetZ() * speed;
        } else {
            entity.motionX = entity.motionY = entity.motionZ = 0;
        }

        boolean flag = entity.forceSpawn;
        entity.forceSpawn = true;
        worldserver1.spawnEntity(entity);
        entity.forceSpawn = flag;
        worldserver1.updateEntityWithOptionalForce(entity, false);
    }

    cart.isDead = true;
    worldserver.resetUpdateEntityTick();
    worldserver1.resetUpdateEntityTick();
}
 
Example #6
Source File: TeleportEntity.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static Entity teleportEntityToDimension(Entity entity, double x, double y, double z, int dimDst)
{
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    WorldServer worldDst = server.getWorld(dimDst);

    teleportInProgress = true;

    if (worldDst == null || ForgeHooks.onTravelToDimension(entity, dimDst) == false)
    {
        teleportInProgress = false;
        return null;
    }

    teleportInProgress = false;

    // Load the chunk first
    int chunkX = (int) Math.floor(x / 16D);
    int chunkZ = (int) Math.floor(z / 16D);
    ChunkLoading.getInstance().loadChunkForcedWithModTicket(dimDst, chunkX, chunkZ, 10);

    if (entity instanceof EntityPlayerMP)
    {
        EntityPlayerMP player = (EntityPlayerMP) entity;
        World worldOld = player.getEntityWorld();
        DummyTeleporter teleporter = new DummyTeleporter(worldDst);

        player.setLocationAndAngles(x, y, z, player.rotationYaw, player.rotationPitch);
        server.getPlayerList().transferPlayerToDimension(player, dimDst, teleporter);

        // Teleporting FROM The End, remove the boss bar that would otherwise get stuck on
        if (worldOld.provider instanceof WorldProviderEnd)
        {
            removeDragonBossBarHack(player, (WorldProviderEnd) worldOld.provider);
        }

        player.setPositionAndUpdate(x, y, z);
        worldDst.updateEntityWithOptionalForce(player, false);
        player.addExperienceLevel(0);
        player.setPlayerHealthUpdated();
        // TODO update food level?
    }
    else
    {
        WorldServer worldSrc = (WorldServer) entity.getEntityWorld();

        // FIXME ugly special case to prevent the chest minecart etc from duping items
        if (entity instanceof EntityMinecartContainer)
        {
            ((EntityMinecartContainer) entity).setDropItemsWhenDead(false);
        }

        Entity entityNew = EntityList.newEntity(entity.getClass(), worldDst);

        if (entityNew != null)
        {
            EntityUtils.copyDataFromOld(entityNew, entity);
            entityNew.setLocationAndAngles(x, y, z, entity.rotationYaw, entity.rotationPitch);

            boolean flag = entityNew.forceSpawn;
            entityNew.forceSpawn = true;
            worldDst.spawnEntity(entityNew);
            entityNew.forceSpawn = flag;

            worldDst.updateEntityWithOptionalForce(entityNew, false);
            entity.isDead = true;

            worldSrc.removeEntity(entity);
            worldSrc.updateEntityWithOptionalForce(entity, false);

            worldSrc.resetUpdateEntityTick();
            worldDst.resetUpdateEntityTick();
        }

        entity = entityNew;
    }

    return entity;
}