Search in sources :

Example 1 with EntityItemFrame

use of net.minecraft.entity.item.EntityItemFrame in project ImmersiveEngineering by BluSunrize.

the class VillageEngineersHouse method placeItemframe.

public void placeItemframe(Random random, World world, int x, int y, int z, EnumFacing side, ItemStack stack) {
    int i1 = this.getXWithOffset(x, z);
    int j1 = this.getYWithOffset(y);
    int k1 = this.getZWithOffset(x, z);
    EntityItemFrame e = new EntityItemFrame(world, new BlockPos(i1, j1, k1), side);
    e.setDisplayedItem(stack);
    if (e.onValidSurface() && world.getEntitiesWithinAABB(EntityHanging.class, new AxisAlignedBB(i1 - .125, j1, k1 - .125, i1 + 1.125, j1 + 1, k1 + 1.125)).isEmpty())
        if (!world.isRemote)
            world.spawnEntityInWorld(e);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityItemFrame(net.minecraft.entity.item.EntityItemFrame) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with EntityItemFrame

use of net.minecraft.entity.item.EntityItemFrame in project RFToolsDimensions by McJty.

the class GenericWorldGenerator method spawnItemFrame.

private EntityItemFrame spawnItemFrame(World world, int x, int y, int z) {
    EntityItemFrame frame = new EntityItemFrame(world, new BlockPos(x, y, z + 1), EnumFacing.NORTH);
    WorldTools.spawnEntity(world, frame);
    frame.setPosition(x, y, z);
    return frame;
}
Also used : EntityItemFrame(net.minecraft.entity.item.EntityItemFrame) BlockPos(net.minecraft.util.math.BlockPos)

Example 3 with EntityItemFrame

use of net.minecraft.entity.item.EntityItemFrame in project RFToolsDimensions by McJty.

the class GenericWorldGenerator method generateDungeon.

private void generateDungeon(World world, Random random, int midx, int starty, int midz) {
    boolean doSmallAntenna = random.nextInt(4) == 0;
    boolean doExtraFeature = random.nextInt(4) == 0;
    Block cornerBlock;
    switch(random.nextInt(3)) {
        case 0:
            cornerBlock = ModBlocks.dimensionalCrossBlock;
            break;
        case 1:
            cornerBlock = ModBlocks.dimensionalPattern1Block;
            break;
        case 2:
            cornerBlock = ModBlocks.dimensionalPattern2Block;
            break;
        default:
            cornerBlock = ModBlocks.dimensionalCross2Block;
    }
    Block buildingBlock = Blocks.STAINED_HARDENED_CLAY;
    int color = random.nextInt(5);
    if (color == 0) {
        color = 3;
    } else if (color == 1) {
        color = 9;
    } else if (color == 2) {
        color = 11;
    } else {
        color = 0;
        buildingBlock = ModBlocks.dimensionalBlankBlock;
    }
    // Spawn the building
    for (int x = midx - 3; x <= midx + 3; x++) {
        for (int z = midz - 3; z <= midz + 3; z++) {
            boolean corner = (x == midx - 3 || x == midx + 3) && (z == midz - 3 || z == midz + 3);
            boolean xside = x == midx - 3 || x == midx + 3;
            boolean zside = z == midz - 3 || z == midz + 3;
            boolean antenna = (x == midx - 2 && z == midz - 2);
            boolean smallAntenna = doSmallAntenna && (x == midx + 2 && z == midz + 2);
            world.setBlockState(new BlockPos(x, starty, z), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
            if (corner) {
                world.setBlockState(new BlockPos(x, starty + 1, z), cornerBlock.getStateFromMeta(1), 2);
                world.setBlockState(new BlockPos(x, starty + 2, z), cornerBlock.getStateFromMeta(1), 2);
                world.setBlockState(new BlockPos(x, starty + 3, z), cornerBlock.getStateFromMeta(1), 2);
            } else if (xside) {
                world.setBlockState(new BlockPos(x, starty + 1, z), buildingBlock.getStateFromMeta(color), 2);
                if (z >= midz - 1 && z <= midz + 1) {
                    world.setBlockState(new BlockPos(x, starty + 2, z), Blocks.GLASS_PANE.getStateFromMeta(0), 2);
                } else {
                    world.setBlockState(new BlockPos(x, starty + 2, z), buildingBlock.getStateFromMeta(color), 2);
                }
                world.setBlockState(new BlockPos(x, starty + 3, z), buildingBlock.getStateFromMeta(color), 2);
            } else if (zside) {
                world.setBlockState(new BlockPos(x, starty + 1, z), buildingBlock.getStateFromMeta(color), 2);
                world.setBlockState(new BlockPos(x, starty + 2, z), buildingBlock.getStateFromMeta(color), 2);
                world.setBlockState(new BlockPos(x, starty + 3, z), buildingBlock.getStateFromMeta(color), 2);
            } else {
                world.setBlockToAir(new BlockPos(x, starty + 1, z));
                world.setBlockToAir(new BlockPos(x, starty + 2, z));
                world.setBlockToAir(new BlockPos(x, starty + 3, z));
            }
            if (antenna) {
                world.setBlockState(new BlockPos(x, starty + 4, z), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
                world.setBlockState(new BlockPos(x, starty + 5, z), Blocks.IRON_BARS.getDefaultState(), 2);
                world.setBlockState(new BlockPos(x, starty + 6, z), Blocks.IRON_BARS.getDefaultState(), 2);
                world.setBlockState(new BlockPos(x, starty + 7, z), Blocks.IRON_BARS.getDefaultState(), 2);
                world.setBlockState(new BlockPos(x, starty + 8, z), Blocks.GLOWSTONE.getDefaultState(), 3);
            } else if (smallAntenna) {
                world.setBlockState(new BlockPos(x, starty + 4, z), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
                world.setBlockState(new BlockPos(x, starty + 5, z), Blocks.IRON_BARS.getDefaultState(), 2);
                world.setBlockToAir(new BlockPos(x, starty + 6, z));
                world.setBlockToAir(new BlockPos(x, starty + 7, z));
                world.setBlockToAir(new BlockPos(x, starty + 8, z));
            } else {
                world.setBlockState(new BlockPos(x, starty + 4, z), Blocks.STONE_SLAB.getDefaultState(), 2);
                world.setBlockToAir(new BlockPos(x, starty + 5, z));
                world.setBlockToAir(new BlockPos(x, starty + 6, z));
                world.setBlockToAir(new BlockPos(x, starty + 7, z));
                world.setBlockToAir(new BlockPos(x, starty + 8, z));
            }
            // Spawn stone under the building for as long as it is air.
            WorldGenerationTools.fillEmptyWithStone(world, x, starty - 1, z);
        }
    }
    if (doExtraFeature) {
        if (!WorldGenerationTools.isSolid(world, midx + 4, starty, midz - 3)) {
            world.setBlockState(new BlockPos(midx + 4, starty, midz - 3), Blocks.IRON_BARS.getDefaultState(), 2);
        }
        world.setBlockState(new BlockPos(midx + 4, starty + 1, midz - 3), Blocks.IRON_BARS.getDefaultState(), 2);
        world.setBlockState(new BlockPos(midx + 4, starty + 2, midz - 3), Blocks.IRON_BARS.getDefaultState(), 2);
        if (!WorldGenerationTools.isSolid(world, midx + 5, starty, midz - 3)) {
            world.setBlockState(new BlockPos(midx + 5, starty, midz - 3), buildingBlock.getStateFromMeta(color), 2);
        }
        world.setBlockState(new BlockPos(midx + 5, starty + 1, midz - 3), buildingBlock.getStateFromMeta(color), 2);
        world.setBlockState(new BlockPos(midx + 5, starty + 2, midz - 3), buildingBlock.getStateFromMeta(color), 2);
        WorldGenerationTools.fillEmptyWithStone(world, midx + 4, starty - 1, midz - 3);
        WorldGenerationTools.fillEmptyWithStone(world, midx + 5, starty - 1, midz - 3);
    }
    // Clear the space before the door.
    for (int x = midx - 3; x <= midx + 3; x++) {
        for (int y = starty + 1; y <= starty + 3; y++) {
            world.setBlockToAir(new BlockPos(x, y, midz - 4));
        }
    }
    // Small platform before the door
    world.setBlockState(new BlockPos(midx - 1, starty, midz - 4), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
    world.setBlockState(new BlockPos(midx, starty, midz - 4), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
    world.setBlockState(new BlockPos(midx + 1, starty, midz - 4), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
    world.setBlockState(new BlockPos(midx, starty + 1, midz - 3), Blocks.IRON_DOOR.getStateFromMeta(1), 2);
    world.setBlockState(new BlockPos(midx, starty + 2, midz - 3), Blocks.IRON_DOOR.getStateFromMeta(8), 2);
    world.setBlockState(new BlockPos(midx - 1, starty + 2, midz - 4), Blocks.STONE_BUTTON.getStateFromMeta(4), 2);
    world.setBlockState(new BlockPos(midx + 1, starty + 2, midz - 2), Blocks.STONE_BUTTON.getStateFromMeta(3), 2);
    world.setBlockState(new BlockPos(midx, starty + 3, midz + 3), Blocks.REDSTONE_LAMP.getDefaultState(), 2);
    world.setBlockState(new BlockPos(midx, starty + 3, midz + 2), Blocks.LEVER.getStateFromMeta(4), 2);
    world.setBlockState(new BlockPos(midx + 2, starty + 1, midz - 2), Blocks.CHEST.getDefaultState(), 2);
    RarityRandomSelector.Distribution<Integer> bestDistribution = DimletRandomizer.getRandomDimlets().createDistribution(0.2f);
    TileEntityChest chest = (TileEntityChest) world.getTileEntity(new BlockPos(midx + 2, starty + 1, midz - 2));
    for (int i = 0; i < random.nextInt(4) + 3; i++) {
        ItemStack stack = DimletRandomizer.getRandomPart(random);
        chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), stack);
    }
    if (WorldgenConfiguration.enableDimletsInRFToolsDungeons > 0) {
        for (int i = 0; i < random.nextInt(WorldgenConfiguration.enableDimletsInRFToolsDungeons); i++) {
            DimletKey key = DimletRandomizer.getRandomDimlets().select(bestDistribution, random);
            if (key != null) {
                ItemStack stack = KnownDimletConfiguration.getDimletStack(key);
                chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), stack);
            }
        }
    }
    // Always generate a few cosmetic dimlets
    for (int i = 0; i < WorldgenConfiguration.uncraftableDimletsInRFToolsDungeons; i++) {
        RarityRandomSelector<Integer, DimletKey> dimlets = DimletRandomizer.getRandomUncraftableDimlets();
        DimletKey key = dimlets.select(bestDistribution, random);
        if (key != null) {
            ItemStack stack = KnownDimletConfiguration.getDimletStack(key);
            chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), stack);
        }
    }
    for (int i = 0; i < random.nextInt(2); i++) {
        chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), new ItemStack(ModItems.dimletParcelItem));
    }
    EntityItemFrame frame1 = spawnItemFrame(world, midx - 1, starty + 2, midz + 2);
    EntityItemFrame frame2 = spawnItemFrame(world, midx, starty + 2, midz + 2);
    EntityItemFrame frame3 = spawnItemFrame(world, midx + 1, starty + 2, midz + 2);
    if (WorldgenConfiguration.enableDimletsInRFToolsFrames) {
        DimletKey rd1 = DimletRandomizer.getRandomDimlets().select(bestDistribution, random);
        if (rd1 != null) {
            frame1.setDisplayedItem(KnownDimletConfiguration.getDimletStack(rd1));
        }
        DimletKey rd2 = DimletRandomizer.getRandomDimlets().select(bestDistribution, random);
        if (rd2 != null) {
            frame2.setDisplayedItem(KnownDimletConfiguration.getDimletStack(rd2));
        }
        DimletKey rd3 = DimletRandomizer.getRandomDimlets().select(bestDistribution, random);
        if (rd3 != null) {
            frame3.setDisplayedItem(KnownDimletConfiguration.getDimletStack(rd3));
        }
    } else {
        frame1.setDisplayedItem(DimletRandomizer.getRandomPart(random));
        frame2.setDisplayedItem(DimletRandomizer.getRandomPart(random));
        frame3.setDisplayedItem(DimletRandomizer.getRandomPart(random));
    }
}
Also used : RarityRandomSelector(mcjty.rftoolsdim.varia.RarityRandomSelector) TileEntityChest(net.minecraft.tileentity.TileEntityChest) EntityItemFrame(net.minecraft.entity.item.EntityItemFrame) GenericBlock(mcjty.lib.container.GenericBlock) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 4 with EntityItemFrame

use of net.minecraft.entity.item.EntityItemFrame in project ArsMagica2 by Mithion.

the class ItemFrameWatcher method checkFrameRadius.

private boolean checkFrameRadius(EntityItemFrameComparator frameComp) {
    int radius = 2;
    boolean shouldRemove = true;
    EntityItemFrame frame = frameComp.frame;
    for (int i = -radius; i <= radius; ++i) {
        for (int j = -radius; j <= radius; ++j) {
            for (int k = -radius; k <= radius; ++k) {
                if (frame.worldObj.getBlock((int) frame.posX + i, (int) frame.posY + j, (int) frame.posZ + k) == BlocksCommonProxy.liquidEssence) {
                    Integer time = watchedFrames.get(frameComp);
                    if (time == null) {
                        time = 0;
                    }
                    time++;
                    watchedFrames.put(frameComp, time);
                    if (time >= processTime) {
                        if (!frame.worldObj.isRemote) {
                            frame.setDisplayedItem(new ItemStack(ItemsCommonProxy.arcaneCompendium));
                            return true;
                        }
                    } else {
                        shouldRemove = false;
                        if (frame.worldObj.isRemote) {
                            spawnCompendiumProgressParticles(frame, (int) frame.posX + i, (int) frame.posY + j, (int) frame.posZ + k);
                        }
                    }
                }
            }
        }
    }
    return shouldRemove;
}
Also used : EntityItemFrame(net.minecraft.entity.item.EntityItemFrame) ItemStack(net.minecraft.item.ItemStack)

Example 5 with EntityItemFrame

use of net.minecraft.entity.item.EntityItemFrame in project minecolonies by Minecolonies.

the class EntityAIStructureBuilder method requestEntityToBuildingIfRequired.

/**
     * Adds entities to the builder building if he needs it.
     */
private void requestEntityToBuildingIfRequired(final Template.EntityInfo entityInfo) {
    if (entityInfo != null) {
        final Entity entity = getEntityFromEntityInfoOrNull(entityInfo);
        if (entity != null) {
            final List<ItemStack> request = new ArrayList<>();
            if (entity instanceof EntityItemFrame) {
                final ItemStack stack = ((EntityItemFrame) entity).getDisplayedItem();
                if (!InventoryUtils.isItemStackEmpty(stack)) {
                    stack.setCount(1);
                    request.add(stack);
                }
                request.add(new ItemStack(Items.ITEM_FRAME, 1));
            } else if (entity instanceof EntityArmorStand) {
                request.add(entity.getPickedResult(new RayTraceResult(worker)));
                entity.getArmorInventoryList().forEach(request::add);
            } else if (entity instanceof EntityMob) {
            //Don't try to request the monster.
            } else {
                request.add(entity.getPickedResult(new RayTraceResult(worker)));
            }
            for (final ItemStack stack : request) {
                final BuildingBuilder building = (BuildingBuilder) getOwnBuilding();
                if (stack != null && stack.getItem() != null) {
                    building.addNeededResource(stack, 1);
                }
            }
        }
    }
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EntityItemFrame(net.minecraft.entity.item.EntityItemFrame) BuildingBuilder(com.minecolonies.coremod.colony.buildings.BuildingBuilder) ArrayList(java.util.ArrayList) RayTraceResult(net.minecraft.util.math.RayTraceResult) EntityArmorStand(net.minecraft.entity.item.EntityArmorStand) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EntityItemFrame (net.minecraft.entity.item.EntityItemFrame)7 ItemStack (net.minecraft.item.ItemStack)4 BlockPos (net.minecraft.util.math.BlockPos)3 ArrayList (java.util.ArrayList)2 Entity (net.minecraft.entity.Entity)2 EntityArmorStand (net.minecraft.entity.item.EntityArmorStand)2 RayTraceResult (net.minecraft.util.math.RayTraceResult)2 AffinityData (am2.playerextensions.AffinityData)1 ExtendedProperties (am2.playerextensions.ExtendedProperties)1 RiftStorage (am2.playerextensions.RiftStorage)1 SkillData (am2.playerextensions.SkillData)1 BuildingBuilder (com.minecolonies.coremod.colony.buildings.BuildingBuilder)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 GenericBlock (mcjty.lib.container.GenericBlock)1 DimletKey (mcjty.rftoolsdim.dimensions.dimlets.DimletKey)1 RarityRandomSelector (mcjty.rftoolsdim.varia.RarityRandomSelector)1 Block (net.minecraft.block.Block)1 EntityMob (net.minecraft.entity.monster.EntityMob)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 TileEntity (net.minecraft.tileentity.TileEntity)1