当前位置: 首页>>代码示例>>Java>>正文


Java World类代码示例

本文整理汇总了Java中net.minecraft.world.World的典型用法代码示例。如果您正苦于以下问题:Java World类的具体用法?Java World怎么用?Java World使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


World类属于net.minecraft.world包,在下文中一共展示了World类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onItemUse

import net.minecraft.world.World; //导入依赖的package包/类
@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;
}
 
开发者ID:jaquadro,项目名称:GardenStuff,代码行数:22,代码来源:ItemCandelillaSeeds.java

示例2: neighborChanged

import net.minecraft.world.World; //导入依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:BlockRedstoneWire.java

示例3: applyBonemeal

import net.minecraft.world.World; //导入依赖的package包/类
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;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:27,代码来源:ItemDye.java

示例4: onItemUse

import net.minecraft.world.World; //导入依赖的package包/类
@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;
   }
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:24,代码来源:PackedUpBB.java

示例5: onBlockPlacedBy

import net.minecraft.world.World; //导入依赖的package包/类
@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));
	}
}
 
开发者ID:bl4ckscor3,项目名称:GlobalXP,代码行数:21,代码来源:XPBlock.java

示例6: generatePotentialRooms

import net.minecraft.world.World; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:25,代码来源:Dungeon.java

示例7: create

import net.minecraft.world.World; //导入依赖的package包/类
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;
}
 
开发者ID:DaedalusGame,项目名称:Soot,代码行数:19,代码来源:AlchemyResult.java

示例8: onItemRightClick

import net.minecraft.world.World; //导入依赖的package包/类
@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);
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:25,代码来源:ItemGlove.java

示例9: addInformation

import net.minecraft.world.World; //导入依赖的package包/类
@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);
            }
        }
    }
}
 
开发者ID:iChun,项目名称:Clef,代码行数:22,代码来源:ItemInstrument.java

示例10: addComponentParts

import net.minecraft.world.World; //导入依赖的package包/类
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;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:25,代码来源:StructureStrongholdPieces.java

示例11: placePodzolAt

import net.minecraft.world.World; //导入依赖的package包/类
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;
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:WorldGenMegaPineTree.java

示例12: onItemRightClick

import net.minecraft.world.World; //导入依赖的package包/类
@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));
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:17,代码来源:ItemRemedyTalisman.java

示例13: tryPlace

import net.minecraft.world.World; //导入依赖的package包/类
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;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:25,代码来源:ItemSlab.java

示例14: onBlockActivated

import net.minecraft.world.World; //导入依赖的package包/类
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;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:28,代码来源:BlockDispenser.java

示例15: getClientGuiElement

import net.minecraft.world.World; //导入依赖的package包/类
@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;
	}
}
 
开发者ID:PC-Logix,项目名称:OpenSensors,代码行数:12,代码来源:CommonProxy.java


注:本文中的net.minecraft.world.World类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。