This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate oil in world and add detector
- 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
1 parent
29aa2df
commit 06556ee
Showing
20 changed files
with
267 additions
and
38 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
6 changes: 6 additions & 0 deletions
6
src/generated/resources/assets/nucleartech/models/item/oil_detector.json
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,6 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "nucleartech:item/oil_detector" | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...resources/data/nucleartech/advancements/recipes/nucleartech_consumables/oil_detector.json
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,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
26
src/generated/resources/data/nucleartech/recipes/oil_detector.json
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,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" | ||
} | ||
} |
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
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
64 changes: 64 additions & 0 deletions
64
src/main/kotlin/at/martinthedragon/nucleartech/items/OilDetector.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,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) | ||
} | ||
} |
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
Oops, something went wrong.