Skip to content

Commit 90aba7b

Browse files
authored
Merge pull request RobertSkalko#6 from SaloEater/Command-give-map-gives-correct-rarity
Command /mns give map now gives correct map rarity
2 parents c031c72 + d4f1472 commit 90aba7b

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/main/java/com/robertx22/addons/dungeon_realm/DungeonAddonEvents.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static boolean checkCooldown(Player p) {
157157
}
158158

159159
static boolean meetsResists(Player p, MapItemData data) {
160-
if (!data.getStatReq().meetsReq(Load.Unit(p).getLevel(), Load.Unit(p))) {
160+
if (!data.getStatReq().meetsReq(Load.Unit(p).getLevel(), Load.Unit(p)) && !p.isCreative()) {
161161
ExplainedResultUtil.sendErrorMessage(p, Chats.MAP_DEVICE_USE_ERROR, Chats.RESISTS_TOO_LOW_FOR_MAP);
162162

163163
List<Component> reqDifference = data.getStatReq().getReqDifference(data.lvl, Load.Unit(p));

src/main/java/com/robertx22/mine_and_slash/vanilla_mc/commands/giveitems/GiveMap.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
import com.robertx22.mine_and_slash.database.registry.ExileDB;
88
import com.robertx22.mine_and_slash.loot.LootInfo;
99
import com.robertx22.mine_and_slash.loot.blueprints.MapBlueprint;
10+
import com.robertx22.mine_and_slash.uncommon.datasaving.StackSaving;
1011
import com.robertx22.mine_and_slash.uncommon.utilityclasses.PlayerUtils;
1112
import com.robertx22.mine_and_slash.vanilla_mc.commands.CommandRefs;
1213
import com.robertx22.mine_and_slash.vanilla_mc.commands.suggestions.GearRaritySuggestions;
1314
import net.minecraft.commands.CommandSourceStack;
1415
import net.minecraft.commands.arguments.EntityArgument;
1516
import net.minecraft.world.entity.player.Player;
17+
import net.minecraft.world.item.ItemStack;
1618

1719
import java.util.Objects;
1820

@@ -48,16 +50,20 @@ private static int execute(CommandSourceStack commandSource, Player player, int
4850
}
4951
}
5052
for (int i = 0; i < amount; i++) {
51-
MapBlueprint blueprint = new MapBlueprint(LootInfo.ofLevel(lvl));
52-
blueprint.level.set(lvl);
53+
MapBlueprint blueprint = new MapBlueprint(LootInfo.ofLevel(1));
54+
ItemStack mapStack = blueprint.createStack();
55+
56+
MapBlueprint b = new MapBlueprint(LootInfo.ofLevel(lvl));
57+
b.level.set(lvl);
5358

5459
if (ExileDB.GearRarities()
5560
.isRegistered(rarity)) {
56-
blueprint.rarity.set(ExileDB.GearRarities()
61+
b.rarity.set(ExileDB.GearRarities()
5762
.get(rarity));
5863
}
5964

60-
PlayerUtils.giveItem(blueprint.createStack(), player);
65+
StackSaving.MAP.saveTo(mapStack, b.createData());
66+
PlayerUtils.giveItem(mapStack, player);
6167
}
6268

6369
return 0;

0 commit comments

Comments
 (0)