mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 03:15:07 +00:00
Avatars, part 1
This commit is contained in:
1 parent
ce231bcea5
commit
77d21be8b6
21 files changed
+704
-49
No files matched your search
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 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 the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Oct 24, 2015, 7:00:21 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.api.item;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import vazkii.botania.api.mana.IManaReceiver;
|
||||
|
||||
/**
|
||||
* A TileEntity that implements this is considered an Avatar.
|
||||
*/
|
||||
public interface IAvatarTile extends IInventory, IManaReceiver {
|
||||
|
||||
/**
|
||||
* Gets the amount of ticks that have elapsed on this avatar while it's functional
|
||||
* (has redstone signal).
|
||||
*/
|
||||
public int getElapsedFunctionalTicks();
|
||||
|
||||
/**
|
||||
* Gets if this avatar is enabled (isn't powered by a redstone signal).
|
||||
*/
|
||||
public boolean isEnabled();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* 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 the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Oct 24, 2015, 6:45:50 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.api.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
/**
|
||||
* An Item that implements this can be wielded by an Avatar.
|
||||
*/
|
||||
public interface IAvatarWieldable {
|
||||
|
||||
/**
|
||||
* Called on update of the avatar tile.
|
||||
*/
|
||||
public void onAvatarUpdate(IAvatarTile tile, ItemStack stack);
|
||||
|
||||
/**
|
||||
* Gets the overlay resource to render on top of the avatar tile.
|
||||
*/
|
||||
public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack);
|
||||
|
||||
}
|
||||
@@ -92,6 +92,7 @@ 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.RenderTileAvatar;
|
||||
import vazkii.botania.client.render.tile.RenderTileBellows;
|
||||
import vazkii.botania.client.render.tile.RenderTileBrewery;
|
||||
import vazkii.botania.client.render.tile.RenderTileCocoon;
|
||||
@@ -119,6 +120,7 @@ import vazkii.botania.client.render.tile.RenderTileTinyPotato;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.TileAlfPortal;
|
||||
import vazkii.botania.common.block.tile.TileAltar;
|
||||
import vazkii.botania.common.block.tile.TileAvatar;
|
||||
import vazkii.botania.common.block.tile.TileBrewery;
|
||||
import vazkii.botania.common.block.tile.TileCocoon;
|
||||
import vazkii.botania.common.block.tile.TileEnchanter;
|
||||
@@ -316,6 +318,7 @@ public class ClientProxy extends CommonProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileBellows.class, new RenderTileBellows());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileGaiaHead.class, new RenderTileSkullOverride());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileTeruTeruBozu.class, new RenderTileTeruTeruBozu());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileAvatar.class, new RenderTileAvatar());
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySkull.class, new RenderTileSkullOverride());
|
||||
|
||||
|
||||
@@ -31,5 +31,6 @@ public final class LibRenderIDs {
|
||||
public static int idLightRelay = -1;
|
||||
public static int idBellows = -1;
|
||||
public static int idTeruTeruBozu = -1;
|
||||
public static int idAvatar = -1;
|
||||
|
||||
}
|
||||
@@ -118,7 +118,13 @@ public final class LibResources {
|
||||
public static final String MODEL_BELLOWS = PREFIX_MODEL + "bellows.png";
|
||||
public static final String MODEL_TERU_TERU_BOZU = PREFIX_MODEL + "teruTeruBozu.png";
|
||||
public static final String MODEL_TERU_TERU_BOZU_HALLOWEEN = PREFIX_MODEL + "teruTeruBozu_halloween.png";
|
||||
|
||||
public static final String MODEL_AVATAR = PREFIX_MODEL + "avatar.png";
|
||||
public static final String MODEL_AVATAR_DIVINING = PREFIX_MODEL + "avatarDivining.png";
|
||||
public static final String MODEL_AVATAR_FIRE = PREFIX_MODEL + "avatarFire.png";
|
||||
public static final String MODEL_AVATAR_MISSILE = PREFIX_MODEL + "avatarMissile.png";
|
||||
public static final String MODEL_AVATAR_RAINBOW = PREFIX_MODEL + "avatarRainbow.png";
|
||||
public static final String MODEL_AVATAR_TORNADO = PREFIX_MODEL + "avatarTornado.png";
|
||||
|
||||
public static final String MISC_PARTICLES = PREFIX_MISC + "particles.png";
|
||||
public static final String MISC_WISP_LARGE = PREFIX_MISC + "wispLarge.png";
|
||||
public static final String MISC_WISP_SMALL = PREFIX_MISC + "wispSmall.png";
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* This class was created by <wiiv>. 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 the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [? (GMT)]
|
||||
*/
|
||||
package vazkii.botania.client.model;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public class ModelAvatar extends ModelBase {
|
||||
|
||||
public ModelRenderer body;
|
||||
public ModelRenderer rightarm;
|
||||
public ModelRenderer leftarm;
|
||||
public ModelRenderer rightleg;
|
||||
public ModelRenderer leftleg;
|
||||
public ModelRenderer head;
|
||||
|
||||
public ModelAvatar() {
|
||||
this.textureWidth = 32;
|
||||
this.textureHeight = 32;
|
||||
this.leftleg = new ModelRenderer(this, 0, 20);
|
||||
this.leftleg.mirror = true;
|
||||
this.leftleg.setRotationPoint(1.5F, 18.0F, -0.5F);
|
||||
this.leftleg.addBox(-1.5F, 0.0F, -1.5F, 3, 6, 3, 0.0F);
|
||||
this.rightarm = new ModelRenderer(this, 0, 20);
|
||||
this.rightarm.setRotationPoint(-3.0F, 15.0F, -1.0F);
|
||||
this.rightarm.addBox(-2.0F, -1.0F, -1.0F, 2, 6, 3, 0.0F);
|
||||
this.setRotateAngle(rightarm, 0.0F, -0.0F, 0.08726646259971647F);
|
||||
this.leftarm = new ModelRenderer(this, 0, 20);
|
||||
this.leftarm.mirror = true;
|
||||
this.leftarm.setRotationPoint(3.0F, 15.0F, -1.0F);
|
||||
this.leftarm.addBox(0.0F, -1.0F, -1.0F, 2, 6, 3, 0.0F);
|
||||
this.setRotateAngle(leftarm, 0.0F, -0.0F, -0.08726646259971647F);
|
||||
this.head = new ModelRenderer(this, 0, 0);
|
||||
this.head.setRotationPoint(0.0F, 14.0F, 0.0F);
|
||||
this.head.addBox(-3.0F, -6.0F, -3.0F, 6, 6, 6, 0.0F);
|
||||
this.rightleg = new ModelRenderer(this, 0, 20);
|
||||
this.rightleg.setRotationPoint(-1.5F, 18.0F, -0.5F);
|
||||
this.rightleg.addBox(-1.5F, 0.0F, -1.5F, 3, 6, 3, 0.0F);
|
||||
this.body = new ModelRenderer(this, 0, 12);
|
||||
this.body.setRotationPoint(0.0F, 14.0F, 0.0F);
|
||||
this.body.addBox(-3.0F, 0.0F, -2.0F, 6, 4, 4, 0.0F);
|
||||
}
|
||||
|
||||
public void render() {
|
||||
float f5 = 1F / 15F;
|
||||
this.leftleg.render(f5);
|
||||
this.rightarm.render(f5);
|
||||
this.leftarm.render(f5);
|
||||
this.head.render(f5);
|
||||
this.rightleg.render(f5);
|
||||
this.body.render(f5);
|
||||
}
|
||||
|
||||
public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) {
|
||||
modelRenderer.rotateAngleX = x;
|
||||
modelRenderer.rotateAngleY = y;
|
||||
modelRenderer.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* 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 the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Oct 24, 2015, 3:51:35 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.client.render.tile;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import vazkii.botania.api.item.IAvatarWieldable;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.client.model.ModelAvatar;
|
||||
import vazkii.botania.common.block.tile.TileAvatar;
|
||||
import vazkii.botania.common.block.tile.TileSparkChanger;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
|
||||
public class RenderTileAvatar extends TileEntitySpecialRenderer {
|
||||
|
||||
private static final float[] ROTATIONS = new float[] {
|
||||
180F, 0F, 90F, 270F
|
||||
};
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_AVATAR);
|
||||
private static final ModelAvatar model = new ModelAvatar();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) {
|
||||
TileAvatar avatar = (TileAvatar) tileentity;
|
||||
Block block = avatar.getBlockType();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
GL11.glTranslated(d0, d1, d2);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
||||
int meta = avatar.getWorldObj() != null ? avatar.getBlockMetadata() : 0;
|
||||
|
||||
GL11.glTranslatef(0.5F, 1.6F, 0.5F);
|
||||
GL11.glScalef(1F, -1F, -1F);
|
||||
GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length - 1, meta - 2), 0)], 0F, 1F, 0F);
|
||||
model.render();
|
||||
|
||||
ItemStack stack = avatar.getStackInSlot(0);
|
||||
if(stack != null) {
|
||||
GL11.glPushMatrix();
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
|
||||
float s = 0.4F;
|
||||
GL11.glScalef(s, s, s);
|
||||
GL11.glRotatef(90F, 0F, 1F, 0F);
|
||||
GL11.glRotatef(180F, 0F, 0F, 1F);
|
||||
GL11.glTranslated(-1.2F, -3.5F, -0.65F);
|
||||
GL11.glRotatef(20F, 0F, 0F, 1F);
|
||||
|
||||
int renderPass = 0;
|
||||
do {
|
||||
IIcon icon = stack.getItem().getIcon(stack, renderPass);
|
||||
if(icon != null) {
|
||||
Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass));
|
||||
GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
|
||||
float f = icon.getMinU();
|
||||
float f1 = icon.getMaxU();
|
||||
float f2 = icon.getMinV();
|
||||
float f3 = icon.getMaxV();
|
||||
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
|
||||
GL11.glColor3f(1F, 1F, 1F);
|
||||
}
|
||||
renderPass++;
|
||||
} while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage()));
|
||||
GL11.glPopMatrix();
|
||||
|
||||
IAvatarWieldable wieldable = (IAvatarWieldable) stack.getItem();
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(wieldable.getOverlayResource(avatar, stack));
|
||||
s = 1.01F;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glScalef(s, s, s);
|
||||
GL11.glTranslatef(0F, -0.01F, 0F);
|
||||
int light = 15728880;
|
||||
int lightmapX = light % 65536;
|
||||
int lightmapY = light / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
|
||||
float alpha = (float) Math.sin(ClientTickHandler.ticksInGame / 20D) / 2F + 0.5F;
|
||||
GL11.glColor4f(1F, 1F, 1F, alpha + 0.183F);
|
||||
model.render();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
GL11.glColor3f(1F, 1F, 1F);
|
||||
GL11.glScalef(1F, -1F, -1F);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
/**
|
||||
* 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 the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Oct 24, 2015, 3:15:11 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.common.util.RotationHelper;
|
||||
import vazkii.botania.api.item.IAvatarWieldable;
|
||||
import vazkii.botania.client.lib.LibRenderIDs;
|
||||
import vazkii.botania.common.block.tile.TileAvatar;
|
||||
import vazkii.botania.common.block.tile.TileSimpleInventory;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class BlockAvatar extends BlockModContainer {
|
||||
|
||||
private static final int[] META_ROTATIONS = new int[] { 2, 5, 3, 4 };
|
||||
|
||||
Random random;
|
||||
|
||||
protected BlockAvatar() {
|
||||
super(Material.wood);
|
||||
setHardness(2.0F);
|
||||
setStepSound(soundTypeWood);
|
||||
setBlockName(LibBlockNames.AVATAR);
|
||||
setBlockBounds(true);
|
||||
|
||||
random = new Random();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) {
|
||||
TileAvatar avatar = (TileAvatar) world.getTileEntity(x, y, z);
|
||||
ItemStack stackOnAvatar = avatar.getStackInSlot(0);
|
||||
ItemStack stackOnPlayer = player.getCurrentEquippedItem();
|
||||
if(stackOnAvatar != null) {
|
||||
ItemStack copyStack = stackOnAvatar.copy();
|
||||
avatar.setInventorySlotContents(0, null);
|
||||
if(!player.inventory.addItemStackToInventory(copyStack))
|
||||
player.dropPlayerItemWithRandomChoice(copyStack, true);
|
||||
return true;
|
||||
} else if(stackOnPlayer != null && stackOnPlayer.getItem() instanceof IAvatarWieldable) {
|
||||
ItemStack copyStack = stackOnPlayer.copy();
|
||||
avatar.setInventorySlotContents(0, copyStack);
|
||||
stackOnPlayer.stackSize--;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z) {
|
||||
setBlockBounds(w.getBlockMetadata(x, y, z) < 4);
|
||||
}
|
||||
|
||||
public void setBlockBounds(boolean horiz) {
|
||||
float f = 1F / 16F;
|
||||
float w = f * 9;
|
||||
float l = f * 6;
|
||||
float ws = (1F - w) / 2;
|
||||
float ls = (1F - l) / 2;
|
||||
|
||||
if(horiz)
|
||||
setBlockBounds(ws, 0F, ls, 1F - ws, 1F + f, 1F - ls);
|
||||
else setBlockBounds(ls, 0F, ws, 1F - ls, 1F + f, 1F - ws);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
|
||||
TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4);
|
||||
|
||||
if (inv != null) {
|
||||
for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) {
|
||||
ItemStack itemstack = inv.getStackInSlot(j1);
|
||||
|
||||
if (itemstack != null) {
|
||||
float f = random.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = random.nextFloat() * 0.8F + 0.1F;
|
||||
EntityItem entityitem;
|
||||
|
||||
for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) {
|
||||
int k1 = random.nextInt(21) + 10;
|
||||
|
||||
if (k1 > itemstack.stackSize)
|
||||
k1 = itemstack.stackSize;
|
||||
|
||||
itemstack.stackSize -= k1;
|
||||
entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX = (float)random.nextGaussian() * f3;
|
||||
entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
|
||||
entityitem.motionZ = (float)random.nextGaussian() * f3;
|
||||
|
||||
if (itemstack.hasTagCompound())
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
par1World.func_147453_f(par2, par3, par4, par5);
|
||||
}
|
||||
|
||||
super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) {
|
||||
int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) {
|
||||
return RotationHelper.rotateVanillaBlock(Blocks.furnace, worldObj, x, y, z, axis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return ModBlocks.livingwood.getIcon(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return LibRenderIDs.idAvatar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileAvatar();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -118,6 +118,7 @@ import vazkii.botania.common.block.subtile.generating.SubTileSpectrolus;
|
||||
import vazkii.botania.common.block.subtile.generating.SubTileThermalily;
|
||||
import vazkii.botania.common.block.tile.TileAlfPortal;
|
||||
import vazkii.botania.common.block.tile.TileAltar;
|
||||
import vazkii.botania.common.block.tile.TileAvatar;
|
||||
import vazkii.botania.common.block.tile.TileBifrost;
|
||||
import vazkii.botania.common.block.tile.TileBrewery;
|
||||
import vazkii.botania.common.block.tile.TileCacophonium;
|
||||
@@ -265,6 +266,7 @@ public final class ModBlocks {
|
||||
public static Block teruTeruBozu;
|
||||
public static Block shimmerrock;
|
||||
public static Block shimmerwoodPlanks;
|
||||
public static Block avatar;
|
||||
|
||||
public static void init() {
|
||||
flower = new BlockModFlower();
|
||||
@@ -355,7 +357,8 @@ public final class ModBlocks {
|
||||
teruTeruBozu = new BlockTeruTeruBozu();
|
||||
shimmerrock = new BlockShimmerrock();
|
||||
shimmerwoodPlanks = new BlockShimmerwoodPlanks();
|
||||
|
||||
avatar = new BlockAvatar();
|
||||
|
||||
ModFluffBlocks.init();
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
@@ -459,6 +462,7 @@ public final class ModBlocks {
|
||||
registerTile(TileGaiaHead.class, LibBlockNames.GAIA_HEAD);
|
||||
registerTile(TileCorporeaRetainer.class, LibBlockNames.CORPOREA_RETAINER);
|
||||
registerTile(TileTeruTeruBozu.class, LibBlockNames.TERU_TERU_BOZU);
|
||||
registerTile(TileAvatar.class, LibBlockNames.AVATAR);
|
||||
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_PUREDAISY, SubTilePureDaisy.class);
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MANASTAR, SubTileManastar.class);
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* 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 the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Oct 24, 2015, 3:17:44 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import vazkii.botania.api.item.IAvatarTile;
|
||||
import vazkii.botania.api.item.IAvatarWieldable;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class TileAvatar extends TileSimpleInventory implements IAvatarTile, ISidedInventory {
|
||||
|
||||
private static final int MAX_MANA = 6400;
|
||||
|
||||
private static final String TAG_ENABLED = "enabled";
|
||||
private static final String TAG_TICKS_ELAPSED = "ticksElapsed";
|
||||
private static final String TAG_MANA = "ticksElapsed";
|
||||
|
||||
boolean enabled;
|
||||
int ticksElapsed;
|
||||
int mana;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
enabled = true;
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal());
|
||||
if(redstoneSide > 0) {
|
||||
enabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack stack = getStackInSlot(0);
|
||||
if(stack != null && stack.getItem() instanceof IAvatarWieldable) {
|
||||
IAvatarWieldable wieldable = (IAvatarWieldable) stack.getItem();
|
||||
wieldable.onAvatarUpdate(this, stack);
|
||||
}
|
||||
|
||||
if(enabled)
|
||||
ticksElapsed++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) {
|
||||
super.writeCustomNBT(par1nbtTagCompound);
|
||||
par1nbtTagCompound.setBoolean(TAG_ENABLED, enabled);
|
||||
par1nbtTagCompound.setInteger(TAG_TICKS_ELAPSED, ticksElapsed);
|
||||
par1nbtTagCompound.setInteger(TAG_MANA, mana);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(NBTTagCompound par1nbtTagCompound) {
|
||||
super.readCustomNBT(par1nbtTagCompound);
|
||||
enabled = par1nbtTagCompound.getBoolean(TAG_ENABLED);
|
||||
ticksElapsed = par1nbtTagCompound.getInteger(TAG_TICKS_ELAPSED);
|
||||
mana = par1nbtTagCompound.getInteger(TAG_MANA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
return itemstack != null && itemstack.getItem() instanceof IAvatarTile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int p_94128_1_) {
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return LibBlockNames.AVATAR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFull() {
|
||||
return mana >= MAX_MANA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recieveMana(int mana) {
|
||||
this.mana = Math.min(MAX_MANA, this.mana + mana);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRecieveManaFromBursts() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentMana() {
|
||||
return mana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getElapsedFunctionalTicks() {
|
||||
return ticksElapsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -74,6 +74,7 @@ public final class BotaniaCreativeTab extends CreativeTabs {
|
||||
addItem(ModItems.manaCookie);
|
||||
addItem(ModItems.rune);
|
||||
|
||||
addBlock(ModBlocks.avatar);
|
||||
addItem(ModItems.dirtRod);
|
||||
addItem(ModItems.skyDirtRod);
|
||||
addItem(ModItems.cobbleRod);
|
||||
|
||||
@@ -34,7 +34,6 @@ public class EntityMagicMissile extends EntityThrowable {
|
||||
|
||||
private static final String TAG_TIME = "time";
|
||||
|
||||
EntityLivingBase target;
|
||||
double lockX, lockY = -1, lockZ;
|
||||
int time = 0;
|
||||
|
||||
@@ -52,18 +51,36 @@ public class EntityMagicMissile extends EntityThrowable {
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
dataWatcher.addObject(25, (byte) 0);
|
||||
dataWatcher.addObject(26, 0);
|
||||
}
|
||||
|
||||
public void setEvil(boolean evil) {
|
||||
dataWatcher.updateObject(25, (byte) (evil ? 1 : 0));
|
||||
}
|
||||
|
||||
|
||||
public boolean isEvil() {
|
||||
return dataWatcher.getWatchableObjectByte(25) == 1;
|
||||
}
|
||||
|
||||
public void setTarget(EntityLivingBase e) {
|
||||
dataWatcher.updateObject(26, e == null ? -1 : e.getEntityId());
|
||||
}
|
||||
|
||||
public EntityLivingBase getTargetEntity() {
|
||||
int id = dataWatcher.getWatchableObjectInt(26);
|
||||
Entity e = worldObj.getEntityByID(id);
|
||||
if(e != null && e instanceof EntityLivingBase)
|
||||
return (EntityLivingBase) e;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
double lastTickPosX = this.lastTickPosX;
|
||||
double lastTickPosY = this.lastTickPosY;
|
||||
double lastTickPosZ = this.lastTickPosZ;
|
||||
|
||||
super.onUpdate();
|
||||
|
||||
if(!worldObj.isRemote && (!getTarget() || time > 40)) {
|
||||
@@ -89,7 +106,8 @@ public class EntityMagicMissile extends EntityThrowable {
|
||||
}
|
||||
Botania.proxy.setSparkleFXCorrupt(false);
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
EntityLivingBase target = getTargetEntity();
|
||||
if(target != null) {
|
||||
if(lockY == -1) {
|
||||
lockX = target.posX;
|
||||
lockY = target.posY;
|
||||
@@ -134,20 +152,23 @@ public class EntityMagicMissile extends EntityThrowable {
|
||||
|
||||
|
||||
public boolean getTarget() {
|
||||
EntityLivingBase target = getTargetEntity();
|
||||
if(target != null && target.getHealth() > 0 && !target.isDead && worldObj.loadedEntityList.contains(target))
|
||||
return true;
|
||||
target = null;
|
||||
if(target != null)
|
||||
setTarget(null);
|
||||
|
||||
double range = 12;
|
||||
List entities = worldObj.getEntitiesWithinAABB(isEvil() ? EntityPlayer.class : IMob.class, AxisAlignedBB.getBoundingBox(posX - range, posY - range, posZ - range, posX + range, posY + range, posZ + range));
|
||||
while(entities.size() > 0) {
|
||||
Entity e = (Entity) entities.get(worldObj.rand.nextInt(entities.size()));
|
||||
if(!(e instanceof EntityLivingBase)) { // Just in case...
|
||||
if(!(e instanceof EntityLivingBase) || e.isDead) { // Just in case...
|
||||
entities.remove(e);
|
||||
continue;
|
||||
}
|
||||
|
||||
target = (EntityLivingBase) e;
|
||||
setTarget(target);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -158,7 +179,7 @@ public class EntityMagicMissile extends EntityThrowable {
|
||||
protected void onImpact(MovingObjectPosition pos) {
|
||||
Block block = worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
|
||||
|
||||
if(!(block instanceof BlockBush) && !(block instanceof BlockLeaves) && (pos.entityHit == null || target == pos.entityHit))
|
||||
if(!(block instanceof BlockBush) && !(block instanceof BlockLeaves) && (pos.entityHit == null || getTargetEntity() == pos.entityHit))
|
||||
setDead();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public final class ModEntities {
|
||||
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);
|
||||
EntityRegistry.registerModEntity(EntityThrownItem.class, LibEntityNames.THROWN_ITEM, id++, Botania.instance, 64, 20, true);
|
||||
EntityRegistry.registerModEntity(EntityMagicMissile.class, LibEntityNames.MAGIC_MISSILE, id++, Botania.instance, 64, 10, true);
|
||||
EntityRegistry.registerModEntity(EntityMagicMissile.class, LibEntityNames.MAGIC_MISSILE, id++, Botania.instance, 64, 2, true);
|
||||
EntityRegistry.registerModEntity(EntityThornChakram.class, LibEntityNames.THORN_CHAKRAM, id++, Botania.instance, 64, 10, true);
|
||||
EntityRegistry.registerModEntity(EntityCorporeaSpark.class, LibEntityNames.CORPOREA_SPARK, id++, Botania.instance, 64, 10, false);
|
||||
EntityRegistry.registerModEntity(EntityEnderAirBottle.class, LibEntityNames.ENDER_AIR_BOTTLE, id++, Botania.instance, 64, 10, true);
|
||||
|
||||
@@ -15,18 +15,25 @@ import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import vazkii.botania.api.item.IAvatarTile;
|
||||
import vazkii.botania.api.item.IAvatarWieldable;
|
||||
import vazkii.botania.api.item.IManaProficiencyArmor;
|
||||
import vazkii.botania.api.mana.IManaUsingItem;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.item.ItemMod;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class ItemDiviningRod extends ItemMod implements IManaUsingItem {
|
||||
public class ItemDiviningRod extends ItemMod implements IManaUsingItem, IAvatarWieldable {
|
||||
|
||||
private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_DIVINING);
|
||||
|
||||
static final int COST = 3000;
|
||||
|
||||
public ItemDiviningRod() {
|
||||
@@ -43,27 +50,7 @@ public class ItemDiviningRod extends ItemMod implements IManaUsingItem {
|
||||
int z = MathHelper.floor_double(p.posZ);
|
||||
int range = IManaProficiencyArmor.Helper.hasProficiency(p) ? 20 : 15;
|
||||
long seedxor = world.rand.nextLong();
|
||||
|
||||
Botania.proxy.setWispFXDepthTest(false);
|
||||
for(int i = -range; i < range + 1; i++)
|
||||
for(int j = -range; j < range + 1; j++)
|
||||
for(int k = -range; k < range + 1; k++) {
|
||||
int xp = x + i;
|
||||
int yp = y + j;
|
||||
int zp = z + k;
|
||||
Block block = world.getBlock(xp, yp, zp);
|
||||
int meta = world.getBlockMetadata(xp, yp, zp);
|
||||
ItemStack orestack = new ItemStack(block, 1, meta);
|
||||
for(int id : OreDictionary.getOreIDs(orestack)) {
|
||||
String s = OreDictionary.getOreName(id);
|
||||
if(s.matches("^ore[A-Z].+")) {
|
||||
Random rand = new Random(s.hashCode() ^ seedxor);
|
||||
Botania.proxy.wispFX(world, xp + world.rand.nextFloat(), yp + world.rand.nextFloat(), zp + world.rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 0.25F, 0F, 8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Botania.proxy.setWispFXDepthTest(true);
|
||||
doHighlight(world, x, y, z, range, seedxor);
|
||||
p.swingItem();
|
||||
} else world.playSoundAtEntity(p, "botania:divinationRod", 1F, 1F);
|
||||
}
|
||||
@@ -71,8 +58,46 @@ public class ItemDiviningRod extends ItemMod implements IManaUsingItem {
|
||||
return stack;
|
||||
}
|
||||
|
||||
public void doHighlight(World world, int x, int y, int z, int range, long seedxor) {
|
||||
Botania.proxy.setWispFXDepthTest(false);
|
||||
for(int i = -range; i < range + 1; i++)
|
||||
for(int j = -range; j < range + 1; j++)
|
||||
for(int k = -range; k < range + 1; k++) {
|
||||
int xp = x + i;
|
||||
int yp = y + j;
|
||||
int zp = z + k;
|
||||
Block block = world.getBlock(xp, yp, zp);
|
||||
int meta = world.getBlockMetadata(xp, yp, zp);
|
||||
ItemStack orestack = new ItemStack(block, 1, meta);
|
||||
for(int id : OreDictionary.getOreIDs(orestack)) {
|
||||
String s = OreDictionary.getOreName(id);
|
||||
if(s.matches("^ore[A-Z].+")) {
|
||||
Random rand = new Random(s.hashCode() ^ seedxor);
|
||||
Botania.proxy.wispFX(world, xp + world.rand.nextFloat(), yp + world.rand.nextFloat(), zp + world.rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 0.25F, 0F, 8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Botania.proxy.setWispFXDepthTest(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesMana(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) {
|
||||
TileEntity te = (TileEntity) tile;
|
||||
World world = te.getWorldObj();
|
||||
if(tile.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 200 == 0 && tile.isEnabled()) {
|
||||
doHighlight(world, te.xCoord, te.yCoord, te.zCoord, 18, te.xCoord ^ te.yCoord ^ te.zCoord);
|
||||
tile.recieveMana(-COST);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) {
|
||||
return avatarOverlay;
|
||||
}
|
||||
}
|
||||
@@ -13,16 +13,23 @@ package vazkii.botania.common.item.rod;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.item.IAvatarTile;
|
||||
import vazkii.botania.api.item.IAvatarWieldable;
|
||||
import vazkii.botania.api.item.IManaProficiencyArmor;
|
||||
import vazkii.botania.api.mana.IManaUsingItem;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.entity.EntityFlameRing;
|
||||
import vazkii.botania.common.item.ItemMod;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class ItemFireRod extends ItemMod implements IManaUsingItem {
|
||||
public class ItemFireRod extends ItemMod implements IManaUsingItem, IAvatarWieldable {
|
||||
|
||||
private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_FIRE);
|
||||
|
||||
private static final int COST = 900;
|
||||
private static final int COOLDOWN = 1200;
|
||||
|
||||
@@ -63,4 +70,22 @@ public class ItemFireRod extends ItemMod implements IManaUsingItem {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) {
|
||||
TileEntity te = (TileEntity) tile;
|
||||
World world = te.getWorldObj();
|
||||
|
||||
if(!world.isRemote && tile.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 300 == 0 && tile.isEnabled()) {
|
||||
EntityFlameRing entity = new EntityFlameRing(world);
|
||||
entity.setPosition(te.xCoord + 0.5, te.yCoord, te.zCoord + 0.5);
|
||||
world.spawnEntityInWorld(entity);
|
||||
tile.recieveMana(-COST);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) {
|
||||
return avatarOverlay;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,21 +10,30 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.rod;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.item.IAvatarTile;
|
||||
import vazkii.botania.api.item.IAvatarWieldable;
|
||||
import vazkii.botania.api.item.IManaProficiencyArmor;
|
||||
import vazkii.botania.api.mana.IManaUsingItem;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.entity.EntityMagicMissile;
|
||||
import vazkii.botania.common.item.ItemMod;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class ItemMissileRod extends ItemMod implements IManaUsingItem {
|
||||
public class ItemMissileRod extends ItemMod implements IManaUsingItem, IAvatarWieldable {
|
||||
|
||||
private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_MISSILE);
|
||||
|
||||
private static final int COST_PER = 120;
|
||||
private static final int COST_AVATAR = 70;
|
||||
|
||||
public ItemMissileRod() {
|
||||
super();
|
||||
@@ -45,16 +54,30 @@ public class ItemMissileRod extends ItemMod implements IManaUsingItem {
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
|
||||
if(count != getMaxItemUseDuration(stack) && count % (IManaProficiencyArmor.Helper.hasProficiency(player) ? 1 : 2) == 0 && !player.worldObj.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, false)) {
|
||||
EntityMagicMissile missile = new EntityMagicMissile(player, false);
|
||||
missile.setPosition(player.posX + (Math.random() - 0.5 * 0.1), player.posY + 2.4 + (Math.random() - 0.5 * 0.1), player.posZ + (Math.random() - 0.5 * 0.1));
|
||||
if(missile.getTarget()) {
|
||||
player.worldObj.playSoundAtEntity(player, "botania:missile", 0.6F, 0.8F + (float) Math.random() * 0.2F);
|
||||
player.worldObj.spawnEntityInWorld(missile);
|
||||
if(spawnMissile(player.worldObj, player, player.posX + (Math.random() - 0.5 * 0.1), player.posY + 2.4 + (Math.random() - 0.5 * 0.1), player.posZ + (Math.random() - 0.5 * 0.1)))
|
||||
ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, true);
|
||||
}
|
||||
|
||||
Botania.proxy.sparkleFX(player.worldObj, player.posX, player.posY + 2.4, player.posZ, 1F, 0.4F, 1F, 6F, 6);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean spawnMissile(World world, EntityLivingBase thrower, double x, double y, double z) {
|
||||
EntityMagicMissile missile;
|
||||
if(thrower != null)
|
||||
missile = new EntityMagicMissile(thrower, false);
|
||||
else missile = new EntityMagicMissile(world);
|
||||
|
||||
missile.setPosition(x, y, z);
|
||||
if(missile.getTarget()) {
|
||||
if(!world.isRemote) {
|
||||
world.playSoundEffect(x, y, z, "botania:missile", 0.6F, 0.8F + (float) Math.random() * 0.2F);
|
||||
world.spawnEntityInWorld(missile);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
|
||||
@@ -71,4 +94,21 @@ public class ItemMissileRod extends ItemMod implements IManaUsingItem {
|
||||
public boolean usesMana(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) {
|
||||
TileEntity te = (TileEntity) tile;
|
||||
World world = te.getWorldObj();
|
||||
if(tile.getCurrentMana() >= COST_AVATAR && tile.getElapsedFunctionalTicks() % 3 == 0 && tile.isEnabled())
|
||||
if(spawnMissile(world, null, te.xCoord + 0.5 + (Math.random() - 0.5 * 0.1), te.yCoord + 2.5 + (Math.random() - 0.5 * 0.1), te.zCoord + (Math.random() - 0.5 * 0.1))) {
|
||||
if(!world.isRemote)
|
||||
tile.recieveMana(-COST_AVATAR);
|
||||
Botania.proxy.sparkleFX(world, te.xCoord + 0.5, te.yCoord + 2.5, te.zCoord + 0.5, 1F, 0.4F, 1F, 6F, 6);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) {
|
||||
return avatarOverlay;
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,14 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.item.IAvatarTile;
|
||||
import vazkii.botania.api.item.IAvatarWieldable;
|
||||
import vazkii.botania.api.item.IManaProficiencyArmor;
|
||||
import vazkii.botania.api.mana.IManaUsingItem;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.TileBifrost;
|
||||
@@ -25,8 +29,10 @@ import vazkii.botania.common.core.helper.Vector3;
|
||||
import vazkii.botania.common.item.ItemMod;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class ItemRainbowRod extends ItemMod implements IManaUsingItem {
|
||||
public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWieldable {
|
||||
|
||||
private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_RAINBOW);
|
||||
|
||||
private static final int MANA_COST = 750;
|
||||
private static final int TIME = 600;
|
||||
|
||||
@@ -122,4 +128,13 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) {
|
||||
return avatarOverlay;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,18 +16,24 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.item.IAvatarTile;
|
||||
import vazkii.botania.api.item.IAvatarWieldable;
|
||||
import vazkii.botania.api.item.IManaProficiencyArmor;
|
||||
import vazkii.botania.api.mana.IManaUsingItem;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.item.ItemMod;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class ItemTornadoRod extends ItemMod implements IManaUsingItem {
|
||||
public class ItemTornadoRod extends ItemMod implements IManaUsingItem, IAvatarWieldable {
|
||||
|
||||
private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_TORNADO);
|
||||
|
||||
private static final int FLY_TIME = 20;
|
||||
private static final int FALL_MULTIPLIER = 3;
|
||||
private static final int MAX_DAMAGE = FLY_TIME * FALL_MULTIPLIER;
|
||||
@@ -140,4 +146,13 @@ public class ItemTornadoRod extends ItemMod implements IManaUsingItem {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) {
|
||||
return avatarOverlay;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -104,6 +104,7 @@ public final class LibBlockNames {
|
||||
public static final String TERU_TERU_BOZU = "teruTeruBozu";
|
||||
public static final String SHIMMERROCK = "shimmerrock";
|
||||
public static final String SHIMMERWOOD_PLANKS = "shimmerwoodPlanks";
|
||||
public static final String AVATAR = "avatar";
|
||||
|
||||
public static final String SUBTILE_PUREDAISY = "puredaisy";
|
||||
public static final String SUBTILE_MANASTAR = "manastar";
|
||||
|
||||
Reference in new issue
Block a user