finish the firecracker gaze

This commit is contained in:
Ellpeck 2019-02-25 12:28:41 +01:00
parent 47af8bb798
commit 7e6f6450e4
8 changed files with 141 additions and 39 deletions

View file

@ -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;
}
}

View file

@ -56,56 +56,60 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick
}
if (this.trackedEntity != null && this.trackedEntity.isDead) {
float generateFactor = 0;
Set<Integer> usedColors = new HashSet<>();
if (this.trackedItem.hasTagCompound()) {
float generateFactor = 0;
Set<Integer> 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<Integer> colors = new HashSet<>();
for (int color : explosion.getIntArray("Colors")) {
usedColors.add(color);
colors.add(color);
Set<Integer> 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<Integer> 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<Integer> 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;
}

View file

@ -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": [{}]
}
}

View file

@ -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

View file

@ -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$()"
}
]
}

View file

@ -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"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 694 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B