Jump to content

Event suggestions


syllabus

Recommended Posts

Just a list of possible events that would allow more freedom while making mods

 

- ItemBobbingEvent

    Located in EntityRenderer

 

	private void setupViewBobbing(float par1)
{
	if (this.mc.renderViewEntity instanceof EntityPlayer)
	{
		EntityPlayer entityplayer = (EntityPlayer)this.mc.renderViewEntity;
		float f1 = entityplayer.distanceWalkedModified - entityplayer.prevDistanceWalkedModified;
		float f2 = -(entityplayer.distanceWalkedModified + f1 * par1);
		float f3 = entityplayer.prevCameraYaw + (entityplayer.cameraYaw - entityplayer.prevCameraYaw) * par1;
		float f4 = entityplayer.prevCameraPitch + (entityplayer.cameraPitch - entityplayer.prevCameraPitch) * par1;
		if(!MinecraftForge.EVENT_BUS.post(new ItemBobbingEvent(entityplayer, f1, f2, f3, f4, par1)))
		{
			GL11.glTranslatef(MathHelper.sin(f2 * (float)Math.PI) * f3 * 0.5F, -Math.abs(MathHelper.cos(f2 * (float)Math.PI) * f3), 0.0F);
			GL11.glRotatef(MathHelper.sin(f2 * (float)Math.PI) * f3 * 3.0F, 0.0F, 0.0F, 1.0F);
			GL11.glRotatef(Math.abs(MathHelper.cos(f2 * (float)Math.PI - 0.2F) * f3) * 5.0F, 1.0F, 0.0F, 0.0F);
			GL11.glRotatef(f4, 1.0F, 0.0F, 0.0F);
		}
	}
}

 

would be used for custom item bobbing (such as swords moving more realistically)

 

- OrientCameraEvent

    Located in EntityRenderer

 

	private void orientCamera(float par1)
{
	EntityLivingBase entitylivingbase = this.mc.renderViewEntity;
	float f1 = entitylivingbase.yOffset - 1.62F;
	double d0 = entitylivingbase.prevPosX + (entitylivingbase.posX - entitylivingbase.prevPosX) * (double)par1;
	double d1 = entitylivingbase.prevPosY + (entitylivingbase.posY - entitylivingbase.prevPosY) * (double)par1 - (double)f1;
	double d2 = entitylivingbase.prevPosZ + (entitylivingbase.posZ - entitylivingbase.prevPosZ) * (double)par1;
	GL11.glRotatef(this.prevCamRoll + (this.camRoll - this.prevCamRoll) * par1, 0.0F, 0.0F, 1.0F);

	if (entitylivingbase.isPlayerSleeping())
	{
		f1 = (float)((double)f1 + 1.0D);
		GL11.glTranslatef(0.0F, 0.3F, 0.0F);

		if (!this.mc.gameSettings.debugCamEnable)
		{
			ForgeHooksClient.orientBedCamera(mc, entitylivingbase);
			GL11.glRotatef(entitylivingbase.prevRotationYaw + (entitylivingbase.rotationYaw - entitylivingbase.prevRotationYaw) * par1 + 180.0F, 0.0F, -1.0F, 0.0F);
			GL11.glRotatef(entitylivingbase.prevRotationPitch + (entitylivingbase.rotationPitch - entitylivingbase.prevRotationPitch) * par1, -1.0F, 0.0F, 0.0F);
		}
	}
	else if(MinecraftForge.EVENT_BUS.post(new OrientCameraEvent(entitylivingbase, f1, d0, d1, d2, par1)))
	{
		;
	}
                ...

 

Used for interesting movements in the viewpoint camera (such as combat jolting/landing jolt)

 

- SetupFogEvent / UpdateFogColorEvent

    Located in EntityRenderer

 

private void updateFogColor(float par1)
{
	WorldClient worldclient = this.mc.theWorld;
	EntityLivingBase entitylivingbase = this.mc.renderViewEntity;
	float f1 = 1.0F / (float)(4 - this.mc.gameSettings.renderDistance);
	f1 = 1.0F - (float)Math.pow((double)f1, 0.25D);
	Vec3 vec3 = worldclient.getSkyColor(this.mc.renderViewEntity, par1);
	float f2 = (float)vec3.xCoord;
	float f3 = (float)vec3.yCoord;
	float f4 = (float)vec3.zCoord;
	Vec3 vec31 = worldclient.getFogColor(par1);
	this.fogColorRed = (float)vec31.xCoord;
	this.fogColorGreen = (float)vec31.yCoord;
	this.fogColorBlue = (float)vec31.zCoord;
	float f5;

	if (this.mc.gameSettings.renderDistance < 2)
	{
		Vec3 vec32 = MathHelper.sin(worldclient.getCelestialAngleRadians(par1)) > 0.0F ? worldclient.getWorldVec3Pool().getVecFromPool(-1.0D, 0.0D, 0.0D) : worldclient.getWorldVec3Pool().getVecFromPool(1.0D, 0.0D, 0.0D);
		f5 = (float)entitylivingbase.getLook(par1).dotProduct(vec32);
                        ...
	if (this.mc.gameSettings.anaglyph)
	{
		f9 = (this.fogColorRed * 30.0F + this.fogColorGreen * 59.0F + this.fogColorBlue * 11.0F) / 100.0F;
		f10 = (this.fogColorRed * 30.0F + this.fogColorGreen * 70.0F) / 100.0F;
		float f11 = (this.fogColorRed * 30.0F + this.fogColorBlue * 70.0F) / 100.0F;
		this.fogColorRed = f9;
		this.fogColorGreen = f10;
		this.fogColorBlue = f11;
	}

	UpdateFogColorEvent event = new UpdateFogColorEvent(fogColorRed, fogColorGreen, fogColorBlue, par1, mc);
	MinecraftForge.EVENT_BUS.post(event);
	fogColorRed = event.fogColorRed;
	fogColorGreen = event.fogColorGreen;
	fogColorBlue = event.fogColorBlue;

	GL11.glClearColor(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 0.0F);
}

 

 

private void setupFog(int par1, float par2)
{
	EntityLivingBase entitylivingbase = this.mc.renderViewEntity;
	boolean flag = false;

	if (entitylivingbase instanceof EntityPlayer)
	{
		flag = ((EntityPlayer)entitylivingbase).capabilities.isCreativeMode;
	}

	if (par1 == 999)
	{
		GL11.glFog(GL11.GL_FOG_COLOR, this.setFogColorBuffer(0.0F, 0.0F, 0.0F, 1.0F));
		GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR);
		GL11.glFogf(GL11.GL_FOG_START, 0.0F);
		GL11.glFogf(GL11.GL_FOG_END, 8.0F);

		if (GLContext.getCapabilities().GL_NV_fog_distance)
		{
			GL11.glFogi(34138, 34139);
		}

		GL11.glFogf(GL11.GL_FOG_START, 0.0F);
	}
	else
	{
		GL11.glFog(GL11.GL_FOG_COLOR, this.setFogColorBuffer(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 1.0F));
		GL11.glNormal3f(0.0F, -1.0F, 0.0F);
		GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
		int j = ActiveRenderInfo.getBlockIdAtEntityViewpoint(this.mc.theWorld, entitylivingbase, par2);
		float f1;
		if (entitylivingbase.isPotionActive(Potion.blindness))
		{
                         ...
else if (this.cloudFog)
		{
			GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP);
			GL11.glFogf(GL11.GL_FOG_DENSITY, 0.1F);
		}
		else if(MinecraftForge.EVENT_BUS.post(new SetupFogEvent(this.farPlaneDistance, par1, par2, mc)))
		{
			;
		}
		else if (j > 0 && Block.blocksList[j].blockMaterial == Material.water)
		{
			GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP);

			if (entitylivingbase.isPotionActive(Potion.waterBreathing))
			{
				GL11.glFogf(GL11.GL_FOG_DENSITY, 0.05F);
			}
			else
			{
				GL11.glFogf(GL11.GL_FOG_DENSITY, 0.1F - (float)EnchantmentHelper.getRespiration(entitylivingbase) * 0.03F);
			}
		}
		else if (j > 0 && Block.blocksList[j].blockMaterial == Material.lava)
		{
			GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP);
			GL11.glFogf(GL11.GL_FOG_DENSITY, 2.0F);
		}

 

Used for changing distance of fog in situations / color (such as having a blizzard with a closer fog line)

 

- WeatherEvent

    Located in World

 

public void updateWeatherBody()
    {
        if (!this.provider.hasNoSky)
        {
        	if(MinecraftForge.EVENT_BUS.post(new WeatherEvent(this)))
        	{
        		return;
        	}
            int i = this.worldInfo.getThunderTime();

            if (i <= 0)
            {
                if (this.worldInfo.isThundering())
                {
                    this.worldInfo.setThunderTime(this.rand.nextInt(12000) + 3600);
                }
                else
                {
                    this.worldInfo.setThunderTime(this.rand.nextInt(168000) + 12000);
                }
            }
            else
            {
                --i;
                this.worldInfo.setThunderTime(i);

                if (i <= 0)
                {
                    this.worldInfo.setThundering(!this.worldInfo.isThundering());
                }
            }

 

 

Also, a hook for mod options for ingame changes, a hook for custom dimension loading screens, and finally a way to create 3D gui's would be nice. (I have the mod options files already, working on custom dimension loading screen code as well. The 3D gui's may be a little complicated but I can get that done.)

 

I didn't really bother to sugar coat the whole thing, but I can certainly explain anything on this post. If possible, it would be very useful to have these events/hooks inside minecraft forge instead of creating my own separate api that really has no point.

Thank you

Link to comment
Share on other sites

How about PlayerWakeUpEvent - pretty self-explanatory, but currently I use LivingUpdateEvent to check if the player is fully asleep instead.

 

InventorySlotClick event would be useful for intercepting inventory interactions, for example if you have a spell that creates magic armor that you don't want the player to be able to remove or that destroys itself if clicked.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Ok yeah I think this might be where the problem starts. For starters, I think you can get rid of your RecipeType impl and make it a static constant instead. I'm not 100% sure this will fix it but it's posssible. RuneInscribingRecipe public class RuneInscribingRecipe implements Recipe<SimpleContainer> { public static final RecipeType<RuneInscribingRecipe> RECIPE_TYPE = new RecipeType<>(){}; // .... @Override public RecipeType<?> getType() { return RECIPE_TYPE; } // .... } RuneInscriberMenu private Optional<RecipeHolder<RuneInscribingRecipe>> getCurrentRecipe() { SimpleContainer inventory = new SimpleContainer(2); inventory.setItem(BASE_INPUT_SLOT, this.inventory.getStackInSlot(BASE_INPUT_SLOT)); inventory.setItem(TEMPLATE_INPUT_SLOT, this.inventory.getStackInSlot(TEMPLATE_INPUT_SLOT)); List<RecipeHolder<RuneInscribingRecipe>> list = this.blockEntity.getLevel().getRecipeManager().getRecipesFor(RuneInscribingRecipe.RECIPE_TYPE, inventory, this.blockEntity.getLevel()); if (list.isEmpty()) { return Optional.empty(); } return Optional.of(list.get(0)); }   Also, this here is a little suspicious where you're getting the `this.inventory.getStackInSlot` calls. I'd try and make sure those are what you expect they are with either a Debug line in IDE or print statement SimpleContainer inventory = new SimpleContainer(2); inventory.setItem(BASE_INPUT_SLOT, this.inventory.getStackInSlot(BASE_INPUT_SLOT)); System.out.printf("CHECKING BASE INPUT OF RECIPE: %s\n", this.inventory.getStackInSlot(BASE_INPUT_SLOT)); inventory.setItem(TEMPLATE_INPUT_SLOT, this.inventory.getStackInSlot(TEMPLATE_INPUT_SLOT)); System.out.printf("CHECKING TEMPLATE INPUT OF RECIPE: %s\n", this.inventory.getStackInSlot(TEMPLATE_INPUT_SLOT)); ^ See what the result of those print statements are, make sure they're right
    • Upon testing again after adding them, the game still doesn't crash however the resource packs are still unfortunately broken.
    • Hi! Can someone please point me to the correct FAQ or place? I'm not able do DuckDuckGo myself out of this one. As you can hopefully see, chunks are not rendered. I run a forge server, fresh install on a linux VM. Curseforge on the Win11 client with Embeddium, Oculus and Unbound shader. No mods. Forge 47.2.23 on server & client.  No errors, no crashes, no apparent CPU or RAM issues with the VM. This screenshot was captured while creative, but the same happens when flying in survival. Waiting (floating) for a few minutes sooner or (often) later, lets the missing chunks appear. Usually takes 5-10 minutes.  When on a local game, the chunks appear slowly, but they do appear without pause.   This must be something simple, obvious, but I can't find the correct "search words" to find my way out. "Chunks not loading / rendering" didn't help. Browsing several forums neither. 
    • This is the Forge forums. We only support Forge here. Read the FAQ
    • 1.The game doesn't crash, everything seems normal, but when i insert the designated items into the block entity, the result item does not show up. 2.Yes, I'm using a custom menu, here's the source code:  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.