Basic Spark Framework.

This commit is contained in:
Lizbeth Rika committed 2014-08-21 18:29:05 +01:00
1 parent 3e445083b2
commit be5db39ac9
13 files changed
+266 -6

No files matched your search

@@ -0,0 +1,26 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
* File Created @ [Aug 21, 2014, 5:44:13 PM (GMT)]
*/
package vazkii.botania.api.mana.spark;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.mana.IManaBlock;
import vazkii.botania.api.mana.IManaReceiver;
public interface ISparkAttachable extends IManaReceiver {
public boolean canAttachSpark(ItemStack stack);
public void attachSpark(ISparkEntity entity);
public ISparkEntity getAttachedSpark();
}
@@ -0,0 +1,24 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
* File Created @ [Aug 21, 2014, 5:44:07 PM (GMT)]
*/
package vazkii.botania.api.mana.spark;
import java.util.Collection;
public interface ISparkEntity {
public ISparkAttachable getAttachedTile();
public Collection<ISparkEntity> getSparkTransferingTo();
public void registerSparkTranfer(ISparkEntity spark);
}
@@ -0,0 +1,18 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
* File Created @ [Aug 21, 2014, 5:44:27 PM (GMT)]
*/
package vazkii.botania.api.mana.spark;
public interface ISparkProvider extends ISparkAttachable {
public boolean canProvideTo(ISparkEntity entity);
}
+1 -1
View File
@@ -1,4 +1,4 @@
@API(owner = "Botania", apiVersion = "7", provides = "BotaniaAPI")
@API(owner = "Botania", apiVersion = "8", provides = "BotaniaAPI")
package vazkii.botania.api;
import cpw.mods.fml.common.API;
@@ -47,9 +47,10 @@ import vazkii.botania.client.render.block.RenderSpreader;
import vazkii.botania.client.render.block.RenderTinyPotato;
import vazkii.botania.client.render.entity.RenderDoppleganger;
import vazkii.botania.client.render.entity.RenderPixie;
import vazkii.botania.client.render.item.RenderTransparentItem;
import vazkii.botania.client.render.entity.RenderSpark;
import vazkii.botania.client.render.item.RenderLens;
import vazkii.botania.client.render.item.RenderLexicon;
import vazkii.botania.client.render.item.RenderTransparentItem;
import vazkii.botania.client.render.tile.RenderTileAlfPortal;
import vazkii.botania.client.render.tile.RenderTileAltar;
import vazkii.botania.client.render.tile.RenderTileEnchanter;
@@ -79,6 +80,7 @@ import vazkii.botania.common.core.proxy.CommonProxy;
import vazkii.botania.common.core.version.VersionChecker;
import vazkii.botania.common.entity.EntityDoppleganger;
import vazkii.botania.common.entity.EntityPixie;
import vazkii.botania.common.entity.EntitySpark;
import vazkii.botania.common.entity.EntityVineBall;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibObfuscation;
@@ -151,6 +153,7 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerEntityRenderingHandler(EntityPixie.class, new RenderPixie());
RenderingRegistry.registerEntityRenderingHandler(EntityVineBall.class, new RenderSnowball(ModItems.vineBall));
RenderingRegistry.registerEntityRenderingHandler(EntityDoppleganger.class, new RenderDoppleganger());
RenderingRegistry.registerEntityRenderingHandler(EntitySpark.class, new RenderSpark());
ShaderHelper.initShaders();
}
@@ -0,0 +1,77 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
* File Created @ [Aug 21, 2014, 5:53:22 PM (GMT)]
*/
package vazkii.botania.client.render.entity;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import vazkii.botania.common.item.ItemSpark;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderEntity;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.EntityPotion;
import net.minecraft.item.ItemPotion;
import net.minecraft.potion.PotionHelper;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
public class RenderSpark extends RenderEntity {
@Override
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) {
IIcon iicon = ItemSpark.worldIcon;
if(iicon != null) {
GL11.glPushMatrix();
GL11.glTranslatef((float)par2, (float)par4, (float)par6);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.025F);
GL11.glScalef(0.75F, 0.75F, 0.75F);
this.bindEntityTexture(par1Entity);
Tessellator tessellator = Tessellator.instance;
this.func_77026_a(tessellator, iicon);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
}
@Override
protected ResourceLocation getEntityTexture(Entity p_110775_1_) {
return TextureMap.locationItemsTexture;
}
private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_) {
float f = p_77026_2_.getMinU();
float f1 = p_77026_2_.getMaxU();
float f2 = p_77026_2_.getMinV();
float f3 = p_77026_2_.getMaxV();
float f4 = 1.0F;
float f5 = 0.5F;
float f6 = 0.25F;
GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
p_77026_1_.startDrawingQuads();
p_77026_1_.setNormal(0.0F, 1.0F, 0.0F);
p_77026_1_.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3);
p_77026_1_.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3);
p_77026_1_.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2);
p_77026_1_.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2);
p_77026_1_.draw();
}
}
@@ -17,6 +17,7 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -34,6 +35,8 @@ import vazkii.botania.api.mana.IKeyLocked;
import vazkii.botania.api.mana.IManaItem;
import vazkii.botania.api.mana.IManaPool;
import vazkii.botania.api.mana.ManaNetworkEvent;
import vazkii.botania.api.mana.spark.ISparkAttachable;
import vazkii.botania.api.mana.spark.ISparkEntity;
import vazkii.botania.api.recipe.RecipeManaInfusion;
import vazkii.botania.client.core.handler.HUDHandler;
import vazkii.botania.client.core.handler.LightningHandler;
@@ -46,7 +49,7 @@ import vazkii.botania.common.core.handler.ManaNetworkHandler;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.item.ModItems;
public class TilePool extends TileMod implements IManaPool, IKeyLocked {
public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAttachable {
public static final int MAX_MANA = 1000000;
public static final int MAX_MANA_DILLUTED = 10000;
@@ -61,6 +64,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked {
private static final String TAG_FRAGILE = "fragile";
private static final String TAG_INPUT_KEY = "inputKey";
private static final String TAG_OUTPUT_KEY = "outputKey";
private static final String TAG_ATTACHED_SPARK = "attachedSpark";
boolean outputting = false;
public boolean alchemy = false;
@@ -69,7 +73,8 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked {
public int color = 0;
int mana;
int knownMana = -1;
int sparkAttached = -1;
public int manaCap = -1;
int soundTicks = 0;
boolean canAccept = true;
@@ -333,4 +338,25 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked {
public String getOutputKey() {
return outputKey;
}
@Override
public boolean canAttachSpark(ItemStack stack) {
return getBlockMetadata() != 2;
}
@Override
public void attachSpark(ISparkEntity entity) {
sparkAttached = ((Entity) entity).getEntityId();
}
@Override
public ISparkEntity getAttachedSpark() {
Entity e = worldObj.getEntityByID(sparkAttached);
if(e != null || !(e instanceof ISparkEntity)) {
sparkAttached = -1;
return null;
}
return (ISparkEntity) e;
}
}
@@ -0,0 +1,55 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
* File Created @ [Aug 21, 2014, 5:43:44 PM (GMT)]
*/
package vazkii.botania.common.entity;
import java.util.Collection;
import vazkii.botania.api.mana.spark.ISparkAttachable;
import vazkii.botania.api.mana.spark.ISparkEntity;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public class EntitySpark extends Entity implements ISparkEntity {
public EntitySpark(World world) {
super(world);
}
@Override
protected void entityInit() {
//etSize(0F, 0F);
}
@Override
protected void readEntityFromNBT(NBTTagCompound cmp) {
}
@Override
protected void writeEntityToNBT(NBTTagCompound cmp) {
}
@Override
public ISparkAttachable getAttachedTile() {
return null;
}
@Override
public Collection<ISparkEntity> getSparkTransferingTo() {
return null;
}
@Override
public void registerSparkTranfer(ISparkEntity spark) {
}
}
@@ -26,6 +26,7 @@ public final class ModEntities {
EntityRegistry.registerModEntity(EntityVineBall.class, LibEntityNames.VINE_BALL, id++, Botania.instance, 64, 10, true);
EntityRegistry.registerModEntity(EntityDoppleganger.class, LibEntityNames.DOPPLEGANGER, id++, Botania.instance, 128, 3, true);
EntityRegistry.registerModEntity(EntityMagicLandmine.class, LibEntityNames.MAGIC_LANDMINE, id++, Botania.instance, 128, 40, false);
EntityRegistry.registerModEntity(EntitySpark.class, LibEntityNames.SPARK, id++, Botania.instance, 64, 10, false);
}
}
@@ -12,8 +12,14 @@
package vazkii.botania.common.item;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import vazkii.botania.api.mana.spark.ISparkAttachable;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.entity.EntitySpark;
import vazkii.botania.common.lib.LibItemNames;
public class ItemSpark extends ItemMod {
@@ -24,6 +30,26 @@ public class ItemSpark extends ItemMod {
setUnlocalizedName(LibItemNames.SPARK);
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xv, float yv, float zv) {
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof ISparkAttachable) {
ISparkAttachable attach = (ISparkAttachable) tile;
if(attach.canAttachSpark(stack) && attach.getAttachedSpark() == null) {
stack.stackSize--;
if(!world.isRemote) {
EntitySpark spark = new EntitySpark(world);
spark.setPosition(x + 0.5, y + 1.5, z + 0.5);
world.spawnEntityInWorld(spark);
attach.attachSpark(spark);
world.markBlockForUpdate(x, y, z);
}
return true;
}
}
return false;
}
@Override
public void registerIcons(IIconRegister par1IconRegister) {
invIcon = IconHelper.forItem(par1IconRegister, this, 0);
@@ -32,7 +58,7 @@ public class ItemSpark extends ItemMod {
@Override
public IIcon getIconFromDamage(int p_77617_1_) {
return invIcon;
return worldIcon;
}
}
@@ -22,5 +22,6 @@ public final class LibEntityNames {
public static final String VINE_BALL = LibResources.PREFIX_MOD + "vineBall";
public static final String DOPPLEGANGER = LibResources.PREFIX_MOD + "doppleganger";
public static final String MAGIC_LANDMINE = LibResources.PREFIX_MOD + "magicLandmine";
public static final String SPARK = LibResources.PREFIX_MOD + "spark";
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 122 KiB

@@ -16,5 +16,8 @@
1,
0
]
}
},
"texture": {
"blur": true
}
}