本文整理汇总了Java中net.minecraft.world.World.isBlockLoaded方法的典型用法代码示例。如果您正苦于以下问题:Java World.isBlockLoaded方法的具体用法?Java World.isBlockLoaded怎么用?Java World.isBlockLoaded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.world.World
的用法示例。
在下文中一共展示了World.isBlockLoaded方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getClientGuiElement
import net.minecraft.world.World; //导入方法依赖的package包/类
@Nullable
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
BlockPos pos = new BlockPos(x, y, z);
TileEntity te = world.isBlockLoaded(pos) ? world.getTileEntity(pos) : null;
switch (EnumGuiId.values()[ID]) {
case PNEUMATIC_GENERATOR:
return new GuiPneumaticGenerator(player.inventory, (TileEntityPneumaticGenerator) te);
case ELECTRIC_COMPRESSOR:
return new GuiElectricCompressor(player.inventory, (TileEntityElectricCompressor) te);
}
return null;
}
示例2: getTileEntity
import net.minecraft.world.World; //导入方法依赖的package包/类
public static TileEntity getTileEntity(BlockPos pos, int dimension) {
World world = DimensionManager.getWorld(dimension);
if (world != null && world.isBlockLoaded(pos)) {
return world.getTileEntity(pos);
}
return null;
}
示例3: matches
import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean matches(World world, BlockPos center, boolean oldState) {
lblPattern:
for (Map.Entry<BlockPos, BlockInformation> entry : pattern.entrySet()) {
BlockInformation info = entry.getValue();
BlockPos at = center.add(entry.getKey());
if(!world.isBlockLoaded(at)) { //We can't say if it's actually properly formed, but it didn't get changed from the last check so....
return oldState;
}
if(info.matchingTag != null) {
TileEntity te = world.getTileEntity(at);
if(te != null && info.matchingTag.getSize() > 0) {
NBTTagCompound cmp = new NBTTagCompound();
te.writeToNBT(cmp);
if(!NBTMatchingHelper.matchNBTCompound(info.matchingTag, cmp)) {
return false; //No match at this position.
}
}
}
IBlockState state = world.getBlockState(at);
Block atBlock = state.getBlock();
int atMeta = atBlock.getMetaFromState(state);
for (IBlockStateDescriptor descriptor : info.matchingStates) {
for (IBlockState applicable : descriptor.applicable) {
Block type = applicable.getBlock();
int meta = type.getMetaFromState(applicable);
if(type.equals(state.getBlock()) && meta == atMeta) {
continue lblPattern; //Matches
}
}
}
return false;
}
return true;
}
示例4: updateTick
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getBlockState(pos.up()).getLightOpacity(worldIn, pos.up()) > 2)
{
worldIn.setBlockState(pos,Util.getDirt(state));
}
else
{
if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
{
for (int i = 0; i < 4; ++i)
{
BlockPos blockpos = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
if (blockpos.getY() >= 0 && blockpos.getY() < 256 && !worldIn.isBlockLoaded(blockpos))
{
return;
}
IBlockState iblockstate = worldIn.getBlockState(blockpos.up());
IBlockState iblockstate1 = worldIn.getBlockState(blockpos);
if (Util.isDirt(iblockstate1.getBlock()) && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && iblockstate.getLightOpacity(worldIn, pos.up()) <= 2)
{
worldIn.setBlockState(blockpos, Util.getGrass(iblockstate1));
}
}
}
}
}
}
示例5: updateTick
import net.minecraft.world.World; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getBlockState(pos.up()).getLightOpacity(worldIn, pos.up()) > 2)
{
worldIn.setBlockState(pos, Blocks.DIRT.getDefaultState());
}
else
{
if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
{
for (int i = 0; i < 4; ++i)
{
BlockPos blockpos = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
if (blockpos.getY() >= 0 && blockpos.getY() < 256 && !worldIn.isBlockLoaded(blockpos))
{
return;
}
IBlockState iblockstate = worldIn.getBlockState(blockpos.up());
IBlockState iblockstate1 = worldIn.getBlockState(blockpos);
if (iblockstate1.getBlock() == Blocks.DIRT && iblockstate1.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && iblockstate.getLightOpacity(worldIn, pos.up()) <= 2)
{
worldIn.setBlockState(blockpos, Blocks.GRASS.getDefaultState());
}
}
}
}
}
}
示例6: updateTick
import net.minecraft.world.World; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getBlockState(pos.up()).getLightOpacity() > 2)
{
worldIn.setBlockState(pos, Blocks.DIRT.getDefaultState());
}
else
{
if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
{
for (int i = 0; i < 4; ++i)
{
BlockPos blockpos = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
if (blockpos.getY() >= 0 && blockpos.getY() < 256 && !worldIn.isBlockLoaded(blockpos))
{
return;
}
IBlockState iblockstate = worldIn.getBlockState(blockpos.up());
IBlockState iblockstate1 = worldIn.getBlockState(blockpos);
if (iblockstate1.getBlock() == Blocks.DIRT && iblockstate1.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && iblockstate.getLightOpacity() <= 2)
{
worldIn.setBlockState(blockpos, Blocks.GRASS.getDefaultState());
}
}
}
}
}
}
示例7: getCanBlockBurn
import net.minecraft.world.World; //导入方法依赖的package包/类
private boolean getCanBlockBurn(World worldIn, BlockPos pos)
{
return pos.getY() >= 0 && pos.getY() < 256 && !worldIn.isBlockLoaded(pos) ? false : worldIn.getBlockState(pos).getMaterial().getCanBurn();
}
示例8: attemptTeleport
import net.minecraft.world.World; //导入方法依赖的package包/类
/**
* Teleports the entity to the specified location. Used for Enderman and Chorus Fruit teleportation
*/
public boolean attemptTeleport(double x, double y, double z)
{
double d0 = this.posX;
double d1 = this.posY;
double d2 = this.posZ;
this.posX = x;
this.posY = y;
this.posZ = z;
boolean flag = false;
BlockPos blockpos = new BlockPos(this);
World world = this.worldObj;
Random random = this.getRNG();
if (world.isBlockLoaded(blockpos))
{
boolean flag1 = false;
while (!flag1 && blockpos.getY() > 0)
{
BlockPos blockpos1 = blockpos.down();
IBlockState iblockstate = world.getBlockState(blockpos1);
if (iblockstate.getMaterial().blocksMovement())
{
flag1 = true;
}
else
{
--this.posY;
blockpos = blockpos1;
}
}
if (flag1)
{
this.setPositionAndUpdate(this.posX, this.posY, this.posZ);
if (world.getCollisionBoxes(this, this.getEntityBoundingBox()).isEmpty() && !world.containsAnyLiquid(this.getEntityBoundingBox()))
{
flag = true;
}
}
}
if (!flag)
{
this.setPositionAndUpdate(d0, d1, d2);
return false;
}
else
{
int i = 128;
for (int j = 0; j < 128; ++j)
{
double d6 = (double)j / 127.0D;
float f = (random.nextFloat() - 0.5F) * 0.2F;
float f1 = (random.nextFloat() - 0.5F) * 0.2F;
float f2 = (random.nextFloat() - 0.5F) * 0.2F;
double d3 = d0 + (this.posX - d0) * d6 + (random.nextDouble() - 0.5D) * (double)this.width * 2.0D;
double d4 = d1 + (this.posY - d1) * d6 + random.nextDouble() * (double)this.height;
double d5 = d2 + (this.posZ - d2) * d6 + (random.nextDouble() - 0.5D) * (double)this.width * 2.0D;
world.spawnParticle(EnumParticleTypes.PORTAL, d3, d4, d5, (double)f, (double)f1, (double)f2, new int[0]);
}
if (this instanceof EntityCreature)
{
((EntityCreature)this).getNavigator().clearPathEntity();
}
return true;
}
}
示例9: processCommand
import net.minecraft.world.World; //导入方法依赖的package包/类
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 4)
{
throw new WrongUsageException("commands.blockdata.usage", new Object[0]);
}
else
{
sender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, 0);
BlockPos blockpos = parseBlockPos(sender, args, 0, false);
World world = sender.getEntityWorld();
if (!world.isBlockLoaded(blockpos))
{
throw new CommandException("commands.blockdata.outOfWorld", new Object[0]);
}
else
{
TileEntity tileentity = world.getTileEntity(blockpos);
if (tileentity == null)
{
throw new CommandException("commands.blockdata.notValid", new Object[0]);
}
else
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
tileentity.writeToNBT(nbttagcompound);
NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttagcompound.copy();
NBTTagCompound nbttagcompound2;
try
{
nbttagcompound2 = JsonToNBT.getTagFromJson(getChatComponentFromNthArg(sender, args, 3).getUnformattedText());
}
catch (NBTException nbtexception)
{
throw new CommandException("commands.blockdata.tagError", new Object[] {nbtexception.getMessage()});
}
nbttagcompound.merge(nbttagcompound2);
nbttagcompound.setInteger("x", blockpos.getX());
nbttagcompound.setInteger("y", blockpos.getY());
nbttagcompound.setInteger("z", blockpos.getZ());
if (nbttagcompound.equals(nbttagcompound1))
{
throw new CommandException("commands.blockdata.failed", new Object[] {nbttagcompound.toString()});
}
else
{
tileentity.readFromNBT(nbttagcompound);
tileentity.markDirty();
world.markBlockForUpdate(blockpos);
sender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, 1);
notifyOperators(sender, this, "commands.blockdata.success", new Object[] {nbttagcompound.toString()});
}
}
}
}
}
示例10: updateTick
import net.minecraft.world.World; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (this.blockMaterial == Material.LAVA)
{
if (worldIn.getGameRules().getBoolean("doFireTick"))
{
int i = rand.nextInt(3);
if (i > 0)
{
BlockPos blockpos = pos;
for (int j = 0; j < i; ++j)
{
blockpos = blockpos.add(rand.nextInt(3) - 1, 1, rand.nextInt(3) - 1);
if (blockpos.getY() >= 0 && blockpos.getY() < worldIn.getHeight() && !worldIn.isBlockLoaded(blockpos))
{
return;
}
Block block = worldIn.getBlockState(blockpos).getBlock();
if (block.blockMaterial == Material.AIR)
{
if (this.isSurroundingBlockFlammable(worldIn, blockpos))
{
worldIn.setBlockState(blockpos, Blocks.FIRE.getDefaultState());
return;
}
}
else if (block.blockMaterial.blocksMovement())
{
return;
}
}
}
else
{
for (int k = 0; k < 3; ++k)
{
BlockPos blockpos1 = pos.add(rand.nextInt(3) - 1, 0, rand.nextInt(3) - 1);
if (blockpos1.getY() >= 0 && blockpos1.getY() < 256 && !worldIn.isBlockLoaded(blockpos1))
{
return;
}
if (worldIn.isAirBlock(blockpos1.up()) && this.getCanBlockBurn(worldIn, blockpos1))
{
worldIn.setBlockState(blockpos1.up(), Blocks.FIRE.getDefaultState());
}
}
}
}
}
}
示例11: onBlockStartBreak
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player) {
World world = player.getEntityWorld();
if (!world.isRemote && player instanceof EntityPlayerMP) {
RayTraceResult rt = this.rayTrace(world, player, false);
if (rt.typeOfHit == RayTraceResult.Type.BLOCK) {
EnumFacing side = rt.sideHit;
List<BlockPos> extraBlocks = getExtraBlocks(world, rt, player);
for (BlockPos pos2 : extraBlocks) {
IBlockState state = world.getBlockState(pos2);
if (!world.isBlockLoaded(pos2) || !player.canPlayerEdit(pos2, side, itemstack) || !(state.getBlock().canHarvestBlock(world, pos2, player))) {
continue;
}
if (player.capabilities.isCreativeMode) {
state.getBlock().onBlockHarvested(world, pos2, state, player);
if (state.getBlock().removedByPlayer(state, world, pos2, player, false)) {
state.getBlock().onBlockDestroyedByPlayer(world, pos2, state);
}
} else {
int xp = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP) player).interactionManager.getGameType(), (EntityPlayerMP) player, pos2);
state.getBlock().onBlockHarvested(world, pos2, state, player);
this.onBlockDestroyed(itemstack, world, state, pos2, player);
if (state.getBlock().removedByPlayer(state, world, pos2, player, true)) {
state.getBlock().onBlockDestroyedByPlayer(world, pos2, state);
state.getBlock().harvestBlock(world, player, pos2, state, world.getTileEntity(pos2), itemstack);
state.getBlock().dropXpOnBlockBreak(world, pos2, xp);
}
}
world.playEvent(2001, pos, Block.getStateId(state));
((EntityPlayerMP) player).connection.sendPacket(new SPacketBlockChange(world, pos));
}
}
}
return false;
}
示例12: attemptTeleport
import net.minecraft.world.World; //导入方法依赖的package包/类
/**
* Teleports the entity to the specified location. Used for Enderman and Chorus Fruit teleportation
*/
public boolean attemptTeleport(double x, double y, double z)
{
double d0 = this.posX;
double d1 = this.posY;
double d2 = this.posZ;
this.posX = x;
this.posY = y;
this.posZ = z;
boolean flag = false;
BlockPos blockpos = new BlockPos(this);
World world = this.world;
Random random = this.getRNG();
if (world.isBlockLoaded(blockpos))
{
boolean flag1 = false;
while (!flag1 && blockpos.getY() > 0)
{
BlockPos blockpos1 = blockpos.down();
IBlockState iblockstate = world.getBlockState(blockpos1);
if (iblockstate.getMaterial().blocksMovement())
{
flag1 = true;
}
else
{
--this.posY;
blockpos = blockpos1;
}
}
if (flag1)
{
this.setPositionAndUpdate(this.posX, this.posY, this.posZ);
if (world.getCollisionBoxes(this, this.getEntityBoundingBox()).isEmpty() && !world.containsAnyLiquid(this.getEntityBoundingBox()))
{
flag = true;
}
}
}
if (!flag)
{
this.setPositionAndUpdate(d0, d1, d2);
return false;
}
else
{
int i = 128;
for (int j = 0; j < 128; ++j)
{
double d6 = (double)j / 127.0D;
float f = (random.nextFloat() - 0.5F) * 0.2F;
float f1 = (random.nextFloat() - 0.5F) * 0.2F;
float f2 = (random.nextFloat() - 0.5F) * 0.2F;
double d3 = d0 + (this.posX - d0) * d6 + (random.nextDouble() - 0.5D) * (double)this.width * 2.0D;
double d4 = d1 + (this.posY - d1) * d6 + random.nextDouble() * (double)this.height;
double d5 = d2 + (this.posZ - d2) * d6 + (random.nextDouble() - 0.5D) * (double)this.width * 2.0D;
world.spawnParticle(EnumParticleTypes.PORTAL, d3, d4, d5, (double)f, (double)f1, (double)f2, new int[0]);
}
if (this instanceof EntityCreature)
{
((EntityCreature)this).getNavigator().clearPathEntity();
}
return true;
}
}
示例13: updateTick
import net.minecraft.world.World; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (this.blockMaterial == Material.LAVA)
{
if (worldIn.getGameRules().getBoolean("doFireTick"))
{
int i = rand.nextInt(3);
if (i > 0)
{
BlockPos blockpos = pos;
for (int j = 0; j < i; ++j)
{
blockpos = blockpos.add(rand.nextInt(3) - 1, 1, rand.nextInt(3) - 1);
if (blockpos.getY() >= 0 && blockpos.getY() < 256 && !worldIn.isBlockLoaded(blockpos))
{
return;
}
Block block = worldIn.getBlockState(blockpos).getBlock();
if (block.blockMaterial == Material.AIR)
{
if (this.isSurroundingBlockFlammable(worldIn, blockpos))
{
worldIn.setBlockState(blockpos, Blocks.FIRE.getDefaultState());
return;
}
}
else if (block.blockMaterial.blocksMovement())
{
return;
}
}
}
else
{
for (int k = 0; k < 3; ++k)
{
BlockPos blockpos1 = pos.add(rand.nextInt(3) - 1, 0, rand.nextInt(3) - 1);
if (blockpos1.getY() >= 0 && blockpos1.getY() < 256 && !worldIn.isBlockLoaded(blockpos1))
{
return;
}
if (worldIn.isAirBlock(blockpos1.up()) && this.getCanBlockBurn(worldIn, blockpos1))
{
worldIn.setBlockState(blockpos1.up(), Blocks.FIRE.getDefaultState());
}
}
}
}
}
}
示例14: execute
import net.minecraft.world.World; //导入方法依赖的package包/类
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 4)
{
throw new WrongUsageException("commands.blockdata.usage", new Object[0]);
}
else
{
sender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, 0);
BlockPos blockpos = parseBlockPos(sender, args, 0, false);
World world = sender.getEntityWorld();
if (!world.isBlockLoaded(blockpos))
{
throw new CommandException("commands.blockdata.outOfWorld", new Object[0]);
}
else
{
IBlockState iblockstate = world.getBlockState(blockpos);
TileEntity tileentity = world.getTileEntity(blockpos);
if (tileentity == null)
{
throw new CommandException("commands.blockdata.notValid", new Object[0]);
}
else
{
NBTTagCompound nbttagcompound = tileentity.writeToNBT(new NBTTagCompound());
NBTTagCompound nbttagcompound1 = nbttagcompound.copy();
NBTTagCompound nbttagcompound2;
try
{
nbttagcompound2 = JsonToNBT.getTagFromJson(getChatComponentFromNthArg(sender, args, 3).getUnformattedText());
}
catch (NBTException nbtexception)
{
throw new CommandException("commands.blockdata.tagError", new Object[] {nbtexception.getMessage()});
}
nbttagcompound.merge(nbttagcompound2);
nbttagcompound.setInteger("x", blockpos.getX());
nbttagcompound.setInteger("y", blockpos.getY());
nbttagcompound.setInteger("z", blockpos.getZ());
if (nbttagcompound.equals(nbttagcompound1))
{
throw new CommandException("commands.blockdata.failed", new Object[] {nbttagcompound.toString()});
}
else
{
tileentity.readFromNBT(nbttagcompound);
tileentity.markDirty();
world.notifyBlockUpdate(blockpos, iblockstate, iblockstate, 3);
sender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, 1);
notifyCommandListener(sender, this, "commands.blockdata.success", new Object[] {nbttagcompound.toString()});
}
}
}
}
}