Skip to content

Commit e0e944c

Browse files
committed
Remove unneeded item() overload
1 parent 903f744 commit e0e944c

File tree

6 files changed

+66
-78
lines changed

6 files changed

+66
-78
lines changed

src/main/java/com/laytonsmith/core/ObjectGenerator.java

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public CArray location(MCLocation l, boolean includeYawAndPitch) {
185185
* @param c
186186
* @param w
187187
* @param t
188-
* @return
188+
* @return
189189
* @deprecated Use {@link #location(Mixed, MCWorld, Target, Environment)} instead.
190190
*/
191191
@Deprecated
@@ -199,11 +199,12 @@ public MCLocation location(Mixed c, MCWorld w, Target t) {
199199
* 4 usages: <ul> <li>(x, y, z)</li> <li>(x, y, z, world)</li> <li>(x, y, z, yaw, pitch)</li> <li>(x, y, z, world,
200200
* yaw, pitch)</li> </ul> In all cases, the pitch and yaw default to 0, and the world defaults to the specified
201201
* world. <em>More conveniently: ([world], x, y, z, [yaw, pitch])</em>
202+
*
202203
* @param c
203204
* @param w
204205
* @param t
205206
* @param env
206-
* @return
207+
* @return
207208
*/
208209
public MCLocation location(Mixed c, MCWorld w, Target t, Environment env) {
209210
if(!(c.isInstanceOf(CArray.TYPE, null, env))) {
@@ -282,33 +283,16 @@ public MCLocation location(Mixed c, MCWorld w, Target t, Environment env) {
282283
* @param is
283284
* @param t
284285
* @return An item array or CNull
285-
* @deprecated Use {@link #item(MCItemStack, Target, Environment)} instead.
286286
*/
287-
@Deprecated
288287
public Construct item(MCItemStack is, Target t) {
289-
return item(is, t, null);
290-
}
291-
292-
/**
293-
* An Item Object consists of data about a particular item stack. Information included is: recipeType, data, qty,
294-
* and an array of enchantment objects (labeled enchants): erecipeType (enchantment recipeType) and elevel
295-
* (enchantment level). For backwards compatibility, this information is also listed in numerical slots as well as
296-
* associative slots. If the MCItemStack is null, or the underlying item is nonexistant (or air) CNull is returned.
297-
*
298-
* @param is
299-
* @param t
300-
* @param env
301-
* @return An item array or CNull
302-
*/
303-
public Construct item(MCItemStack is, Target t, Environment env) {
304288
if(is == null || is.isEmpty()) {
305289
return CNull.NULL;
306290
}
307291

308-
CArray ret = CArray.GetAssociativeArray(t, null, env);
309-
ret.set("name", new CString(is.getType().getName(), t), t, env);
310-
ret.set("qty", new CInt(is.getAmount(), t), t, env);
311-
ret.set("meta", itemMeta(is, t), t, env);
292+
CArray ret = CArray.GetAssociativeArray(t, null, null);
293+
ret.set("name", new CString(is.getType().getName(), t), t, null);
294+
ret.set("qty", new CInt(is.getAmount(), t), t, null);
295+
ret.set("meta", itemMeta(is, t), t, null);
312296
return ret;
313297
}
314298

@@ -333,7 +317,7 @@ public MCItemStack item(Mixed i, Target t, Environment env) {
333317
* @param i
334318
* @param t
335319
* @param legacy
336-
* @return
320+
* @return
337321
* @deprecated Use {@link #item(Mixed, Target, boolean, Environment)} instead.
338322
*/
339323
@Deprecated
@@ -420,9 +404,12 @@ public MCItemStack item(Mixed i, Target t, boolean legacy, Environment env) {
420404
MCMaterial newmaterial;
421405
String entityName = spawntype.val().toUpperCase();
422406
newmaterial = switch(entityName) {
423-
case "MUSHROOM_COW" -> StaticLayer.GetMaterial("MOOSHROOM_SPAWN_EGG");
424-
case "PIG_ZOMBIE" -> StaticLayer.GetMaterial("ZOMBIE_PIGMAN_SPAWN_EGG");
425-
default -> StaticLayer.GetMaterial(entityName + "_SPAWN_EGG");
407+
case "MUSHROOM_COW" ->
408+
StaticLayer.GetMaterial("MOOSHROOM_SPAWN_EGG");
409+
case "PIG_ZOMBIE" ->
410+
StaticLayer.GetMaterial("ZOMBIE_PIGMAN_SPAWN_EGG");
411+
default ->
412+
StaticLayer.GetMaterial(entityName + "_SPAWN_EGG");
426413
};
427414
if(newmaterial != null) {
428415
material = newmaterial;
@@ -2215,7 +2202,7 @@ public CArray enchants(Map<MCEnchantment, Integer> map, Target t) {
22152202
/**
22162203
* @param enchantArray
22172204
* @param t
2218-
* @return
2205+
* @return
22192206
* @deprecated Use {@link #enchants(CArray, Target, Environment)} instead.
22202207
*/
22212208
@Deprecated
@@ -2293,7 +2280,7 @@ public CArray attributeModifier(MCAttributeModifier m, Target t) {
22932280
/**
22942281
* @param m
22952282
* @param t
2296-
* @return
2283+
* @return
22972284
* @deprecated Use {@link #attributeModifier(CArray, Target, Environment)} instead.
22982285
*/
22992286
@Deprecated
@@ -2410,7 +2397,7 @@ public CArray potions(List<MCLivingEntity.MCEffect> effectList, Target t) {
24102397
/**
24112398
* @param ea
24122399
* @param t
2413-
* @return
2400+
* @return
24142401
* @deprecated Use {@link #potions(CArray, Target, Environment)} instead.
24152402
*/
24162403
@Deprecated
@@ -2479,7 +2466,7 @@ public CArray potionData(MCPotionData mcpd, Target t) {
24792466
/**
24802467
* @param pd
24812468
* @param t
2482-
* @return
2469+
* @return
24832470
* @deprecated Use {@link #potionData(CArray, Target, Environment)} instead.
24842471
*/
24852472
@Deprecated
@@ -2524,7 +2511,7 @@ public MCPotionData potionData(CArray pd, Target t, Environment env) {
25242511
/**
25252512
* @param potionArray
25262513
* @param t
2527-
* @return
2514+
* @return
25282515
* @deprecated Use {@link #legacyPotionData(CArray, Target, Environment)} instead.
25292516
*/
25302517
@Deprecated
@@ -2601,7 +2588,7 @@ public CArray fireworkEffect(MCFireworkEffect mcfe, Target t) {
26012588
/**
26022589
* @param fe
26032590
* @param t
2604-
* @return
2591+
* @return
26052592
* @deprecated Use {@link #fireworkEffect(CArray, Target, Environment)} instead.
26062593
*/
26072594
@Deprecated
@@ -2761,7 +2748,7 @@ public Construct recipe(MCRecipe r, Target t) {
27612748
/**
27622749
* @param c
27632750
* @param t
2764-
* @return
2751+
* @return
27652752
* @deprecated Use {@link #recipe(Mixed, Target, Environment)} instead.
27662753
*/
27672754
@Deprecated
@@ -2901,7 +2888,8 @@ public MCRecipe recipe(Mixed c, Target t, Environment env) {
29012888
}
29022889
return ret;
29032890
}
2904-
default -> throw new CREIllegalArgumentException("Could not find valid recipe type.", t);
2891+
default ->
2892+
throw new CREIllegalArgumentException("Could not find valid recipe type.", t);
29052893
}
29062894
}
29072895

@@ -3017,7 +3005,7 @@ public MCMaterial material(Mixed name, Target t) {
30173005
/**
30183006
* @param ca
30193007
* @param t
3020-
* @return
3008+
* @return
30213009
* @deprecated Use {@link #blockData(CArray, Target, Environment)} instead.
30223010
*/
30233011
@Deprecated
@@ -3033,7 +3021,7 @@ public MCBlockData blockData(CArray ca, Target t, Environment env) {
30333021
* @param ca
30343022
* @param blockType
30353023
* @param t
3036-
* @return
3024+
* @return
30373025
* @deprecated Use {@link #blockData(CArray, MCMaterial, Target, Environment)} instead.
30383026
*/
30393027
@Deprecated
@@ -3118,7 +3106,7 @@ private Construct blockState(String value) {
31183106
* @param l
31193107
* @param pa
31203108
* @param t
3121-
* @return
3109+
* @return
31223110
* @deprecated Use {@link #particleData(MCParticle, MCLocation, CArray, Target, Environment)} instead.
31233111
*/
31243112
@Deprecated

src/main/java/com/laytonsmith/core/events/drivers/BlockEvents.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws Even
261261

262262
CArray drops = new CArray(t);
263263
for(MCItemStack stack : event.getDrops()) {
264-
drops.push(ObjectGenerator.GetGenerator().item(stack, t, env), t, env);
264+
drops.push(ObjectGenerator.GetGenerator().item(stack, t), t, env);
265265
}
266266
map.put("drops", drops);
267267

@@ -400,7 +400,7 @@ public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws Even
400400
map.put("player", new CString(event.getPlayer().getName(), t));
401401
map.put("block", new CString(mat.getName(), t));
402402
map.put("location", ObjectGenerator.GetGenerator().location(block.getLocation(), false));
403-
map.put("item", ObjectGenerator.GetGenerator().item(event.getItemInHand(), Target.UNKNOWN, env));
403+
map.put("item", ObjectGenerator.GetGenerator().item(event.getItemInHand(), Target.UNKNOWN));
404404
if(event.getHand() == MCEquipmentSlot.WEAPON) {
405405
map.put("hand", new CString("main_hand", Target.UNKNOWN));
406406
} else {
@@ -1089,7 +1089,7 @@ public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws Even
10891089
MCBlock block = event.getBlock();
10901090

10911091
map.put("type", new CString(block.getType().getName(), t));
1092-
map.put("item", ObjectGenerator.GetGenerator().item(event.getItem(), t, env));
1092+
map.put("item", ObjectGenerator.GetGenerator().item(event.getItem(), t));
10931093
map.put("location", ObjectGenerator.GetGenerator().location(block.getLocation(), false));
10941094

10951095
CArray velocity = ObjectGenerator.GetGenerator().vector(event.getVelocity(), t);

src/main/java/com/laytonsmith/core/events/drivers/EntityEvents.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws Even
149149
Map<String, Mixed> ret = evaluate_helper(event);
150150
ret.put("location", ObjectGenerator.GetGenerator().location(event.getLocation(), false));
151151
ret.put("id", new CString(event.getEntity().getUniqueId().toString(), t));
152-
ret.put("item", ObjectGenerator.GetGenerator().item(event.getEntity().getItemStack(), t, env));
152+
ret.put("item", ObjectGenerator.GetGenerator().item(event.getEntity().getItemStack(), t));
153153
return ret;
154154
} else {
155155
throw new EventException("Could not convert to MCItemDespawnEvent");
@@ -224,7 +224,7 @@ public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws Even
224224
Map<String, Mixed> ret = evaluate_helper(event);
225225
ret.put("location", ObjectGenerator.GetGenerator().location(event.getLocation(), false));
226226
ret.put("id", new CString(event.getEntity().getUniqueId().toString(), t));
227-
ret.put("item", ObjectGenerator.GetGenerator().item(event.getEntity().getItemStack(), t, env));
227+
ret.put("item", ObjectGenerator.GetGenerator().item(event.getEntity().getItemStack(), t));
228228
return ret;
229229
} else {
230230
throw new EventException("Could not convert to MCItemSpawnEvent");
@@ -648,7 +648,7 @@ public Map<String, Mixed> evaluate(BindableEvent event, Environment env)
648648
Map<String, Mixed> map = evaluate_helper(event);
649649
CArray drops = new CArray(t);
650650
for(MCItemStack is : e.getDrops()) {
651-
drops.push(ObjectGenerator.GetGenerator().item(is, t, env), t, env);
651+
drops.push(ObjectGenerator.GetGenerator().item(is, t), t, env);
652652
}
653653
map.put("type", new CString(dead.getType().name(), t));
654654
map.put("id", new CString(dead.getUniqueId().toString(), t));
@@ -1123,7 +1123,7 @@ public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws Even
11231123
MCPlayerDropItemEvent event = (MCPlayerDropItemEvent) e;
11241124
Map<String, Mixed> map = evaluate_helper(e);
11251125

1126-
map.put("item", ObjectGenerator.GetGenerator().item(event.getItemDrop().getItemStack(), Target.UNKNOWN, env));
1126+
map.put("item", ObjectGenerator.GetGenerator().item(event.getItemDrop().getItemStack(), Target.UNKNOWN));
11271127
map.put("id", new CString(event.getItemDrop().getUniqueId().toString(), Target.UNKNOWN));
11281128

11291129
return map;
@@ -1202,7 +1202,7 @@ public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws Even
12021202
MCPlayerPickupItemEvent event = (MCPlayerPickupItemEvent) e;
12031203
Map<String, Mixed> map = evaluate_helper(e);
12041204
map.put("id", new CString(event.getItem().getUniqueId().toString(), Target.UNKNOWN));
1205-
map.put("item", ObjectGenerator.GetGenerator().item(event.getItem().getItemStack(), Target.UNKNOWN, env));
1205+
map.put("item", ObjectGenerator.GetGenerator().item(event.getItem().getItemStack(), Target.UNKNOWN));
12061206
map.put("remaining", new CInt(event.getRemaining(), Target.UNKNOWN));
12071207
return map;
12081208
} else {
@@ -1870,7 +1870,7 @@ public Map<String, Mixed> evaluate(BindableEvent event, Environment env) throws
18701870
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_17_X)) {
18711871
MCItemStack item = e.getItem();
18721872
if(item != null) {
1873-
ret.put("item", ObjectGenerator.GetGenerator().item(item, Target.UNKNOWN, env));
1873+
ret.put("item", ObjectGenerator.GetGenerator().item(item, Target.UNKNOWN));
18741874
} else {
18751875
ret.put("item", CNull.NULL);
18761876
}

0 commit comments

Comments
 (0)