finish the projectile generator

This commit is contained in:
Ellpeck 2019-03-31 23:53:53 +02:00
parent d21ca60c2d
commit 7b1d30ac85
13 changed files with 161 additions and 2 deletions

View file

@ -3,19 +3,30 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityProjectileGenerator;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderProjectileGenerator;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import de.ellpeck.naturesaura.reg.ITESRProvider;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.init.SoundEvents;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.Tuple;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.ProjectileImpactEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockProjectileGenerator extends BlockContainerImpl {
public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider {
public BlockProjectileGenerator() {
super(Material.ROCK, "projectile_generator", TileEntityProjectileGenerator.class, "projectile_generator");
this.setSoundType(SoundType.STONE);
@ -47,10 +58,30 @@ public class BlockProjectileGenerator extends BlockContainerImpl {
BlockPos spot = IAuraChunk.getLowestSpot(entity.world, pos, 35, pos);
IAuraChunk.getAuraChunk(entity.world, spot).storeAura(spot, amount);
PacketHandler.sendToAllAround(entity.world, pos, 32,
new PacketParticles((float) entity.posX, (float) entity.posY, (float) entity.posZ, 26, pos.getX(), pos.getY(), pos.getZ()));
entity.world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_ENDEREYE_LAUNCH, SoundCategory.BLOCKS, 0.8F, 1F);
generator.nextSide = generator.nextSide.rotateY();
generator.sendToClients();
entity.setDead();
event.setCanceled(true);
}
@Override
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public Tuple<Class, TileEntitySpecialRenderer> getTESR() {
return new Tuple<>(TileEntityProjectileGenerator.class, new RenderProjectileGenerator());
}
}

View file

@ -0,0 +1,55 @@
package de.ellpeck.naturesaura.blocks.tiles.render;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityProjectileGenerator;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderProjectileGenerator extends TileEntitySpecialRenderer<TileEntityProjectileGenerator> {
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/projectile_generator_overlay.png");
private final ModelOverlay model = new ModelOverlay();
@Override
public void render(TileEntityProjectileGenerator te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
if (te.nextSide == EnumFacing.NORTH) {
GlStateManager.rotate(270, 0, 1, 0);
GlStateManager.translate(-0.001F, 0, -1);
} else if (te.nextSide == EnumFacing.EAST) {
GlStateManager.rotate(180, 0, 1, 0);
GlStateManager.translate(-1.001F, 0, -1);
} else if (te.nextSide == EnumFacing.SOUTH) {
GlStateManager.rotate(90, 0, 1, 0);
GlStateManager.translate(-1.001F, 0, 0);
} else {
GlStateManager.translate(-0.001F, 0, 0);
}
this.bindTexture(RES);
this.model.render();
GlStateManager.popMatrix();
}
private static class ModelOverlay extends ModelBase {
private final ModelRenderer box;
public ModelOverlay() {
this.box = new ModelRenderer(this, 0, 0);
this.box.setTextureSize(64, 64);
this.box.addBox(0, 0, 0, 16, 16, 16);
}
public void render() {
this.box.render(1 / 16F);
}
}
}

View file

@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -414,6 +415,25 @@ public class PacketParticles implements IMessage {
message.posZ + world.rand.nextFloat() * depth,
0F, 0F, 0F, 0xd60cff, 1F + world.rand.nextFloat(), 60, 0F, false, true);
break;
case 26: // Projectile generator
int x = message.data[0];
int y = message.data[1];
int z = message.data[2];
for (int i = world.rand.nextInt(10) + 5; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle(
x + 0.25F + world.rand.nextFloat() * 0.5F,
y + 1.01F,
z + 0.25F + world.rand.nextFloat() * 0.5F,
world.rand.nextGaussian() * 0.01F,
world.rand.nextFloat() * 0.04F + 0.02F,
world.rand.nextGaussian() * 0.01F,
0x5ccc30, 1F + world.rand.nextFloat() * 1.5F, 40, 0F, false, true);
for (int i = world.rand.nextInt(10) + 10; i >= 0; i--)
world.spawnParticle(EnumParticleTypes.FIREWORKS_SPARK,
message.posX, message.posY, message.posZ,
world.rand.nextGaussian() * 0.03F,
world.rand.nextGaussian() * 0.03F,
world.rand.nextGaussian() * 0.03F);
}
}
});

View file

@ -52,6 +52,7 @@ tile.naturesaura.chunk_loader.name=World Eye
tile.naturesaura.dimension_rail_overworld.name=Rail of the Overworld
tile.naturesaura.dimension_rail_end.name=Rail of the End
tile.naturesaura.dimension_rail_nether.name=Rail of the Nether
tile.naturesaura.projectile_generator.name=Shooting Mark
item.naturesaura.eye.name=Environmental Eye
item.naturesaura.eye_improved.name=Environmental Ocular

View file

@ -0,0 +1,21 @@
{
"name": "Shooting Mark",
"icon": "naturesaura:projectile_generator",
"category": "creating",
"advancement": "naturesaura:sky_ingot",
"pages": [
{
"type": "text",
"text": "The strength of any shot $(thing)projectiles$() is, in some instances, strong enough to pierce living beings and even move them around by way of teleportation. However, this power can be used to create $(aura) as well: The $(item)Shooting Mark$() converts the energy of any projectiles shot at it into $(aura) that it spreads into the environment."
},
{
"type": "text",
"text": "For this, different kinds of projectiles produce different amounts - a $(item)snowball$() is much less rich in energy than, say, an $(item)ender pearl$().$(p)There is a caveat, however: Projectiles need to be shot at the four sides $(thing)in order$(), starting on the north face. Projectiles that hit on any non-active side will not cause any $(aura) to be produced."
},
{
"type": "crafting",
"recipe": "naturesaura:projectile_generator",
"text": "Creating the $(item)Shooting Mark$()"
}
]
}

View file

@ -11,7 +11,7 @@
},
{
"type": "text",
"text": "$(aura) to maintain its sight.$(p)To set it up, simply place it down and provide it with a $(thing)redstone signal$() - the stronger the signal, the higher its range in blocks will be. Due to the nature of how observation in this manner seems to function, the range isn't always met exactly, meaning that sometimes, the areas that will be loaded are $(thing)slightly bigger$() than the range that is shown - it's a bit $(thing)chunky$(), to say the least."
"text": "$(aura) to maintain its sight.$(p)To set it up, simply place it down and provide it with a $(thing)redstone signal$() - the stronger the signal, the higher its radius in blocks will be, with about 30 being the maximum. Due to the nature of how observation in this manner seems to function, the range isn't always met exactly, meaning that sometimes, the areas that will be loaded are $(thing)slightly bigger$() than the expected range."
},
{
"type": "crafting",

View file

@ -0,0 +1,31 @@
{
"type": "forge:ore_shaped",
"pattern": [
"SFI",
"TXT",
"ILS"
],
"key": {
"F": {
"item": "minecraft:feather"
},
"L": {
"item": "minecraft:flint"
},
"S": {
"item": "naturesaura:infused_stone"
},
"T": {
"item": "naturesaura:token_rage"
},
"I": {
"item": "naturesaura:sky_ingot"
},
"X": {
"item": "minecraft:compass"
}
},
"result": {
"item": "naturesaura:projectile_generator"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 B

After

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 346 B

After

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 349 B

After

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B