Skip to content

Commit

Permalink
fix noted inventory script resizing, also meta patches
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 16, 2020
1 parent 19188d1 commit 337b1ab
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
Expand Up @@ -290,6 +290,9 @@ else if (typeName.equals("script") && holder != null) {
return null;
}
result = ((InventoryScriptContainer) script.getContainer()).getInventoryFrom(context);
if (size != -1) {
result.setSize(size);
}
}
if (result == null) {
ScriptTag script = ScriptTag.valueOf(holder, context);
Expand Down Expand Up @@ -510,6 +513,9 @@ else if (inventory == null) {
return;
}
int oldSize = inventory.getSize();
if (oldSize == size) {
return;
}
ItemStack[] oldContents = inventory.getContents();
ItemStack[] newContents = new ItemStack[size];
if (oldSize > size) {
Expand Down
@@ -1,6 +1,7 @@
package com.denizenscript.denizen.objects.properties.inventory;

import com.denizenscript.denizen.objects.InventoryTag;
import com.denizenscript.denizen.utilities.debugging.Debug;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizencore.objects.ObjectTag;
Expand Down Expand Up @@ -45,7 +46,7 @@ public void setSize(int size) {

@Override
public String getPropertyString() {
if (getSize() > 0 && inventory.getIdType().equals("generic") && inventory.getInventoryType() == InventoryType.CHEST) {
if (getSize() > 0 && (inventory.getIdType().equals("generic") || inventory.getIdType().equals("script")) && inventory.getInventoryType() == InventoryType.CHEST) {
return String.valueOf(getSize());
}
else {
Expand Down Expand Up @@ -85,8 +86,13 @@ public void adjust(Mechanism mechanism) {
// @tags
// <InventoryTag.size>
// -->
if (mechanism.matches("size") && inventory.getIdType().equals("generic") && mechanism.requireInteger()) {
setSize(mechanism.getValue().asInt());
if (mechanism.matches("size") && mechanism.requireInteger()) {
if (inventory.getIdType().equals("generic") || inventory.getIdType().equals("script")) {
setSize(mechanism.getValue().asInt());
}
else {
Debug.echoError("Inventories of type '" + inventory.getIdType() + "' cannot have their size changed!");
}
}

}
Expand Down
Expand Up @@ -81,23 +81,28 @@ public class ItemScriptContainer extends ScriptContainer {
// recipes:
// 1:
// # The type can be: shaped, shapeless, stonecutting, furnace, blast, smoker, or campfire.
// # | All recipes must include this key!
// type: shaped
// # The recipe can optionally have a custom internal recipe ID (for recipe books).
// # If not specified, will be of the form "<type>_<script.name>_<id>" where ID is the recipe list index (starting at 1, counting up).
// # IDs will always have the namespace "denizen". So, for the below, the full ID is "denizen:my_custom_item_id"
// # Note that most users should not set a custom ID. If you choose to set a custom one, be careful to avoid duplicates or invalid text.
// # Note that the internal rules for Recipe IDs are very strict (limited to "a-z", "0-9", "/", ".", "_", or "-").
// # | Most recipes should exclude this key.
// recipe_id: my_custom_item_id
// # You can optional add a group as well. If unspecified, the item will have no group.
// # Groups are used to merge together similar recipes in the recipe book (in particular, multiple recipes for one item).
// # | Most recipes should exclude this key.
// group: my_custom_group
// # You can optionally specify the quantity to output. The default is 1 (or whatever the item script's quantity is).
// # | Only some recipes should have this key.
// output_quantity: 4
// # You must specify the input for the recipe. The below is a sample of a 3x3 shaped recipe. Other recipe types have a different format.
// # You are allowed to have non-3x3 shapes (can be any value 1-3 x 1-3, so for example 1x3, 2x1, and 2x2 are fine).
// # For an empty slot, use "air".
// # By default, items require an exact match. For a material-based match, use the format "material:MaterialNameHere" like "material:stick".
// # To make multiple different items match for any slot, just separate them with slashes, like "stick/stone". To match multiple materials, use "material:a/b/c".
// # | All recipes must include this key!
// input:
// - ItemTag|ItemTag|ItemTag
// - ItemTag|ItemTag|ItemTag
Expand All @@ -121,8 +126,10 @@ public class ItemScriptContainer extends ScriptContainer {
// # Furnace, blast, smoker, and campfire recipes take one input and have additional options.
// type: furnace
// # Optionally specify the cook time as a duration (default 2s).
// # | Only some recipes should have this key.
// cook_time: 1s
// # Optionally specify experience reward amount (default 0).
// # | Only some recipes should have this key.
// experience: 5
// input: ItemTag
//
Expand Down
Expand Up @@ -2277,6 +2277,7 @@ public static void adjustServer(Mechanism mechanism) {
// @description
// Suggests to the internal systems that it's a good time to clean the memory.
// Does NOT force a memory cleaning.
// This should generally not be used unless you have a very good specific reason to use it.
// @tags
// <server.ram_free>
// -->
Expand Down

0 comments on commit 337b1ab

Please sign in to comment.