Java Code Examples for net.minecraft.world.World

The following are top voted examples for showing how to use net.minecraft.world.World. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: GardenStuff   File: ItemCandelillaSeeds.java   Source Code and License 6 votes vote down vote up
@Override
public EnumActionResult onItemUse (EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    IBlockState state = worldIn.getBlockState(pos);

    if (facing != EnumFacing.UP)
        return EnumActionResult.FAIL;
    if (!player.canPlayerEdit(pos.offset(facing), facing, stack))
        return EnumActionResult.FAIL;
    if (!state.getBlock().canSustainPlant(state, worldIn, pos, EnumFacing.UP, this))
        return EnumActionResult.FAIL;
    if (!worldIn.isAirBlock(pos.up()))
        return EnumActionResult.FAIL;

    worldIn.setBlockState(pos.up(), ModBlocks.candelilla.getDefaultState());
    if (player instanceof EntityPlayerMP)
        CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP)player, pos.up(), stack);

    stack.shrink(1);
    return EnumActionResult.SUCCESS;
}
 
Example 2
Project: CustomWorldGen   File: BlockRedstoneWire.java   Source Code and License 6 votes vote down vote up
/**
 * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
 * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
 * block, etc.
 */
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn)
{
    if (!worldIn.isRemote)
    {
        if (this.canPlaceBlockAt(worldIn, pos))
        {
            this.updateSurroundingRedstone(worldIn, pos, state);
        }
        else
        {
            this.dropBlockAsItem(worldIn, pos, state, 0);
            worldIn.setBlockToAir(pos);
        }
    }
}
 
Example 3
Project: BaseClient   File: ItemDye.java   Source Code and License 6 votes vote down vote up
public static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target)
{
    IBlockState iblockstate = worldIn.getBlockState(target);

    if (iblockstate.getBlock() instanceof IGrowable)
    {
        IGrowable igrowable = (IGrowable)iblockstate.getBlock();

        if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote))
        {
            if (!worldIn.isRemote)
            {
                if (igrowable.canUseBonemeal(worldIn, worldIn.rand, target, iblockstate))
                {
                    igrowable.grow(worldIn, worldIn.rand, target, iblockstate);
                }

                --stack.stackSize;
            }

            return true;
        }
    }

    return false;
}
 
Example 4
Project: minecraft-quiverbow   File: PackedUpBB.java   Source Code and License 6 votes vote down vote up
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float sideX, float sideY, float sideZ)
   {
	if (world.isRemote) { return true; }	// Not doing this on client side
	
	Entity_BB turret = new Entity_BB(world, player);
	
	turret.setPosition(x + 0.5, y + 1 , z + 0.5);		
	world.spawnEntityInWorld(turret);
	
	// Custom name
	if (stack.hasDisplayName())	{ AI_Properties.applyNameTag(player, turret, stack, false); }
	
	if (player.capabilities.isCreativeMode) { return true; }	// Not deducting them in creative mode

	stack.stackSize -= 1;
	if (stack.stackSize <= 0)	// Used up
	{
		player.setCurrentItemOrArmor(0, null);
	}
	
	return true;
   }
 
Example 5
Project: GlobalXP   File: XPBlock.java   Source Code and License 6 votes vote down vote up
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
	if(worldIn.isRemote || !stack.hasTagCompound())
		return;
	
	TileEntity te = worldIn.getTileEntity(pos);
	
	if(te instanceof TileEntityXPBlock)
	{
		NBTTagCompound tag = stack.getTagCompound().getCompoundTag("BlockEntityTag");

		tag.setInteger("x", pos.getX());
		tag.setInteger("y", pos.getY());
		tag.setInteger("z", pos.getZ());
		((TileEntityXPBlock)te).readFromNBT(tag);
		((TileEntityXPBlock)te).markDirty();
		GlobalXP.network.sendToAllAround(new SPacketUpdateXPBlock((TileEntityXPBlock)te), new NetworkRegistry.TargetPoint(worldIn.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 64));
	}
}
 
Example 6
Project: Loot-Slash-Conquer   File: Dungeon.java   Source Code and License 6 votes vote down vote up
/**
 * Generates a stores potential room positions off of the current template. Note: this does not take into account existing rooms. Check for existing rooms when spawning each specific room position.
 * @param currentTemplate
 */
private List<DungeonRoomPosition> generatePotentialRooms(TemplateManager manager, World world, Template currentTemplate, Rotation currentTemplateRotation, BlockPos currentCenter, Rotation currentSide)
{
	List<DungeonRoomPosition> list = Lists.newArrayList();
	
	//Rotation side = Rotation.values()[(int) (Math.random() * 4)];
	for (Rotation side : Rotation.values())
	{
		Template nextTemplate = DungeonHelper.getRandomizedDungeonTemplate(manager, world);
		Rotation nextTemplateRotation = Rotation.values()[(int) (Math.random() * 4)];
		BlockPos centeredPosition = DungeonHelper.translateToNextRoom(currentTemplate, nextTemplate, currentCenter, side, currentTemplateRotation, nextTemplateRotation);
		StructureBoundingBox boundingBox = DungeonHelper.getStructureBoundingBox(nextTemplate, nextTemplateRotation, centeredPosition);
		
		if (currentSide == null || (currentSide != null && currentSide.add(Rotation.CLOCKWISE_180) != side)) // check to make sure we aren't spawning a room on the side we just spawned from.
		{
			list.add(new DungeonRoomPosition(centeredPosition, nextTemplate, nextTemplateRotation, side, boundingBox));
		}
	}
	
	return list;
}
 
Example 7
Project: Soot   File: AlchemyResult.java   Source Code and License 6 votes vote down vote up
public static AlchemyResult create(AspectList list,AspectRangeList range,World world)
{
    AlchemyResult result = new AlchemyResult();
    double totalDelta = 0;
    double totalCompare = 0;
    for (String aspect: range.minAspects.getAspects()) {
        int amt = list.getAspect(aspect);
        int compareAmt = range.getExact(aspect,world);
        double delta = Math.abs(amt - compareAmt);
        result.totalAsh += amt;
        totalDelta += delta;
        totalCompare += compareAmt;
        result.deltas.put(aspect,(int)delta);
    }
    result.accuracy = Math.max(0.0,1.0 - totalDelta / totalCompare);
    result.accuracy = Math.round(result.accuracy * 100.0) / 100.0;
    return result;
}
 
Example 8
Project: PurificatiMagicae   File: ItemGlove.java   Source Code and License 6 votes vote down vote up
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{

    ItemStack glove = playerIn.getHeldItem(handIn);
    if (handIn == EnumHand.OFF_HAND)
    {
        ItemStack shard = playerIn.getHeldItem(EnumHand.MAIN_HAND);
        if (shard.getItem() == ItemRegistry.crystal_shard)
        {
            int shrink = playerIn.isSneaking() ? shard.getCount() : 1;
            playerIn.playSound(SoundRegistry.GLASS, 1, 1);
            if (ItemSipAmulet.checkForAmulet(playerIn))
            {
                ItemStack amulet = ItemUtils.getBauble(playerIn, BaubleType.AMULET.getValidSlots()[0]);
                amulet.getCapability(CapabilityRegistry.SIP_STORE_CAP, null).add(SipUtils.getSipInStack(shard), shrink);
                ItemUtils.setBauble(playerIn, BaubleType.AMULET.getValidSlots()[0], amulet);
            }
            playerIn.getHeldItem(EnumHand.MAIN_HAND).shrink(shrink);
            return new ActionResult<>(EnumActionResult.SUCCESS, glove);
        }
    }
    return new ActionResult<>(EnumActionResult.PASS, glove);
}
 
Example 9
Project: Clef   File: ItemInstrument.java   Source Code and License 6 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack is, @Nullable World worldIn, List<String> list, ITooltipFlag flag)
{
    NBTTagCompound tag = is.getTagCompound();
    if(tag != null)
    {
        Instrument instrument = InstrumentLibrary.getInstrumentByName(tag.getString("itemName"));
        if(instrument != null)
        {
            list.add(I18n.translateToLocal("item.clef.instrument." + instrument.info.itemName + ".desc"));
            list.add(I18n.translateToLocal(instrument.info.twoHanded && Clef.config.allowOneHandedTwoHandedInstrumentUse == 0 ? "clef.item.twoHanded" : "clef.item.oneHanded"));
            if(GuiScreen.isShiftKeyDown())
            {
                list.add("");
                list.add(I18n.translateToLocal("clef.item.packName") + ": " + instrument.packInfo.packName);
                list.add(I18n.translateToLocal("clef.item.itemName") + ": " + instrument.info.itemName);
            }
        }
    }
}
 
Example 10
Project: Backmemed   File: StructureStrongholdPieces.java   Source Code and License 6 votes vote down vote up
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
{
    if (this.isLiquidInStructureBoundingBox(worldIn, structureBoundingBoxIn))
    {
        return false;
    }
    else
    {
        this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 0, 0, 0, 4, 4, 4, true, randomIn, StructureStrongholdPieces.STRONGHOLD_STONES);
        this.placeDoor(worldIn, randomIn, structureBoundingBoxIn, this.entryDoor, 1, 1, 0);
        EnumFacing enumfacing = this.getCoordBaseMode();

        if (enumfacing != EnumFacing.NORTH && enumfacing != EnumFacing.EAST)
        {
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, 4, 1, 1, 4, 3, 3, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
        }
        else
        {
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 1, 1, 0, 3, 3, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
        }

        return true;
    }
}
 
Example 11
Project: CustomWorldGen   File: WorldGenMegaPineTree.java   Source Code and License 6 votes vote down vote up
private void placePodzolAt(World worldIn, BlockPos pos)
{
    for (int i = 2; i >= -3; --i)
    {
        BlockPos blockpos = pos.up(i);
        IBlockState iblockstate = worldIn.getBlockState(blockpos);
        Block block = iblockstate.getBlock();

        if (block.canSustainPlant(iblockstate, worldIn, blockpos, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.SAPLING)))
        {
            this.setBlockAndNotifyAdequately(worldIn, blockpos, PODZOL);
            break;
        }

        if (iblockstate.getMaterial() != Material.AIR && i < 0)
        {
            break;
        }
    }
}
 
Example 12
Project: Bewitchment   File: ItemRemedyTalisman.java   Source Code and License 6 votes vote down vote up
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
	if (!world.isRemote) {
		IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player);
		for (int i = 0; i < baubles.getSlots(); i++)
			if (baubles.getStackInSlot(i).isEmpty() && baubles.isItemValidForSlot(i, player.getHeldItem(hand), player)) {
				baubles.setStackInSlot(i, player.getHeldItem(hand).copy());
				if (!player.capabilities.isCreativeMode) {
					player.setHeldItem(hand, ItemStack.EMPTY);
				}
				onEquipped(player.getHeldItem(hand), player);
				break;
			}
	}
	return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
 
Example 13
Project: BaseClient   File: ItemSlab.java   Source Code and License 6 votes vote down vote up
private boolean tryPlace(ItemStack stack, World worldIn, BlockPos pos, Object variantInStack)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (iblockstate.getBlock() == this.singleSlab)
    {
        Comparable comparable = iblockstate.getValue(this.singleSlab.getVariantProperty());

        if (comparable == variantInStack)
        {
            IBlockState iblockstate1 = this.doubleSlab.getDefaultState().withProperty((IProperty)this.singleSlab.getVariantProperty(), comparable);

            if (worldIn.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBox(worldIn, pos, iblockstate1)) && worldIn.setBlockState(pos, iblockstate1, 3))
            {
                worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.doubleSlab.stepSound.getPlaceSound(), (this.doubleSlab.stepSound.getVolume() + 1.0F) / 2.0F, this.doubleSlab.stepSound.getFrequency() * 0.8F);
                --stack.stackSize;
            }

            return true;
        }
    }

    return false;
}
 
Example 14
Project: Backmemed   File: BlockDispenser.java   Source Code and License 5 votes vote down vote up
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityDispenser)
        {
            playerIn.displayGUIChest((TileEntityDispenser)tileentity);

            if (tileentity instanceof TileEntityDropper)
            {
                playerIn.addStat(StatList.DROPPER_INSPECTED);
            }
            else
            {
                playerIn.addStat(StatList.DISPENSER_INSPECTED);
            }
        }

        return true;
    }
}
 
Example 15
Project: OpenSensors   File: CommonProxy.java   Source Code and License 5 votes vote down vote up
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
		int x, int y, int z) {
	TileEntity te = world.getTileEntity(x, y, z);
	if (te != null && te instanceof TileEntitySensor) {
		TileEntitySensor icte = (TileEntitySensor) te;
		return new SensorContainer(player.inventory, icte);
	} else {
		return null;
	}
}
 
Example 16
Project: BaseClient   File: BlockOre.java   Source Code and License 5 votes vote down vote up
/**
 * Spawns this Block's drops into the World as EntityItems.
 */
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
{
    super.dropBlockAsItemWithChance(worldIn, pos, state, chance, fortune);

    if (this.getItemDropped(state, worldIn.rand, fortune) != Item.getItemFromBlock(this))
    {
        int i = 0;

        if (this == Blocks.coal_ore)
        {
            i = MathHelper.getRandomIntegerInRange(worldIn.rand, 0, 2);
        }
        else if (this == Blocks.diamond_ore)
        {
            i = MathHelper.getRandomIntegerInRange(worldIn.rand, 3, 7);
        }
        else if (this == Blocks.emerald_ore)
        {
            i = MathHelper.getRandomIntegerInRange(worldIn.rand, 3, 7);
        }
        else if (this == Blocks.lapis_ore)
        {
            i = MathHelper.getRandomIntegerInRange(worldIn.rand, 2, 5);
        }
        else if (this == Blocks.quartz_ore)
        {
            i = MathHelper.getRandomIntegerInRange(worldIn.rand, 2, 5);
        }

        this.dropXpOnBlockBreak(worldIn, pos, i);
    }
}
 
Example 17
Project: Backmemed   File: BlockTripWireHook.java   Source Code and License 5 votes vote down vote up
private boolean checkForDrop(World worldIn, BlockPos pos, IBlockState state)
{
    if (!this.canPlaceBlockAt(worldIn, pos))
    {
        this.dropBlockAsItem(worldIn, pos, state, 0);
        worldIn.setBlockToAir(pos);
        return false;
    }
    else
    {
        return true;
    }
}
 
Example 18
Project: Backmemed   File: BlockObserver.java   Source Code and License 5 votes vote down vote up
/**
 * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
 */
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    if (((Boolean)state.getValue(field_190963_a)).booleanValue() && worldIn.isUpdateScheduled(pos, this))
    {
        this.func_190961_e(worldIn, pos, state.withProperty(field_190963_a, Boolean.valueOf(false)));
    }
}
 
Example 19
Project: BaseClient   File: BiomeGenDesert.java   Source Code and License 5 votes vote down vote up
public void decorate(World worldIn, Random rand, BlockPos pos)
{
    super.decorate(worldIn, rand, pos);

    if (rand.nextInt(1000) == 0)
    {
        int i = rand.nextInt(16) + 8;
        int j = rand.nextInt(16) + 8;
        BlockPos blockpos = worldIn.getHeight(pos.add(i, 0, j)).up();
        (new WorldGenDesertWells()).generate(worldIn, rand, blockpos);
    }
}
 
Example 20
Project: Proyecto-DASI   File: BlockDrawingHelper.java   Source Code and License 5 votes vote down vote up
/**
 * Draw a single Minecraft block.
 * @param b Contains information about the block to be drawn.
 * @param w The world in which to draw.
 * @throws Exception Throws an exception if the block type is not recognised.
 */
private void DrawPrimitive( DrawBlock b, World w ) throws Exception
{
    XMLBlockState blockType = new XMLBlockState(b.getType(), b.getColour(),  b.getFace(), b.getVariant());
    if (!blockType.isValid())
        throw new Exception("Unrecogised item type: " + b.getType().value());
    BlockPos pos = new BlockPos( b.getX(), b.getY(), b.getZ() );
    setBlockState(w, pos, blockType );
}
 
Example 21
Project: ForgeHax   File: AimbotMod.java   Source Code and License 5 votes vote down vote up
/**
 * Finds entity closest to crosshair
 */
public Entity findTargetEntity(Vec3d selfPos, Vec3d selfLookVec, Angle viewAngles) {
    final World world = Minecraft.getMinecraft().world;
    final Vec3d selfLookVecNormal = selfLookVec.normalize();
    Entity target = null;
    double shortestDistance = -1;
    synchronized (world.loadedEntityList) {
        for (Entity entity : Collections.synchronizedList(Lists.newArrayList(world.loadedEntityList))) {
            if(entity != null) {
                Vec3d pos = EntityUtils.getOBBCenter(entity);
                if (isValidTarget(entity, pos, selfPos, selfLookVec, viewAngles)) {
                    double distance = pos
                            .subtract(selfPos)
                            .normalize()
                            .subtract(selfLookVecNormal)
                            .lengthVector();
                    if (shortestDistance == -1 || distance < shortestDistance) {
                        target = entity;
                        shortestDistance = distance;
                    }
                }
            }
        }
    }

    //System.out.printf("Took %d ms\n", System.currentTimeMillis() - start);
    LocalPlayerUtils.setTargetEntity(target);
    return target;
}
 
Example 22
Project: BaseClient   File: StructureMineshaftStart.java   Source Code and License 5 votes vote down vote up
public StructureMineshaftStart(World worldIn, Random rand, int chunkX, int chunkZ)
{
    super(chunkX, chunkZ);
    StructureMineshaftPieces.Room structuremineshaftpieces$room = new StructureMineshaftPieces.Room(0, rand, (chunkX << 4) + 2, (chunkZ << 4) + 2);
    this.components.add(structuremineshaftpieces$room);
    structuremineshaftpieces$room.buildComponent(structuremineshaftpieces$room, this.components, rand);
    this.updateBoundingBox();
    this.markAvailableHeight(worldIn, rand, 10);
}
 
Example 23
Project: Loot-Slash-Conquer   File: EntityProjectileBase.java   Source Code and License 5 votes vote down vote up
/** Only use this constructor if a player shoots the projectile with the correct item. */
public EntityProjectileBase(World world, double x, double y, double z, float velocity, float inaccuracy, EntityPlayer player, ItemStack stack)
{
	super(world, x, y, z);
	this.shoot(x, y, z, velocity, inaccuracy);
	this.player = player;
	this.stack = stack;
}
 
Example 24
Project: BaseClient   File: Block.java   Source Code and License 5 votes vote down vote up
/**
 * Spawns the given amount of experience into the World as XP orb entities
 */
protected void dropXpOnBlockBreak(World worldIn, BlockPos pos, int amount)
{
    if (!worldIn.isRemote)
    {
        while (amount > 0)
        {
            int i = EntityXPOrb.getXPSplit(amount);
            amount -= i;
            worldIn.spawnEntityInWorld(new EntityXPOrb(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, i));
        }
    }
}
 
Example 25
Project: minecraft-quiverbow   File: SoulCairn.java   Source Code and License 5 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
	if (world.isRemote) { return stack; }								// Not doing this on client side
	if (this.getDamage(stack) >= this.getMaxDamage()) { return stack; }	// Is empty

	this.doSingleFire(stack, world, player);	// Handing it over to the neutral firing function
	return stack;
}
 
Example 26
Project: minecraft-quiverbow   File: SugarEngine.java   Source Code and License 5 votes vote down vote up
private void doSpinSFX(ItemStack stack, World world, Entity player)
{
	// SFX
	int spin = stack.stackTagCompound.getInteger("spinning");

	float volume = 0.8F;
	float pitch = 1.8F;

	// Increasing in frequency as we spin up
	if (spin == 1) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }			// +4
	else if (spin == 5) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +4
	else if (spin == 9) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +4

	else if (spin == 13) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +3
	else if (spin == 16) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +3
	else if (spin == 19) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +3

	else if (spin == 21) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +2
	else if (spin == 23) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +2
	else if (spin == 25) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +2

	else if (spin == 27) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +1
	else if (spin == 28) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +1
	else if (spin == 29) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +1

	else if (spin >= 30) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +++
}
 
Example 27
Project: ExSartagine   File: BlockRange.java   Source Code and License 5 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
		EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {

	if(!(worldIn.getTileEntity(pos) instanceof TileEntityRange) || hand == EnumHand.OFF_HAND)
		return false;

	playerIn.openGui(ExSartagine.instance, 3, worldIn, pos.getX(), pos.getY(), pos.getZ());
	return true;
}
 
Example 28
Project: BaseClient   File: ItemPotion.java   Source Code and License 5 votes vote down vote up
/**
 * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
 * the Item before the action is complete.
 */
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --stack.stackSize;
    }

    if (!worldIn.isRemote)
    {
        List<PotionEffect> list = this.getEffects(stack);

        if (list != null)
        {
            for (PotionEffect potioneffect : list)
            {
                playerIn.addPotionEffect(new PotionEffect(potioneffect));
            }
        }
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);

    if (!playerIn.capabilities.isCreativeMode)
    {
        if (stack.stackSize <= 0)
        {
            return new ItemStack(Items.glass_bottle);
        }

        playerIn.inventory.addItemStackToInventory(new ItemStack(Items.glass_bottle));
    }

    return stack;
}
 
Example 29
Project: genera   File: BlockBurdockCrop.java   Source Code and License 5 votes vote down vote up
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
    super.updateTick(worldIn, pos, state, rand);
    if (!worldIn.isRemote) {
        if (state.getValue(AGE) == 2) {
            EntityFaerie faerie = new EntityFaerie(worldIn, 6.0D, 2, 0.2F, 0);
            faerie.setPosition((double) pos.getX(), (double) pos.up().getY(), (double) pos.getZ());
            worldIn.spawnEntity(faerie);
        }
    }
}
 
Example 30
Project: BaseClient   File: WorldGenFire.java   Source Code and License 5 votes vote down vote up
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    for (int i = 0; i < 64; ++i)
    {
        BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));

        if (worldIn.isAirBlock(blockpos) && worldIn.getBlockState(blockpos.down()).getBlock() == Blocks.netherrack)
        {
            worldIn.setBlockState(blockpos, Blocks.fire.getDefaultState(), 2);
        }
    }

    return true;
}
 
Example 31
Project: Bewitchment   File: WorldGenOre.java   Source Code and License 5 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
	if (world.provider.getDimensionType().getId() == 0) {
		Set<BiomeDictionary.Type> set = BiomeDictionary.getTypes(world.getBiome(new BlockPos(chunkX, 0, chunkZ)));

		for (BiomeDictionary.Type type : set) {
			if (biomes.isEmpty() || biomes.contains(type)) {
				generateOre(world, random, chunkX, chunkZ);
				break;
			}
		}
	}
}
 
Example 32
Project: CustomWorldGen   File: BlockBeacon.java   Source Code and License 5 votes vote down vote up
public static void updateColorAsync(final World worldIn, final BlockPos glassPos)
{
    HttpUtil.DOWNLOADER_EXECUTOR.submit(new Runnable()
    {
        public void run()
        {
            Chunk chunk = worldIn.getChunkFromBlockCoords(glassPos);

            for (int i = glassPos.getY() - 1; i >= 0; --i)
            {
                final BlockPos blockpos = new BlockPos(glassPos.getX(), i, glassPos.getZ());

                if (!chunk.canSeeSky(blockpos))
                {
                    break;
                }

                IBlockState iblockstate = worldIn.getBlockState(blockpos);

                if (iblockstate.getBlock() == Blocks.BEACON)
                {
                    ((WorldServer)worldIn).addScheduledTask(new Runnable()
                    {
                        public void run()
                        {
                            TileEntity tileentity = worldIn.getTileEntity(blockpos);

                            if (tileentity instanceof TileEntityBeacon)
                            {
                                ((TileEntityBeacon)tileentity).updateBeacon();
                                worldIn.addBlockEvent(blockpos, Blocks.BEACON, 1, 0);
                            }
                        }
                    });
                }
            }
        }
    });
}
 
Example 33
Project: BaseClient   File: BlockSilverfish.java   Source Code and License 5 votes vote down vote up
/**
 * Spawns this Block's drops into the World as EntityItems.
 */
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
{
    if (!worldIn.isRemote && worldIn.getGameRules().getBoolean("doTileDrops"))
    {
        EntitySilverfish entitysilverfish = new EntitySilverfish(worldIn);
        entitysilverfish.setLocationAndAngles((double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D, 0.0F, 0.0F);
        worldIn.spawnEntityInWorld(entitysilverfish);
        entitysilverfish.spawnExplosionParticle();
    }
}
 
Example 34
Project: Thermionics   File: BlockPotStill.java   Source Code and License 5 votes vote down vote up
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	if (!world.isRemote) {
		player.openGui(Thermionics.instance(), EnumGui.POT_STILL.id(), world, pos.getX(), pos.getY(), pos.getZ());
	} else {
		
	}
	return true;
}
 
Example 35
Project: BaseClient   File: DemoWorldManager.java   Source Code and License 5 votes vote down vote up
/**
 * Attempts to right-click use an item by the given EntityPlayer in the given World
 */
public boolean tryUseItem(EntityPlayer player, World worldIn, ItemStack stack)
{
    if (this.demoTimeExpired)
    {
        this.sendDemoReminder();
        return false;
    }
    else
    {
        return super.tryUseItem(player, worldIn, stack);
    }
}
 
Example 36
Project: Anima-Mundi   File: AnimaWorldGenerator.java   Source Code and License 5 votes vote down vote up
private void addOreSpawn(IBlockState block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chance, int minY, int maxY){
	int diffMinMaxY = maxY - minY;
	for(int x = 0; x < chance; x++){
		int posX = (blockXPos * 16)+ random.nextInt(maxX);
		int posY = minY + random.nextInt(diffMinMaxY);
		int posZ = (blockZPos * 16) + random.nextInt(maxZ);
		(new WorldGenMinable(block, maxVeinSize)).generate(world, random, new BlockPos(posX, posY, posZ));
	}
}
 
Example 37
Project: CustomWorldGen   File: ItemDye.java   Source Code and License 5 votes vote down vote up
public static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target, EntityPlayer player)
{
    IBlockState iblockstate = worldIn.getBlockState(target);

    int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, worldIn, target, iblockstate, stack);
    if (hook != 0) return hook > 0;

    if (iblockstate.getBlock() instanceof IGrowable)
    {
        IGrowable igrowable = (IGrowable)iblockstate.getBlock();

        if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote))
        {
            if (!worldIn.isRemote)
            {
                if (igrowable.canUseBonemeal(worldIn, worldIn.rand, target, iblockstate))
                {
                    igrowable.grow(worldIn, worldIn.rand, target, iblockstate);
                }

                --stack.stackSize;
            }

            return true;
        }
    }

    return false;
}
 
Example 38
Project: BaseClient   File: WorldGenTrees.java   Source Code and License 5 votes vote down vote up
private void func_181650_b(World p_181650_1_, BlockPos p_181650_2_, PropertyBool p_181650_3_)
{
    this.func_181651_a(p_181650_1_, p_181650_2_, p_181650_3_);
    int i = 4;

    for (p_181650_2_ = p_181650_2_.down(); p_181650_1_.getBlockState(p_181650_2_).getBlock().getMaterial() == Material.air && i > 0; --i)
    {
        this.func_181651_a(p_181650_1_, p_181650_2_, p_181650_3_);
        p_181650_2_ = p_181650_2_.down();
    }
}
 
Example 39
Project: Mods   File: EntityMonoculus.java   Source Code and License 5 votes vote down vote up
public EntityMonoculus(World worldIn) {
	super(worldIn);
	this.setSize(4, 4);
	this.setHeldItem(EnumHand.MAIN_HAND, ItemFromData.getNewStack("mnceye"));

	this.moveHelper = new MonoculusMoveHelper(this);
	// TODO Auto-generated constructor stub
}
 
Example 40
Project: BaseClient   File: Block.java   Source Code and License 5 votes vote down vote up
/**
 * Spawns the given ItemStack as an EntityItem into the World at the given position
 */
public static void spawnAsEntity(World worldIn, BlockPos pos, ItemStack stack)
{
    if (!worldIn.isRemote && worldIn.getGameRules().getBoolean("doTileDrops"))
    {
        float f = 0.5F;
        double d0 = (double)(worldIn.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
        double d1 = (double)(worldIn.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
        double d2 = (double)(worldIn.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
        EntityItem entityitem = new EntityItem(worldIn, (double)pos.getX() + d0, (double)pos.getY() + d1, (double)pos.getZ() + d2, stack);
        entityitem.setDefaultPickupDelay();
        worldIn.spawnEntityInWorld(entityitem);
    }
}
 
Example 41
Project: CustomWorldGen   File: Block.java   Source Code and License 4 votes vote down vote up
/**
 * Called after the block is set in the Chunk data, but before the Tile Entity is set
 */
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
}
 
Example 42
Project: ArcaneMagic   File: BlockFancyLight.java   Source Code and License 4 votes vote down vote up
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
	return;
}
 
Example 43
Project: CustomWorldGen   File: BlockChest.java   Source Code and License 4 votes vote down vote up
private boolean isBlocked(World worldIn, BlockPos pos)
{
    return this.isBelowSolidBlock(worldIn, pos) || this.isOcelotSittingOnChest(worldIn, pos);
}
 
Example 44
Project: Backmemed   File: ChunkProviderClient.java   Source Code and License 4 votes vote down vote up
public ChunkProviderClient(World worldIn)
{
    this.blankChunk = new EmptyChunk(worldIn, 0, 0);
    this.worldObj = worldIn;
}
 
Example 45
Project: Backmemed   File: BlockPistonBase.java   Source Code and License 4 votes vote down vote up
private boolean doMove(World worldIn, BlockPos pos, EnumFacing direction, boolean extending)
{
    if (!extending)
    {
        worldIn.setBlockToAir(pos.offset(direction));
    }

    BlockPistonStructureHelper blockpistonstructurehelper = new BlockPistonStructureHelper(worldIn, pos, direction, extending);

    if (!blockpistonstructurehelper.canMove())
    {
        return false;
    }
    else
    {
        List<BlockPos> list = blockpistonstructurehelper.getBlocksToMove();
        List<IBlockState> list1 = Lists.<IBlockState>newArrayList();

        for (int i = 0; i < list.size(); ++i)
        {
            BlockPos blockpos = (BlockPos)list.get(i);
            list1.add(worldIn.getBlockState(blockpos).getActualState(worldIn, blockpos));
        }

        List<BlockPos> list2 = blockpistonstructurehelper.getBlocksToDestroy();
        int k = list.size() + list2.size();
        IBlockState[] aiblockstate = new IBlockState[k];
        EnumFacing enumfacing = extending ? direction : direction.getOpposite();

        for (int j = list2.size() - 1; j >= 0; --j)
        {
            BlockPos blockpos1 = (BlockPos)list2.get(j);
            IBlockState iblockstate = worldIn.getBlockState(blockpos1);
            iblockstate.getBlock().dropBlockAsItem(worldIn, blockpos1, iblockstate, 0);
            worldIn.setBlockState(blockpos1, Blocks.AIR.getDefaultState(), 4);
            --k;
            aiblockstate[k] = iblockstate;
        }

        for (int l = list.size() - 1; l >= 0; --l)
        {
            BlockPos blockpos3 = (BlockPos)list.get(l);
            IBlockState iblockstate2 = worldIn.getBlockState(blockpos3);
            worldIn.setBlockState(blockpos3, Blocks.AIR.getDefaultState(), 2);
            blockpos3 = blockpos3.offset(enumfacing);
            worldIn.setBlockState(blockpos3, Blocks.PISTON_EXTENSION.getDefaultState().withProperty(FACING, direction), 4);
            worldIn.setTileEntity(blockpos3, BlockPistonMoving.createTilePiston((IBlockState)list1.get(l), direction, extending, false));
            --k;
            aiblockstate[k] = iblockstate2;
        }

        BlockPos blockpos2 = pos.offset(direction);

        if (extending)
        {
            BlockPistonExtension.EnumPistonType blockpistonextension$enumpistontype = this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT;
            IBlockState iblockstate3 = Blocks.PISTON_HEAD.getDefaultState().withProperty(BlockPistonExtension.FACING, direction).withProperty(BlockPistonExtension.TYPE, blockpistonextension$enumpistontype);
            IBlockState iblockstate1 = Blocks.PISTON_EXTENSION.getDefaultState().withProperty(BlockPistonMoving.FACING, direction).withProperty(BlockPistonMoving.TYPE, this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT);
            worldIn.setBlockState(blockpos2, iblockstate1, 4);
            worldIn.setTileEntity(blockpos2, BlockPistonMoving.createTilePiston(iblockstate3, direction, true, true));
        }

        for (int i1 = list2.size() - 1; i1 >= 0; --i1)
        {
            worldIn.notifyNeighborsOfStateChange((BlockPos)list2.get(i1), aiblockstate[k++].getBlock(), false);
        }

        for (int j1 = list.size() - 1; j1 >= 0; --j1)
        {
            worldIn.notifyNeighborsOfStateChange((BlockPos)list.get(j1), aiblockstate[k++].getBlock(), false);
        }

        if (extending)
        {
            worldIn.notifyNeighborsOfStateChange(blockpos2, Blocks.PISTON_HEAD, false);
        }

        return true;
    }
}
 
Example 46
Project: Pangu   File: ItemPanguFood.java   Source Code and License 4 votes vote down vote up
@Override
protected void onFoodEaten(ItemStack stack, World worldIn, @Nonnull EntityPlayer player) {
    if (!worldIn.isRemote && getStats(stack).getPotion() != null && worldIn.rand.nextFloat() < getStats(stack).getPotionEffectProbability())
        player.addPotionEffect(getStats(stack).getPotion());
}
 
Example 47
Project: CustomWorldGen   File: BlockTripWireHook.java   Source Code and License 4 votes vote down vote up
@Nullable
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos)
{
    return NULL_AABB;
}
 
Example 48
Project: ModularMachinery   File: BlockInputBus.java   Source Code and License 4 votes vote down vote up
@Nullable
@Override
public TileEntity createTileEntity(World world, IBlockState state) {
    return new TileItemInputBus(state.getValue(BUS_TYPE));
}
 
Example 49
Project: BaseClient   File: EntityEgg.java   Source Code and License 4 votes vote down vote up
public EntityEgg(World worldIn, double x, double y, double z)
{
    super(worldIn, x, y, z);
}
 
Example 50
Project: Backmemed   File: BlockShulkerBox.java   Source Code and License 4 votes vote down vote up
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos)
{
    return Container.calcRedstoneFromInventory((IInventory)worldIn.getTileEntity(pos));
}
 
Example 51
Project: BaseClient   File: BlockLiquid.java   Source Code and License 4 votes vote down vote up
/**
 * Called when a neighboring block changes.
 */
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
    this.checkForMixing(worldIn, pos, state);
}
 
Example 52
Project: Backmemed   File: EntityZombie.java   Source Code and License 4 votes vote down vote up
public EntityZombie(World worldIn)
{
    super(worldIn);
    this.setSize(0.6F, 1.95F);
}
 
Example 53
Project: pnc-repressurized   File: EntityVortex.java   Source Code and License 4 votes vote down vote up
public EntityVortex(World world) {
    super(world);
}
 
Example 54
Project: pnc-repressurized   File: HackableDispenser.java   Source Code and License 4 votes vote down vote up
@Override
public void addPostHackInfo(World world, BlockPos pos, List<String> curInfo, EntityPlayer player) {
    curInfo.add("pneumaticHelmet.hacking.finished.dispensed");
}
 
Example 55
Project: BaseClient   File: C02PacketUseEntity.java   Source Code and License 4 votes vote down vote up
public Entity getEntityFromWorld(World worldIn)
{
    return worldIn.getEntityByID(this.entityId);
}
 
Example 56
Project: Backmemed   File: EntityEgg.java   Source Code and License 4 votes vote down vote up
public EntityEgg(World worldIn, double x, double y, double z)
{
    super(worldIn, x, y, z);
}
 
Example 57
Project: pnc-repressurized   File: SemiBlockManager.java   Source Code and License 4 votes vote down vote up
public <T extends ISemiBlock> Stream<T> getSemiBlocks(Class<T> clazz, World world, BlockPos pos) {
    return StreamUtils.ofType(clazz, getSemiBlocks(world, pos));
}
 
Example 58
Project: pnc-repressurized   File: ProgrammedDroneUtils.java   Source Code and License 4 votes vote down vote up
public static EntityCreature retrieveFluidAmazonStyle(World world, BlockPos pos, FluidStack queriedFluid) {
    if (world.isRemote) return null;
    if (queriedFluid == null) throw new IllegalArgumentException("Can't query a null FluidStack");
    if (queriedFluid.amount <= 0)
        throw new IllegalArgumentException("Can't query a FluidStack with an amount of <= 0");

    EntityDrone drone = getChargedDispenserUpgradeDrone(world);

    // Program the drone
    int startY = world.getHeight(pos.add(30, 0, 0)).getY() + 30;
    drone.setPosition(pos.getX() + 30, startY, pos.getZ());
    List<IProgWidget> widgets = drone.progWidgets;

    ProgWidgetStart start = new ProgWidgetStart();
    start.setX(92);
    start.setY(41);
    widgets.add(start);

    int yBase = 52;

    ProgWidgetLiquidImport im = new ProgWidgetLiquidImport();
    im.setX(92);
    im.setY(yBase);
    im.setCount(queriedFluid.amount);
    im.setUseCount(true);
    widgets.add(im);

    ProgWidgetArea area = new ProgWidgetArea();
    area.setX(107);
    area.setY(yBase);
    area.x1 = pos.getX();
    area.y1 = pos.getY();
    area.z1 = pos.getZ();
    widgets.add(area);

    ProgWidgetLiquidFilter filter = new ProgWidgetLiquidFilter();
    filter.setX(107);
    filter.setY(yBase + 11);
    filter.setFluid(queriedFluid.getFluid());
    widgets.add(filter);

    yBase += 22;

    ProgWidgetGoToLocation gotoPiece = new ProgWidgetGoToLocation();
    gotoPiece.setX(92);
    gotoPiece.setY(yBase);
    widgets.add(gotoPiece);

    area = new ProgWidgetArea();
    area.setX(107);
    area.setY(yBase);
    area.x1 = pos.getX() + 30;
    area.y1 = startY;
    area.z1 = pos.getZ();
    widgets.add(area);

    ProgWidgetSuicide suicide = new ProgWidgetSuicide();
    suicide.setX(92);
    suicide.setY(yBase + 11);
    widgets.add(suicide);

    TileEntityProgrammer.updatePuzzleConnections(widgets);

    world.spawnEntity(drone);
    return drone;
}
 
Example 59
Project: Backmemed   File: BlockMushroom.java   Source Code and License 4 votes vote down vote up
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
    return (double)rand.nextFloat() < 0.4D;
}
 
Example 60
Project: Bewitchment   File: BrewEffect.java   Source Code and License 4 votes vote down vote up
public void update(World world, BlockPos pos, EntityLivingBase entity) {
	brew.apply(world, pos, entity, amplifier, duration--);
}