Skip to content

Commit 14a8c99

Browse files
committed
add support new VW features
1 parent 5775075 commit 14a8c99

File tree

8 files changed

+145
-91
lines changed

8 files changed

+145
-91
lines changed

build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ repositories {
2929
includeGroupByRegex("space\\.impact\\..+")
3030
}
3131
}
32+
mavenLocal()
3233
}
3334

3435
dependencies {
3536
api("space.impact:Packet-Network:1.1.8")
3637
api("space.impact:Impact-API:0.0.4:dev")
3738
api("space.impact:WAILAPlugins:0.3.1:dev")
38-
api("space.impact:VirtualWorld:1.4.1:dev")
39+
api("space.impact:VirtualWorld:1.4.2:dev")
3940
api("space.impact:gregtech-impact:5.09.35.25:dev") { isTransitive = false }
4041
api("com.github.GTNewHorizons:ModularUI:1.1.24:dev") { isTransitive = false }
4142
api("com.github.GTNewHorizons:NotEnoughItems:2.3.+:dev") { isChanging = true }

src/main/java/com/impact/addon/gt/tiles/ore_mining/GTMTEOreSamplingMachine.kt

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ import gregtech.api.util.GT_Utility
2323
import net.minecraft.entity.item.EntityItem
2424
import net.minecraft.entity.player.EntityPlayer
2525
import net.minecraft.item.ItemStack
26+
import net.minecraft.nbt.NBTTagCompound
27+
import net.minecraft.server.MinecraftServer
2628
import net.minecraft.tileentity.TileEntity
2729
import space.gtimpact.virtual_world.api.VirtualAPI
28-
import space.gtimpact.virtual_world.api.VirtualOreVein
2930
import space.gtimpact.virtual_world.api.OreVeinCount
3031
import space.impact.api.ImpactAPI
3132
import space.impact.api.multiblocks.structure.IStructureDefinition
@@ -76,6 +77,7 @@ class GTMTEOreSamplingMachine : GT_MetaTileEntity_MultiParallelBlockBase<GTMTEOr
7677
private val hatch: HashSet<GTMTE_OreHatch> = hashSetOf()
7778
private var currentVeinCount: OreVeinCount? = null
7879
private var isHanded = false
80+
private var playerHandler: EntityPlayer? = null
7981

8082
private fun checkHatch(te: IGregTechTileEntity?, index: Short): Boolean {
8183
val mte = te?.metaTileEntity ?: return false
@@ -133,6 +135,20 @@ class GTMTEOreSamplingMachine : GT_MetaTileEntity_MultiParallelBlockBase<GTMTEOr
133135
} else false
134136
}
135137

138+
override fun saveNBTData(aNBT: NBTTagCompound) {
139+
super.saveNBTData(aNBT)
140+
playerHandler?.also { player ->
141+
aNBT.setString("playerHandler", player.gameProfile.name)
142+
}
143+
}
144+
145+
override fun loadNBTData(aNBT: NBTTagCompound) {
146+
super.loadNBTData(aNBT)
147+
aNBT.getString("playerHandler")?.also { name ->
148+
playerHandler = MinecraftServer.getServer().configurationManager.func_152612_a(name)
149+
}
150+
}
151+
136152
override fun onRightclick(
137153
te: IGregTechTileEntity,
138154
p: EntityPlayer,
@@ -143,8 +159,8 @@ class GTMTEOreSamplingMachine : GT_MetaTileEntity_MultiParallelBlockBase<GTMTEOr
143159
): Boolean {
144160
if (!mMachine) return true
145161
if (side != 1.toByte() || isHanded) return true
162+
playerHandler = p
146163
isHanded = true
147-
VirtualWorldScan.scanVeinOre(te.chunk, LAYER, p)
148164
currentVeinCount = VirtualAPI.extractOreFromChunk(te.chunk, LAYER, 1)
149165
checkRecipe(null)
150166
return true
@@ -166,6 +182,10 @@ class GTMTEOreSamplingMachine : GT_MetaTileEntity_MultiParallelBlockBase<GTMTEOr
166182
droppedItem.motionY = ((4 + w.rand.nextFloat()) * multiplier).toDouble()
167183
droppedItem.motionZ = ((-0.5f + w.rand.nextFloat()) * multiplier).toDouble()
168184
w.spawnEntityInWorld(droppedItem)
185+
playerHandler?.also { player ->
186+
VirtualWorldScan.scanVeinOre(te.chunk, LAYER, player)
187+
playerHandler = null
188+
}
169189
isHanded = false
170190
}
171191
} else {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.impact.addon.nei.impactplugin
2+
3+
import codechicken.nei.api.API
4+
import com.impact.mods.gregtech.GT_ItemList
5+
import gregtech.api.enums.ItemList
6+
7+
object RecipeCatalystRegister {
8+
9+
@JvmStatic
10+
fun register() {
11+
listOf(ItemList.OilDrill1, ItemList.OilDrill2, ItemList.OilDrill3).forEach { item ->
12+
API.addRecipeCatalyst(item.get(1), "virtual_world_fluids_dim")
13+
API.addRecipeCatalyst(item.get(1), "virtual_world_fluids_all")
14+
}
15+
listOf(GT_ItemList.CoalMiner, GT_ItemList.BasicMiner, GT_ItemList.AdvancedMiner).forEach { item ->
16+
API.addRecipeCatalyst(item.get(1), "virtual_world_ores_dim")
17+
API.addRecipeCatalyst(item.get(1), "virtual_world_ores_all")
18+
}
19+
}
20+
}

src/main/java/com/impact/addon/vw/VirtualWorldIntegration.kt

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.impact.addon.vw
22

3-
import com.impact.common.oregeneration.Dimensions
43
import gregtech.api.enums.ItemList
54
import gregtech.api.enums.Materials
65
import gregtech.api.enums.OrePrefixes
@@ -2210,42 +2209,9 @@ object VirtualWorldIntegration {
22102209
color = Materials.Platinum.color(),
22112210
ores = listOf(Materials.Platinum.toOreComponent(100))
22122211
)
2213-
2214-
VirtualOreVein(
2215-
id = 1000,
2216-
name = "Empty",
2217-
dimensions = Dimensions.values().map { it.id to "${it.name} (${it.tier})" },
2218-
rangeSize = 1..10,
2219-
layer = 0,
2220-
weight = 5.0,
2221-
color = Materials._NULL.color(),
2222-
ores = listOf(),
2223-
isHidden = true,
2224-
)
2225-
VirtualOreVein(
2226-
id = 1001,
2227-
name = "Empty",
2228-
dimensions = Dimensions.values().map { it.id to "${it.name} (${it.tier})" },
2229-
rangeSize = 1..10,
2230-
layer = 1,
2231-
weight = 5.0,
2232-
color = Materials._NULL.color(),
2233-
ores = listOf(),
2234-
isHidden = true,
2235-
)
22362212
}
22372213

22382214
private fun registerFluidVeins() {
2239-
VirtualFluidVein(
2240-
id = 0,
2241-
name = "Empty",
2242-
weight = 33.0,
2243-
rangeSize = 1..10,
2244-
color = Materials._NULL.color(),
2245-
dimensions = Dimensions.values().map { it.id to "${it.name} (${it.tier})" },
2246-
fluid = Materials.Water.getAnyFluid(),
2247-
isHidden = true,
2248-
)
22492215
VirtualFluidVein(
22502216
id = 1,
22512217
name = "Oil",
@@ -2579,8 +2545,17 @@ object VirtualWorldIntegration {
25792545
dimensions = listOf(Makemake).map { it.id to "${it.name} (${it.tier})" },
25802546
fluid = Materials.NaquadahEnriched.getAnyFluid()
25812547
)
2548+
VirtualFluidVein(
2549+
id = 38,
2550+
name = "Argon",
2551+
weight = 5.0,
2552+
rangeSize = 100..400,
2553+
color = Materials.Argon.color(),
2554+
dimensions = listOf(Makemake).map { it.id to "${it.name} (${it.tier})" },
2555+
fluid = Materials.Argon.getAnyFluid()
2556+
)
25822557
}
2583-
2558+
25842559
private fun Materials.getAnyFluid(): FluidStack {
25852560
return getFluid(0) ?: getGas(0) ?: getMolten(0)!!
25862561
}

src/main/java/com/impact/addon/vw/VirtualWorldScan.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import space.gtimpact.virtual_world.extras.toTranslate
1616
object VirtualWorldScan {
1717

1818
@JvmStatic
19-
fun scanStart(te: IGregTechTileEntity, tierScanner: Int, type: Int, layer: Int, player: EntityPlayer) {
19+
fun scanStart(te: IGregTechTileEntity, tierScanner: Int, player: EntityPlayer) {
2020
val radius = when (tierScanner) {
2121
2 -> 9
2222
3 -> 11
@@ -25,15 +25,14 @@ object VirtualWorldScan {
2525
else -> 7
2626
}
2727

28-
when (type) {
29-
TYPE_ORES -> scanOres(te.world, layer, player as EntityPlayerMP, radius)
30-
TYPE_FLUIDS -> scanFluids(te.world, player as EntityPlayerMP, radius)
31-
}
28+
scanOres(te.world, 0, player as EntityPlayerMP, radius)
29+
scanOres(te.world, 1, player, radius)
30+
scanFluids(te.world, player, radius)
3231
}
3332

3433
@JvmStatic
35-
fun scanVeinOre(chunk: Chunk, layer: Int, player: EntityPlayer, needShowGui: Boolean = false): OreVeinCount? {
36-
scanOres(chunk.worldObj, layer, player, 4, needShowGui)
34+
fun scanVeinOre(chunk: Chunk, layer: Int, player: EntityPlayer, needScanSize: Boolean = false): OreVeinCount? {
35+
scanOres(chunk.worldObj, layer, player, 4, needScanSize = needScanSize)
3736
val list = arrayListOf<OreVeinCount?>()
3837
VirtualAPI.getVeinChunks(chunk).forEach {
3938
chunk.worldObj.getChunkFromChunkCoords(it.chunkXPos, it.chunkZPos)?.also { ch ->

0 commit comments

Comments
 (0)