From 5dc3a7a83d91a9317b64e9a208766238237ebf95 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 28 Oct 2018 17:39:53 +0100 Subject: [PATCH] added the aura detector --- .../naturesaura/blocks/BlockAuraDetector.java | 29 ++++++++++++++++++ .../ellpeck/naturesaura/blocks/ModBlocks.java | 1 + .../blocks/tiles/TileEntityAuraDetector.java | 22 +++++++++++++ .../ellpeck/naturesaura/items/ModItems.java | 2 +- .../blockstates/aura_detector.json | 14 +++++++++ .../assets/naturesaura/lang/en_US.lang | 1 + .../en_us/entries/using/aura_detector.json | 17 ++++++++++ .../naturesaura/recipes/aura_detector.json | 22 +++++++++++++ .../textures/blocks/aura_detector.png | Bin 0 -> 418 bytes 9 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraDetector.java create mode 100644 src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraDetector.java create mode 100644 src/main/resources/assets/naturesaura/blockstates/aura_detector.json create mode 100644 src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/aura_detector.json create mode 100644 src/main/resources/assets/naturesaura/recipes/aura_detector.json create mode 100644 src/main/resources/assets/naturesaura/textures/blocks/aura_detector.png diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraDetector.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraDetector.java new file mode 100644 index 00000000..80364b5e --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraDetector.java @@ -0,0 +1,29 @@ +package de.ellpeck.naturesaura.blocks; + +import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraDetector; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public class BlockAuraDetector extends BlockContainerImpl { + + public BlockAuraDetector() { + super(Material.ROCK, "aura_detector", TileEntityAuraDetector.class, "aura_detector"); + } + + @Override + public boolean hasComparatorInputOverride(IBlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos) { + TileEntity tile = worldIn.getTileEntity(pos); + if (tile instanceof TileEntityAuraDetector) + return ((TileEntityAuraDetector) tile).redstonePower; + else + return 0; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java index 2bf92c95..a8b0755e 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java @@ -19,4 +19,5 @@ public final class ModBlocks { public static final Block INFUSED_STONE = new BlockImpl("infused_stone", Material.ROCK).setSoundType(SoundType.STONE).setHardness(1.75F); public static final Block FURNACE_HEATER = new BlockFurnaceHeater(); public static final Block POTION_GENERATOR = new BlockPotionGenerator(); + public static final Block AURA_DETECTOR = new BlockAuraDetector(); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraDetector.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraDetector.java new file mode 100644 index 00000000..76b57972 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraDetector.java @@ -0,0 +1,22 @@ +package de.ellpeck.naturesaura.blocks.tiles; + +import de.ellpeck.naturesaura.aura.chunk.AuraChunk; +import net.minecraft.util.ITickable; +import net.minecraft.util.math.MathHelper; + +public class TileEntityAuraDetector extends TileEntityImpl implements ITickable { + + public int redstonePower; + + @Override + public void update() { + if (!this.world.isRemote && this.world.getTotalWorldTime() % 80 == 0) { + int amount = AuraChunk.getAuraInArea(this.world, this.pos, 8); + int power = MathHelper.clamp(MathHelper.ceil(amount / (AuraChunk.DEFAULT_AURA * 2F) * 15F), 0, 15); + if (this.redstonePower != power) { + this.redstonePower = power; + this.world.updateComparatorOutputLevel(this.pos, this.getBlockType()); + } + } + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/items/ModItems.java b/src/main/java/de/ellpeck/naturesaura/items/ModItems.java index c077928f..778647d5 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ModItems.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ModItems.java @@ -15,6 +15,7 @@ public final class ModItems { public static final Item INFUSED_IRON = new ItemImpl("infused_iron"); public static final Item ANCIENT_STICK = new ItemImpl("ancient_stick"); public static final Item COLOR_CHANGER = new ItemColorChanger(); + public static final Item AURA_CACHE = new ItemAuraCache(); public static final Item.ToolMaterial TOOL_MATERIAL_INFUSED_IRON = EnumHelper.addToolMaterial(NaturesAura.MOD_ID.toUpperCase(Locale.ROOT) + "_INFUSED_IRON", 3, 300, 6.25F, 2.25F, 16); @@ -23,5 +24,4 @@ public final class ModItems { public static final Item INFUSED_SHOVEL = new ItemShovelNA("infused_iron_shovel", TOOL_MATERIAL_INFUSED_IRON); public static final Item INFUSED_HOE = new ItemHoeNA("infused_iron_hoe", TOOL_MATERIAL_INFUSED_IRON); public static final Item INFUSED_SWORD = new ItemSwordNA("infused_iron_sword", TOOL_MATERIAL_INFUSED_IRON); - public static final Item AURA_CACHE = new ItemAuraCache(); } diff --git a/src/main/resources/assets/naturesaura/blockstates/aura_detector.json b/src/main/resources/assets/naturesaura/blockstates/aura_detector.json new file mode 100644 index 00000000..85469512 --- /dev/null +++ b/src/main/resources/assets/naturesaura/blockstates/aura_detector.json @@ -0,0 +1,14 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "minecraft:cube_all", + "textures": { + "all": "naturesaura:blocks/aura_detector" + }, + "transform": "forge:default-block" + }, + "variants": { + "normal": [{}], + "inventory": [{}] + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/lang/en_US.lang b/src/main/resources/assets/naturesaura/lang/en_US.lang index 140283e5..e0c25ad6 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -13,6 +13,7 @@ tile.naturesaura.ancient_planks.name=Ancient Planks tile.naturesaura.infused_stone.name=Infused Rock tile.naturesaura.furnace_heater.name=Extraneous Firestarter tile.naturesaura.potion_generator.name=Absorber of Lingering +tile.naturesaura.aura_detector.name=Aura Detector item.naturesaura.eye.name=Environmental Eye item.naturesaura.gold_fiber.name=Brilliant Fiber diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/aura_detector.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/aura_detector.json new file mode 100644 index 00000000..263b70ba --- /dev/null +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/aura_detector.json @@ -0,0 +1,17 @@ +{ + "name": "Aura Detector", + "icon": "naturesaura:aura_detector", + "category": "using", + "advancement": "naturesaura:infused_materials", + "pages": [ + { + "type": "text", + "text": "When working with $(aura), sometimes it can be beneficial to know about its levels in an area without having to be there to check in person. The $(item)Aura Detector$() gives out a $(thing)redstone$() signal based on the amount of $(aura) in the close vicinity around it, so long as you attach a $(item)Comparator$() to it. For that, its range of display is similar to that of the $(l:items/eye)Environmental Eye$()." + }, + { + "type": "crafting", + "text": "Creating the $(item)Aura Detector$()", + "recipe": "naturesaura:aura_detector" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/recipes/aura_detector.json b/src/main/resources/assets/naturesaura/recipes/aura_detector.json new file mode 100644 index 00000000..a43488dd --- /dev/null +++ b/src/main/resources/assets/naturesaura/recipes/aura_detector.json @@ -0,0 +1,22 @@ +{ + "type": "forge:ore_shaped", + "pattern": [ + "RSR", + "SIS", + "RSR" + ], + "key": { + "S": { + "item": "naturesaura:infused_stone" + }, + "R": { + "item": "minecraft:redstone" + }, + "I": { + "item": "naturesaura:eye" + } + }, + "result": { + "item": "naturesaura:aura_detector" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/blocks/aura_detector.png b/src/main/resources/assets/naturesaura/textures/blocks/aura_detector.png new file mode 100644 index 0000000000000000000000000000000000000000..ffb5ce758271931efa2e24c671825c5a74f2f437 GIT binary patch literal 418 zcmV;T0bTxyP)N2bZe?^J zG%hhNF=Hy6O8@`?AW1|)R5(v1q9&d-qNxbSV5W3^T>_p>`YH@i}`T&(ib{Phkm&u<2uV;)dz0_Wo;_xqm_6pOjE zJ6Y`T^=%>*>I6j=!51no4m$$o00E!$A~ELixlZ>2BLp0SFyyZ5Y}YxZWFq3>fX9mig6zBqdHefV@Ns)Ekx2*sE2ss?zWDt*GbiLUgUKOE z05XLtmOyk+T97Kx3{)tn1@RCt2Q1!!1O(=xf#MDxEf)t2LP5X~AtEH`E&(taqHIk; z1u literal 0 HcmV?d00001