本文整理了Java中net.minecraft.world.World.playEvent()
方法的一些代码示例,展示了World.playEvent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。World.playEvent()
方法的具体详情如下:
包路径:net.minecraft.world.World
类名称:World
方法名:playEvent
暂无
代码示例来源:origin: EngineHub/WorldEdit
@Override
public boolean playEffect(Vector3 position, int type, int data) {
getWorld().playEvent(type, ForgeAdapter.toBlockPos(position.toBlockPoint()), data);
return true;
}
代码示例来源:origin: Vazkii/Botania
@Override
protected void playDispenseSound(IBlockSource source) {
source.getWorld().playEvent(1000, source.getBlockPos(), 0);
}
代码示例来源:origin: Vazkii/Botania
@Override
protected void playDispenseSound(IBlockSource source)
{
if (field_179241_b)
{
source.getWorld().playEvent(1000, source.getBlockPos(), 0);
}
else
{
source.getWorld().playEvent(1001, source.getBlockPos(), 0);
}
}
}
代码示例来源:origin: Vazkii/Botania
@Override
protected void onImpact(@Nonnull RayTraceResult pos) {
if(pos.getBlockPos() != null && !world.isRemote) {
List<BlockPos> coordsList = getCoordsToPut(pos.getBlockPos());
world.playEvent(2002, new BlockPos(this), 8);
for(BlockPos coords : coordsList) {
world.setBlockState(coords, Blocks.END_STONE.getDefaultState());
if(Math.random() < 0.1)
world.playEvent(2001, coords, Block.getStateId(Blocks.END_STONE.getDefaultState()));
}
setDead();
}
}
代码示例来源:origin: Vazkii/Botania
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
ItemStack stack = player.getHeldItem(hand);
if(stack.getItemDamage() == 4 || stack.getItemDamage() == 14)
return EntityDoppleganger.spawn(player, stack, world, pos, stack.getItemDamage() == 14) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
else if(stack.getItemDamage() == 20 && net.minecraft.item.ItemDye.applyBonemeal(stack, world, pos, player, hand)) {
if(!world.isRemote)
world.playEvent(2005, pos, 0);
return EnumActionResult.SUCCESS;
}
return super.onItemUse(player, world, pos, hand, side, par8, par9, par10);
}
代码示例来源:origin: Vazkii/Botania
@Override
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, BlockPos pos, EnumFacing side) {
if(player == null || world.isRemote)
return false;
if(!player.isSneaking()) {
playerPositions.put(player.getUniqueID(), new DimWithPos(world.provider.getDimension(), pos));
world.playSound(null, pos, ModSounds.ding, SoundCategory.BLOCKS, 0.5F, 1F);
} else {
spawnAsEntity(world, pos, new ItemStack(this));
world.setBlockToAir(pos);
world.playEvent(2001, pos, Block.getStateId(getDefaultState()));
}
return true;
}
代码示例来源:origin: Vazkii/Botania
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
IBlockState state = world.getBlockState(pos);
if(Item.getItemFromBlock(state.getBlock()) == Items.AIR)
return EnumActionResult.PASS;
ItemStack blockStack = new ItemStack(state.getBlock());
int[] ids = OreDictionary.getOreIDs(blockStack);
for(int i : ids) {
String name = OreDictionary.getOreName(i);
if(name.equals("grass")) {
world.playEvent(2001, pos, Block.getStateId(state));
world.setBlockState(pos, ModBlocks.enchantedSoil.getDefaultState());
player.getHeldItem(hand).shrink(1);
return EnumActionResult.SUCCESS;
}
}
return EnumActionResult.PASS;
}
代码示例来源:origin: Vazkii/Botania
@Override
protected void onImpact(RayTraceResult pos) {
if (world.isRemote)
return;
EntityLivingBase thrower = getThrower();
if(pos.entityHit != null && thrower != null && pos.entityHit != thrower && !pos.entityHit.isDead) {
if(thrower instanceof EntityPlayer)
pos.entityHit.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) thrower), Math.random() < 0.25 ? 10 : 5);
else pos.entityHit.attackEntityFrom(DamageSource.GENERIC, Math.random() < 0.25 ? 10 : 5);
}
if (pos.getBlockPos() != null) {
IBlockState state = world.getBlockState(pos.getBlockPos());
if(ConfigHandler.blockBreakParticles && !state.getBlock().isAir(state, world, pos.getBlockPos()))
world.playEvent(2001, pos.getBlockPos(), Block.getStateId(state));
}
setDead();
}
代码示例来源:origin: Vazkii/Botania
@Override
public void onBurstCollision(IManaBurst burst, World world, BlockPos pos) {
if(!burst.isFake() && !world.isRemote) {
world.playEvent(2001, pos, Block.getStateId(getDefaultState()));
world.setBlockToAir(pos);
EntityManaStorm storm = new EntityManaStorm(world);
storm.setPosition(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
world.spawnEntity(storm);
}
}
代码示例来源:origin: Vazkii/Botania
@Override
protected void onImpact(@Nonnull RayTraceResult var1) {
if(!world.isRemote) {
if(var1 != null) {
EnumFacing dir = var1.sideHit;
if(dir != null && dir.getAxis() != EnumFacing.Axis.Y) {
BlockPos pos = var1.getBlockPos().offset(dir);
while(pos.getY() > 0) {
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if(block.isAir(state, world, pos)) {
IBlockState stateSet = ModBlocks.solidVines.getDefaultState().withProperty(propMap.get(dir.getOpposite()), true);
world.setBlockState(pos, stateSet, 1 | 2);
world.playEvent(2001, pos, Block.getStateId(stateSet));
pos = pos.down();
} else break;
}
}
}
this.world.setEntityState(this, (byte)3);
setDead();
}
}
代码示例来源:origin: Vazkii/Botania
@Override
public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) {
TileEntity te = (TileEntity) tile;
World world = te.getWorld();
if(!world.isRemote && tile.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 4 == 0 && world.rand.nextInt(8) == 0 && tile.isEnabled()) {
BlockPos pos = ((TileEntity) tile).getPos().offset(tile.getAvatarFacing());
IBlockState state = world.getBlockState(pos);
if(state.getBlock().isAir(state, world, pos)) {
world.setBlockState(pos, Blocks.DIRT.getDefaultState());
world.playEvent(2001, pos, Block.getStateId(Blocks.DIRT.getDefaultState()));
tile.recieveMana(-COST);
}
}
}
代码示例来源:origin: Vazkii/Botania
@Override
public void onUpdate() {
super.onUpdate();
if(supertile.getWorld().isRemote || redstoneSignal > 0)
return;
if(mana >= COST && ticksExisted % 2 == 0) {
BlockPos coords = getCoordsToPut();
if(coords != null) {
IBlockState state = getStoneToPut(coords);
if(state != null) {
supertile.getWorld().setBlockState(coords, state);
if(ConfigHandler.blockBreakParticles)
supertile.getWorld().playEvent(2001, coords, Block.getStateId(state));
mana -= COST;
sync();
}
}
}
}
代码示例来源:origin: Vazkii/Botania
@Override
public void onUpdate() {
super.onUpdate();
if(supertile.getWorld().isRemote)
return;
if(ticksExisted % 200 == 0)
sync();
if(ticksExisted % 6 == 0 && redstoneSignal == 0) {
int range = getRange();
int x = supertile.getPos().getX() + supertile.getWorld().rand.nextInt(range * 2 + 1) - range;
int z = supertile.getPos().getZ() + supertile.getWorld().rand.nextInt(range * 2 + 1) - range;
for(int i = 4; i > -2; i--) {
int y = supertile.getPos().getY() + i;
BlockPos pos = new BlockPos(x, y, z);
if(supertile.getWorld().isAirBlock(pos))
continue;
if(isPlant(pos) && mana > 5) {
Block block = supertile.getWorld().getBlockState(pos).getBlock();
mana -= 5;
supertile.getWorld().scheduleUpdate(pos, block, 1);
if(ConfigHandler.blockBreakParticles)
supertile.getWorld().playEvent(2005, pos, 6 + supertile.getWorld().rand.nextInt(4));
supertile.getWorld().playSound(null, x, y, z, ModSounds.agricarnation, SoundCategory.BLOCKS, 0.01F, 0.5F + (float) Math.random() * 0.5F);
break;
}
}
}
}
代码示例来源:origin: Vazkii/Botania
IBlockState state = block.getStateFromMeta(meta);
player.world.setBlockState(coords, state, 1 | 2);
player.world.playEvent(2001, coords, Block.getStateId(state));
代码示例来源:origin: Vazkii/Botania
public static void removeBlockWithDrops(EntityPlayer player, ItemStack stack, World world, BlockPos pos,
Predicate<IBlockState> filter,
boolean dispose, boolean particles) {
if(!world.isBlockLoaded(pos))
return;
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if(!world.isRemote && filter.test(state)
&& !block.isAir(state, world, pos) && state.getPlayerRelativeBlockHardness(player, world, pos) > 0
&& block.canHarvestBlock(player.world, pos, player)) {
int exp = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP) player).interactionManager.getGameType(), (EntityPlayerMP) player, pos);
if(exp == -1)
return;
if(!player.capabilities.isCreativeMode) {
TileEntity tile = world.getTileEntity(pos);
if(block.removedByPlayer(state, world, pos, player, true)) {
block.onPlayerDestroy(world, pos, state);
if(!dispose || !ItemElementiumPick.isDisposable(block)) {
block.harvestBlock(world, player, pos, state, tile, stack);
block.dropXpOnBlockBreak(world, pos, exp);
}
}
damageItem(stack, 1, player, 80);
} else world.setBlockToAir(pos);
if(particles && ConfigHandler.blockBreakParticles && ConfigHandler.blockBreakParticlesTool)
world.playEvent(2001, pos, Block.getStateId(state));
}
}
代码示例来源:origin: Vazkii/Botania
@Override
public void onUpdate() {
super.onUpdate();
if(supertile.getWorld().isRemote || redstoneSignal > 0)
return;
if(ticksExisted % 30 == 0 && mana >= COST) {
BlockPos pos = new BlockPos(
supertile.getPos().getX() - RANGE + supertile.getWorld().rand.nextInt(RANGE * 2 + 1),
supertile.getPos().getY() + RANGE,
supertile.getPos().getZ() - RANGE + supertile.getWorld().rand.nextInt(RANGE * 2 + 1)
);
BlockPos up = pos.up();
for(int i = 0; i < RANGE * 2; i++) {
IBlockState stateAbove = supertile.getWorld().getBlockState(up);
Block blockAbove = stateAbove.getBlock();
if((supertile.getWorld().isAirBlock(up) || blockAbove.isReplaceable(supertile.getWorld(), up)) && stateAbove.getMaterial() != Material.WATER && ModBlocks.flower.canPlaceBlockAt(supertile.getWorld(), up)) {
EnumDyeColor color = EnumDyeColor.byMetadata(supertile.getWorld().rand.nextInt(16));
IBlockState state = ModBlocks.flower.getDefaultState().withProperty(BotaniaStateProps.COLOR, color);
if(ConfigHandler.blockBreakParticles)
supertile.getWorld().playEvent(2001, up, Block.getStateId(state));
supertile.getWorld().setBlockState(up, state, 1 | 2);
mana -= COST;
sync();
break;
}
up = pos;
pos = pos.down();
}
}
}
代码示例来源:origin: Vazkii/Botania
@Override
public void onUpdate() {
super.onUpdate();
if (supertile.getWorld().isRemote)
return;
int mana = 1800;
if(getMaxMana() - this.mana >= mana && !supertile.getWorld().isRemote && ticksExisted % 80 == 0) {
for(int i = 0; i < RANGE * 2 + 1; i++)
for(int j = 0; j < RANGE * 2 + 1; j++)
for(int k = 0; k < RANGE * 2 + 1; k++) {
BlockPos pos = supertile.getPos().add(i - RANGE, j - RANGE, k - RANGE);
IBlockState state = supertile.getWorld().getBlockState(pos);
Block block = state.getBlock();
if(block instanceof BlockCake) {
int nextSlicesEaten = state.getValue(BlockCake.BITES) + 1;
if(nextSlicesEaten > 6)
supertile.getWorld().setBlockToAir(pos);
else supertile.getWorld().setBlockState(pos, state.withProperty(BlockCake.BITES, nextSlicesEaten), 1 | 2);
supertile.getWorld().playEvent(2001, pos, Block.getStateId(state));
supertile.getWorld().playSound(null, supertile.getPos(), SoundEvents.ENTITY_GENERIC_EAT, SoundCategory.BLOCKS, 1F, 0.5F + (float) Math.random() * 0.5F);
this.mana += mana;
sync();
return;
}
}
}
}
代码示例来源:origin: Vazkii/Botania
@Override
public void onUpdate() {
super.onUpdate();
if(!supertile.getWorld().isRemote && ticksExisted % 5 == 0) {
if(mana >= COST) {
BlockPos coords = getCoordsToPut();
if(coords != null) {
supertile.getWorld().setBlockToAir(coords);
if(ConfigHandler.blockBreakParticles)
supertile.getWorld().playEvent(2001, coords, Block.getStateId(Blocks.SAND.getDefaultState()));
EntityItem item = new EntityItem(supertile.getWorld(), coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5, new ItemStack(Items.CLAY_BALL));
supertile.getWorld().spawnEntity(item);
mana -= COST;
}
}
}
}
代码示例来源:origin: Vazkii/Botania
@Override
public void onUpdate() {
super.onUpdate();
if(supertile.getWorld().isRemote || redstoneSignal > 0 || !canOperate())
return;
int cost = getCost();
if(mana >= cost && ticksExisted % getDelay() == 0) {
BlockPos coords = getCoordsToPut();
if(coords != null) {
ItemStack stack = getOreToPut();
if(!stack.isEmpty()) {
Block block = Block.getBlockFromItem(stack.getItem());
int meta = stack.getItemDamage();
supertile.getWorld().setBlockState(coords, block.getStateFromMeta(meta), 1 | 2);
if(ConfigHandler.blockBreakParticles)
supertile.getWorld().playEvent(2001, coords, Block.getIdFromBlock(block) + (meta << 12));
supertile.getWorld().playSound(null, supertile.getPos(), ModSounds.orechid, SoundCategory.BLOCKS, 2F, 1F);
mana -= cost;
sync();
}
}
}
}
代码示例来源:origin: Vazkii/Botania
@SubscribeEvent
public static void onMinecartUpdate(MinecartUpdateEvent event) {
BlockPos entPos = new BlockPos(event.getEntity());
IBlockState state = event.getEntity().world.getBlockState(entPos);
Block block = state.getBlock();
boolean air = block.isAir(state, event.getEntity().world, entPos);
int floatTicks = event.getEntity().getEntityData().getInteger(TAG_FLOAT_TICKS);
if(block == ModBlocks.ghostRail)
event.getEntity().getEntityData().setInteger(TAG_FLOAT_TICKS, 20);
else if(block instanceof BlockRailBase || block == ModBlocks.dreamwood) {
event.getEntity().getEntityData().setInteger(TAG_FLOAT_TICKS, 0);
if(floatTicks > 0)
event.getEntity().world.playEvent(2003, entPos, 0);
}
floatTicks = event.getEntity().getEntityData().getInteger(TAG_FLOAT_TICKS);
if(floatTicks > 0) {
IBlockState stateBelow = event.getEntity().world.getBlockState(entPos.down());
Block blockBelow = stateBelow.getBlock();
boolean airBelow = blockBelow.isAir(stateBelow, event.getEntity().world, entPos.down());
if(air && airBelow || !air && !airBelow)
event.getEntity().noClip = true;
event.getEntity().motionY = 0.2;
event.getEntity().motionX *= 1.4;
event.getEntity().motionZ *= 1.4;
event.getEntity().getEntityData().setInteger(TAG_FLOAT_TICKS, floatTicks - 1);
event.getEntity().world.playEvent(2000, entPos, 0);
} else event.getEntity().noClip = false;
}
内容来源于网络,如有侵权,请联系作者删除!