Skip to content

Commit 35d9b80

Browse files
authored
Merge pull request #124 from Conno2429/1.7-port
Conno's 1.7.3 bump & fixes
2 parents eaef0d9 + 3da1501 commit 35d9b80

9 files changed

Lines changed: 235 additions & 58 deletions

File tree

common/src/main/java/generations/gg/generations/core/generationscore/common/battle/GenerationsInstructionProcessor.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ object GenerationsInstructionProcessor {
5454
val name = s3[1]
5555

5656
val ability = battlePokemon.originalPokemon.ability.name
57-
battlePokemon.originalPokemon.persistentData.putString("original_ability", ability)
57+
58+
// Prevent terapagos original ability from becoming tera shell instead of tera shift
59+
if (name != "stellar") {
60+
battlePokemon.originalPokemon.persistentData.putString("original_ability", ability)
61+
}
5862

5963
if (effectedPokemon.form.name.equals("Dusk-Mane")) {
6064
battlePokemon.originalPokemon.persistentData.putString("necro_fusion", "dusk")

common/src/main/java/generations/gg/generations/core/generationscore/common/client/InteractWheelGuiFactoryProxy.kt

Lines changed: 146 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,50 +28,173 @@ import com.google.common.collect.Multimap
2828
import generations.gg.generations.core.generationscore.common.GenerationsCore
2929
import generations.gg.generations.core.generationscore.common.network.GenerationsNetwork
3030
import generations.gg.generations.core.generationscore.common.network.packets.GensInteractPokemonPacket
31+
import java.util.UUID
3132
import net.minecraft.client.Minecraft
3233
import net.minecraft.network.chat.Component
33-
import java.util.*
3434
import org.joml.Vector3f
3535

3636
fun createPokemonInteractGui(
3737
pokemonID: UUID,
38-
canMountShoulder: Boolean,
38+
canMountShoulder:
39+
Boolean,
3940
canGiveHeld: Boolean,
4041
canGiveCosmetic: Boolean,
4142
canRide: Boolean,
42-
changeFormData: Pair<Boolean, String>): InteractWheelGUI {
43-
43+
changeFormData: Pair<Boolean, String>
44+
): InteractWheelGUI {
4445
val mountShoulder = InteractWheelOption(
45-
iconResource = cobblemonResource("textures/gui/interact/icon_shoulder.png"),
46+
iconResource = cobblemonResource("textures/gui/interact/interact_wheel_icon_shoulder.png"),
4647
tooltipText = "cobblemon.ui.interact.mount.shoulder",
48+
enabled = canMountShoulder,
4749
onPress = {
4850
if (canMountShoulder) {
4951
InteractPokemonPacket(pokemonID, InteractTypePokemon.SHOULDER).sendToServer()
5052
closeGUI()
5153
}
5254
}
5355
)
54-
val giveItem = InteractWheelOption(
55-
iconResource = cobblemonResource("textures/gui/interact/icon_held_item.png"),
56+
val giveHeldItem = InteractWheelOption(
57+
iconResource = cobblemonResource("textures/gui/interact/interact_wheel_icon_held_item.png"),
5658
tooltipText = "cobblemon.ui.interact.give.item",
59+
enabled = canGiveHeld,
5760
onPress = {
58-
InteractPokemonPacket(pokemonID, InteractTypePokemon.HELD_ITEM).sendToServer()
59-
closeGUI()
61+
if (canGiveHeld) {
62+
InteractPokemonPacket(pokemonID, InteractTypePokemon.HELD_ITEM).sendToServer()
63+
closeGUI()
64+
}
65+
}
66+
)
67+
val giveCosmeticItem = InteractWheelOption(
68+
iconResource = cobblemonResource("textures/gui/interact/interact_wheel_icon_cosmetic_item.png"),
69+
tooltipText = "cobblemon.ui.interact.give.cosmetic_item",
70+
enabled = canGiveCosmetic,
71+
onPress = {
72+
if (canGiveCosmetic) {
73+
InteractPokemonPacket(pokemonID, InteractTypePokemon.COSMETIC_ITEM).sendToServer()
74+
closeGUI()
75+
}
76+
}
77+
)
78+
79+
val ride = InteractWheelOption(
80+
iconResource = cobblemonResource("textures/gui/interact/interact_wheel_icon_ride.png"),
81+
tooltipText = "cobblemon.ui.interact.ride",
82+
enabled = canRide,
83+
onPress = {
84+
if (canRide) {
85+
InteractPokemonPacket(pokemonID, InteractTypePokemon.RIDE).sendToServer()
86+
closeGUI()
87+
}
6088
}
6189
)
6290

6391
val options: Multimap<Orientation, InteractWheelOption> = ArrayListMultimap.create()
64-
options.put(Orientation.NORTHWEST, giveItem)
65-
if (canMountShoulder) {
66-
options.put(Orientation.NORTHEAST, mountShoulder)
67-
}
92+
options.put(Orientation.NORTH, giveHeldItem)
93+
options.put(Orientation.NORTHEAST, giveCosmeticItem)
94+
options.put(Orientation.WEST, ride)
95+
options.put(Orientation.NORTHWEST, mountShoulder)
6896

69-
createOption(pokemonID, changeFormData)?.also { options.put(Orientation.SOUTHWEST, it) }
97+
createOption(pokemonID, changeFormData)?.also { options.put(Orientation.EAST, it) }
7098

71-
CobblemonEvents.POKEMON_INTERACTION_GUI_CREATION.post(PokemonInteractionGUICreationEvent(pokemonID, canMountShoulder, true, false /* TOODO: is the items given cosmetic in thsi context? */, false /* TODO: I'm not even sure about this part. */, options))
99+
CobblemonEvents.POKEMON_INTERACTION_GUI_CREATION.post(PokemonInteractionGUICreationEvent(
100+
pokemonID = pokemonID,
101+
mountShoulder = canMountShoulder,
102+
giveHeld = canGiveHeld,
103+
giveCosmetic = canGiveCosmetic,
104+
canRide = canRide,
105+
options = options
106+
))
72107
return InteractWheelGUI(options, Component.translatable("cobblemon.ui.interact.pokemon"))
73108
}
74109

110+
fun createPlayerInteractGui(optionsPacket: PlayerInteractOptionsPacket): InteractWheelGUI {
111+
val trade = InteractWheelOption(
112+
iconResource = cobblemonResource("textures/gui/interact/interact_wheel_icon_trade.png"),
113+
secondaryIconResource = if (CobblemonClient.requests.tradeOffers[optionsPacket.targetId] != null)
114+
cobblemonResource("textures/gui/interact/interact_wheel_icon_exclamation.png")
115+
else null,
116+
colour = { null },
117+
tooltipText = "cobblemon.ui.interact.trade",
118+
onPress = {
119+
val tradeOffer = CobblemonClient.requests.tradeOffers[optionsPacket.targetId]
120+
if (tradeOffer == null) {
121+
CobblemonNetwork.sendToServer(OfferTradePacket(optionsPacket.targetId))
122+
} else {
123+
CobblemonClient.requests.tradeOffers.remove(optionsPacket.targetId)
124+
CobblemonNetwork.sendToServer(AcceptTradeRequestPacket(tradeOffer.requestID))
125+
}
126+
closeGUI()
127+
}
128+
)
129+
val activeBattleRequest = CobblemonClient.requests.battleChallenges[optionsPacket.targetId]
130+
val activeTeamRequest = CobblemonClient.requests.multiBattleTeamRequests[optionsPacket.targetId]
131+
val battle = InteractWheelOption(
132+
iconResource = cobblemonResource("textures/gui/interact/interact_wheel_icon_battle.png"),
133+
secondaryIconResource = if(activeBattleRequest != null|| activeTeamRequest != null)
134+
cobblemonResource("textures/gui/interact/interact_wheel_icon_exclamation.png")
135+
else null,
136+
colour = { null },
137+
tooltipText = "cobblemon.ui.interact.battle",
138+
onPress = {
139+
Minecraft.getInstance().setScreen(BattleConfigureGUI(optionsPacket, activeBattleRequest, activeTeamRequest))
140+
}
141+
)
142+
143+
val spectate = InteractWheelOption(
144+
iconResource = cobblemonResource("textures/gui/interact/interact_wheel_icon_spectate_battle.png"),
145+
colour = { if (CobblemonClient.requests.battleChallenges[optionsPacket.targetId] != null) Vector3f(0F, 0.6F, 0F) else null },
146+
onPress = {
147+
SpectateBattlePacket(optionsPacket.targetId).sendToServer()
148+
closeGUI()
149+
},
150+
tooltipText = "cobblemon.ui.interact.spectate"
151+
)
152+
val options: Multimap<Orientation, InteractWheelOption> = ArrayListMultimap.create()
153+
// TODO: hasChallenge and hasTeamRequest get calculated a bunch of times. Might consider having the server just passing it over.
154+
val hasChallenge = CobblemonClient.requests.battleChallenges[optionsPacket.targetId] != null
155+
val hasTeamRequest = CobblemonClient.requests.multiBattleTeamRequests[optionsPacket.targetId] != null
156+
// The way things are positioned should probably be more thought out if more options are added
157+
var addBattleOption = false
158+
optionsPacket.options.forEach {
159+
if (!addBattleOption && (hasChallenge || hasTeamRequest || BattleConfigureGUI.battleRequestMap.containsKey(it.key))) {
160+
if(it.value === PlayerInteractOptionsPacket.OptionStatus.AVAILABLE) {
161+
options.put(Orientation.NORTH, battle)
162+
addBattleOption = true
163+
} else {
164+
options.put(Orientation.NORTH, InteractWheelOption(
165+
iconResource = cobblemonResource("textures/gui/interact/interact_wheel_icon_battle.png"),
166+
secondaryIconResource = null,
167+
colour = { Vector3f(0.5f, 0.5f, 0.5f) },
168+
tooltipText = getLangKey(it.value),
169+
onPress = {}
170+
))
171+
}
172+
}
173+
if (it.key == PlayerInteractOptionsPacket.Options.SPECTATE_BATTLE) {
174+
if(!hasChallenge) {
175+
options.put(Orientation.NORTH, spectate)
176+
}
177+
}
178+
if (it.key == PlayerInteractOptionsPacket.Options.TRADE) {
179+
if (it.value == PlayerInteractOptionsPacket.OptionStatus.AVAILABLE) {
180+
options.put(Orientation.NORTHEAST, trade)
181+
} else {
182+
val langKey = getLangKey(it.value)
183+
options.put(
184+
Orientation.NORTHEAST, InteractWheelOption(
185+
iconResource = cobblemonResource("textures/gui/interact/interact_wheel_icon_trade.png"),
186+
secondaryIconResource = null,
187+
colour = { Vector3f(0.5f, 0.5f, 0.5f) },
188+
tooltipText = langKey,
189+
onPress = {}
190+
))
191+
}
192+
}
193+
}
194+
195+
return InteractWheelGUI(options, Component.translatable("cobblemon.ui.interact.player"))
196+
}
197+
75198
fun createOption(pokemonID: UUID, changeFormData: Pair<Boolean, String>): InteractWheelOption? {
76199
var path = ""
77200
var aspect = changeFormData.second
@@ -118,6 +241,14 @@ fun createOption(pokemonID: UUID, changeFormData: Pair<Boolean, String>): Intera
118241
return null
119242
}
120243

244+
private fun getLangKey(status: PlayerInteractOptionsPacket.OptionStatus) : String {
245+
return when (status) {
246+
PlayerInteractOptionsPacket.OptionStatus.TOO_FAR -> "cobblemon.ui.interact.too_far"
247+
PlayerInteractOptionsPacket.OptionStatus.INSUFFICIENT_POKEMON -> "cobblemon.battle.error.no_pokemon_opponent"
248+
else -> "cobblemon.ui.interact.unavailable"
249+
}
250+
}
251+
121252
private fun closeGUI() {
122253
Minecraft.getInstance().setScreen(null)
123254
}

common/src/main/java/generations/gg/generations/core/generationscore/common/config/SpeciesKey.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ data class SpeciesKey(val species: ResourceLocation, val aspects: Set<String> =
4343
val properties = createProperties()
4444
properties.level = level
4545
val pokemon = properties.create()
46-
// pokemon.setAspects(aspects());
46+
pokemon.forcedAspects = aspects
4747
return pokemon
4848
}
4949

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
package generations.gg.generations.core.generationscore.common.mixin;
22

3-
import com.cobblemon.mod.common.api.riding.behaviour.RidingBehaviour;
4-
import com.cobblemon.mod.common.api.riding.behaviour.RidingBehaviourSettings;
5-
import com.cobblemon.mod.common.api.riding.behaviour.RidingBehaviourState;
63
import com.cobblemon.mod.common.entity.PlatformType;
74
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
5+
import com.cobblemon.mod.common.util.PlayerExtensionsKt;
86
import generations.gg.generations.core.generationscore.common.network.packets.GensInteractPokemonUIPacket;
97
import generations.gg.generations.core.generationscore.common.util.PokemonEntityFunctionsKt;
108
import generations.gg.generations.core.generationscore.common.world.entity.PokemonInteractProxy;
11-
import kotlin.jvm.functions.Function3;
129
import net.minecraft.server.level.ServerPlayer;
1310
import net.minecraft.world.InteractionHand;
1411
import net.minecraft.world.InteractionResult;
1512
import net.minecraft.world.entity.player.Player;
1613
import net.minecraft.world.item.ItemStack;
17-
import org.jetbrains.annotations.NotNull;
1814
import org.spongepowered.asm.mixin.Mixin;
19-
import org.spongepowered.asm.mixin.Shadow;
2015
import org.spongepowered.asm.mixin.injection.At;
2116
import org.spongepowered.asm.mixin.injection.Inject;
2217
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@@ -32,35 +27,61 @@ private void showInteractionWheel(ServerPlayer player, ItemStack itemStack, Call
3227
ci.cancel();
3328
}
3429

30+
@Inject(method = "mobInteract", at = @At("HEAD"), cancellable = true)
31+
private void generations$customShoulderMega(Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir) {
32+
PokemonEntity self = (PokemonEntity) (Object) this;
3533

36-
// @Inject(method = "mobInteract", at = @At("HEAD"), cancellable = true)
37-
// private void generations$customShoulderMega(Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir) {
38-
// PokemonEntity self = (PokemonEntity) (Object) this;
39-
//
40-
// if (hand == InteractionHand.MAIN_HAND && player instanceof ServerPlayer serverPlayer && self.getPokemon().getOwnerPlayer() == player) {
41-
// if (player.isShiftKeyDown()) {
42-
// boolean canMount = self.canSitOnShoulder();
43-
// boolean canChangeForm = PokemonEntityFunctionsKt.canChangeForm(self).getFirst();
44-
// String aspect = PokemonEntityFunctionsKt.canChangeForm(self).getSecond();
45-
//
46-
// System.out.println(self.getAspects());
47-
// if (!aspect.isEmpty() && self.getAspects().contains(aspect) || self.getAspects().contains("primal") || self.getAspects().contains("ultra-fusion")) {
48-
// aspect = "revert";
49-
// }
50-
//
51-
// Pair<Boolean, String> changeFormData = new Pair<>(canChangeForm, aspect);
52-
//
53-
// new GensInteractPokemonUIPacket(self.getUUID(), canMount, changeFormData).sendToPlayer(serverPlayer);
54-
// cir.setReturnValue(InteractionResult.SUCCESS);
55-
// return;
56-
// } else {
57-
// if (((PokemonEntityAccessor) self).invokeAttemptItemInteraction(serverPlayer, player.getItemInHand(hand))) {
58-
// cir.setReturnValue(InteractionResult.SUCCESS);
59-
// return;
60-
// }
61-
// }
62-
// }
63-
// }
64-
//
34+
if (hand == InteractionHand.MAIN_HAND && player instanceof ServerPlayer serverPlayer && self.getPokemon().getOwnerPlayer() == player) {
35+
if (player.isShiftKeyDown()) {
36+
ItemStack itemStack = player.getItemInHand(hand);
6537

38+
boolean canMount = self.canSitOnShoulder() && PlayerExtensionsKt.party(serverPlayer).toGappyList().contains(self.getPokemon());
39+
40+
boolean canGiveHeld = !(self.getPokemon().heldItem().isEmpty() && itemStack.isEmpty());
41+
42+
var cosmeticItemDefinition = com.cobblemon.mod.common.CobblemonCosmeticItems.findValidCosmeticForPokemonAndItem(
43+
serverPlayer.level().registryAccess(),
44+
self.getPokemon(),
45+
itemStack
46+
);
47+
48+
boolean canGiveCosmetic =
49+
(!self.getPokemon().getCosmeticItem().isEmpty() && itemStack.isEmpty())
50+
|| cosmeticItemDefinition != null;
51+
52+
boolean canRide = self.ifRidingAvailableSupply(false, (behaviour, settings, state) -> {
53+
if (self.getPlatform() != PlatformType.NONE) return false;
54+
if (self.getTethering() != null) return false;
55+
if (self.getSeats().isEmpty()) return false;
56+
if ((self.getOwner() instanceof ServerPlayer sp) && PlayerExtensionsKt.isInBattle(serverPlayer)) return false;
57+
if (self.getOwner() != serverPlayer && self.getPassengers().isEmpty()) return false;
58+
return behaviour.isActive(settings, state, self);
59+
});
60+
61+
boolean canChangeForm = PokemonEntityFunctionsKt.canChangeForm(self).getFirst();
62+
String aspect = PokemonEntityFunctionsKt.canChangeForm(self).getSecond();
63+
64+
if (!aspect.isEmpty() && self.getAspects().contains(aspect)
65+
|| self.getAspects().contains("primal")
66+
|| self.getAspects().contains("ultra-fusion")) {
67+
aspect = "revert";
68+
}
69+
70+
Pair<Boolean, String> changeFormData = new Pair<>(canChangeForm, aspect);
71+
72+
new GensInteractPokemonUIPacket(
73+
self.getUUID(),
74+
canMount,
75+
canGiveHeld,
76+
canGiveCosmetic,
77+
canRide,
78+
changeFormData
79+
).sendToPlayer(serverPlayer);
80+
81+
cir.setReturnValue(InteractionResult.SUCCESS);
82+
return;
83+
}
84+
85+
}
86+
}
6687
}

common/src/main/java/generations/gg/generations/core/generationscore/common/network/packets/GensInteractPokemonUIPacket.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class GensInteractPokemonUIPacket(
2626
val canGiveHeld: Boolean,
2727
val canGiveCosmetic: Boolean,
2828
val canRide: Boolean,
29-
val changeFormData: Pair<Boolean, String>): NetworkPacket<GensInteractPokemonUIPacket> {
29+
val changeFormData: Pair<Boolean, String>
30+
): NetworkPacket<GensInteractPokemonUIPacket> {
3031

3132
override val id = ID
3233

common/src/main/java/generations/gg/generations/core/generationscore/common/util/PokemonFunctions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ fun ItemStack.getPokemon(): Pokemon? {
189189

190190
fun Pokemon.fixIVS() {
191191
println("Name: ${this.species.name}")
192-
val special = isLegendary() || isUltraBeast() || species.name == "ursaluna-bloodmoon" || species.name in setOf(
192+
val special = isLegendary() || isUltraBeast() || isMythical() || species.name == "ursaluna-bloodmoon" || species.name in setOf(
193193
"Gouging Fire",
194194
"Raging Bolt",
195195
"Walking Wake",

common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/GenerationsItems.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@ object GenerationsItems: ItemPlatformRegistry() {
16461646
createFormChangingItem(
16471647
it,
16481648
"type",
1649-
type.name,
1649+
type.showdownId,
16501650
cobblemonResource("arceus")
16511651
).also { CobblemonHeldItemManager.registerRemap(it, name.replace("_", "")) }
16521652
},
@@ -1672,7 +1672,7 @@ object GenerationsItems: ItemPlatformRegistry() {
16721672
createFormChangingItem(
16731673
it,
16741674
"type",
1675-
type.name,
1675+
type.showdownId(),
16761676
cobblemonResource("silvally")
16771677
).also { CobblemonHeldItemManager.registerRemap(it, name.replace("_", "").replace("drive", "")) }
16781678
},

0 commit comments

Comments
 (0)