From 7e6f6450e40b783c31216868d9b285345247ac6e Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 25 Feb 2019 12:28:41 +0100 Subject: [PATCH] finish the firecracker gaze --- .../blocks/BlockFireworkGenerator.java | 23 ++++- .../tiles/TileEntityFireworkGenerator.java | 80 +++++++++--------- .../blockstates/firework_generator.json | 20 +++++ .../assets/naturesaura/lang/en_US.lang | 1 + .../entries/creating/firework_generator.json | 25 ++++++ .../recipes/firework_generator.json | 31 +++++++ .../textures/blocks/firework_generator.png | Bin 0 -> 694 bytes .../blocks/firework_generator_top.png | Bin 0 -> 600 bytes 8 files changed, 141 insertions(+), 39 deletions(-) create mode 100644 src/main/resources/assets/naturesaura/blockstates/firework_generator.json create mode 100644 src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/creating/firework_generator.json create mode 100644 src/main/resources/assets/naturesaura/recipes/firework_generator.json create mode 100644 src/main/resources/assets/naturesaura/textures/blocks/firework_generator.png create mode 100644 src/main/resources/assets/naturesaura/textures/blocks/firework_generator_top.png diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFireworkGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFireworkGenerator.java index a8d66f99..892ad932 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFireworkGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFireworkGenerator.java @@ -1,10 +1,31 @@ package de.ellpeck.naturesaura.blocks; +import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.blocks.tiles.TileEntityFireworkGenerator; +import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; -public class BlockFireworkGenerator extends BlockContainerImpl { +public class BlockFireworkGenerator extends BlockContainerImpl implements IVisualizable { public BlockFireworkGenerator() { super(Material.ROCK, "firework_generator", TileEntityFireworkGenerator.class, "firework_generator"); + this.setSoundType(SoundType.STONE); + this.setHardness(3F); + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { + return new AxisAlignedBB(pos).grow(4); + } + + @Override + @SideOnly(Side.CLIENT) + public int getVisualizationColor(World world, BlockPos pos) { + return 0xa442f4; } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFireworkGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFireworkGenerator.java index 70164aa4..7dfebeb4 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFireworkGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFireworkGenerator.java @@ -56,56 +56,60 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick } if (this.trackedEntity != null && this.trackedEntity.isDead) { - float generateFactor = 0; - Set usedColors = new HashSet<>(); + if (this.trackedItem.hasTagCompound()) { + float generateFactor = 0; + Set usedColors = new HashSet<>(); - NBTTagCompound compound = this.trackedItem.getTagCompound(); - NBTTagCompound fireworks = compound.getCompoundTag("Fireworks"); + NBTTagCompound compound = this.trackedItem.getTagCompound(); + NBTTagCompound fireworks = compound.getCompoundTag("Fireworks"); - NBTTagList explosions = fireworks.getTagList("Explosions", 10); - if (!explosions.isEmpty()) { int flightTime = fireworks.getInteger("Flight"); - generateFactor += flightTime; + NBTTagList explosions = fireworks.getTagList("Explosions", 10); + if (!explosions.isEmpty()) { + generateFactor += flightTime; - for (NBTBase base : explosions) { - NBTTagCompound explosion = (NBTTagCompound) base; - generateFactor += 1.5F; + for (NBTBase base : explosions) { + NBTTagCompound explosion = (NBTTagCompound) base; + generateFactor += 1.5F; - boolean flicker = explosion.getBoolean("Flicker"); - if (flicker) - generateFactor += 1; + boolean flicker = explosion.getBoolean("Flicker"); + if (flicker) + generateFactor += 1; - boolean trail = explosion.getBoolean("Trail"); - if (trail) - generateFactor += 8; + boolean trail = explosion.getBoolean("Trail"); + if (trail) + generateFactor += 8; - byte type = explosion.getByte("Type"); - generateFactor += new float[]{0, 1, 0.5F, 20, 0.5F}[type]; + byte type = explosion.getByte("Type"); + generateFactor += new float[]{0, 1, 0.5F, 20, 0.5F}[type]; - Set colors = new HashSet<>(); - for (int color : explosion.getIntArray("Colors")) { - usedColors.add(color); - colors.add(color); + Set colors = new HashSet<>(); + for (int color : explosion.getIntArray("Colors")) { + usedColors.add(color); + colors.add(color); + } + generateFactor += 0.75F * colors.size(); } - generateFactor += 0.75F * colors.size(); + } + + if (generateFactor > 0) { + int toAdd = MathHelper.ceil(generateFactor * 10000F); + if (this.canGenerateRightNow(35, toAdd)) { + this.toRelease = toAdd; + this.releaseTimer = 15 * flightTime + 40; + } + + List data = new ArrayList<>(); + data.add(this.pos.getX()); + data.add(this.pos.getY()); + data.add(this.pos.getZ()); + data.addAll(usedColors); + PacketHandler.sendToAllLoaded(this.world, this.pos, new PacketParticles( + (float) this.trackedEntity.posX, (float) this.trackedEntity.posY, (float) this.trackedEntity.posZ, + 24, Ints.toArray(data))); } } - int toAdd = MathHelper.ceil(generateFactor * 10000F); - if (this.canGenerateRightNow(35, toAdd)) { - this.toRelease = toAdd; - this.releaseTimer = 80; - } - - List data = new ArrayList<>(); - data.add(this.pos.getX()); - data.add(this.pos.getY()); - data.add(this.pos.getZ()); - data.addAll(usedColors); - PacketHandler.sendToAllLoaded(this.world, this.pos, new PacketParticles( - (float) this.trackedEntity.posX, (float) this.trackedEntity.posY, (float) this.trackedEntity.posZ, - 24, Ints.toArray(data))); - this.trackedEntity = null; this.trackedItem = null; } diff --git a/src/main/resources/assets/naturesaura/blockstates/firework_generator.json b/src/main/resources/assets/naturesaura/blockstates/firework_generator.json new file mode 100644 index 00000000..e0fcb748 --- /dev/null +++ b/src/main/resources/assets/naturesaura/blockstates/firework_generator.json @@ -0,0 +1,20 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "minecraft:cube", + "textures": { + "particle": "naturesaura:blocks/firework_generator", + "up": "naturesaura:blocks/firework_generator_top", + "down": "#particle", + "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 5a0ce068..bfd61459 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -47,6 +47,7 @@ tile.naturesaura.time_changer.name=Shifting Sundial tile.naturesaura.generator_limit_remover.name=Creational Catalyst tile.naturesaura.ender_crate.name=Ender Crate tile.naturesaura.powder_placer.name=Powder Manipulator +tile.naturesaura.firework_generator.name=Firecracker Gaze item.naturesaura.eye.name=Environmental Eye item.naturesaura.eye_improved.name=Environmental Ocular diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/creating/firework_generator.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/creating/firework_generator.json new file mode 100644 index 00000000..5b6a7598 --- /dev/null +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/creating/firework_generator.json @@ -0,0 +1,25 @@ +{ + "name": "Firecracker Gaze", + "icon": "naturesaura:firework_generator", + "category": "creating", + "advancement": "naturesaura:offering", + "pages": [ + { + "type": "text", + "text": "$(item)Fireworks$() are beautiful to look at, while it is a bit pricy to create ones that look really good. The $(item)Firecracker Gaze$() seemingly shares this opinion especially: Consuming any fireworks that are $(thing)dropped$() on the ground around it, it will shoot them up into the air. Once they explode, their explosive and colorful energy is absorbed, and, based on the complexity of the firework," + }, + { + "type": "text", + "text": "more or less $(aura) is created and spread into the environment as a result. For the complexity, especially the $(thing)value$() of the items used in the firework's creation is of importance, but also, the amount of $(thing)firework stars$(), the amount of $(thing)colors$() and some other variables factor into the amount of $(aura) created from each shot." + }, + { + "type": "text", + "text": "Additionally, it should be noted that, while a firework is already being shot into the air by the $(item)Firecracker Gaze$(), or while it is consuming an explosion's energy, dropping any more fireworks into its collection area will cause the fireworks to be consumed, but no $(aura) to be created from them. This implies that it would be wise to set up some sort of $(thing)timer$() for its automation." + }, + { + "type": "crafting", + "recipe": "naturesaura:firework_generator", + "text": "Creating the $(item)Firecracker Gaze$()" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/recipes/firework_generator.json b/src/main/resources/assets/naturesaura/recipes/firework_generator.json new file mode 100644 index 00000000..dad3c121 --- /dev/null +++ b/src/main/resources/assets/naturesaura/recipes/firework_generator.json @@ -0,0 +1,31 @@ +{ + "type": "forge:ore_shaped", + "pattern": [ + "SFS", + "GIG", + "TSJ" + ], + "key": { + "F": { + "item": "minecraft:fireworks" + }, + "G": { + "item": "minecraft:gunpowder" + }, + "S": { + "item": "naturesaura:infused_stone" + }, + "T": { + "item": "naturesaura:token_rage" + }, + "J": { + "item": "naturesaura:token_joy" + }, + "I": { + "item": "naturesaura:sky_ingot" + } + }, + "result": { + "item": "naturesaura:firework_generator" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/blocks/firework_generator.png b/src/main/resources/assets/naturesaura/textures/blocks/firework_generator.png new file mode 100644 index 0000000000000000000000000000000000000000..981e0f6794f5f1ce2a20ad6123a1ee25e81591d0 GIT binary patch literal 694 zcmV;n0!jUeP)HQ4#;wNJxOOFKFA7C9PsN@w@azbj?Xrc=PLjsocHl$trh|Fym zEB$69Fzjvm$Z`Xcs{I~ya%EuQku9%9pZ~yceT#6V*`B|UBf+y|BX|8Jz~1W^ti`~j z%0D6ZTil-Bk*yZay+rV>7zq@0)Z)yAu^FgUF*tD#Osa!{?TA%@-LhcC>9!gPa;IZ} zDcpwx12XT(srXN3c+k zn|dTjHWhNaW#207P|!OfxvQz*VslHUXFHik@sc_%POmJ`2XB_K@0enfWM%nT(6sd* z3)y#gG<9hm$l?igctJ(?3xRu|z@0}3mWpChv}q;mS%Q!@&U7!yj*8A)C}|Her-gd0 zz~Ah7oz1FhN+PG3D7QmMK8@@yy`l^ss4FEUdhDo)Jx~9(khwK_spnsIscAoGeIrDfV2<8P12Q0epiYaGS9_z>;jJ>SM#e~Zq@fFpCJ05VZF z_zO6mzN#dP-?5ieSW2ET+Z=8;Rsfl(-%rSteU_46UM(&G-XIe#->$SEUJM!@nX=DP z<+axV@otTsa=ezV+(UdyII(pqB$Fk4K7vH&;dV0tQ+=!Sx|E*K24G=_M(V&UXY mc=}X~av^pkRe*n21AhQ;j1n4c4!f2B0000