diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockProjectileGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockProjectileGenerator.java index 25663ef1..4dbd16a5 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockProjectileGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockProjectileGenerator.java @@ -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 getTESR() { + return new Tuple<>(TileEntityProjectileGenerator.class, new RenderProjectileGenerator()); + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderProjectileGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderProjectileGenerator.java new file mode 100644 index 00000000..58117597 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderProjectileGenerator.java @@ -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 { + 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); + } + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java index 2faff5f9..c1487915 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java @@ -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); } } }); diff --git a/src/main/resources/assets/naturesaura/lang/en_US.lang b/src/main/resources/assets/naturesaura/lang/en_US.lang index 1b5548bb..36a081b9 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -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 diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/creating/projectile_generator.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/creating/projectile_generator.json new file mode 100644 index 00000000..458b66a9 --- /dev/null +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/creating/projectile_generator.json @@ -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$()" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/chunk_loader.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/chunk_loader.json index ec2fe2cf..08594850 100644 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/chunk_loader.json +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/chunk_loader.json @@ -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", diff --git a/src/main/resources/assets/naturesaura/recipes/projectile_generator.json b/src/main/resources/assets/naturesaura/recipes/projectile_generator.json new file mode 100644 index 00000000..b3b62166 --- /dev/null +++ b/src/main/resources/assets/naturesaura/recipes/projectile_generator.json @@ -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" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/blocks/dimension_rail_end.png b/src/main/resources/assets/naturesaura/textures/blocks/dimension_rail_end.png index 8f0ecbcf..ec9892e0 100644 Binary files a/src/main/resources/assets/naturesaura/textures/blocks/dimension_rail_end.png and b/src/main/resources/assets/naturesaura/textures/blocks/dimension_rail_end.png differ diff --git a/src/main/resources/assets/naturesaura/textures/blocks/dimension_rail_nether.png b/src/main/resources/assets/naturesaura/textures/blocks/dimension_rail_nether.png index 8a36ea01..44575fcc 100644 Binary files a/src/main/resources/assets/naturesaura/textures/blocks/dimension_rail_nether.png and b/src/main/resources/assets/naturesaura/textures/blocks/dimension_rail_nether.png differ diff --git a/src/main/resources/assets/naturesaura/textures/blocks/dimension_rail_overworld.png b/src/main/resources/assets/naturesaura/textures/blocks/dimension_rail_overworld.png index 3effb522..28f25843 100644 Binary files a/src/main/resources/assets/naturesaura/textures/blocks/dimension_rail_overworld.png and b/src/main/resources/assets/naturesaura/textures/blocks/dimension_rail_overworld.png differ diff --git a/src/main/resources/assets/naturesaura/textures/blocks/projectile_generator.png b/src/main/resources/assets/naturesaura/textures/blocks/projectile_generator.png new file mode 100644 index 00000000..4529a25c Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/blocks/projectile_generator.png differ diff --git a/src/main/resources/assets/naturesaura/textures/blocks/projectile_generator_top.png b/src/main/resources/assets/naturesaura/textures/blocks/projectile_generator_top.png new file mode 100644 index 00000000..9a8fc3d3 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/blocks/projectile_generator_top.png differ diff --git a/src/main/resources/assets/naturesaura/textures/models/projectile_generator_overlay.png b/src/main/resources/assets/naturesaura/textures/models/projectile_generator_overlay.png new file mode 100644 index 00000000..fa07c34e Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/models/projectile_generator_overlay.png differ