Skip to content

Commit

Permalink
Patched back-dating bugs
Browse files Browse the repository at this point in the history
- How CuboidClipboard handles offsets and things is slightly differnt - so altered all that.
- There is no support for sponge schem files, so replaced purple.schem with ruins.schematic
- Soe other accidental mistakes during conversion
  • Loading branch information
BuildTools committed Apr 22, 2020
1 parent 3a55258 commit 922feb7
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 17 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ dependencies {
testImplementation "org.mockito:mockito-core:3.3.+"
}


processResources {
// auto assign values in the plugin.yml
// Do not filter schematics as they get corrupted when trying to be read as text
filesNotMatching("**.schem") {
filesNotMatching(["**.schematic"]) {
filter {
line ->
line
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/mdsimmo/bomberman/Bomberman.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public BmSetting getSettings() {

private void extractResources() {
String[] schematics = new String[] {
"purple.schem"
"ruins.schematic"
};
for (String schem : schematics) {
try (InputStream input = new BufferedInputStream(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class GameCreate(parent: Cmd) : Cmd(parent) {

private fun defaultSchema(plugin: String): String? {
return when(plugin.toLowerCase()) {
"bm", "bomberman" -> "purple"
"bm", "bomberman" -> "ruins"
else -> null
}
}
Expand Down Expand Up @@ -168,8 +168,8 @@ class GameCreate(parent: Cmd) : Cmd(parent) {
val box = selectionBounds(region)
val game = buildGameFromRegion(gameName, box, flags)
Text.CREATE_SUCCESS.with("game", game).sendTo(sender)
} catch (e: IncompleteRegionException) { // FIXME can selection occur in world other than selection?
throw RuntimeException("Selection World different to selection", e)
} catch (e: IncompleteRegionException) {
context(Text.CREATE_NEED_SELECTION).sendTo(sender)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class Explosion private constructor(
private fun isPassing(b: Block, settings: GameSettings): Boolean {
val t = b.type
return t == Material.AIR || t == settings.fireType
|| (t.isSolid && !(settings.indestructible.contains(t) || settings.destructible.contains(t)))
|| (!t.isSolid && !(settings.indestructible.contains(t) || settings.destructible.contains(t)))
|| settings.passDestroy.contains(t)
|| settings.passKeep.contains(t)
|| settings.passRevert.contains(t)
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/io/github/mdsimmo/bomberman/game/Game.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
@file:Suppress("DEPRECATION")

package io.github.mdsimmo.bomberman.game

import com.sk89q.worldedit.BlockVector
import com.sk89q.worldedit.CuboidClipboard
import com.sk89q.worldedit.Vector
import com.sk89q.worldedit.WorldEdit
import com.sk89q.worldedit.bukkit.BukkitWorld
import com.sk89q.worldedit.regions.CuboidRegion
Expand Down Expand Up @@ -175,7 +178,7 @@ class Game private constructor(val name: String, private var schema: Arena, val

plugin.logger.info("Searching for spawns...")
val spawns = mutableSetOf<Location>()
for (loc in CuboidRegion(clip.origin, clip.origin.add(clip.offset))) {
for (loc in CuboidRegion(Vector.ZERO, clip.size.subtract(1, 1, 1))) {
val block = clip.getBlock(loc)
block.nbtData?.let {
if (
Expand All @@ -185,8 +188,7 @@ class Game private constructor(val name: String, private var schema: Arena, val
it.getString("Text4").contains("[spawn]", ignoreCase = true)
) {
spawns += Location(box.world, loc.x, loc.y, loc.z)
.subtract(clip.origin.x, clip.origin.y, clip.origin.z)
.add(origin)
.add(origin).add(clip.offset.x, clip.offset.y, clip.offset.z)
}
}
}
Expand All @@ -208,7 +210,7 @@ class Game private constructor(val name: String, private var schema: Arena, val

// Paste the schematic
val editSession = WorldEdit.getInstance().editSessionFactory.getEditSession(BukkitWorld(box.world) as World, -1)
val operation = clip.paste(editSession, BlockVector(origin.blockX, origin.blockY, origin.blockZ), flags.skipAir)
clip.paste(editSession, BlockVector(origin.blockX, origin.blockY, origin.blockZ), flags.skipAir)
editSession.flushQueue()

// TODO undo arena build
Expand Down Expand Up @@ -305,8 +307,7 @@ class Game private constructor(val name: String, private var schema: Arena, val
val clip = schema.loadClipboard()
val editSession = WorldEdit.getInstance().editSessionFactory
.getEditSession(BukkitWorld(schema.origin.world) as World, -1)
val offset = BlockVector(schema.origin.x, schema.origin.y, schema.origin.z)
.subtract(clip.origin)
val offset = BlockVector(schema.origin.x, schema.origin.y, schema.origin.z).add(clip.offset)
spawnBlocks()
.filter { (isSpawn, _) ->
replaceSpawnSign or !isSpawn
Expand All @@ -324,7 +325,7 @@ class Game private constructor(val name: String, private var schema: Arena, val
spawnBlocks().forEach { (sign, block) ->
if (sign) {
block.type = Material.AIR
} else if (block.type.isSolid) {
} else if (!block.type.isSolid) {
block.type = Material.STAINED_GLASS
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ class GameSettings : ConfigurationSerializable {
Pair(Material.SNOW_BLOCK, it),
Pair(Material.DIRT, it),
Pair(Material.SAND, it),
Pair(Material.GRAVEL, it)
Pair(Material.GRAVEL, it),
Pair(Material.SANDSTONE, it)
)
}
var destructible = setOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ object WorldEditUtils {
@JvmStatic
fun pastedBounds(pasteLocation: Location, clipboard: CuboidClipboard): Box {
val pasteVec = BlockVector(pasteLocation.blockX, pasteLocation.blockY, pasteLocation.blockZ)
val delta = pasteVec.subtract(clipboard.origin)
val min = clipboard.offset.add(delta)
val max = clipboard.offset.add(delta).add(clipboard.size)
val delta = pasteVec.subtract(clipboard.origin).add(clipboard.offset)
val min = clipboard.origin.add(delta)
val max = clipboard.origin.add(delta).add(clipboard.size)

return Box(pasteLocation.world!!, convert(min), convert(max))
}
Expand Down
Binary file removed src/main/resources/purple.schem
Binary file not shown.
Binary file added src/main/resources/ruins.schematic
Binary file not shown.

0 comments on commit 922feb7

Please sign in to comment.