From fe07d9304e725b7ab5c65e07bcf10b3deaa019d5 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 28 Oct 2018 16:21:43 +0100 Subject: [PATCH] finish up the ritual of the brewer --- .../de/ellpeck/naturesaura/ModConfig.java | 5 +- .../de/ellpeck/naturesaura/NaturesAura.java | 5 ++ .../blocks/BlockPotionGenerator.java | 2 + .../tiles/TileEntityPotionGenerator.java | 47 ++++++++++++------- .../naturesaura/packet/PacketParticles.java | 44 +++++++++++++++-- .../naturesaura/particles/ParticleMagic.java | 5 +- .../entries/creating/potion_generator.json | 15 ++++-- .../naturesaura/recipes/potion_generator.json | 25 ++++++++++ 8 files changed, 122 insertions(+), 26 deletions(-) create mode 100644 src/main/resources/assets/naturesaura/recipes/potion_generator.json diff --git a/src/main/java/de/ellpeck/naturesaura/ModConfig.java b/src/main/java/de/ellpeck/naturesaura/ModConfig.java index fa9f1234..c5a73d99 100644 --- a/src/main/java/de/ellpeck/naturesaura/ModConfig.java +++ b/src/main/java/de/ellpeck/naturesaura/ModConfig.java @@ -12,11 +12,14 @@ public final class ModConfig { public static class General { + @Comment("If using Dragon's Breath in a Brewing Stand should not cause a glass bottle to appear") + public boolean removeDragonBreathContainerItem = true; + } public static class Client { - @Comment("The percentage of particles that should be displayed, where 1 is 100% and 0 is 0%.") + @Comment("The percentage of particles that should be displayed, where 1 is 100% and 0 is 0%") @RangeDouble(min = 0, max = 1) public double particleAmount = 1; diff --git a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java index 9f025bdb..d63497e3 100644 --- a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java +++ b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java @@ -18,6 +18,7 @@ import de.ellpeck.naturesaura.proxy.IProxy; import de.ellpeck.naturesaura.recipes.ModRecipes; import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.capabilities.CapabilityManager; @@ -84,6 +85,10 @@ public final class NaturesAura { public void postInit(FMLPostInitializationEvent event) { ModRegistry.postInit(event); proxy.postInit(event); + + if (ModConfig.general.removeDragonBreathContainerItem) { + Items.DRAGON_BREATH.setContainerItem(null); + } } @EventHandler diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPotionGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPotionGenerator.java index 135d634a..a6d2de60 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPotionGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPotionGenerator.java @@ -6,5 +6,7 @@ import net.minecraft.block.material.Material; public class BlockPotionGenerator extends BlockContainerImpl { public BlockPotionGenerator() { super(Material.ROCK, "potion_generator", TileEntityPotionGenerator.class, "potion_generator"); + this.setHardness(5F); + this.setHarvestLevel("pickaxe", 1); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java index 742192c6..6a77522a 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java @@ -2,10 +2,13 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.aura.chunk.AuraChunk; import de.ellpeck.naturesaura.blocks.Multiblocks; +import de.ellpeck.naturesaura.packet.PacketHandler; +import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.entity.EntityAreaEffectCloud; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionType; +import net.minecraft.potion.PotionUtils; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.math.AxisAlignedBB; @@ -22,40 +25,48 @@ public class TileEntityPotionGenerator extends TileEntityImpl implements ITickab 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)); + List clouds = this.world.getEntitiesWithinAABB(EntityAreaEffectCloud.class, new AxisAlignedBB(this.pos).grow(2)); 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()) { + if (!addedOne) { + PotionType type = ReflectionHelper.getPrivateValue(EntityAreaEffectCloud.class, cloud, "field_184502_e", "potion"); + if (type == null) continue; - } - if (!addedOne) { - int toAdd = (effect.getAmplifier() * 5 + 1) * (effect.getDuration() / 80); + for (PotionEffect effect : type.getEffects()) { + Potion potion = effect.getPotion(); + if (potion.isBadEffect() || potion.isInstant()) { + continue; + } + + boolean dispersed = false; + int toAdd = (effect.getAmplifier() * 5 + 1) * (effect.getDuration() / 40); 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); + dispersed = true; } } - addedOne = true; - } - float newRadius = cloud.getRadius() - 0.25F; - if (newRadius < 0.5F) - cloud.setDead(); - else - cloud.setRadius(newRadius); + PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles( + this.pos.getX(), this.pos.getY(), this.pos.getZ(), 5, + PotionUtils.getPotionColor(type), dispersed ? 1 : 0)); + + addedOne = true; + break; + } } + + float newRadius = cloud.getRadius() - 0.25F; + if (newRadius < 0.5F) + cloud.setDead(); + else + cloud.setRadius(newRadius); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java index a78b782b..2040eed4 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java @@ -21,12 +21,14 @@ public class PacketParticles implements IMessage { private float posY; private float posZ; private int type; + private int[] data; - public PacketParticles(float posX, float posY, float posZ, int type) { + public PacketParticles(float posX, float posY, float posZ, int type, int... data) { this.posX = posX; this.posY = posY; this.posZ = posZ; this.type = type; + this.data = data; } public PacketParticles() { @@ -38,7 +40,12 @@ public class PacketParticles implements IMessage { this.posX = buf.readFloat(); this.posY = buf.readFloat(); this.posZ = buf.readFloat(); - this.type = buf.readInt(); + this.type = buf.readByte(); + + this.data = new int[buf.readByte()]; + for (int i = 0; i < this.data.length; i++) { + this.data[i] = buf.readInt(); + } } @Override @@ -46,7 +53,12 @@ public class PacketParticles implements IMessage { buf.writeFloat(this.posX); buf.writeFloat(this.posY); buf.writeFloat(this.posZ); - buf.writeInt(this.type); + buf.writeByte(this.type); + + buf.writeByte(this.data.length); + for (int i : this.data) { + buf.writeInt(i); + } } public static class Handler implements IMessageHandler { @@ -106,6 +118,32 @@ public class PacketParticles implements IMessage { world.rand.nextGaussian() * 0.01F, world.rand.nextFloat() * 0.01F, world.rand.nextGaussian() * 0.01F, 0x00FF00, world.rand.nextFloat() * 1.5F + 0.75F, 40, 0F, false, true); } + break; + case 5: // Potion generator + int color = message.data[0]; + boolean disperse = message.data[1] > 0; + for (int i = world.rand.nextInt(5) + 5; i >= 0; i--) { + NaturesAura.proxy.spawnMagicParticle(world, + message.posX + world.rand.nextFloat(), + message.posY + 1.1F, + message.posZ + world.rand.nextFloat(), + world.rand.nextGaussian() * 0.005F, world.rand.nextFloat() * 0.05F, world.rand.nextGaussian() * 0.005F, + color, 2F + world.rand.nextFloat(), 80, 0F, true, true); + + if (disperse) + for (int x = -1; x <= 1; x += 2) + for (int z = -1; z <= 1; z += 2) { + NaturesAura.proxy.spawnMagicParticle(world, + message.posX + x * 3 + 0.5F, + message.posY + 2.5, + message.posZ + z * 3 + 0.5F, + world.rand.nextGaussian() * 0.01F, + world.rand.nextFloat() * 0.02F, + world.rand.nextGaussian() * 0.01F, + 0xd6340c, 1F + world.rand.nextFloat() * 2F, 150, 0F, true, true); + } + } + break; } } }); diff --git a/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java b/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java index 34ed36cc..111cf543 100644 --- a/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java +++ b/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java @@ -29,7 +29,10 @@ public class ParticleMagic extends Particle { this.motionY = motionY; this.motionZ = motionZ; - this.setRBGColorF(((color >> 16) & 255) / 255F, ((color >> 8) & 255) / 255F, (color & 255) / 255F); + float r = (((color >> 16) & 255) / 255F) * (1F - this.rand.nextFloat() * 0.35F); + float g = (((color >> 8) & 255) / 255F) * (1F - this.rand.nextFloat() * 0.35F); + float b = ((color & 255) / 255F) * (1F - this.rand.nextFloat() * 0.35F); + this.setRBGColorF(r, g, b); TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks(); this.setParticleTexture(map.getAtlasSprite(TEXTURE.toString())); 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 index 5e7ac175..837892c9 100644 --- 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 @@ -3,15 +3,24 @@ "icon": "naturesaura:potion_generator", "category": "creating", "advancement": "naturesaura:infused_materials", - "priority": true, "pages": [ { "type": "text", - "text": "bla bla bla" + "text": "As ashes turn to ashes, and dust to dust, a similar natural conversion can be achieved with $(aura) and equally magic $(item)Potions$(). Specifically, $(item)Lingering Potions$() have certain magical abilities that allow one to extract the effects and convert them into $(aura) efficiently.$(p)To do this, simply build the $(item)Ritual of the Brewer$() as depicted on the next page." + }, + { + "type": "text", + "text": "Then, throwing any kind of positive, lasting $(item)Lingering Potion$() down in its vicinity will cause the effect to be consumed and turned into $(aura) that will be spread into the area.$(p)Notice that, however, only one effect can be converted at one time, and throwing multiple potions at the ritual will cause their powers to go to waste. Additionally, once there is enough $(aura) in the area, additional potion effects will similarly go to waste." }, { "type": "multiblock", - "multiblock_id": "naturesaura:potion_generator" + "multiblock_id": "naturesaura:potion_generator", + "text": "Creating the $(item)Ritual of the Brewer$() with the $(item)Absorber of Lingering$() in the center" + }, + { + "type": "crafting", + "recipe": "naturesaura:potion_generator", + "text": "Creating the $(item)Absorber of Lingering$()" } ] } \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/recipes/potion_generator.json b/src/main/resources/assets/naturesaura/recipes/potion_generator.json new file mode 100644 index 00000000..d57b0e33 --- /dev/null +++ b/src/main/resources/assets/naturesaura/recipes/potion_generator.json @@ -0,0 +1,25 @@ +{ + "type": "forge:ore_shaped", + "pattern": [ + "BRB", + "IWI", + "BRB" + ], + "key": { + "B": { + "item": "minecraft:nether_brick" + }, + "R": { + "item": "minecraft:blaze_rod" + }, + "I": { + "item": "naturesaura:infused_iron" + }, + "W": { + "item": "minecraft:nether_wart" + } + }, + "result": { + "item": "naturesaura:potion_generator" + } +} \ No newline at end of file