net.minecraftforge.fml.common.eventhandler.SubscribeEvent Java Examples

The following examples show how to use net.minecraftforge.fml.common.eventhandler.SubscribeEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlockyEntities.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@SubscribeEvent
public static void onCollision(GetCollisionBoxesEvent e) {
	if (e.getEntity() != null) {
		for (BaseVehicleEntity bsv : e.getWorld().getEntitiesWithinAABB(BaseVehicleEntity.class,
				e.getAabb().grow(16))) {
			if (bsv != e.getEntity()) {
				for (BlockPos bp : bsv.getBlocks().keySet()) {
					if (bp != null) {
						bsv.getBlocks().get(bp).blockstate.addCollisionBoxToList(bsv.getStorage(),
								bsv.localBlockPosToGlobal(bp), e.getAabb(), e.getCollisionBoxesList(),
								e.getEntity(), false);
					}
				}
			}
		}
	}
}
 
Example #2
Source File: SquashableMod.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@SubscribeEvent
public static void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
    EntityLivingBase entity = event.getEntityLiving();
    if (entity.world.isRemote) {
        return;
    }

    if (entity.collidedHorizontally && isBeingPushedByPiston(entity)) {
        Squashable squashable = entity.getCapability(squashableCap(), null);
        if (squashable == null) {
            return;
        }

        double[] pistonDeltas = getPistonDeltas(entity);
        double pushedAngle = Math.atan2(pistonDeltas[2], pistonDeltas[0]);

        EnumFacing.Axis faceAxis = EnumFacing.fromAngle(entity.rotationYaw).getAxis();
        EnumFacing.Axis pushAxis = EnumFacing.fromAngle(pushedAngle).getAxis();

        EnumFacing.Axis squashAxis = faceAxis == pushAxis ? EnumFacing.Axis.Z : EnumFacing.Axis.X;

        squashable.squash(squashAxis);

        NETWORK.sendToAllTracking(new SquashEntityMessage(entity, squashAxis), entity);
    }
}
 
Example #3
Source File: CommunityMod.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onItemTooltip(ItemTooltipEvent event)
{
    ItemStack stack = event.getItemStack();

    if (!stack.isEmpty() && CommunityGlobals.MOD_ID.equals(stack.getItem().getRegistryName().getNamespace()))
    {
        SubModContainer subMod = SubModLoader.getSubModOrigin(stack.getItem());

        if (subMod != null)
        {
            event.getToolTip().add(TextFormatting.DARK_GRAY + "(" + subMod.getName() + " - " + subMod.getAttribution() + ")");
        }
    }
}
 
Example #4
Source File: Scheduler.java    From SkyblockAddons with MIT License 6 votes vote down vote up
@SubscribeEvent()
public void ticker(TickEvent.ClientTickEvent e) {
    if (e.phase == TickEvent.Phase.START) {
        totalTicks++;
        Set<Command> commands = queue.get(totalTicks);
        if (commands != null) {
            for (Command command : commands) {
                for (int times = 0; times < command.getCount().getValue(); times++) {
                    command.getCommandType().execute(command, times+1);
                }
            }
            queue.remove(totalTicks);
        }
        if (totalTicks % 12000 == 0 || delayingMagmaCall) { // check magma boss every 15 minutes
            if (main.getPlayerListener().getMagmaAccuracy() != EnumUtils.MagmaTimerAccuracy.EXACTLY) {
                if (main.getUtils().isOnSkyblock()) {
                    delayingMagmaCall = false;
                    main.getUtils().fetchMagmaBossEstimate();
                } else if (!delayingMagmaCall) {
                    delayingMagmaCall = true;
                }
            }
        }
        ChromaManager.increment(); // Run every tick
    }
}
 
Example #5
Source File: RenderListener.java    From SkyblockAddons with MIT License 6 votes vote down vote up
@SubscribeEvent()
public void onRenderLiving(RenderLivingEvent.Specials.Pre<EntityLivingBase> e) {
    Entity entity = e.entity;
    if (main.getConfigValues().isEnabled(Feature.MINION_DISABLE_LOCATION_WARNING) && entity.hasCustomName()) {
        if (entity.getCustomNameTag().startsWith("§cThis location isn\'t perfect! :(")) {
            e.setCanceled(true);
        }
        if (entity.getCustomNameTag().startsWith("§c/!\\")) {
            for (Entity listEntity : Minecraft.getMinecraft().theWorld.loadedEntityList) {
                if (listEntity.hasCustomName() && listEntity.getCustomNameTag().startsWith("§cThis location isn\'t perfect! :(") &&
                        listEntity.posX == entity.posX && listEntity.posZ == entity.posZ &&
                        listEntity.posY + 0.375 == entity.posY) {
                    e.setCanceled(true);
                    break;
                }
            }
        }
    }
}
 
Example #6
Source File: PlayerListener.java    From SkyblockAddons with MIT License 6 votes vote down vote up
/**
 * Block emptying of buckets separately because they aren't handled like blocks.
 * The event name {@code FillBucketEvent} is misleading. The event is fired when buckets are emptied also so
 * it should really be called {@code BucketEvent}.
 *
 * @param bucketEvent the event
 */
@SubscribeEvent
public void onBucketEvent(FillBucketEvent bucketEvent) {
    ItemStack bucket = bucketEvent.current;
    EntityPlayer player = bucketEvent.entityPlayer;

    if (main.getUtils().isOnSkyblock() && player instanceof EntityPlayerSP) {
        if (main.getConfigValues().isEnabled(Feature.AVOID_PLACING_ENCHANTED_ITEMS)) {
            String skyblockItemId = ItemUtils.getSkyBlockItemID(bucket);

            if (skyblockItemId != null && skyblockItemId.equals("ENCHANTED_LAVA_BUCKET")) {
                bucketEvent.setCanceled(true);
            }
        }
    }
}
 
Example #7
Source File: PlayerListener.java    From SkyblockAddons with MIT License 6 votes vote down vote up
/**
 * Reset all the timers and stuff when joining a new world.
 */
@SubscribeEvent()
public void onWorldJoin(EntityJoinWorldEvent e) {
    if (e.entity == Minecraft.getMinecraft().thePlayer) {
        lastWorldJoin = System.currentTimeMillis();
        lastBoss = -1;
        magmaTick = 1;
        timerTick = 1;
        main.getInventoryUtils().resetPreviousInventory();
        recentlyLoadedChunks.clear();
        countedEndermen.clear();
        EndstoneProtectorManager.reset();

        IslandWarpGui.Marker doubleWarpMarker = IslandWarpGui.getDoubleWarpMarker();
        if (doubleWarpMarker != null) {
            IslandWarpGui.setDoubleWarpMarker(null);
            Minecraft.getMinecraft().thePlayer.sendChatMessage("/warp "+doubleWarpMarker.getWarpName());
        }
    }
}
 
Example #8
Source File: CommonProxy.java    From TofuCraftReload with MIT License 6 votes vote down vote up
@SubscribeEvent
   public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
	//boildEdamame
	GameRegistry.addSmelting( new ItemStack(ItemLoader.material,1,3), new ItemStack(ItemLoader.foodset,16,22), 0.25f);
	//SoyBeenParched
	GameRegistry.addSmelting( new ItemStack(ItemLoader.soybeans,1), new ItemStack(ItemLoader.material,1,6), 0.2f);

	GameRegistry.addSmelting( new ItemStack(ItemLoader.material,1,13), new ItemStack(ItemLoader.material,1,14), 0.2f);
	
	RecipesUtil.addOreDictionarySmelting("listAlltofu", new ItemStack(ItemLoader.tofu_food,1,3), 0.2f);
	
	GameRegistry.addSmelting(new ItemStack(ItemLoader.tofu_food,1,2), new ItemStack(ItemLoader.foodset,1,16), 0.2f);
	GameRegistry.addSmelting(new ItemStack(ItemLoader.material,1,20), new ItemStack(ItemLoader.foodset,1,8), 0.2f);
	GameRegistry.addSmelting(new ItemStack(ItemLoader.foodset,1,11), new ItemStack(ItemLoader.foodset,1,12), 0.2f);
	
	RecipesUtil.addOreDictionarySmelting("listAlltofuBlock", new ItemStack(BlockLoader.GRILD), 0.6f);
}
 
Example #9
Source File: GnuLinux.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent()
public static void onClientChat(ClientChatEvent e) {
    String msg = e.getMessage();

    if (linuxPatern.matcher(msg).find()) {
        Minecraft.getMinecraft().player.playSound(GNU_LINUX, 10f, 1f);
        e.setMessage(linuxPatern.matcher(e.getMessage()).replaceAll("GNU/Linux"));
    }
}
 
Example #10
Source File: WillsAssortedThingsEventHandler.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public static void onPlayerRightClick(PlayerInteractEvent.EntityInteract event) {
    EntityPlayer player = event.getEntityPlayer();
    if (event.getEntityPlayer().getHeldItemMainhand().getItem() == Items.ARROW) {
        if (event.getTarget() instanceof EntityChicken) {
            event.getWorld().playSound(player.posX, player.posY, player.posZ, SoundEvents.ENTITY_CHICKEN_HURT, SoundCategory.VOICE, 2.0f, 1.3f, false);
            player.getHeldItemMainhand().setCount(player.getHeldItemMainhand().getCount()-1);
            player.inventory.addItemStackToInventory(new ItemStack(ModItems.CHICKEN_ARROW));
        }
    }
}
 
Example #11
Source File: WorldTickHandler.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@SubscribeEvent
public void tickEnd(TickEvent.WorldTickEvent event) {
    if (event.side != Side.SERVER) {
        return;
    }

    if (event.phase == TickEvent.Phase.END) {

        World world = event.world;
        int dim = world.provider.getDimension();

        ArrayDeque<ChunkPos> chunks = chunksToGen.get(dim);

        if (chunks != null && !chunks.isEmpty()) {
            ChunkPos c = chunks.pollFirst();
            long worldSeed = world.getSeed();
            Random rand = new Random(worldSeed);
            long xSeed = rand.nextLong() >> 2 + 1L;
            long zSeed = rand.nextLong() >> 2 + 1L;
            rand.setSeed(xSeed * c.x + zSeed * c.z ^ worldSeed);
            OreGenerator.instance.generateWorld(rand, c.x, c.z, world, false);
            chunksToGen.put(dim, chunks);
        } else if (chunks != null) {
            chunksToGen.remove(dim);
        }
    }
}
 
Example #12
Source File: TraverseWorld.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public static void replaceVillageBlocks(BiomeEvent.GetVillageBlockID event) {
    if (villageReplacementBiomes.keySet().contains(event.getBiome())) {
        event.setReplacement(villageReplacementBiomes.get(event.getBiome()).getBiomeSpecificState(event.getOriginal()));
        event.setResult(Event.Result.DENY);
    }
}
 
Example #13
Source File: TraverseWorld.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public static void registerBiomes(RegistryEvent.Register<Biome> event) {
    register(V0, autumnalWoodsBiome, BiomeType.COOL, "autumnal_woods", 8, TraverseConfig.disableAutumnalWoods, true, event, FOREST);
    register(V0, woodlandsBiome, BiomeType.WARM, "woodlands", 9, TraverseConfig.disableWoodlands, true, NO_REPLACEMENTS, event, PLAINS);
    register(V0, miniJungleBiome, BiomeType.WARM, "mini_jungle", 3, TraverseConfig.disableMiniJungle, true, event, DENSE, JUNGLE, HOT, WET);
    register(V0, meadowBiome, BiomeType.COOL, "meadow", 7, TraverseConfig.disableMeadow, true, NO_REPLACEMENTS, event, PLAINS, LUSH, WET);
    register(V0, lushSwampBiome, BiomeType.WARM, "green_swamp", 6, TraverseConfig.disableLushSwamp, false, event, LUSH, WET, SWAMP);
    register(V0, redDesertBiome, BiomeType.DESERT, "red_desert", 6, TraverseConfig.disableRedDesert, false, RED_DESERT_REPLACEMENTS, event, HOT, DRY, SANDY);
    register(V0, temperateRainforestBiome, BiomeType.COOL, "temperate_rainforest", 8, TraverseConfig.disableTemperateRainforest, true, event, FOREST, CONIFEROUS);
    register(V1, badlandsBiome, BiomeType.WARM, "badlands", 5, TraverseConfig.disableBadlands, false, NO_REPLACEMENTS, event, PLAINS, DRY, HOT, SPARSE);
    register(V1, mountainousDesertBiome, BiomeType.DESERT, "mountainous_desert", 2, TraverseConfig.disableMountainousDesert, false, event, MOUNTAIN, DRY, HOT, SANDY);
    register(V1, rockyPlateauBiome, BiomeType.WARM, "rocky_plateau", 4, TraverseConfig.disableRockyPlateau, false, NO_REPLACEMENTS, event, HOT, MOUNTAIN);
    register(V1, forestedHillsBiome, BiomeType.COOL, "forested_hills", 6, TraverseConfig.disableForestedHills, true, event, FOREST, HILLS);
    register(V1, birchForestedHillsBiome, BiomeType.COOL, "birch_forested_hills", 2, TraverseConfig.disableBirchForestedHills, true, event, FOREST, HILLS);
    register(V1, autumnalWoodedHillsBiome, BiomeType.COOL, "autumnal_wooded_hills", 1, TraverseConfig.disableAutumnalWoodedHills, true, event, FOREST, HILLS);
    register(V2, cliffsBiome, BiomeType.COOL, "cliffs", 2, TraverseConfig.disableCliffs, false, event, MOUNTAIN, COLD, HILLS);
    register(V2, glacierBiome, BiomeType.ICY, "glacier", 6, TraverseConfig.disableGlacier, false, event, MOUNTAIN, COLD, SNOWY);
    register(V2, glacierSpikesBiome, BiomeType.ICY, "glacier_spikes", 2, TraverseConfig.disableGlacierSpikes, false, event, MOUNTAIN, COLD, SNOWY);
    register(V2, snowyConiferousForestBiome, BiomeType.ICY, "snowy_coniferous_forest", 5, TraverseConfig.disableSnowyConiferousForest, true, event, COLD, SNOWY, FOREST, CONIFEROUS);
    register(V3, lushHillsBiome, BiomeType.COOL, "lush_hills", 6, TraverseConfig.disableLushHills, true, NO_REPLACEMENTS, event, LUSH, HILLS, SPARSE, WET);
    register(V3, canyonBiome, BiomeType.DESERT, "canyon", 5, TraverseConfig.disableCanyon, false, event, DRY, DEAD);
    register(V3, cragCliffsBiome, BiomeType.COOL, "crag_cliffs", 4, TraverseConfig.disableCragCliffs, false, event, COLD, DEAD);
    register(V4, desertShrublandBiome, BiomeType.DESERT, "desert_shrubland", 5, TraverseConfig.disableDesertShrubland, false, DESERT_REPLACEMENTS, event, HOT, DRY, SANDY, DEAD);
    register(V5, thicketBiome, BiomeType.WARM, "thicket", 6, TraverseConfig.disableThicket, true, event, DENSE, FOREST);
    register(V5, aridHighlandBiome, BiomeType.DESERT, "arid_highland", 4, TraverseConfig.disableAridHighland, false, DESERT_REPLACEMENTS, event, HOT, DRY, SPARSE, MOUNTAIN, HILLS);
    register(V5, rockyPlainsBiome, BiomeType.COOL, "rocky_plains", 4, TraverseConfig.disableRockyPlains, true, NO_REPLACEMENTS, event, PLAINS, HILLS, SPARSE);
}
 
Example #14
Source File: SexyFont.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void frame(TickEvent.RenderTickEvent e) {
	if(e.phase == TickEvent.Phase.START) {
		Minecraft mc = Minecraft.getMinecraft();
		if(mc.player == null) {
			SexyFont.sexyTime = false;
		} else {
			Item head = mc.player.inventory.armorItemInSlot(EntityEquipmentSlot.HEAD.getIndex()).getItem();
			SexyFont.sexyTime = head == SexyFont.Items.SEXY_GLASSES;
		}
	}
}
 
Example #15
Source File: SquashableMod.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void onRenderLivingPost(RenderLivingEvent.Post<?> event) {
    if (originalModel != null) {
        ModelHooks.setMainModel(event.getRenderer(), originalModel);
        originalModel = null;
    }
}
 
Example #16
Source File: NeatNether.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public static void onCropGrow(BlockEvent.CropGrowEvent.Post event)
{
	if(event.getWorld().provider.getDimension() == -1 && event.getState().getBlock() == Blocks.NETHER_WART)
	{
		int age =  event.getState().getValue(BlockNetherWart.AGE);
		if(age < 3 && event.getWorld().rand.nextBoolean())
		{
			event.getWorld().setBlockState(event.getPos(), event.getState().withProperty(BlockNetherWart.AGE, age + 1));
		}

	}
}
 
Example #17
Source File: SakuraEventLoader.java    From Sakura_mod with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
   @SubscribeEvent
public static void KeyInput(InputEvent.KeyInputEvent event) {
	if(ClientProxy.ChangeMode.isPressed()){
		ClientProxy.getNetwork().sendToServer(new PacketKeyMessage(SakuraMain.MODID));
	 }
}
 
Example #18
Source File: PotionFire.java    From Sakura_mod with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onAttacking(AttackEntityEvent event) {
	if(event.getTarget() instanceof EntityLivingBase){
		EntityLivingBase target = (EntityLivingBase) event.getTarget();
		EntityPlayer player = event.getEntityPlayer();
		if(player.isPotionActive(this)){
			target.setFire(600);
		}
	}
}
 
Example #19
Source File: PotionExp.java    From Sakura_mod with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onDropExp(LivingExperienceDropEvent event) {
	if(event.getAttackingPlayer()!=null){
		EntityPlayer player = event.getAttackingPlayer();
		if(player.isPotionActive(this)){
			int exp =(event.getOriginalExperience()/2)*player.getActivePotionEffect(this).getAmplifier();
			event.setDroppedExperience(event.getOriginalExperience()+exp);
		}
	}
}
 
Example #20
Source File: WhatAreThose.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public static void onEquipEvent(TickEvent.PlayerTickEvent event) {
    if (rand.nextInt(1000) < 1) {
        EntityPlayer player = event.player;
        BlockPos pos = new BlockPos(player.posX, player.posY, player.posZ);
        IBlockState state = player.world.getBlockState(pos.add(0, -1, 0));
        if (player.onGround) {
            for (ItemStack stack : player.inventory.armorInventory) {
                if (stack.getItem() instanceof ItemArmor && ((ItemArmor) stack.getItem()).getEquipmentSlot() == EntityEquipmentSlot.FEET && state == Blocks.DIAMOND_BLOCK) {
                    player.sendMessage(new TextComponentString("What are THOOOOOSE!?"));
                }
            }
        }
    }
}
 
Example #21
Source File: SubmodGnomes.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public static void registerSounds(RegistryEvent.Register<SoundEvent> event)
{
	IForgeRegistry<SoundEvent> registry = event.getRegistry();
	
	GNOME_SPEAK = registerSoundEvent(registry, "mob.gnome.say");
	GNOME_DEATH = registerSoundEvent(registry, "mob.gnome.death");
}
 
Example #22
Source File: SakuraEventLoader.java    From Sakura_mod with MIT License 5 votes vote down vote up
@SubscribeEvent
   public static void onFuelRegister(FurnaceFuelBurnTimeEvent event) {
   	if(ItemStack.areItemsEqual(event.getItemStack(), new ItemStack(BlockLoader.BAMBOO)))
   		event.setBurnTime(400);
   	if(ItemStack.areItemsEqual(event.getItemStack(), new ItemStack(ItemLoader.MATERIAL, 1,51)))
   		event.setBurnTime(1600);
   	if(ItemStack.areItemsEqual(event.getItemStack(), new ItemStack(BlockLoader.BAMBOO_CHARCOAL_BLOCK)))
   		event.setBurnTime(8000);
}
 
Example #23
Source File: WorldGenLoader.java    From Sakura_mod with MIT License 5 votes vote down vote up
@SubscribeEvent
   public void HotSpringGen(Decorate event) {
   	if(Loader.isModLoaded("tfc"))
   		return;
   	BlockPos pos = event.getChunkPos().getBlock(event.getRand().nextInt(16) + 8, 0, event.getRand().nextInt(16) + 8);
   	BlockPos newPos = WorldUtil.findGround(event.getWorld(),pos, true, false, true);
   	Biome biome = event.getWorld().getBiome(pos);
       
   	if (newPos != null&&event.getWorld().provider instanceof WorldProviderSurface&&biome != Biomes.DESERT && biome != Biomes.DESERT_HILLS && event.getRand().nextFloat() < SakuraConfig.hotspring_weight / 10000.0F) {
           new WorldGenHotSpring().generate(event.getWorld(), event.getRand(), newPos);
       }
}
 
Example #24
Source File: WorldGenLoader.java    From Sakura_mod with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onOreGen(OreGenEvent.Post event) {
	World worldIn = event.getWorld();
       int genY = 10 + event.getRand().nextInt(24);
	if (SakuraConfig.every_where_sakura_diamond||(worldIn.getBiome(new BlockPos(event.getPos().getX(), 0, event.getPos().getZ())) == SakuraBiomes.BAMBOOFOREST ||
		worldIn.getBiome(new BlockPos(event.getPos().getX(), 0, event.getPos().getZ())) == SakuraBiomes.MAPLEFOREST)) {
		BlockPos pos=new BlockPos(event.getPos().getX(),genY, event.getPos().getZ());
               for (int i = 0; i < 2; i++) {
                   new WorldGenMinable(BlockLoader.SAKURA_DIAMOND_ORE.getDefaultState(),3 + event.getRand().nextInt(5)).generate(worldIn, event.getRand(), pos);
               }
       }
}
 
Example #25
Source File: ModTest.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public static void onDrawScreen(GuiScreenEvent.DrawScreenEvent e)
{
    if (isLoaded && e.getGui() instanceof GuiModList)
    {
        e.getGui().drawString(e.getGui().mc.fontRenderer, "ExampleMod loaded! Neat, eh?", e.getMouseX(), e.getMouseY(), -1);
    }
}
 
Example #26
Source File: InfinitePain.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public static void onLanding(LivingFallEvent event) {
	EntityLivingBase elb = event.getEntityLiving();
	if(elb.hasItemInSlot(EntityEquipmentSlot.FEET) && elb.getItemStackFromSlot(EntityEquipmentSlot.FEET).getItem() == PAIN_BOOTS) {
		if(event.getDistance() >= minTriggerHeight) {

			boolean notObstructed = true;
			double impactPosition = 0;

			for(int i = (int) elb.posY + 2; i < elb.world.provider.getHeight(); i++) {
				BlockPos pos = new BlockPos(elb.posX, i, elb.posZ);
				IBlockState state = elb.world.getBlockState(pos);
				if(state.isFullBlock() || state.isFullCube()) {
					notObstructed = false;
					impactPosition = i;
					break;
				}
			}


			if(notObstructed) {
				elb.setPositionAndUpdate(elb.posX, elb.world.provider.getHeight() + heightToAdd, elb.posZ);
				event.setDamageMultiplier(0);
			} else {
				elb.addVelocity(0, (impactPosition - elb.posY) / 2, 0);
				elb.attackEntityFrom(DamageSource.GENERIC, damageOnImpact);
				event.setDamageMultiplier(0);
			}
		}
	}
}
 
Example #27
Source File: TofuEventLoader.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@SubscribeEvent
  public void decorateBiome(DecorateBiomeEvent.Post event)
  {
      World worldObj = event.getWorld();
      Random rand = event.getRand();
      @SuppressWarnings("deprecation")
BlockPos pos = event.getPos();
      // Hellsoybeans
      if (rand.nextInt(600) < Math.min((Math.abs(pos.getX()) + Math.abs(pos.getZ())) / 2, 400) - 100)
      {
          if (Biome.getIdForBiome(worldObj.getBiome(pos)) == Biome.getIdForBiome(Biomes.HELL))
          {
              int k = pos.getX();
              int l = pos.getZ();
              BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos();
              
              for (int i = 0; i < 10; ++i)
              {
                  int j1 = k + rand.nextInt(16) + 8;
                  int k1 = rand.nextInt(128);
                  int l1 = l + rand.nextInt(16) + 8;
                  mutable.setPos(j1, k1, l1);
                  
                  (new WorldGenCrops((BlockBush)BlockLoader.SOYBEAN_NETHER)
                  		{ 
                  			@Override
						protected IBlockState getStateToPlace() {
                  				return this.plantBlock.getDefaultState().withProperty(BlockSoybeanNether.AGE, 7);
                  			}
                  		})
                  		.generate(worldObj, rand, mutable);           
              }
          }
      }
  }
 
Example #28
Source File: ModGenuinePeoplePersonalities.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void onFarmlandTrample(BlockEvent.FarmlandTrampleEvent event) {
    EventData data = new EventData(event);
    if (data.getPlayer() == null || data.getPlayer().world.isRemote) return;
    if (!testCooldown(data.getPlayer())) return;
    if (generateComplaint(StringType.TRAMPLE, data.getPlayer(), data.getBlock(), data)) {
        resetCooldown(data.getPlayer());
    }
}
 
Example #29
Source File: SquashableMod.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public static void onEntityTrack(PlayerEvent.StartTracking event) {
    Entity target = event.getTarget();
    Squashable squashable = target.getCapability(squashableCap(), null);
    if (squashable == null) {
        return;
    }

    EnumFacing.Axis squashedAxis = squashable.getSquashedAxis();
    if (squashedAxis != null) {
        NETWORK.sendTo(new SquashEntityMessage(target, squashedAxis), (EntityPlayerMP) event.getEntityPlayer());
    }
}
 
Example #30
Source File: ElectricBoogaloo.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public static void itemToolTipEvent(ItemTooltipEvent event) {
    if (twosList == null || twosList.length < 1 || event.getToolTip().isEmpty())
        return;
    boolean isPotion = event.getItemStack().getItem() instanceof ItemPotion || event.getItemStack().getItem() instanceof ItemArrow;

    for (int i = 0; i < event.getToolTip().size(); i++) {
        String toolTip = event.getToolTip().get(i);
        String lowerTip = toolTip.toLowerCase();
        boolean relocateReset = false;
        if (lowerTip.endsWith("§r")) {
            lowerTip = lowerTip.substring(0, lowerTip.length() - 2);
            toolTip = toolTip.substring(0, toolTip.length() - 2);
            relocateReset = true;
        }
        for (String to : twosList) {
            String boogaloo = null;
            if (isPotion && TIMER_PATTERN.matcher(lowerTip).find()) {
                String potionName = lowerTip.substring(0, lowerTip.indexOf('(') - 1);
                if (potionName.endsWith(to)) {
                    int index = toolTip.indexOf('(') - 1;
                    String beforeTimer = toolTip.substring(0, index);
                    String timer = toolTip.substring(index);
                    boogaloo = I18n.format("tooltip.community_mod.electric", beforeTimer) + timer;
                }
            }
            if (lowerTip.endsWith(to)) {
                boogaloo = I18n.format("tooltip.community_mod.electric", toolTip);
                if (relocateReset)
                    boogaloo += "§r";
            }
            if (!Strings.isNullOrEmpty(boogaloo))
                event.getToolTip().set(i, boogaloo);
        }
    }
}