Skip to content

Instantly share code, notes, and snippets.

@MerchantPug
Last active November 21, 2023 12:10
Show Gist options
  • Save MerchantPug/1ab00a122399f77873239e1cda854dd9 to your computer and use it in GitHub Desktop.
Save MerchantPug/1ab00a122399f77873239e1cda854dd9 to your computer and use it in GitHub Desktop.

Scale Modifying in Origins

Credits

  • LuaDotExe
  • Sylent

Why was this resource made?

This document was made as I have noticed that this is a bit of a grey area when it comes to Origins datapacking and addon development. Pehkui has always been a very common dependency in the custom Origins scene, and I think that it's probably about time that a resource on how to do size changes in Origins was made.

The common traits of scale changing

Every scale change that I know of when it comes to Origins uses the Pehkui library. This is because scale changes are a very intensive thing, and it's just much easier to have a common library do the work for you.

Pehkui is available on both Fabric and Forge, although most Origins related devs will focus on purely Fabric development as it is the official and much more popular version of the mod.

The Methods (No Extra Dependencies)

Favour using these if you don't use extra dependencies for anything else. It will make your datapack more accessible if you only need Origins and Pehkui.

Action On Callback + /scale

How it looks in JSON

{
    "type": "origins:action_on_callback",
    "entity_action_chosen": {
	"type": "origins:and",
	"actions": [
		{
			"type": "origins:execute_command",
			"command": "scale set pehkui:height 0.25 @s"
		},
		{
			"type": "origins:execute_command",
			"command": "scale set pehkui:width 0.5 @s"
		},
		{
			"type": "origins:execute_command",
			"command": "scale persist set true @s"
		}
	]
    },
    "entity_action_lost": {
        "type": "origins:execute_command",
        "command": "scale reset @s"
    }
}

Origins Discord #power-library Link (Credits to LuaDotExe)

How it works This power works by setting the player's scale upon having it be chosen, the player's scale will then reset upon losing this power.

The upsides of this method

  • Checking for size changes made with this method is as easy as using a command.
  • Highly customisable, as it is purely a datapack function.

The downsides of this method

  • It is more complicated than if there was a functional power type.
  • Conditional support is not possible with this method.

Extra Information

  • There's other variations to this method, such as using mcfunctions, etc. But generally people will use the action_on_callback power type if they're creating an origin with a static scale change.

Rising Action and Falling Action with Action Over Time

How it looks in JSON

{
    "type": "origins:multiple",
    "conditional": {
        "type": "origins:action_over_time",
        "rising_action": {
            "type": "origins:change_resource",
            "change": 1,
            "resource": "*:*_state"
        },
        "falling_action": {
            "type": "origins:change_resource",
            "change": -1,
            "resource": "*:*_state"
        },
        "interval": 1,
        "condition": {
            "type": "origins:on_fire"
        }
    },
    "state": {
        "type": "origins:resource",
        "min": 0,
        "max": 1,
        "min_action": {
            "type": "origins:and",
            "actions": [
                {
                    "type": "origins:execute_command",
                    "command": "scale set pehkui:height 1.0 @s"
                },
                {
                    "type": "origins:execute_command",
                    "command": "scale set pehkui:width 1.0 @s"
                },
                {
                    "type": "origins:execute_command",
                    "command": "scale persist set false @s"
                }
            ]
        },
        "max_action": {
            "type": "origins:and",
            "actions": [
                {
                    "type": "origins:execute_command",
                    "command": "scale set pehkui:height 0.5 @s"
                },
                {
                    "type": "origins:execute_command",
                    "command": "scale set pehkui:width 0.5 @s"
                },
                {
                    "type": "origins:execute_command",
                    "command": "scale persist set true @s"
                }
            ]
        },
        "hud_render": {
            "should_render": false
        }
    },
    "on_lost": {
        "type": "origins:action_on_callback",
        "entity_action_lost": {
            "type": "origins:execute_command",
            "command": "scale reset @s"
        }
    }
}

How it works This power works by storing a state of 0 and 1 in a resource. It will execute actions upon changing to either one, which will then set the player's scale to a different value. You can then plug a condition into an action over time that changes the resource value depending on rising (when the condition is met) (1) or falling (when the condition is no longer met) (0).

The upsides of this method

  • Checking for size changes made with this method is as easy as using a command.
  • Highly customisable, as it is purely a datapack function.

The downsides of this method

  • It is still more complicated than if there were a functional power type.
  • Doesn't quite stack with other conditionals, this is good for one conditional power, but not great for if there's more than that.

Mess around and find out

You can mess around with commands to achieve more specific results, such as creating a function to recursively update your scale based on the origin's max health. This will require more effort on your end, but you can achieve results that you couldn't with anything mentioned here, I'd recommend asking for help if you want a result that is a bit hard to figure out.

The Methods (Extra Dependencies)

Methods with extra dependencies are specified in a different category, as it's ill advised to use them when you don't need to. Size changing is perfectly viable without an extra dependency on top of Pehkui, so only use these if you're using other more mandatory things from them.

Extra Origins' Modify Size Power Type

Extra Origins includes the modify size power type for use on its Inchling origin.

How it looks in JSON

{
	"type": "extraorigins:modify_size",
	"scale_types": [
	  "pehkui:width",
	  "pehkui:height"
	],
	"scale": 0.25
}

Referenced from https://github.com/MoriyaShiine/extra-origins/wiki

Field Type Default Description
scale_types Array of Identifiers [ "extraorigins:modify_size" ] The scale types to modify.
scale Float The scale to set each scale_types scale to.

The upsides of this method

  • It's very easy to understand from a JSON perspective.
  • It supports entity conditions, provided you're only using one power.

The downsides of this method

  • You will have to add/disable 4 extra origins to your game, this is not ideal for most.
  • This method is unable to stack with others of the same type, even if one is active and one is not.
  • It does not have the option to use a modifier, something that I feel is very vital when it comes to these sorts of powers.
  • It is hard to check for inside conditions when it comes to others trying to utilise it.

Extra Information

  • If the datapack is on Origins Forge, this power will never work as Extra Origins will never be available on the loader, please don't harass anybody over this decision.
    • The above probably isn't very important to most users, but I would prefer to point it out just in case.

Apugli's Modify Scale Power Type

How it looks in JSON

{
  "type": "apugli:modify_scale",
  "delay": 40,
  "scale_types": [
    "pehkui:width",
    "pehkui:height",
    "pehkui:drops"
  ],
  "modifiers": {
    "operation": "multiply_total_multiplicative",
    "value": 0.25
  }
}
Field Type Default Description
scale_type Identifier optional If set, this scale type will be modified.
scale_types Array of Identifiers optional If set, these scale types will be modified.
modifier Attribute Modifier optional If set, this modifier that will apply to the scale value.
modifiers Array of Attribute Modifiers optional If set, these modifiers that will apply to the scale value.
delay Float 0 If set, this delay will be applied to scale changes.

The upsides of this method

  • If you understand how modifiers work, this is a very powerful option for scale changing.
  • It stacks with other powers of this type and other scale changes due to hooking into Pehkui's modifier system.
  • It supports entity conditions.

The downsides of this method

  • Due to being a new addition, this will not function on versions prior to Apugli 2.8.0, and is unstable on versions prior to 2.9.0.
  • Has more potential to be unstable than any other option on this list. Please report bugs here if you find any.

Anything else

Anything else that is not mentioned here is either on shaky grounds, or I haven't paid attention to it yet. Please message me (@merchantpug on Discord) if you've found any size changing methods that have not been covered here.

I will actively not be including any methods that utilise code used without permission, and if you bring it up to me, I will most likely get the original dev involved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment