-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed the professions manager, now when you click on any profession…
… it open corresponding building screen, to hire the pawns in there.
- Loading branch information
Showing
6 changed files
with
86 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...tworking/java/net/remmintan/mods/minefortress/networking/c2s/C2SOpenBuildingHireScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package net.remmintan.mods.minefortress.networking.c2s | ||
|
||
import net.minecraft.network.PacketByteBuf | ||
import net.minecraft.screen.NamedScreenHandlerFactory | ||
import net.minecraft.server.MinecraftServer | ||
import net.minecraft.server.network.ServerPlayerEntity | ||
import net.remmintan.mods.minefortress.core.interfaces.networking.FortressC2SPacket | ||
|
||
class C2SOpenBuildingHireScreen(val profId: String) : FortressC2SPacket { | ||
|
||
companion object { | ||
const val CHANNEL = "open_building_hire_screen" | ||
} | ||
|
||
constructor(buf: PacketByteBuf) : this(buf.readString()) | ||
|
||
override fun write(buf: PacketByteBuf) { | ||
buf.writeString(profId) | ||
} | ||
|
||
override fun handle(server: MinecraftServer?, player: ServerPlayerEntity?) { | ||
val provider = getManagersProvider(server, player) | ||
val manager = provider.professionsManager | ||
|
||
val profession = manager.getProfession(profId) | ||
val requirementType = profession.getRequirementType() | ||
val requirementLevel = profession.getRequirementLevel() | ||
val buildings = provider.buildingsManager.getBuildings(requirementType, requirementLevel) | ||
if (buildings.isNotEmpty()) { | ||
val building = buildings[0] | ||
if (building is NamedScreenHandlerFactory) { | ||
player!!.openHandledScreen(building) | ||
//player.currentScreenHandler. | ||
// TODO tell screen handler or building to open hire menu | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters