本文整理汇总了Java中net.minecraftforge.event.world.ExplosionEvent类的典型用法代码示例。如果您正苦于以下问题:Java ExplosionEvent类的具体用法?Java ExplosionEvent怎么用?Java ExplosionEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExplosionEvent类属于net.minecraftforge.event.world包,在下文中一共展示了ExplosionEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDetonate
import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void onDetonate(ExplosionEvent.Detonate event) {
World world = event.world;
if (world.isRemote) {
return;
}
ProtectedBlocks protectedBlocks = ProtectedBlocks.getProtectedBlocks(world);
if (!protectedBlocks.hasProtections()) {
return;
}
List<BlockPos> affectedBlocks = event.getAffectedBlocks();
int i = 0;
while (i < affectedBlocks.size()) {
BlockPos block = affectedBlocks.get(i);
if (protectedBlocks.isProtected(world, block)) {
affectedBlocks.remove(i);
} else {
i++;
}
}
}
示例2: onBlockChange
import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@Listener
public void onBlockChange(ChangeBlockEvent event) {
// Depends on SpongeForge#550
if (event instanceof ExplosionEvent.Detonate) {
return;
}
Optional<PluginContainer> optPluginContainer = event.getCause().first(PluginContainer.class);
if (optPluginContainer.isPresent()) {
return;
}
for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
if (manager.getApplicableZone(transaction.getOriginal().getLocation().get()).isPresent()) {
event.setCancelled(true);
break;
}
}
}
示例3: onDetonate
import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void onDetonate(ExplosionEvent.Detonate event) {
World world = event.world;
if (world.isRemote) {
return;
}
ProtectedBlocks protectedBlocks = ProtectedBlocks.getProtectedBlocks(world);
if (!protectedBlocks.hasProtections()) {
return;
}
List<ChunkPosition> affectedBlocks = event.getAffectedBlocks();
int i = 0;
while (i < affectedBlocks.size()) {
ChunkPosition block = affectedBlocks.get(i);
if (protectedBlocks.isProtected(world, block.chunkPosX, block.chunkPosY, block.chunkPosZ)) {
affectedBlocks.remove(i);
} else {
i++;
}
}
}
示例4: onExplode
import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void onExplode(ExplosionEvent.Detonate event) {
List<Block> affectedBlocks = Arrays.asList(Blocks.GRASS, Blocks.SANDSTONE, Blocks.STONE, Blocks.SAND, Blocks.DIRT, Blocks.COBBLESTONE, Blocks.GRAVEL);
if (!event.getWorld().isRemote) {
Explosion explosion = event.getExplosion();
AxisAlignedBB axisAlignedBB = new AxisAlignedBB(explosion.getPosition().xCoord - 3, explosion.getPosition().yCoord - 3, explosion.getPosition().zCoord - 3, explosion.getPosition().xCoord + 3, explosion.getPosition().yCoord + 3, explosion.getPosition().zCoord + 3);
List<EntityPlayer> players = event.getWorld().getEntitiesWithinAABB(EntityPlayer.class, axisAlignedBB);
for (EntityPlayer player : players) {
if (getBaubleFromInv(ItemExplosionRing.class, player) != null) {
Iterator<BlockPos> iterator = explosion.getAffectedBlockPositions().iterator();
while (iterator.hasNext()) {
BlockPos position = iterator.next();
Block block = event.getWorld().getBlockState(position).getBlock();
if (!affectedBlocks.contains(block) && block != Blocks.AIR) {
iterator.remove();
}
}
}
}
}
}
示例5: explosionEventStart
import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void explosionEventStart(ExplosionEvent.Start event) {
World world = event.getWorld();
Random random = new Random();
BlockPos explosionPosition = new BlockPos(event.getExplosion().getPosition());
for (int dz = -detectionRadius; dz <= detectionRadius; dz++) {
for (int dx = -detectionRadius; dx <= detectionRadius; dx++) {
for (int dy = -detectionRadius; dy <= detectionRadius; dy++) {
BlockPos pos = explosionPosition.add(dx, dy, dz);
if (world.getBlockState(pos).getBlock() == Blocks.BEDROCK && random.nextDouble() < 0.2d) {
EnumFacing face = EnumFacing.getFacingFromVector(-dx, -dy, -dz);
if (world.getBlockState(pos.add(face.getDirectionVec())).getMaterial() == Material.AIR) {
PlayerInteractEventHandler.SendPacket(pos, face, event.getWorld().provider.getDimension());
}
}
}
}
}
}
示例6: onExplosion
import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
/**
* Forge 1254 is needed for this
*/
@SubscribeEvent
public void onExplosion(ExplosionEvent.Start ev) {
if(ev.world.isRemote)
return;
if (ev.isCanceled())
return;
List<ChunkPos> chunks = WorldUtils.getChunksInBox(ev.world.provider.dimensionId, (int) (ev.explosion.explosionX - ev.explosion.explosionSize - 2), (int) (ev.explosion.explosionZ - ev.explosion.explosionSize - 2), (int) (ev.explosion.explosionX + ev.explosion.explosionSize + 2), (int) (ev.explosion.explosionZ + ev.explosion.explosionSize + 2));
for(ChunkPos chunk : chunks) {
TownBlock block = MyTownUniverse.instance.blocks.get(ev.world.provider.dimensionId, chunk.getX(), chunk.getZ());
if(block == null) {
if(!(Boolean)Wild.instance.flagsContainer.getValue(FlagType.EXPLOSIONS)) {
ev.setCanceled(true);
return;
}
} else {
if (!(Boolean) block.getTown().flagsContainer.getValue(FlagType.EXPLOSIONS)) {
ev.setCanceled(true);
block.getTown().notifyEveryone(MyTown.instance.LOCAL.getLocalization(FlagType.EXPLOSIONS.getTownNotificationKey()));
return;
}
}
}
}
示例7: handleIronExplosions
import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void handleIronExplosions(ExplosionEvent.Detonate event){
Iterator<Entity> iterator = event.getAffectedEntities().iterator();
while(iterator.hasNext()) {
Entity entity = iterator.next();
if(entity instanceof EntityItem) {
ItemStack stack = ((EntityItem)entity).getEntityItem();
if(stack != null && !entity.isDead && PneumaticCraftUtils.isSameOreDictStack(stack, IRON_INGOT) || PneumaticCraftUtils.isSameOreDictStack(stack, IRON_BLOCK)) {
Random rand = new Random();
if(stack.stackSize >= 3 || rand.nextDouble() >= Config.configCompressedIngotLossRate / 100D) {
Item newItem = PneumaticCraftUtils.isSameOreDictStack(stack, IRON_INGOT) ? Itemss.ingotIronCompressed : Item.getItemFromBlock(Blockss.compressedIron);
ItemStack newStack = new ItemStack(newItem, stack.stackSize, stack.getItemDamage());
if(stack.stackSize >= 3) {
newStack.stackSize = (int)(stack.stackSize * (rand.nextDouble() * Math.min(Config.configCompressedIngotLossRate * 0.02D, 0.2D) + (Math.max(0.9D, 1D - Config.configCompressedIngotLossRate * 0.01D) - Config.configCompressedIngotLossRate * 0.01D)));
}
((EntityItem)entity).setEntityItemStack(newStack);
iterator.remove();
for(EntityPlayer player : (List<EntityPlayer>)event.world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(event.explosion.explosionX - 32, event.explosion.explosionY - 32, event.explosion.explosionZ - 32, event.explosion.explosionX + 32, event.explosion.explosionY + 32, event.explosion.explosionZ + 32))) {
AchievementHandler.giveAchievement(player, newStack);
}
}
}
}
}
}
示例8: onExplosionStart
import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void onExplosionStart(ExplosionEvent.Detonate event){
// Make the explosions by the Ice Queen slow the player.
Explosion explosion = event.explosion;
if(explosion.exploder instanceof EntityIceQueen){
EntityIceQueen queen = (EntityIceQueen)explosion.exploder;
List<Entity> entitiesHit = event.getAffectedEntities();
for(Entity entity : entitiesHit){
if(entity instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer)entity;
player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), 300, 2));
player.attackEntityFrom(DamageSource.setExplosionSource(explosion), (float)queen.getEntityAttribute(SharedMonsterAttributes.attackDamage).getBaseValue() / 2);
}
}
}
}
示例9: handleIronExplosions
import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void handleIronExplosions(ExplosionEvent.Detonate event) {
Iterator<Entity> iterator = event.getAffectedEntities().iterator();
while (iterator.hasNext()) {
Entity entity = iterator.next();
if (entity instanceof EntityItem) {
ItemStack stack = ((EntityItem) entity).getItem();
if (!stack.isEmpty() && !entity.isDead && (PneumaticCraftUtils.isSameOreDictStack(stack, IRON_INGOT) || PneumaticCraftUtils.isSameOreDictStack(stack, IRON_BLOCK))) {
Random rand = new Random();
int lossRate = ConfigHandler.general.configCompressedIngotLossRate;
if (stack.getCount() >= 3 || rand.nextDouble() >= lossRate / 100D) {
Item newItem = PneumaticCraftUtils.isSameOreDictStack(stack, IRON_INGOT) ? Itemss.INGOT_IRON_COMPRESSED : Item.getItemFromBlock(Blockss.COMPRESSED_IRON);
ItemStack newStack = new ItemStack(newItem, stack.getCount(), stack.getItemDamage());
if (stack.getCount() >= 3) {
newStack.setCount((int) (stack.getCount() * (rand.nextDouble() * Math.min(lossRate * 0.02D, 0.2D) + (Math.max(0.9D, 1D - lossRate * 0.01D) - lossRate * 0.01D))));
}
((EntityItem) entity).setItem(newStack);
iterator.remove();
if (!event.getWorld().isRemote) {
Vec3d exp = event.getExplosion().getPosition();
for (EntityPlayer player : event.getWorld().getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(exp.x - 32, exp.y - 32, exp.z - 32, exp.x + 32, exp.y + 32, exp.z + 32))) {
AdvancementTriggers.EXPLODE_IRON.trigger((EntityPlayerMP) player);
}
}
}
}
}
}
}
示例10: onExplosionDetonate
import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
public static void onExplosionDetonate(World world, Explosion explosion, List<Entity> list, double diameter)
{
//Filter entities to only those who are effected, to prevent modders from seeing more then will be hurt.
/* Enable this if we get issues with modders looping to much.
Iterator<Entity> itr = list.iterator();
Vec3 p = explosion.getPosition();
while (itr.hasNext())
{
Entity e = itr.next();
double dist = e.getDistance(p.xCoord, p.yCoord, p.zCoord) / diameter;
if (e.isImmuneToExplosions() || dist > 1.0F) itr.remove();
}
*/
MinecraftForge.EVENT_BUS.post(new ExplosionEvent.Detonate(world, explosion, list));
}
示例11: explosionDetonate
import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void explosionDetonate(ExplosionEvent.Detonate event)
{
Iterator<BlockPos> iterator = event.getAffectedBlocks().iterator();
while (iterator.hasNext())
{
BlockPos pos = iterator.next();
if (event.getWorld().getBlockState(pos).getBlock() instanceof IExplosionImmune)
{
iterator.remove();
}
}
}
示例12: onExplosionDetonate
import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
public static void onExplosionDetonate(World world, Explosion explosion, List<Entity> list, double diameter)
{
//Filter entities to only those who are effected, to prevent modders from seeing more then will be hurt.
/* Enable this if we get issues with modders looping to much.
Iterator<Entity> itr = list.iterator();
while (itr.hasNext())
{
Entity e = itr.next();
double dist = e.getDistance(explosion.explosionX, explosion.explosionY, explosion.explosionZ) / diameter;
if (dist > 1.0F) itr.remove();
}
*/
MinecraftForge.EVENT_BUS.post(new ExplosionEvent.Detonate(world, explosion, list));
}
示例13: onImpact
import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@Override
protected void onImpact(RayTraceResult result) {
if (!this.worldObj.isRemote) {
SourceBombExplosion explosion =
new SourceBombExplosion(this.worldObj, this, this.posX, this.posY, this.posZ, 5.0F);
if (!MinecraftForge.EVENT_BUS.post(new ExplosionEvent.Start(this.worldObj, explosion))) {
explosion.doExplosionA();
explosion.doExplosionB(true);
}
this.setDead();
}
}
示例14: onExplosion
import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onExplosion(ExplosionEvent.Detonate evt) {
if(evt.isCanceled()) return;
try {
BlockDropRegistry.registerExplodedBlocks(evt.getAffectedBlocks());
} catch (Exception ex) {
LogHelper.error("Error handling explosion detonation event; please report this along with your config file.", ex);
}
}
示例15: onExplosion
import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void onExplosion(final ExplosionEvent.Detonate event) {
if (!BLOCK_CREEPER_BLOCK_DAMAGE)
return;
if (event.explosion.getExplosivePlacedBy() instanceof EntityCreeper)
// Reset the affected block list
event.explosion.func_180342_d();
}