diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPotionGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPotionGenerator.java new file mode 100644 index 00000000..135d634a --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPotionGenerator.java @@ -0,0 +1,10 @@ +package de.ellpeck.naturesaura.blocks; + +import de.ellpeck.naturesaura.blocks.tiles.TileEntityPotionGenerator; +import net.minecraft.block.material.Material; + +public class BlockPotionGenerator extends BlockContainerImpl { + public BlockPotionGenerator() { + super(Material.ROCK, "potion_generator", TileEntityPotionGenerator.class, "potion_generator"); + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java index b94321cc..2bf92c95 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java @@ -18,4 +18,5 @@ public final class ModBlocks { public static final Block WOOD_STAND = new BlockWoodStand(); 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(); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/Multiblocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/Multiblocks.java index 34e7c56f..6c9ff427 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/Multiblocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/Multiblocks.java @@ -36,4 +36,16 @@ public final class Multiblocks { '0', StateMatcher.fromPredicate(Blocks.SAPLING, state -> state.getBlock() instanceof BlockSapling || state.getBlock() instanceof BlockLog), ' ', StateMatcher.ANY) ).setSymmetrical(true); + public static final Multiblock POTION_GENERATOR = MultiblockRegistry.registerMultiblock( + new ResourceLocation(NaturesAura.MOD_ID, "potion_generator"), + new Multiblock(new String[][]{ + {"R R", " ", " ", " ", " ", " ", "R R"}, + {"N N", " ", " ", " ", " ", " ", "N N"}, + {"N N", " ", " ", " 0 ", " ", " ", "N N"}, + {" N N ", "NNN NNN", " NRRRN ", " R R ", " NRRRN ", "NNN NNN", " N N "}}, + 'N', Blocks.NETHER_BRICK, + 'R', Blocks.RED_NETHER_BRICK, + '0', ModBlocks.POTION_GENERATOR, + ' ', StateMatcher.ANY) + ).setSymmetrical(true); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java new file mode 100644 index 00000000..742192c6 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java @@ -0,0 +1,63 @@ +package de.ellpeck.naturesaura.blocks.tiles; + +import de.ellpeck.naturesaura.aura.chunk.AuraChunk; +import de.ellpeck.naturesaura.blocks.Multiblocks; +import net.minecraft.entity.EntityAreaEffectCloud; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.potion.PotionType; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ITickable; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.relauncher.ReflectionHelper; + +import java.util.List; + +public class TileEntityPotionGenerator extends TileEntityImpl implements ITickable { + + @Override + public void update() { + if (!this.world.isRemote && this.world.getTotalWorldTime() % 10 == 0) { + if (Multiblocks.POTION_GENERATOR.validate(this.world, this.pos)) { + boolean addedOne = false; + + List clouds = this.world.getEntitiesWithinAABB(EntityAreaEffectCloud.class, new AxisAlignedBB(this.pos).grow(3)); + for (EntityAreaEffectCloud cloud : clouds) { + if (cloud.isDead) + continue; + + PotionType type = ReflectionHelper.getPrivateValue(EntityAreaEffectCloud.class, cloud, "field_184502_e", "potion"); + if (type == null) + continue; + + for (PotionEffect effect : type.getEffects()) { + Potion potion = effect.getPotion(); + if (potion.isBadEffect() || potion.isInstant()) { + continue; + } + + if (!addedOne) { + int toAdd = (effect.getAmplifier() * 5 + 1) * (effect.getDuration() / 80); + for (EnumFacing dir : EnumFacing.HORIZONTALS) { + BlockPos offset = this.pos.offset(dir, 8); + BlockPos spot = AuraChunk.getClosestSpot(this.world, offset, 10, offset); + if (AuraChunk.getAuraInArea(this.world, spot, 10) < 15000) { + AuraChunk chunk = AuraChunk.getAuraChunk(this.world, spot); + chunk.storeAura(spot, toAdd / 4); + } + } + addedOne = true; + } + + float newRadius = cloud.getRadius() - 0.25F; + if (newRadius < 0.5F) + cloud.setDead(); + else + cloud.setRadius(newRadius); + } + } + } + } + } +} diff --git a/src/main/resources/assets/naturesaura/blockstates/potion_generator.json b/src/main/resources/assets/naturesaura/blockstates/potion_generator.json new file mode 100644 index 00000000..b636eb86 --- /dev/null +++ b/src/main/resources/assets/naturesaura/blockstates/potion_generator.json @@ -0,0 +1,20 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "minecraft:cube", + "textures": { + "particle": "naturesaura:blocks/potion_generator", + "up": "naturesaura:blocks/potion_generator_top", + "down": "naturesaura:blocks/potion_generator_bottom", + "north": "#particle", + "east": "#particle", + "south": "#particle", + "west": "#particle" + }, + "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 1c07a26a..140283e5 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -12,6 +12,7 @@ tile.naturesaura.wood_stand.name=Wooden Stand 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 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/creating/potion_generator.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/creating/potion_generator.json new file mode 100644 index 00000000..5e7ac175 --- /dev/null +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/creating/potion_generator.json @@ -0,0 +1,17 @@ +{ + "name": "Ritual of the Brewer", + "icon": "naturesaura:potion_generator", + "category": "creating", + "advancement": "naturesaura:infused_materials", + "priority": true, + "pages": [ + { + "type": "text", + "text": "bla bla bla" + }, + { + "type": "multiblock", + "multiblock_id": "naturesaura:potion_generator" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/blocks/potion_generator.png b/src/main/resources/assets/naturesaura/textures/blocks/potion_generator.png new file mode 100644 index 00000000..caea4192 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/blocks/potion_generator.png differ diff --git a/src/main/resources/assets/naturesaura/textures/blocks/potion_generator_bottom.png b/src/main/resources/assets/naturesaura/textures/blocks/potion_generator_bottom.png new file mode 100644 index 00000000..ce270069 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/blocks/potion_generator_bottom.png differ diff --git a/src/main/resources/assets/naturesaura/textures/blocks/potion_generator_top.png b/src/main/resources/assets/naturesaura/textures/blocks/potion_generator_top.png new file mode 100644 index 00000000..fdff1a8c Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/blocks/potion_generator_top.png differ