本文整理汇总了C#中World.SetBlock方法的典型用法代码示例。如果您正苦于以下问题:C# World.SetBlock方法的具体用法?C# World.SetBlock怎么用?C# World.SetBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类World
的用法示例。
在下文中一共展示了World.SetBlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OldBuild
public void OldBuild(World world, BlockPos chunkPos, BlockPos pos, OldTerrainGen gen)
{
int leaves = gen.GetNoise(pos.x, 0, pos.z, 1f, 2, 1) + 1;
pos = pos.Add(chunkPos);
for (int x = -leaves; x <= leaves; x++)
{
for (int y = 3; y <= 6; y++)
{
for (int z = -leaves; z <= leaves; z++)
{
if (Chunk.InRange(pos.x + x - chunkPos.x) && Chunk.InRange(pos.z + z - chunkPos.z))
{
Block block = "leaves";
block.modified = false;
world.SetBlock(pos.Add(x, y, z), block, false);
}
}
}
}
for (int y = 0; y <= 5; y++)
{
if (y < Config.Env.WorldMaxY)
{
Block block = "log";
block.modified = false;
world.SetBlock(pos.Add(0, y, 0), block, false);
}
}
}
示例2: OnScheduledUpdate
public override void OnScheduledUpdate(World world, Vector3 position)
{
// Check for water
int closest = int.MaxValue;
for (int y = -1; y < 1; y++ )
for (int x = -8; x < 8; x++)
for (int z = -8; z < 8; z++)
{
if (position.Y + y < 0)
continue;
var blockPosition = new Vector3(x, position.Y + y, z);
var block = world.GetBlock(blockPosition);
if (block is WaterFlowingBlock || block is WaterStillBlock)
{
var distance = position.DistanceTo(blockPosition);
if (distance < closest)
closest = (int)distance;
}
}
closest = -(closest - 4) + 4;
Metadata = (byte)closest;
if (closest >= 5 && MathHelper.Random.Next(5) == 0)
world.SetBlock(position, new DirtBlock());
else
{
world.SetBlock(position, this);
ScheduleUpdate(world, position, DateTime.Now.AddSeconds(MathHelper.Random.Next(30, 120)));
}
base.OnScheduledUpdate(world, position);
}
示例3: TestBuckets
public void TestBuckets()
{
World world = new World(new Level(), new FlatlandGenerator());
world.WorldGenerator.Initialize(new Level());
PlayerEntity player = new PlayerEntity(Difficulty.Normal)
{
GameMode = GameMode.Creative
};
Vector3 targetBlock = new Vector3(0, 2, 0);
Vector3 alteredBlock = targetBlock + Vector3.Up;
world.SetBlock(alteredBlock, new AirBlock());
BucketItem bucket = new BucketItem();
LavaBucketItem lavaBucket = new LavaBucketItem();
WaterBucketItem waterBucket = new WaterBucketItem();
// TODO: Survival tests
waterBucket.OnItemUsedOnBlock(world, targetBlock, Vector3.Up, Vector3.Zero, player);
Assert.AreEqual(new WaterFlowingBlock(), world.GetBlock(alteredBlock));
bucket.OnItemUsedOnBlock(world, targetBlock, Vector3.Up, Vector3.Zero, player);
Assert.AreEqual(new AirBlock(), world.GetBlock(alteredBlock));
lavaBucket.OnItemUsedOnBlock(world, targetBlock, Vector3.Up, Vector3.Zero, player);
Assert.AreEqual(new LavaFlowingBlock(), world.GetBlock(alteredBlock));
bucket.OnItemUsedOnBlock(world, targetBlock, Vector3.Up, Vector3.Zero, player);
Assert.AreEqual(new AirBlock(), world.GetBlock(alteredBlock));
world.SetBlock(alteredBlock, new BedrockBlock());
bucket.OnItemUsedOnBlock(world, targetBlock, Vector3.Up, Vector3.Zero, player);
Assert.AreEqual(new BedrockBlock(), world.GetBlock(alteredBlock));
}
示例4: OnItemUsedOnBlock
public override void OnItemUsedOnBlock(World world, Vector3 clickedBlock, Vector3 clickedSide, Vector3 cursorPosition, Entities.Entity usedBy)
{
var entity = (PlayerEntity)usedBy;
// TODO: Check for source block
// TODO: Survival
if (world.GetBlock(clickedBlock + clickedSide) is WaterFlowingBlock || world.GetBlock(clickedBlock + clickedSide) is WaterStillBlock)
{
world.SetBlock(clickedBlock + clickedSide, new AirBlock());
}
if (world.GetBlock(clickedBlock + clickedSide) is LavaFlowingBlock || world.GetBlock(clickedBlock + clickedSide) is LavaStillBlock)
{
world.SetBlock(clickedBlock + clickedSide, new AirBlock());
}
}
示例5: OnItemUsedOnBlock
public override void OnItemUsedOnBlock(World world, Vector3 clickedBlock, Vector3 clickedSide, Vector3 cursorPosition, Entity usedBy)
{
if (clickedSide == Vector3.Up)
{
// Floor sign
byte metadata = (byte)((usedBy.Yaw % 360 / 360 * 16) + 8 % 16);
world.SetBlock(clickedBlock + clickedSide, new SignPostBlock(metadata));
}
else if (clickedSide != Vector3.Down)
{
// Wall sign
world.SetBlock(clickedBlock + clickedSide, new WallSignBlock(MathHelper.DirectionByRotationFlat(usedBy, true)));
}
}
示例6: OnItemUsedOnBlock
public override void OnItemUsedOnBlock(World world, Vector3 clickedBlock, Vector3 clickedSide, Vector3 cursorPosition, Entities.Entity usedBy)
{
if (clickedSide != Vector3.Up)
return;
Vector3 away = DataUtility.FowardVector(usedBy);
var near = world.GetBlock(clickedBlock + clickedSide);
var far = world.GetBlock(clickedBlock + clickedSide + away);
if (near is AirBlock && far is AirBlock)
{
// Place bed
world.SetBlock(clickedBlock + clickedSide, new BedBlock(BedBlock.Vector3ToBedDirection(away), false));
world.SetBlock(clickedBlock + clickedSide + away, new BedBlock(BedBlock.Vector3ToBedDirection(away), true));
}
}
示例7: OnBlockRightClicked
public override bool OnBlockRightClicked(Vector3 clickedBlock, Vector3 clickedSide, Vector3 cursorPosition, World world, Entities.Entity usedBy)
{
if (!UpperHalf)
{
Closed = !Closed;
world.SetBlock(clickedBlock, this);
}
else
{
DoorBlock block = (DoorBlock)world.GetBlock(clickedBlock + Vector3.Down);
block.Closed = !block.Closed;
world.SetBlock(clickedBlock + Vector3.Down, block);
}
return false;
}
示例8: generate
public override bool generate(World world, java.util.Random random, int i, int j, int k)
{
if (BlockData.BlockMaterial(world.GetBlock(i, j, k)) != Material.Water)
{
return false;
}
int l = random.nextInt(field_35290_b - 2) + 2;
byte byte0 = 2;
for (int i1 = i - l; i1 <= i + l; i1++)
{
for (int j1 = k - l; j1 <= k + l; j1++)
{
int k1 = i1 - i;
int l1 = j1 - k;
if (k1 * k1 + l1 * l1 > l * l)
{
continue;
}
for (int i2 = j - byte0; i2 <= j + byte0; i2++)
{
int j2 = world.GetBlock(i1, i2, j1);
if (j2 == (byte)Blocks.Dirt || j2 == (byte)Blocks.Grass)
{
world.SetBlock(i1, i2, j1, (byte)field_35291_a);
}
}
}
}
return true;
}
示例9: BlockUpdate
public override void BlockUpdate(World world, Vector3 updatedBlock, Vector3 modifiedBlock)
{
if (UpperHalf)
{
var block = world.GetBlock(updatedBlock + Vector3.Down);
if (!(block is DoorBlock))
world.SetBlock(updatedBlock, new AirBlock());
}
else
{
var block = world.GetBlock(updatedBlock + Vector3.Up);
if (!(block is DoorBlock))
world.SetBlock(updatedBlock, new AirBlock());
}
base.BlockUpdate(world, updatedBlock, modifiedBlock);
}
示例10: generate
public override bool generate(World world, java.util.Random random, int i, int j, int k)
{
if (BlockData.BlockMaterial(world.GetBlock(i, j, k)) != Material.Water)
{
return false;
}
int l = random.nextInt(numberOfBlocks - 2) + 2;
int i1 = 1;
for (int j1 = i - l; j1 <= i + l; j1++)
{
for (int k1 = k - l; k1 <= k + l; k1++)
{
int l1 = j1 - i;
int i2 = k1 - k;
if (l1 * l1 + i2 * i2 > l * l)
{
continue;
}
for (int j2 = j - i1; j2 <= j + i1; j2++)
{
int k2 = world.GetBlock(j1, j2, k1);
if (k2 == (byte)Blocks.Dirt || k2 == (byte)Blocks.ClayBlock)
{
world.SetBlock(j1, j2, k1, (byte)clayBlockId);
}
}
}
}
return true;
}
示例11: OnBlockRightClicked
public override bool OnBlockRightClicked(Vector3 clickedBlock, Vector3 clickedSide,
Vector3 cursorPosition, World world, Entity usedBy)
{
Metadata ^= 0x8;
world.SetBlock(clickedBlock, this);
return false;
}
示例12: generate
public override bool generate(World world, java.util.Random random, int i, int j, int k)
{
if (world.GetBlock(i, j + 1, k) != (byte)Blocks.Netherrack)
{
return false;
}
if (world.GetBlock(i, j, k) != 0 && world.GetBlock(i, j, k) != (byte)Blocks.Netherrack)
{
return false;
}
int l = 0;
if (world.GetBlock(i - 1, j, k) == (byte)Blocks.Netherrack)
{
l++;
}
if (world.GetBlock(i + 1, j, k) == (byte)Blocks.Netherrack)
{
l++;
}
if (world.GetBlock(i, j, k - 1) == (byte)Blocks.Netherrack)
{
l++;
}
if (world.GetBlock(i, j, k + 1) == (byte)Blocks.Netherrack)
{
l++;
}
if (world.GetBlock(i, j - 1, k) == (byte)Blocks.Netherrack)
{
l++;
}
int i1 = 0;
if (world.IsAirBlock(i - 1, j, k))
{
i1++;
}
if (world.IsAirBlock(i + 1, j, k))
{
i1++;
}
if (world.IsAirBlock(i, j, k - 1))
{
i1++;
}
if (world.IsAirBlock(i, j, k + 1))
{
i1++;
}
if (world.IsAirBlock(i, j - 1, k))
{
i1++;
}
if (l == 4 && i1 == 1)
{
world.SetBlock(i, j, k, (byte)field_4250_a);
world.physics.AddCheck(i, j, k);
//Block.blocksList[field_4250_a].updateTick(world, i, j, k, random);
}
return true;
}
示例13: BlockUpdate
public override void BlockUpdate(World world, Vector3 updatedBlock, Vector3 modifiedBlock)
{
var block = world.GetBlock(updatedBlock + Vector3.Up);
if (!(block is AirBlock) && !(block is IGrowableBlock))
world.SetBlock(updatedBlock, new DirtBlock());
base.BlockUpdate(world, updatedBlock, modifiedBlock);
}
示例14: OnItemUsed
public override void OnItemUsed(World world, Vector3 clickedBlock, Vector3 clickedSide, Vector3 cursorPosition, Entities.Entity usedBy)
{
var block = world.GetBlock(clickedBlock);
if (block is DirtBlock || block is GrassBlock)
world.SetBlock(clickedBlock, new FarmlandBlock());
base.OnItemUsed(world, clickedBlock, clickedSide, cursorPosition, usedBy);
}
示例15: Grow
public bool Grow(World world, Vector3 position, bool instant)
{
if (instant)
return false; // TODO
else
{
var possibleGrowth = new List<Vector3>();
for (int y = -3; y <= 1; y++)
{
for (int x = -1; x <= 1; x++)
{
for (int z = -1; z <= 1; z++)
{
var blockPosition = position + new Vector3(x, y, z);
var block = world.SafeGetBlock(blockPosition);
var above = world.SafeGetBlock(blockPosition + Vector3.Up);
if (block is DirtBlock && above is AirBlock)
possibleGrowth.Add(blockPosition);
}
}
}
if (!possibleGrowth.Any())
return false;
var newPosition = possibleGrowth[MathHelper.Random.Next(possibleGrowth.Count)];
world.SetBlock(newPosition, new GrassBlock());
ScheduleGrowth(world, newPosition);
return true;
}
}