-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
106 additions
and
39 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
2 changes: 1 addition & 1 deletion
2
src/main/java/fr/unreal852/quantum/callback/PlayerRespawnHandler.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
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
65 changes: 65 additions & 0 deletions
65
src/main/java/fr/unreal852/quantum/command/CreatePortalCommand.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,65 @@ | ||
package fr.unreal852.quantum.command | ||
|
||
import com.mojang.brigadier.Command | ||
import com.mojang.brigadier.CommandDispatcher | ||
import com.mojang.brigadier.context.CommandContext | ||
import fr.unreal852.quantum.Quantum | ||
import fr.unreal852.quantum.command.suggestion.BlocksSuggestionProvider | ||
import fr.unreal852.quantum.command.suggestion.WorldsDimensionSuggestionProvider | ||
import net.kyrptonaught.customportalapi.api.CustomPortalBuilder | ||
import net.minecraft.command.argument.DimensionArgumentType | ||
import net.minecraft.command.argument.IdentifierArgumentType | ||
import net.minecraft.item.Items | ||
import net.minecraft.server.command.CommandManager | ||
import net.minecraft.server.command.ServerCommandSource | ||
|
||
class CreatePortalCommand : Command<ServerCommandSource> { | ||
override fun run(context: CommandContext<ServerCommandSource>): Int { | ||
|
||
if (context.source == null) | ||
return 0 | ||
|
||
try { | ||
|
||
val portalBlock = IdentifierArgumentType.getIdentifier(context, PORTAL_BLOCK_ARG) | ||
val destinationWorld = IdentifierArgumentType.getIdentifier(context, PORTAL_DESTINATION_ARG) | ||
|
||
CustomPortalBuilder.beginPortal() | ||
.frameBlock(portalBlock) | ||
.lightWithItem(Items.DIAMOND) | ||
.destDimID(destinationWorld) | ||
.tintColor(255, 0, 0) | ||
.registerPortal() | ||
|
||
} catch (e: Exception) { | ||
Quantum.LOGGER.error("An error occurred while creating the world.", e) | ||
} | ||
|
||
return 1 | ||
} | ||
|
||
companion object { | ||
|
||
private const val PORTAL_BLOCK_ARG = "portalFrameBlock" | ||
private const val PORTAL_DESTINATION_ARG = "destinationWorld" | ||
|
||
fun register(dispatcher: CommandDispatcher<ServerCommandSource>) { | ||
dispatcher.register(CommandManager.literal("qt") | ||
.then(CommandManager.literal("createportal") | ||
.requires { commandSource: ServerCommandSource -> commandSource.hasPermissionLevel(4) } | ||
.then( | ||
CommandManager.argument(PORTAL_BLOCK_ARG, IdentifierArgumentType.identifier()) | ||
.suggests(BlocksSuggestionProvider()) | ||
.executes(CreatePortalCommand()) | ||
.then( | ||
CommandManager.argument(PORTAL_DESTINATION_ARG, DimensionArgumentType.dimension()) | ||
.suggests(WorldsDimensionSuggestionProvider()) | ||
.executes(CreatePortalCommand()) | ||
) | ||
) | ||
) | ||
) | ||
} | ||
} | ||
} | ||
|
29 changes: 29 additions & 0 deletions
29
src/main/java/fr/unreal852/quantum/portal/QuantumPortalData.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,29 @@ | ||
package fr.unreal852.quantum.portal | ||
|
||
import net.minecraft.util.Identifier | ||
|
||
class QuantumPortalData { | ||
|
||
val isEnabled: Boolean = true | ||
|
||
lateinit var destinationId: Identifier | ||
private set | ||
|
||
lateinit var portalBlockId: Identifier | ||
private set | ||
|
||
lateinit var portalIgniteItemId: Identifier | ||
private set | ||
|
||
var portalColor: Int = 0 | ||
private set | ||
|
||
constructor() | ||
|
||
constructor(destId: Identifier, portalBlockId: Identifier, portalIgniteItemId: Identifier, color: Int) { | ||
this.destinationId = destId | ||
this.portalBlockId = portalBlockId | ||
this.portalIgniteItemId = portalIgniteItemId | ||
this.portalColor = color | ||
} | ||
} |
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
34 changes: 0 additions & 34 deletions
34
src/main/java/fr/unreal852/quantum/world/config/QuantumPortalConfig.kt
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...um/world/states/QuantumPersistentState.kt → ...tum/world/state/QuantumPersistentState.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
2 changes: 1 addition & 1 deletion
2
...rld/states/QuantumWorldPersistentState.kt → ...orld/state/QuantumWorldPersistentState.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