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 00000000..981e0f67 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/blocks/firework_generator.png differ diff --git a/src/main/resources/assets/naturesaura/textures/blocks/firework_generator_top.png b/src/main/resources/assets/naturesaura/textures/blocks/firework_generator_top.png new file mode 100644 index 00000000..67691531 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/blocks/firework_generator_top.png differ