The Official Hook Request Thread

This sub-forum is dedicated to add-ons and texture packs for Better Than Wolves.
User avatar
FlowerChild
Site Admin
Posts: 18753
Joined: Mon Jul 04, 2011 7:24 pm

The Official Hook Request Thread

Post by FlowerChild »

WARNING: This thread is for mod authors only. If you are not the author of an *existing* mod (planned mods don't count), DO NOT post to this thread. I will ban the shit out of you.

With that out of the way, it occurred to me that while me setting aside a huge chunk of time to finalize a BTW API might be an unrealistic dream on my part, there are many who are already creating add-on mods for BTW.

As a result, I wanted to create this thread so that you can request *specific* hooks from me if you feel you really need them.

Some ground rules:

-Only post hook requests for stuff you need for features *right now*. Do not under any circumstances post "it would be nice" hook requests, as those are in neverending supply. Also, please do not try to come up with feature ideas specifically to make use of "it would be nice" hooks. Basically, I'm doing this to help you guys out, so please don't abuse it by making frivolous requests.

-Try to focus on stuff I already have built into the mod but which you do not have easy access to. For example, I currently have multiplayer hooks built into the server code, but they are BTW specific in many cases. Requesting I make them general purpose so that you can use them for your add-on specific messages would be a perfectly valid request (I already intend to do that one though, so no point suggesting it). Asking me to build new functionality into the mod however, to make your features possible, is unlikely to be responded to favorably.

-This is not a thread for discussion, it's for requests. If someone makes a request that you could also benefit from, then feel free to say as much as that will help me prioritize any resulting tasks, but PLEASE do not start protracted conversations about the potential hooks.

-Be concise. I don't want to hear your life story. Briefly explain what you need and why you need it and leave it at that. I'm a smart guy, and will figure it out from there.
User avatar
Sarudak
Site Admin
Posts: 2786
Joined: Thu Nov 24, 2011 7:59 pm

Re: The Official Hook Request Thread

Post by Sarudak »

I'm going to post this here even though you already know about it.

I could really use a hook into the millstone to be able to add new recipes. I specifically want to add blaze rods -> blaze powder for my hardcore grinding mod.

The ability to replace existing recipes would also be cool since I had some plans to complexify the paper production process but my plan would require the ability to replace sugarcane -> sugar in the millstone with an item of my own.
User avatar
FlowerChild
Site Admin
Posts: 18753
Joined: Mon Jul 04, 2011 7:24 pm

Re: The Official Hook Request Thread

Post by FlowerChild »

Yup, first one is very reasonable.

Second one is new functionality, so not likely to happen.
User avatar
utakataJ6
Posts: 200
Joined: Sun Mar 25, 2012 11:56 am
Location: District of Columbia

Re: The Official Hook Request Thread

Post by utakataJ6 »

I'll ditto the millstone hook, as I have in the past.

The only other hook I can forsee would be some way to change the function like "canStay" for nether groth - mediate's Zinc blocks and slabs destroy mushrooms in such a function, and the (reasonable) request was made to extend this fungicide function to groth if possible.
morvelaira:
Not all Minecraft players have stamped down the knee-jerk, lawful-good Superman reaction yet. We do hold a rather high proportion of the enlightened on these forums ;)
flowerchild:
Not to mention a mod that trains the player to be rather morally ambivalent ;)
User avatar
utakataJ6
Posts: 200
Joined: Sun Mar 25, 2012 11:56 am
Location: District of Columbia

Re: The Official Hook Request Thread

Post by utakataJ6 »

Alright, looking into the mediate codebase, there are actually very few edits to your vanilla classes, and thus few significant issues at the moment.

So here are the hooks I would request:
1. Most importantly, I've like some way to get to EntityPlayer. I do a few things here - I'll let you use your judgement on what's best done.
*Function for assessing the amount of cotton armor worn
Spoiler
Show

Code: Select all

	protected boolean isComfortable()
	{
		int fuzzy = 0;
		if(this.inventory.armorInventory[3] != null && this.inventory.armorInventory[3].getItem().shiftedIndex == mod_Mediate.armorHeadCotton.shiftedIndex)
		{fuzzy ++;}
		if(this.inventory.armorInventory[2] != null && this.inventory.armorInventory[2].getItem().shiftedIndex == mod_Mediate.armorBodyCotton.shiftedIndex)
		{fuzzy ++;}
		if(this.inventory.armorInventory[1] != null && this.inventory.armorInventory[1].getItem().shiftedIndex == mod_Mediate.armorLegCotton.shiftedIndex)
		{fuzzy ++;}
		if(this.inventory.armorInventory[0] != null && this.inventory.armorInventory[0].getItem().shiftedIndex == mod_Mediate.armorFootCotton.shiftedIndex)
		{fuzzy ++;}
		if(fuzzy > 1)
		{return true;}
		return false;
	}
*Redone fall function, for assessing if the player is impaled by a stalagmite (or potentially other similar object
Spoiler
Show

Code: Select all

    protected void fall(float par1)
    {
        if (!this.capabilities.allowFlying)
        {
            if (par1 >= 2.0F)
            {
                this.addStat(StatList.distanceFallenStat, (int)Math.round((double)par1 * 100.0D));		
			}
			super.fall(par1);
            if (par1 >= 1.0F)
            {
			    int var1 = MathHelper.floor_double(this.posX);
				int var2 = MathHelper.floor_double(this.boundingBox.minY);
				int var3 = MathHelper.floor_double(this.posZ);
				if(this.worldObj.getBlockId(var1, var2 - 1, var3) == mod_Mediate.blockStala.blockID)
				{
					if(this.inventory.armorInventory[1] == null || this.inventory.armorInventory[1].getItem().shiftedIndex == mod_Mediate.armorLegCotton.shiftedIndex || [if it equals your biker leggings, specific code removed for public])
					{
						int varb;
						double var4;
						double var6;
						double var8;
						int par2 = 30;
						this.health -= par2;
						for (varb = 0; varb < 10; ++varb)
							{
								var4 = this.posX + this.worldObj.rand.nextDouble();
								var6 = this.posY + 1.0D + this.worldObj.rand.nextDouble();
								var8 = this.posZ + this.worldObj.rand.nextDouble();
								this.worldObj.spawnParticle("reddust", var4, var6, var8, 0.0D, 0.0D, 0.0D);
							}
						this.onDeath(DamageSource.fall);
					}
				}
			}
        }
    }
*finally, the following is placed in OnLivingUpdate, following the sprinting clause, for Cotton's armor effect
Spoiler
Show

Code: Select all

        if (this.isComfortable())
        {
            this.landMovementFactor = (float)((double)this.landMovementFactor + (double)this.capabilities.getWalkSpeed() * 0.1D);
            this.jumpMovementFactor = (float)((double)this.jumpMovementFactor + (double)this.speedInAir * 0.1D);
        }
2. Entity Animal - some way to check what block the animal is on. If they're on lead blocks or slabs I prevent them from breeding.
3. EntityVillager - this is an annoying one. Currenly, I'm adding trade recipes. Modloader provides a function to add trade recipes, but half of that code seems to be broken, as you may have noticed - any bits involving negative numbers. For the moment, I'll be using the modloader code, but it is impossible to balance trades with that currently. If you would like more information on what the issue is here, please mention so.

That's it. Only the Entity Player hooks are really crucial. My only other significant edit was to BlockMushroom, and that's the same as what I wanted to do to nether Groth - so I'll just look harder for a way around it.

If I might make a suggestion, I suspect the fall function could be done fairly easily with a list of items which do (or do not) protect the player in this case, or a list of armor materials as such, + a list of blocks that cause impalement, + adding most of that code into BTW?
morvelaira:
Not all Minecraft players have stamped down the knee-jerk, lawful-good Superman reaction yet. We do hold a rather high proportion of the enlightened on these forums ;)
flowerchild:
Not to mention a mod that trains the player to be rather morally ambivalent ;)
User avatar
FlowerChild
Site Admin
Posts: 18753
Joined: Mon Jul 04, 2011 7:24 pm

Re: The Official Hook Request Thread

Post by FlowerChild »

Cool. I'll slate the Mill Stone hooks for the next release, and start considering how to best approach the other issues you mention.
User avatar
utakataJ6
Posts: 200
Joined: Sun Mar 25, 2012 11:56 am
Location: District of Columbia

Re: The Official Hook Request Thread

Post by utakataJ6 »

Post made in the interest of lightening your potential workload.

I managed to work the mushroom-destroying code perfectly well outside of base classes, and was able to apply the same strategy to nether groth.

Additionally, I was able to recreate a ...version... of the no-birthing animals code ...outside of entityAnimal.

Third, the modloader trading code isn't as broken as I had thought, and I'm doing just fine without EntityVillager.

SO, these are things you could know one doesn't need hooks for, if asked in the future.
morvelaira:
Not all Minecraft players have stamped down the knee-jerk, lawful-good Superman reaction yet. We do hold a rather high proportion of the enlightened on these forums ;)
flowerchild:
Not to mention a mod that trains the player to be rather morally ambivalent ;)
User avatar
FlowerChild
Site Admin
Posts: 18753
Joined: Mon Jul 04, 2011 7:24 pm

Re: The Official Hook Request Thread

Post by FlowerChild »

utakataJ6 wrote:Third, the modloader trading code isn't as broken as I had thought, and I'm doing just fine without EntityVillager.
Hehe...interesting. That was the other one I had added to my todo list for the next release, as it's relatively straight-forward. I'll take a look at the ML code myself then, although the changes I personally have planned for villager trading will likely require me to rig something up anyways.
utakataJ6 wrote:SO, these are things you could know one doesn't need hooks for, if asked in the future.
Thanks for the info.
User avatar
utakataJ6
Posts: 200
Joined: Sun Mar 25, 2012 11:56 am
Location: District of Columbia

Re: The Official Hook Request Thread

Post by utakataJ6 »

Right. Speaking of those changes, while I don't expect an answer because nobody likes spoilers, EntityAIVillagerMate is kind of the golden base class for Mediate, even though all I do in it is change a single number (random 5 becomes random 6 to allow the green villager). I hope if it receives large edits, you'd be willing to give me a hook there. It could be as simple as changing that line
Spoiler
Show

Code: Select all

    
private void giveBirth()
    {
        EntityVillager var1 = new EntityVillager(this.worldObj);
        this.mate.setGrowingAge(6000);
        this.villagerObj.setGrowingAge(6000);
        var1.setGrowingAge(-24000);
        var1.setProfession(this.villagerObj.getRNG().nextInt(6));//mediate edits
        var1.setLocationAndAngles(this.villagerObj.posX, this.villagerObj.posY, this.villagerObj.posZ, 0.0F, 0.0F);
        this.worldObj.spawnEntityInWorld(var1);
        this.worldObj.setEntityState(var1, (byte)12);
    }
to a variable in the BTW config file, I believe. Still. Good to know you're taking looks at these kind of things; means a lot.
morvelaira:
Not all Minecraft players have stamped down the knee-jerk, lawful-good Superman reaction yet. We do hold a rather high proportion of the enlightened on these forums ;)
flowerchild:
Not to mention a mod that trains the player to be rather morally ambivalent ;)
User avatar
FlowerChild
Site Admin
Posts: 18753
Joined: Mon Jul 04, 2011 7:24 pm

Re: The Official Hook Request Thread

Post by FlowerChild »

Yup, I can do that. Glad you mentioned it actually, as I already modified that file to give villagers birthing effects for the next release.
User avatar
FlowerChild
Site Admin
Posts: 18753
Joined: Mon Jul 04, 2011 7:24 pm

Re: The Official Hook Request Thread

Post by FlowerChild »

Added the following static variable to EntityAIVillagerMate for the next release to cover the above:

Code: Select all

	public static int m_iNumProfessionTypes = 5;
User avatar
FlowerChild
Site Admin
Posts: 18753
Joined: Mon Jul 04, 2011 7:24 pm

Re: The Official Hook Request Thread

Post by FlowerChild »

Hey guys,

My apologies, but I don't have it in me to get the Mill Stone hooks in for the next release. It was the last item on my todo list for it.

Just wanted to let you know that you haven't been forgotten and that I will get it in as soon as I can.
User avatar
utakataJ6
Posts: 200
Joined: Sun Mar 25, 2012 11:56 am
Location: District of Columbia

Re: The Official Hook Request Thread

Post by utakataJ6 »

First of all, thank you SO much for the static - that was of course as easy as breathing to use, and it would have been such a problem otherwise.

I'd like to officially request a way to add items to the bellows featherlight list, and others to the hopper filter lists.

I would have suggested these earlier, but I have spent much of the last 48 hours playing through the BTW/MeC tech tree from start to finish, accommodating my planned releases up to Minecraft 1.4, to make SURE there would be no other hooks that I could foresee. Afaik there are not.

Again, huge appreciation for what you've done so far. I'm really starting to feel the mods linked now, in a way that was not there initially.
morvelaira:
Not all Minecraft players have stamped down the knee-jerk, lawful-good Superman reaction yet. We do hold a rather high proportion of the enlightened on these forums ;)
flowerchild:
Not to mention a mod that trains the player to be rather morally ambivalent ;)
User avatar
FlowerChild
Site Admin
Posts: 18753
Joined: Mon Jul 04, 2011 7:24 pm

Re: The Official Hook Request Thread

Post by FlowerChild »

Yup, I'm all done refactoring the Mill Stone code so that you can add recipes to and remove recipes from it. It uses my bulk crafting manager now, so the recipes can also have multiple outputs, and theoretically multiple inputs (not sure why that would be needed, but it can be done anyways).

I decided to do pretty much a full refactor of the Mill Stone code while I was at it, as it was some very old code, didn't follow most of my current coding conventions, and needed to be optimized for SMP anyways, so it's much cleaner overall now.

Next I'll tackle the Hopper Filters, followed by the Bellows blowing, and Saw. None of those should be particularly difficult (will just create interfaces for each so that custom blocks and items can define their own properties), but I'm also planning on reworking how the Bellows interacts with items at the same time, which might take me a couple of hours.
DAGR99
Posts: 18
Joined: Wed May 23, 2012 2:06 pm

Re: The Official Hook Request Thread

Post by DAGR99 »

First of all, I know this is a newb question, but where is the code for the hooks you have not specifically displayed in the thread?
Second of all, I would like to request a hook for mining charges. In the same way that cobblestone, when detonated by mining charges, turns into gravel. I would like to (spoiler!) be able to turn ores, when detonated, to turn into items I define in the code. I understand you are a busy person (you REALLY need a break), so I will not be picky about when you release this new hook. Just would like confirmation about whether or not it is possible at his time
Last thing: This is an extra, but would be necessary later. A hook for new anvil recipes.
Thanks!

edit: About the first question, if you used the templates that utakataJ6 gave you, could you specify.
User avatar
FlowerChild
Site Admin
Posts: 18753
Joined: Mon Jul 04, 2011 7:24 pm

Re: The Official Hook Request Thread

Post by FlowerChild »

DAGR99 wrote:First of all, I know this is a newb question, but where is the code for the hooks you have not specifically displayed in the thread?
DAGR: Don't post in this thread again, or I will instantly and permanently ban you. I'm not here to teach you how to mod, or how to program.

Some of the things you're asking for are already in the mod (it's up to you to figure out how to use them), and I get the impression you didn't read or understand the OP.

Again: don't post here.
User avatar
DaveYanakov
Posts: 2090
Joined: Sat Jul 23, 2011 5:17 am

Re: The Official Hook Request Thread

Post by DaveYanakov »

I am relaying this for a friend of mine since forum registration has been closed.

[18:27] <Warr1024> basically, I want to be able to drop class files into the jar, or somewhere else accessible by the server, and have my mod get loaded after FC's does.
[18:28] <Warr1024> #2 is simple: I would like a hook at the end of ServerConfigurationManager.initializeConnectionToPlayer() after FC's, so that I can notify players of the addon, and/or do compatibility-check-type things.
[18:29] <Warr1024> Those 2 are enough to release BWR, with current features intact, without including FC or vMC code.

The SMP only addon is written and in current use on our private server but it cannot currently be made public without distributing code. Unless he has completely missed something, modloader will not work and Mojang is a long ways off from providing an API.
Better is the enemy of Good
User avatar
FlowerChild
Site Admin
Posts: 18753
Joined: Mon Jul 04, 2011 7:24 pm

Re: The Official Hook Request Thread

Post by FlowerChild »

Dude...there's a statement about SMP hooks in the OP. Seeing as how I don't know this guy, and don't know his mod, and you aren't a mod author yourself, I'd ask you not to post here again.
User avatar
FlowerChild
Site Admin
Posts: 18753
Joined: Mon Jul 04, 2011 7:24 pm

Re: The Official Hook Request Thread

Post by FlowerChild »

Just a brief note:

If any of you guys have complex blocks (as in blocks that are visually comprised of multiple smaller blocks) that you'd like to do a proper ray-trace against (for the purposes of what the player is clicking on precisely, or where arrows can hit a portion of the block), a couple of releases ago I wrote a small utility class called:

FCUtilsRayTraceVsComplexBlock

If you do a search on that within the code, you should find examples of its use (I think I initially used it for the Hopper and a few other things, but I've yet to convert all such code over to the system yet). It makes doing these kinds of ray-traces a trivial affair, while the vanilla code for it is always a complex special case that makes it a much bigger pain in the ass than it needs to be.

I designed it to use the same kind of parameters typically used in rendering code, so using it is generally just a matter of copy/pasting your rendering code and changing the functions called to do the ray-trace instead.

I didn't mention that one in the release notes, but having just used it to do ray traces vs fences (vanilla ones as well), Tables, and Benches, I just thought I'd mention it because it makes this kind of thing really *really* easy.
User avatar
DNoved1
Posts: 221
Joined: Wed Jan 23, 2013 5:29 pm

Re: The Official Hook Request Thread

Post by DNoved1 »

A hook for custom client --> server packets. Better Than Horses needs this to send certain keypresses, and NetServerHandler seems to be already modified, so yah. Also, bonus points if you send the EntityPlayerMP object when the hook is called.
User avatar
FlowerChild
Site Admin
Posts: 18753
Joined: Mon Jul 04, 2011 7:24 pm

Re: The Official Hook Request Thread

Post by FlowerChild »

Sounds reasonable. I'll take a look.
User avatar
jorgebonafe
Posts: 2714
Joined: Mon Sep 19, 2011 3:22 am
Location: Brasil

Re: The Official Hook Request Thread

Post by jorgebonafe »

DNoved1 wrote:A hook for custom client --> server packets. Better Than Horses needs this to send certain keypresses, and NetServerHandler seems to be already modified, so yah. Also, bonus points if you send the EntityPlayerMP object when the hook is called.
FC, did you think about adding this hook? It turns out I'm also gonna need this to make my addon server compatible.
Better Than Wolves was borne of anal sex. True Story.
User avatar
FlowerChild
Site Admin
Posts: 18753
Joined: Mon Jul 04, 2011 7:24 pm

Re: The Official Hook Request Thread

Post by FlowerChild »

jorgebonafe wrote:FC, did you think about adding this hook? It turns out I'm also gonna need this to make my addon server compatible.
Yup, still on my todo man. Sorry about the delays here, I'm trying hard to finalize BTW and will likely be adding additional hooks and add-on support post-release once I get that done.
User avatar
DNoved1
Posts: 221
Joined: Wed Jan 23, 2013 5:29 pm

Re: The Official Hook Request Thread

Post by DNoved1 »

DNoved1 wrote:A hook for custom client --> server packets. Better Than Horses needs this to send certain keypresses, and NetServerHandler seems to be already modified, so yah. Also, bonus points if you send the EntityPlayerMP object when the hook is called.
Just thought I'd give an update on this hook request, in that it is in fact totally unnecessary. I have found an alternative (for anyone interested, see below).
Spoiler
Show
Rather than modify the NetServerHandler and the NetClientHandler classes to redirect Packet250CustomPayload packets to mod files, one can instead create a custom packet class extending Packet250CustomPayload and overriding the processPacket method to redirect the packet to your mod rather than the normal NetHandler. If one employs this method they will also have to add an associated id to class mapping in the packet class by calling Packet.addIdToClassMapping. This does however mean that every mod will have to have a unique packet id if it uses them, or they will have to create a common packet which redirects to every mod, though that would require an api of sorts.
User avatar
Yhetti
Posts: 427
Joined: Sat Feb 09, 2013 7:57 pm

Re: The Official Hook Request Thread

Post by Yhetti »

I am not sure if you're still even looking at this thread, but I have reached a roadblock whilst adding the extra dye colors to entities(for deco addon).
The wolf and sheep each have a cutoff for when the collar/fleece color is changed:
Spoiler
Show
public int getCollarColor()
{
return this.dataWatcher.getWatchableObjectByte(20) & 15;
}
The " &15" cuts me off. If I am allowed an extra bit (by changing the 15 to 31) there I can have up to 32 colors, but there's no way around this because the entity classes use these methods to save the data and (for wolves) they use them when the player "smooshes" the entity with dye. Obviously I can make my own subclasses for rendering, it's just the EntityWolf, EntitySheep that are causing problems. For sheep it is a bit different because the only open bits are after the bit that indicates it is sheared, but if you're willing to add it in, I can even rewrite the "get" method and send them to you.
Locked