Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Generate oil in world and add detector
Browse files Browse the repository at this point in the history
- Oil bubbles will now generate in your worlds. You can find them using
  the Oil Detector.
- The machine template folder would crash the game if the results tag
  was empty.
  • Loading branch information
MartinTheDragon committed Jul 4, 2021
1 parent 29aa2df commit 06556ee
Show file tree
Hide file tree
Showing 20 changed files with 267 additions and 38 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

#versions
mod_version=0.0.5.2
mod_version=0.0.6.0
kotlin_version=1.5.20
jei_version=7.7.0.106
3 changes: 3 additions & 0 deletions src/generated/resources/.cache/cache
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ fee35a44ac16d8b8b7269663346cc36acdcabf68 assets/nucleartech/models/item/nuclear_
5a9a6a0ac1d4e3f4288a63b0d1eb2ba6f4cf66b5 assets/nucleartech/models/item/obsidian_plate_stamp.json
c62d262039ff2f488d414f467754888ea9a28b6e assets/nucleartech/models/item/obsidian_wire_stamp.json
15ae59269234bf4ce3cfe43f4a356fc46e376dcf assets/nucleartech/models/item/oil_deposit.json
072126771fb370e870bf83bce18d67b791a5c959 assets/nucleartech/models/item/oil_detector.json
d0e3f6ba88be461777371f57f1df1c68e47d20ee assets/nucleartech/models/item/oil_sand.json
b497578af2fbbd8f94dd227b05cb1a5d3efe2e56 assets/nucleartech/models/item/overclocked_circuit.json
5a0c9fb5bea4a5b570e1744733a36962b4695804 assets/nucleartech/models/item/own_opinion.json
Expand Down Expand Up @@ -1073,6 +1074,7 @@ a938c8f44da871b1d75323e4870480b4f35d784b data/nucleartech/advancements/recipes/n
f99e1c701d1b5e8109148d897c3d9a012f2f6997 data/nucleartech/advancements/recipes/nucleartech_blocks/weidanium_block_from_weidanium_ingot.json
051ef0ad077d543c040ec41cba6f321597a96402 data/nucleartech/advancements/recipes/nucleartech_blocks/white_phosphorus_block_from_white_phosphorus_ingot.json
503a7cb95a16bdc5a0c6dfb9af774a5c7be592f8 data/nucleartech/advancements/recipes/nucleartech_blocks/yellowcake_block_from_yellowcake.json
4133d6be480d7e4735d2c0a61cb6773e8dfba3e4 data/nucleartech/advancements/recipes/nucleartech_consumables/oil_detector.json
71fca5c6b227cf402d4d86e262d9812e73ed57ef data/nucleartech/advancements/recipes/nucleartech_parts/advanced_alloy_ingot_from_advanced_alloy_block.json
600aeb75cfc58e2aba44e818e667e165abb9edeb data/nucleartech/advancements/recipes/nucleartech_parts/advanced_alloy_ingot_from_powder.json
da9eae9024c2786b55583c75bead953887f6bc3b data/nucleartech/advancements/recipes/nucleartech_parts/advanced_alloy_ingot_from_red_copper_ingot_and_steel_ingot.json
Expand Down Expand Up @@ -1532,6 +1534,7 @@ c4d51ef899a3754295da093a04e3f89b06932340 data/nucleartech/recipes/niter_from_nit
d8f432f3d1296f4793137db31481df8965b5f81c data/nucleartech/recipes/nuclear_waste_block_from_nuclear_waste.json
46c0e24b245f5d6a27ccc26dc7ed5949343569fb data/nucleartech/recipes/nuclear_waste_block_from_nuclear_wastes_any.json
d33cb27a7ee1d869f131a19ba00e11f7109c5a52 data/nucleartech/recipes/nuclear_waste_from_nuclear_waste_block.json
d7dff878482c8302a1bfbcba0293f67717d9f075 data/nucleartech/recipes/oil_detector.json
7406a7ac2dff4950cc89f14b4348a57b5742bc9d data/nucleartech/recipes/paa_alloy_plate_from_mixed_plate_and_gold_plate.json
a735d2d49d7b805642792c82ca9475c1339a62c4 data/nucleartech/recipes/plutonium_block_from_plutonium_ingot.json
71f7e429edebb288b1a2cba7ec0646364d1e447c data/nucleartech/recipes/plutonium_fuel_block_from_plutonium_fuel_ingot.json
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "nucleartech:item/oil_detector"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"nucleartech:oil_detector"
]
},
"criteria": {
"has_advanced_circuit": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "nucleartech:advanced_circuit"
}
]
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "nucleartech:oil_detector"
}
}
},
"requirements": [
[
"has_advanced_circuit",
"has_the_recipe"
]
]
}
26 changes: 26 additions & 0 deletions src/generated/resources/data/nucleartech/recipes/oil_detector.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"type": "minecraft:crafting_shaped",
"group": "oil_detector",
"pattern": [
"G C",
"GAC",
"SSS"
],
"key": {
"G": {
"tag": "forge:wires/gold"
},
"S": {
"tag": "forge:plates/steel"
},
"C": {
"tag": "forge:ingots/copper"
},
"A": {
"item": "nucleartech:advanced_circuit"
}
},
"result": {
"item": "nucleartech:oil_detector"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,10 @@ enum class CreativeTabs(val itemGroup: ItemGroup) {
object : ItemGroup("nucleartech_machines") {
override fun makeIcon() = ItemStack(ModBlockItems.safe.get()) // TODO
}
),
Consumables(
object : ItemGroup("nucleartech_consumables") {
override fun makeIcon() = ItemStack(ModItems.oilDetector.get()) // TODO
}
)
}
4 changes: 4 additions & 0 deletions src/main/kotlin/at/martinthedragon/nucleartech/ModItems.kt
Original file line number Diff line number Diff line change
Expand Up @@ -496,4 +496,8 @@ object ModItems {
val sirenTrackEASAlarmScreech: RegistryObject<Item> = ITEMS.register("siren_track_eas_alarm_screech") { SirenTrack(SoundEvents.sirenTrackEASAlarmScreech, 1f, true, "siren_track_eas_alarm_screech", 0xB3A8C1) }
val sirenTrackAPCPass: RegistryObject<Item> = ITEMS.register("siren_track_apc_pass") { SirenTrack(SoundEvents.sirenTrackAPCPass, 1f, false, "siren_track_apc_pass", 0x3437D3) }
val sirenTrackRazortrainHorn: RegistryObject<Item> = ITEMS.register("siren_track_razortrain_horn") { SirenTrack(SoundEvents.sirenTrackRazortrainHorn, 1f, false, "siren_track_razortrain_horn", 0x7750ED) }

// Consumables

val oilDetector: RegistryObject<OilDetector> = ITEMS.register("oil_detector") { OilDetector(Item.Properties().tab(CreativeTabs.Consumables.itemGroup).stacksTo(1)) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import at.martinthedragon.nucleartech.datagen.*
import at.martinthedragon.nucleartech.recipes.RecipeSerializers
import at.martinthedragon.nucleartech.recipes.RecipeTypes
import at.martinthedragon.nucleartech.tileentities.TileEntityTypes
import at.martinthedragon.nucleartech.worldgen.WorldGeneration
import net.minecraft.block.Block
import net.minecraft.inventory.container.ContainerType
import net.minecraft.item.Item
import net.minecraft.item.crafting.IRecipeSerializer
import net.minecraft.tileentity.TileEntityType
import net.minecraft.util.ResourceLocation
import net.minecraft.world.gen.feature.Feature
import net.minecraftforge.event.RegistryEvent
import net.minecraftforge.eventbus.api.SubscribeEvent
import net.minecraftforge.fml.RegistryObject
Expand All @@ -32,6 +34,7 @@ object RegistriesAndLifecycle {
val TILE_ENTITIES: DeferredRegister<TileEntityType<*>> = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, NuclearTech.MODID)
val CONTAINERS: DeferredRegister<ContainerType<*>> = DeferredRegister.create(ForgeRegistries.CONTAINERS, NuclearTech.MODID)
val RECIPE_SERIALIZERS: DeferredRegister<IRecipeSerializer<*>> = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, NuclearTech.MODID)
val FEATURES: DeferredRegister<Feature<*>> = DeferredRegister.create(ForgeRegistries.FEATURES, NuclearTech.MODID)

init {
BLOCKS.register(FMLJavaModLoadingContext.get().modEventBus)
Expand All @@ -45,6 +48,8 @@ object RegistriesAndLifecycle {
ContainerTypes
RECIPE_SERIALIZERS.register(FMLJavaModLoadingContext.get().modEventBus)
RecipeSerializers
FEATURES.register(FMLJavaModLoadingContext.get().modEventBus)
WorldGeneration.Features
}

// using kotlin's strong type system
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/at/martinthedragon/nucleartech/SoundEvents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ object SoundEvents {
val sirenTrackAPCPass = SoundEvent(ResourceLocation(NuclearTech.MODID, "siren.apc_pass"))
val sirenTrackRazortrainHorn = SoundEvent(ResourceLocation(NuclearTech.MODID, "siren.razortrain_horn"))
val pressOperate = SoundEvent(ResourceLocation(NuclearTech.MODID, "press.operate"))

val itemGenericBleep = SoundEvent(ResourceLocation(NuclearTech.MODID, "item.generic.bleep"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ class NuclearItemModelProvider(
simpleItem(ModItems.sirenTrackEASAlarmScreech.get())
simpleItem(ModItems.sirenTrackAPCPass.get())
simpleItem(ModItems.sirenTrackRazortrainHorn.get())
simpleItem(ModItems.oilDetector.get())

// BlockItems

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class NuclearRecipeProvider(generator: DataGenerator) : RecipeProvider(generator

pressRecipes(consumer)
blastFurnaceRecipes(consumer)
consumables(consumer)
}

private fun pressRecipes(consumer: Consumer<IFinishedRecipe>) {
Expand Down Expand Up @@ -298,6 +299,10 @@ class NuclearRecipeProvider(generator: DataGenerator) : RecipeProvider(generator
blastingRecipe(ModItems.saturniteIngot.get(), NuclearTags.Items.DUSTS_METEORITE, ModItems.starmetalIngot.get(), 2F, 2, "meteorite_dust", consumer)
}

private fun consumables(consumer: Consumer<IFinishedRecipe>) {
ShapedRecipeBuilder.shaped(ModItems.oilDetector.get()).define('G', NuclearTags.Items.WIRES_GOLD).define('S', NuclearTags.Items.PLATES_STEEL).define('C', NuclearTags.Items.INGOTS_COPPER).define('A', ModItems.advancedCircuit.get()).pattern("G C").pattern("GAC").pattern("SSS").group("oil_detector").unlockedBy("has_${ModItems.advancedCircuit.id.path}", has(ModItems.advancedCircuit.get())).save(consumer, ResourceLocation(NuclearTech.MODID, "oil_detector"))
}

// so we can also use tags when declaring a shapeless recipe requiring multiple items of one type
private fun ShapelessRecipeBuilder.requires(itemTag: ITag<Item>, count: Int): ShapelessRecipeBuilder {
for (i in 0 until count) requires(itemTag)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package at.martinthedragon.nucleartech.items

import at.martinthedragon.nucleartech.NuclearTags
import at.martinthedragon.nucleartech.SoundEvents
import net.minecraft.client.util.ITooltipFlag
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.Item
import net.minecraft.item.ItemStack
import net.minecraft.util.ActionResult
import net.minecraft.util.Hand
import net.minecraft.util.math.BlockPos
import net.minecraft.util.text.ITextComponent
import net.minecraft.util.text.TextFormatting
import net.minecraft.util.text.TranslationTextComponent
import net.minecraft.world.World

class OilDetector(properties: Properties) : Item(properties) {
override fun appendHoverText(stack: ItemStack, world: World?, tooltip: MutableList<ITextComponent>, flag: ITooltipFlag) =
autoTooltip(stack, tooltip)

override fun use(world: World, player: PlayerEntity, hand: Hand): ActionResult<ItemStack> {
fun checkColumns(world: World, playerPos: BlockPos, offsetX: Int, offsetZ: Int): Boolean {
val oilOreTag = NuclearTags.Blocks.ORES_OIL
for (i in 5..(playerPos.y + 15)) {
val found = when {
offsetX == 0 && offsetZ == 0 -> world.getBlockState(BlockPos(playerPos.x, i, playerPos.z)).`is`(oilOreTag)
offsetX == 0 -> world.getBlockState(BlockPos(playerPos.x, i, playerPos.z + offsetZ)).`is`(oilOreTag) ||
world.getBlockState(BlockPos(playerPos.x, i, playerPos.z - offsetZ)).`is`(oilOreTag)
offsetZ == 0 -> world.getBlockState(BlockPos(playerPos.x + offsetX, i, playerPos.z)).`is`(oilOreTag) ||
world.getBlockState(BlockPos(playerPos.x - offsetX, i, playerPos.z)).`is`(oilOreTag)
else -> world.getBlockState(BlockPos(playerPos.x + offsetX, i, playerPos.z + offsetZ)).`is`(oilOreTag) ||
world.getBlockState(BlockPos(playerPos.x - offsetX, i, playerPos.z + offsetZ)).`is`(oilOreTag) ||
world.getBlockState(BlockPos(playerPos.x + offsetX, i, playerPos.z - offsetZ)).`is`(oilOreTag) ||
world.getBlockState(BlockPos(playerPos.x - offsetX, i, playerPos.z - offsetZ)).`is`(oilOreTag)
}

if (found) return true
}
return false
}

if (world.isClientSide) {
val playerPosition = player.blockPosition()
if (checkColumns(world, playerPosition, 0, 0)) {
player.displayClientMessage(TranslationTextComponent("$descriptionId.below").withStyle(TextFormatting.DARK_GREEN), true)
} else if (
checkColumns(world, playerPosition, 5, 0) ||
checkColumns(world, playerPosition, 0, 5) ||
checkColumns(world, playerPosition, 10, 0) ||
checkColumns(world, playerPosition, 0, 10) ||
checkColumns(world, playerPosition, 5, 5)
) {
player.displayClientMessage(TranslationTextComponent("$descriptionId.near").withStyle(TextFormatting.GOLD), true)
} else {
player.displayClientMessage(TranslationTextComponent("$descriptionId.no_oil").withStyle(TextFormatting.RED), true)
}
}

player.playSound(SoundEvents.itemGenericBleep, 1F, 1F)

val itemStack = player.getItemInHand(hand)
return ActionResult.sidedSuccess(itemStack, world.isClientSide)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,10 @@ class UseTemplateFolderScreen : Screen(NarratorChatListener.NO_TITLE) {
nextButton.visible = currentPage < pagesCount
if (currentPage == pagesCount) {
val itemCount = (if (searchResults.isEmpty()) itemList.size else searchResults.size) - (currentPage - 1) * RECIPES_PER_PAGE
if (itemCount != 0) {
for (i in 0 until itemCount)
templateButtons[i].visible = true
for (i in itemCount until RECIPES_PER_PAGE)
templateButtons[i].visible = false
}
for (i in 0 until itemCount)
templateButtons[i].visible = true
for (i in itemCount until RECIPES_PER_PAGE)
templateButtons[i].visible = false
} else templateButtons.forEach { it.visible = true }
}

Expand Down
Loading

0 comments on commit 06556ee

Please sign in to comment.