Skip to content

Commit

Permalink
Refactor getDelegate to item, and some small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Intybyte committed Nov 4, 2024
1 parent e7aefc6 commit b646376
Show file tree
Hide file tree
Showing 28 changed files with 92 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ public void openTransmitterControlPanel(@Nonnull Player p) {
menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}

menu.addItem(2, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER.getDelegate(), im -> {
menu.addItem(2, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER.item(), im -> {
im.setDisplayName(ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"));
im.setLore(null);
}));

menu.addMenuClickHandler(2, ChestMenuUtils.getEmptyClickHandler());

int complexity = getNetworkComplexity(p.getUniqueId());
menu.addItem(4, new CustomItemStack(SlimefunItems.GPS_CONTROL_PANEL.getDelegate(), "&7Network Info", "", "&8\u21E8 &7Status: " + getStatusText(p, complexity), "&8\u21E8 &7Complexity: &f" + complexity));
menu.addItem(4, new CustomItemStack(SlimefunItems.GPS_CONTROL_PANEL.item(), "&7Network Info", "", "&8\u21E8 &7Status: " + getStatusText(p, complexity), "&8\u21E8 &7Complexity: &f" + complexity));
menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler());

menu.addItem(6, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints"), "", ChatColor.GRAY + "\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup")));
Expand All @@ -177,7 +177,7 @@ public void openTransmitterControlPanel(@Nonnull Player p) {
if (sfi instanceof GPSTransmitter transmitter) {
int slot = inventory[index];

menu.addItem(slot, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER.getDelegate(), "&bGPS Transmitter", "&8\u21E8 &7World: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &7Signal Strength: &f" + transmitter.getMultiplier(l.getBlockY()), "&8\u21E8 &7Ping: &f" + NumberUtils.roundDecimalNumber(1000D / l.getY()) + "ms"));
menu.addItem(slot, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER.item(), "&bGPS Transmitter", "&8\u21E8 &7World: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &7Signal Strength: &f" + transmitter.getMultiplier(l.getBlockY()), "&8\u21E8 &7Ping: &f" + NumberUtils.roundDecimalNumber(1000D / l.getY()) + "ms"));
menu.addMenuClickHandler(slot, ChestMenuUtils.getEmptyClickHandler());

index++;
Expand Down Expand Up @@ -232,14 +232,14 @@ public void openWaypointControlPanel(@Nonnull Player p) {
menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}

menu.addItem(2, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER.getDelegate(), "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"), "", ChatColor.GRAY + "\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup")));
menu.addItem(2, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER.item(), "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"), "", ChatColor.GRAY + "\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup")));
menu.addMenuClickHandler(2, (pl, slot, item, action) -> {
openTransmitterControlPanel(pl);
return false;
});

int complexity = getNetworkComplexity(p.getUniqueId());
menu.addItem(4, new CustomItemStack(SlimefunItems.GPS_CONTROL_PANEL.getDelegate(), "&7Network Info", "", "&8\u21E8 &7Status: " + (complexity > 0 ? "&2&lONLINE" : "&4&lOFFLINE"), "&8\u21E8 &7Complexity: &f" + complexity));
menu.addItem(4, new CustomItemStack(SlimefunItems.GPS_CONTROL_PANEL.item(), "&7Network Info", "", "&8\u21E8 &7Status: " + (complexity > 0 ? "&2&lONLINE" : "&4&lOFFLINE"), "&8\u21E8 &7Complexity: &f" + complexity));
menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler());

menu.addItem(6, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public SlimefunItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType reci
Validate.notNull(recipeType, "'recipeType' is not allowed to be null!");

this.itemGroup = itemGroup;
this.itemStackTemplate = item.getDelegate();
this.itemStackTemplate = item.item();
this.id = item.getItemId();
this.recipeType = recipeType;
this.recipe = recipe;
Expand Down Expand Up @@ -1190,7 +1190,7 @@ public final int hashCode() {
return null;
}

var delegate = slimefunItemStack.getDelegate();
var delegate = slimefunItemStack.item();
if (delegate.getType() == Material.AIR) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull Color color, @Nonnull Poti
}

public SlimefunItemStack(@Nonnull SlimefunItemStack item, int amount) {
this(item.getItemId(), item.getDelegate());
this(item.getItemId(), item.item());
setAmount(amount);
}

Expand Down Expand Up @@ -337,7 +337,7 @@ public final int hashCode() {
/**
* @return underlying ItemStack used
*/
public @Nonnull ItemStack getDelegate() {
public @Nonnull ItemStack item() {
return delegate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class RecipeType implements Keyed {
public static final RecipeType ENHANCED_CRAFTING_TABLE = new RecipeType(new NamespacedKey(Slimefun.instance(), "enhanced_crafting_table"), SlimefunItems.ENHANCED_CRAFTING_TABLE, "", "&a&oA regular Crafting Table cannot", "&a&ohold this massive Amount of Power...");
public static final RecipeType JUICER = new RecipeType(new NamespacedKey(Slimefun.instance(), "juicer"), SlimefunItems.JUICER, "", "&a&oUsed for Juice Creation");

public static final RecipeType ANCIENT_ALTAR = new RecipeType(new NamespacedKey(Slimefun.instance(), "ancient_altar"), SlimefunItems.ANCIENT_ALTAR.getDelegate(), (recipe, output) -> {
public static final RecipeType ANCIENT_ALTAR = new RecipeType(new NamespacedKey(Slimefun.instance(), "ancient_altar"), SlimefunItems.ANCIENT_ALTAR.item(), (recipe, output) -> {
AltarRecipe altarRecipe = new AltarRecipe(Arrays.asList(recipe), output);
AncientAltar altar = ((AncientAltar) SlimefunItems.ANCIENT_ALTAR.getItem());
altar.getRecipes().add(altarRecipe);
Expand Down Expand Up @@ -91,7 +91,7 @@ public RecipeType(ItemStack item, String machine) {
}

public RecipeType(NamespacedKey key, SlimefunItemStack slimefunItem, String... lore) {
this(key, slimefunItem.getDelegate(), null, lore);
this(key, slimefunItem.item(), null, lore);
}

public RecipeType(NamespacedKey key, ItemStack item, BiConsumer<ItemStack[], ItemStack> callback, String... lore) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void onExecute(CommandSender sender, String[] args) {
}

Slimefun.runSync(() -> {
ItemStack item = SlimefunItems.RESTORED_BACKPACK.clone().getDelegate();
ItemStack item = SlimefunItems.RESTORED_BACKPACK.clone().item();
Slimefun.getBackpackListener().setBackpackId(backpackOwner, item, 2, id);
player.getInventory().addItem(item);
Slimefun.getLocalization().sendMessage(sender, "commands.backpack.restored-backpack-given");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DebugFishCommand extends SubCommand {
@Override
public void onExecute(CommandSender sender, String[] args) {
if (sender instanceof Player player && sender.hasPermission("slimefun.debugging")) {
player.getInventory().addItem(SlimefunItems.DEBUG_FISH.clone().getDelegate());
player.getInventory().addItem(SlimefunItems.DEBUG_FISH.clone().item());
} else {
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected void registerDefaultFuelTypes() {
registerFuel(new MachineFuel(4, new ItemStack(Material.SHROOMLIGHT)));
registerFuel(new MachineFuel(2, new ItemStack(Material.CRIMSON_FUNGUS)));
registerFuel(new MachineFuel(2, new ItemStack(Material.WARPED_FUNGUS)));
registerFuel(new MachineFuel(16, SlimefunItems.STRANGE_NETHER_GOO.getDelegate()));
registerFuel(new MachineFuel(16, SlimefunItems.STRANGE_NETHER_GOO.item()));

if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) {
registerFuel(new MachineFuel(2, new ItemStack(Material.GLOW_BERRIES)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public CombustionGenerator(ItemGroup itemGroup, SlimefunItemStack item, RecipeTy

@Override
protected void registerDefaultFuelTypes() {
registerFuel(new MachineFuel(30, SlimefunItems.OIL_BUCKET.getDelegate()));
registerFuel(new MachineFuel(90, SlimefunItems.FUEL_BUCKET.getDelegate()));
registerFuel(new MachineFuel(30, SlimefunItems.OIL_BUCKET.item()));
registerFuel(new MachineFuel(90, SlimefunItems.FUEL_BUCKET.item()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected MachineRecipe findNextRecipe(BlockMenu menu) {
ItemStack item = menu.getItemInSlot(slot);

if (item != null && item.getType().getMaxDurability() > 0 && ((Damageable) item.getItemMeta()).getDamage() > 0) {
if (SlimefunUtils.isItemSimilar(ductTape, SlimefunItems.DUCT_TAPE.getDelegate(), true, false)) {
if (SlimefunUtils.isItemSimilar(ductTape, SlimefunItems.DUCT_TAPE.item(), true, false)) {
ItemStack repairedItem = repair(item);

if (!menu.fits(repairedItem, getOutputSlots())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,25 @@ protected void registerDefaultRecipes() {
recipeList.add(new ItemStack(Material.BUCKET));

recipeList.add(new ItemStack(Material.COOKED_BEEF));
recipeList.add(SlimefunItems.BEEF_JERKY.getDelegate());
recipeList.add(SlimefunItems.BEEF_JERKY.item());

recipeList.add(new ItemStack(Material.COOKED_PORKCHOP));
recipeList.add(SlimefunItems.PORK_JERKY.getDelegate());
recipeList.add(SlimefunItems.PORK_JERKY.item());

recipeList.add(new ItemStack(Material.COOKED_CHICKEN));
recipeList.add(SlimefunItems.CHICKEN_JERKY.getDelegate());
recipeList.add(SlimefunItems.CHICKEN_JERKY.item());

recipeList.add(new ItemStack(Material.COOKED_MUTTON));
recipeList.add(SlimefunItems.MUTTON_JERKY.getDelegate());
recipeList.add(SlimefunItems.MUTTON_JERKY.item());

recipeList.add(new ItemStack(Material.COOKED_RABBIT));
recipeList.add(SlimefunItems.RABBIT_JERKY.getDelegate());
recipeList.add(SlimefunItems.RABBIT_JERKY.item());

recipeList.add(new ItemStack(Material.COOKED_COD));
recipeList.add(SlimefunItems.FISH_JERKY.getDelegate());
recipeList.add(SlimefunItems.FISH_JERKY.item());

recipeList.add(new ItemStack(Material.COOKED_SALMON));
recipeList.add(SlimefunItems.FISH_JERKY.getDelegate());
recipeList.add(SlimefunItems.FISH_JERKY.item());

if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_19)) {
recipeList.add(new ItemStack(Material.MUD));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public CarbonPress(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recip
@Override
protected void registerDefaultRecipes() {
registerRecipe(15, new ItemStack[] { new ItemStack(Material.CHARCOAL, 4) }, new ItemStack[] { new ItemStack(Material.COAL) });
registerRecipe(20, new ItemStack[] { new ItemStack(Material.COAL, 8) }, new ItemStack[] { SlimefunItems.CARBON.getDelegate() });
registerRecipe(180, new ItemStack[] { new ItemStack(Material.COAL_BLOCK, 8) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.CARBON, 9).getDelegate() });
registerRecipe(30, new ItemStack[] { new CustomItemStack(SlimefunItems.CARBON.getDelegate(), 4) }, new ItemStack[] { SlimefunItems.COMPRESSED_CARBON.getDelegate() });
registerRecipe(60, new ItemStack[] { SlimefunItems.CARBON_CHUNK.getDelegate(), SlimefunItems.SYNTHETIC_DIAMOND.getDelegate() }, new ItemStack[] { SlimefunItems.RAW_CARBONADO.getDelegate() });
registerRecipe(60, new ItemStack[] { SlimefunItems.CARBON_CHUNK.getDelegate() }, new ItemStack[] { SlimefunItems.SYNTHETIC_DIAMOND.getDelegate() });
registerRecipe(90, new ItemStack[] { SlimefunItems.RAW_CARBONADO.getDelegate() }, new ItemStack[] { SlimefunItems.CARBONADO.getDelegate() });
registerRecipe(20, new ItemStack[] { new ItemStack(Material.COAL, 8) }, new ItemStack[] { SlimefunItems.CARBON.item() });
registerRecipe(180, new ItemStack[] { new ItemStack(Material.COAL_BLOCK, 8) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.CARBON, 9).item() });
registerRecipe(30, new ItemStack[] { new CustomItemStack(SlimefunItems.CARBON.item(), 4) }, new ItemStack[] { SlimefunItems.COMPRESSED_CARBON.item() });
registerRecipe(60, new ItemStack[] { SlimefunItems.CARBON_CHUNK.item(), SlimefunItems.SYNTHETIC_DIAMOND.item() }, new ItemStack[] { SlimefunItems.RAW_CARBONADO.item() });
registerRecipe(60, new ItemStack[] { SlimefunItems.CARBON_CHUNK.item() }, new ItemStack[] { SlimefunItems.SYNTHETIC_DIAMOND.item() });
registerRecipe(90, new ItemStack[] { SlimefunItems.RAW_CARBONADO.item() }, new ItemStack[] { SlimefunItems.CARBONADO.item() });
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ protected MachineRecipe findNextRecipe(BlockMenu menu) {
for (int slot : getInputSlots()) {
ItemStack input = menu.getItemInSlot(slot);
MachineRecipe recipe = null;
if (SlimefunUtils.isItemSimilar(input, SlimefunItems.SIFTED_ORE.getDelegate(), true, false)) {
if (SlimefunUtils.isItemSimilar(input, SlimefunItems.SIFTED_ORE.item(), true, false)) {
if (!legacyMode && !hasFreeSlot(menu)) {
return null;
}

recipe = new MachineRecipe(4 / getSpeed(), new ItemStack[] { SlimefunItems.SIFTED_ORE.getDelegate() }, new ItemStack[] { oreWasher.getRandomDust() });
recipe = new MachineRecipe(4 / getSpeed(), new ItemStack[] { SlimefunItems.SIFTED_ORE.item() }, new ItemStack[] { oreWasher.getRandomDust() });

if (!legacyMode || menu.fits(recipe.getOutput()[0], getOutputSlots())) {
menu.consumeItem(slot);
return recipe;
}
} else if (SlimefunUtils.isItemSimilar(input, SlimefunItems.PULVERIZED_ORE.getDelegate(), true)) {
recipe = new MachineRecipe(4 / getSpeed(), new ItemStack[] { SlimefunItems.PULVERIZED_ORE.getDelegate() }, new ItemStack[] { SlimefunItems.PURE_ORE_CLUSTER.getDelegate() });
} else if (SlimefunUtils.isItemSimilar(input, SlimefunItems.PULVERIZED_ORE.item(), true)) {
recipe = new MachineRecipe(4 / getSpeed(), new ItemStack[] { SlimefunItems.PULVERIZED_ORE.item() }, new ItemStack[] { SlimefunItems.PURE_ORE_CLUSTER.item() });
} else if (SlimefunUtils.isItemSimilar(input, new ItemStack(Material.SAND), true)) {
recipe = new MachineRecipe(4 / getSpeed(), new ItemStack[] { new ItemStack(Material.SAND) }, new ItemStack[] { SlimefunItems.SALT.getDelegate() });
recipe = new MachineRecipe(4 / getSpeed(), new ItemStack[] { new ItemStack(Material.SAND) }, new ItemStack[] { SlimefunItems.SALT.item() });
}

if (recipe != null && menu.fits(recipe.getOutput()[0], getOutputSlots())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public List<ItemStack> getDisplayRecipes() {
protected void registerDefaultRecipes() {
// this is an extra recipe on top of PostSetup.loadSmelteryRecipes() for converting
// Vanilla Gold Ingot to Slimefun gold dust and Vanilla Copper Ingot into Slimefun copper dust
registerRecipe(3, new ItemStack(Material.GOLD_INGOT), SlimefunItems.GOLD_DUST.getDelegate());
registerRecipe(3, new ItemStack(Material.GOLD_INGOT), SlimefunItems.GOLD_DUST.item());

if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) {
registerRecipe(3, new ItemStack(Material.COPPER_INGOT), SlimefunItems.COPPER_DUST.getDelegate());
registerRecipe(3, new ItemStack(Material.COPPER_INGOT), SlimefunItems.COPPER_DUST.item());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ElectricPress(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec

@Override
protected void registerDefaultRecipes() {
addRecipe(4, new SlimefunItemStack(SlimefunItems.STONE_CHUNK, 3).getDelegate(), new ItemStack(Material.COBBLESTONE));
addRecipe(4, new SlimefunItemStack(SlimefunItems.STONE_CHUNK, 3).item(), new ItemStack(Material.COBBLESTONE));
addRecipe(4, new ItemStack(Material.FLINT, 6), new ItemStack(Material.COBBLESTONE));
addRecipe(5, new ItemStack(Material.GLASS), new ItemStack(Material.GLASS_PANE, 3));
addRecipe(4, new ItemStack(Material.SNOWBALL, 4), new ItemStack(Material.SNOW_BLOCK));
Expand All @@ -44,15 +44,15 @@ protected void registerDefaultRecipes() {
addRecipe(3, new ItemStack(Material.CLAY_BALL, 4), new ItemStack(Material.CLAY));
addRecipe(3, new ItemStack(Material.BRICK, 4), new ItemStack(Material.BRICKS));

addRecipe(6, SlimefunItems.COPPER_INGOT.getDelegate(), new CustomItemStack(SlimefunItems.COPPER_WIRE.getDelegate(), 3));
addRecipe(6, SlimefunItems.COPPER_INGOT.item(), new CustomItemStack(SlimefunItems.COPPER_WIRE.item(), 3));
addRecipe(16, new SlimefunItemStack(SlimefunItems.STEEL_INGOT, 8), SlimefunItems.STEEL_PLATE);
addRecipe(18, new SlimefunItemStack(SlimefunItems.REINFORCED_ALLOY_INGOT, 8), SlimefunItems.REINFORCED_PLATE);

addRecipe(8, new ItemStack(Material.NETHER_WART), new CustomItemStack(SlimefunItems.MAGIC_LUMP_1.getDelegate(), 2));
addRecipe(8, new ItemStack(Material.NETHER_WART), new CustomItemStack(SlimefunItems.MAGIC_LUMP_1.item(), 2));
addRecipe(10, new SlimefunItemStack(SlimefunItems.MAGIC_LUMP_1, 4), SlimefunItems.MAGIC_LUMP_2);
addRecipe(12, new SlimefunItemStack(SlimefunItems.MAGIC_LUMP_2, 4), SlimefunItems.MAGIC_LUMP_3);

addRecipe(10, new ItemStack(Material.ENDER_EYE), new CustomItemStack(SlimefunItems.ENDER_LUMP_1.getDelegate(), 2));
addRecipe(10, new ItemStack(Material.ENDER_EYE), new CustomItemStack(SlimefunItems.ENDER_LUMP_1.item(), 2));
addRecipe(12, new SlimefunItemStack(SlimefunItems.ENDER_LUMP_1, 4), SlimefunItems.ENDER_LUMP_2);
addRecipe(14, new SlimefunItemStack(SlimefunItems.ENDER_LUMP_2, 4), SlimefunItems.ENDER_LUMP_3);

Expand Down Expand Up @@ -94,7 +94,7 @@ private void addRecipe(int seconds, ItemStack input, ItemStack output) {

@ParametersAreNonnullByDefault
private void addRecipe(int seconds, SlimefunItemStack sfItem1, SlimefunItemStack sfItem2) {
registerRecipe(seconds, sfItem1.getDelegate(), sfItem2.getDelegate());
registerRecipe(seconds, sfItem1.item(), sfItem2.item());
}

@Override
Expand Down
Loading

0 comments on commit b646376

Please sign in to comment.