mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-14 01:04:16 +00:00
Finalzied the lenses. Added the effect for the damaging and bore lenses.
This commit is contained in:
1 parent
9b226c1643
commit
6f32b307b2
5 files changed
+116
-33
No files matched your search
@@ -54,5 +54,7 @@ public interface IManaBurst {
|
||||
public ItemStack getSourceLens();
|
||||
|
||||
public void setSourceLens(ItemStack lens);
|
||||
|
||||
public boolean hasAlreadyCollidedAt(int x, int y, int z);
|
||||
|
||||
}
|
||||
@@ -34,8 +34,9 @@ public interface ILens {
|
||||
/**
|
||||
* Called when a mana burst fired from a mana spreader with this focus collides against
|
||||
* any block. This is called after the collision is handled.
|
||||
* @return True to kill the burst. False to keep it alive.
|
||||
*/
|
||||
public void collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, ItemStack stack);
|
||||
public boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack);
|
||||
|
||||
/**
|
||||
* Called when a mana burst fired from a mana spreader with this focus is updated.
|
||||
|
||||
@@ -13,7 +13,6 @@ package vazkii.botania.client.render.item;
|
||||
|
||||
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.Tessellator;
|
||||
@@ -103,19 +102,20 @@ public class RenderLens implements IItemRenderer {
|
||||
Color color = new Color(color_);
|
||||
GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) 255);
|
||||
|
||||
boolean shiny = ItemLens.getStoredColor(item) != -1;
|
||||
icon = ItemLens.iconGlass;
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glTranslatef(0F, 0F, -0.5F);
|
||||
renderShinyLensIcon(icon);
|
||||
renderShinyLensIcon(icon, shiny);
|
||||
GL11.glRotatef(180F, 0F, 1F, 0F);
|
||||
GL11.glTranslatef(-16F, 0F, 0F);
|
||||
renderShinyLensIcon(icon);
|
||||
renderShinyLensIcon(icon, shiny);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
}
|
||||
|
||||
public static void renderShinyLensIcon(Icon icon) {
|
||||
public static void renderShinyLensIcon(Icon icon, boolean shiny) {
|
||||
float par1 = 0;
|
||||
float par2 = 0;
|
||||
float par4 = 16;
|
||||
@@ -123,7 +123,8 @@ public class RenderLens implements IItemRenderer {
|
||||
float zLevel = 0F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setBrightness(240);
|
||||
if(shiny)
|
||||
tessellator.setBrightness(240);
|
||||
tessellator.addVertexWithUV((double)(par1 + 0), (double)(par2 + par5), (double)zLevel, (double)icon.getMinU(), (double)icon.getMaxV());
|
||||
tessellator.addVertexWithUV((double)(par1 + par4), (double)(par2 + par5), (double)zLevel, (double)icon.getMaxU(), (double)icon.getMaxV());
|
||||
tessellator.addVertexWithUV((double)(par1 + par4), (double)(par2 + 0), (double)zLevel, (double)icon.getMaxU(), (double)icon.getMinV());
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
package vazkii.botania.common.entity;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -55,6 +56,8 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
|
||||
final int dataWatcherEntries = 10;
|
||||
final int dataWatcherStart = 32 - dataWatcherEntries;
|
||||
|
||||
List<String> alreadyCollidedAt = new ArrayList();
|
||||
|
||||
public EntityManaBurst(World world) {
|
||||
super(world);
|
||||
setSize(0F, 0F);
|
||||
@@ -267,6 +270,9 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
|
||||
|
||||
@Override
|
||||
protected void onImpact(MovingObjectPosition movingobjectposition) {
|
||||
boolean collided = false;
|
||||
boolean dead = false;
|
||||
|
||||
if(movingobjectposition.entityHit == null) {
|
||||
TileEntity tile = worldObj.getBlockTileEntity(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
|
||||
|
||||
@@ -280,13 +286,21 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
|
||||
PacketDispatcher.sendPacketToAllInDimension(tile.getDescriptionPacket(), worldObj.provider.dimensionId);
|
||||
}
|
||||
|
||||
setDead();
|
||||
dead = true;
|
||||
}
|
||||
|
||||
collided = true;
|
||||
}
|
||||
|
||||
ILens lens = getLensInstance();
|
||||
if(lens != null)
|
||||
lens.collideBurst(this, movingobjectposition, collidedTile != null && collidedTile instanceof IManaReceiver && ((IManaReceiver) collidedTile).canRecieveManaFromBursts(), getSourceLens());
|
||||
dead = lens.collideBurst(this, movingobjectposition, collidedTile != null && collidedTile instanceof IManaReceiver && ((IManaReceiver) collidedTile).canRecieveManaFromBursts(), dead, getSourceLens());
|
||||
|
||||
if(collided && !hasAlreadyCollidedAt(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ))
|
||||
alreadyCollidedAt.add(getCollisionLocString(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ));
|
||||
|
||||
if(dead)
|
||||
setDead();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -418,4 +432,13 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
|
||||
lastYMotion = motionY;
|
||||
lastZMotion = motionZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAlreadyCollidedAt(int x, int y, int z) {
|
||||
return alreadyCollidedAt.contains(getCollisionLocString(x, y, z));
|
||||
}
|
||||
|
||||
private String getCollisionLocString(int x, int y, int z) {
|
||||
return x + ":" + y + ":" + z;
|
||||
}
|
||||
}
|
||||
@@ -12,16 +12,22 @@
|
||||
package vazkii.botania.common.item;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.passive.EntitySheep;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.StatCollector;
|
||||
@@ -39,28 +45,28 @@ import vazkii.botania.common.lib.LibItemNames;
|
||||
public class ItemLens extends ItemMod implements ILens {
|
||||
|
||||
private static final String TAG_COLOR = "color";
|
||||
|
||||
|
||||
public static Icon iconGlass;
|
||||
|
||||
|
||||
final int subtypes = 9;
|
||||
Icon[] ringIcons;
|
||||
|
||||
|
||||
public ItemLens() {
|
||||
super(LibItemIDs.idLens);
|
||||
setUnlocalizedName(LibItemNames.LENS);
|
||||
setMaxStackSize(1);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister) {
|
||||
iconGlass = IconHelper.forName(par1IconRegister, "lensInside");
|
||||
|
||||
|
||||
ringIcons = new Icon[subtypes];
|
||||
for(int i = 0; i < ringIcons.length; i++)
|
||||
ringIcons[i] = IconHelper.forNameRaw(par1IconRegister, LibItemNames.LENS_NAMES[i]);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
for(int i = 0; i < subtypes; i++) {
|
||||
@@ -71,17 +77,17 @@ public class ItemLens extends ItemMod implements ILens {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Icon getIconFromDamageForRenderPass(int par1, int par2) {
|
||||
return par2 == 0 ? ringIcons[Math.min(subtypes - 1, par1)] : iconGlass;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Icon getIconFromDamage(int par1) {
|
||||
return getIconFromDamageForRenderPass(par1, 0);
|
||||
@@ -91,25 +97,25 @@ public class ItemLens extends ItemMod implements ILens {
|
||||
public int getColorFromItemStack(ItemStack par1ItemStack, int par2) {
|
||||
return par2 == 1 ? getLensColor(par1ItemStack) : 0xFFFFFF;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack par1ItemStack) {
|
||||
return "item." + LibItemNames.LENS_NAMES[Math.min(subtypes - 1, par1ItemStack.getItemDamage())];
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
|
||||
int storedColor = getStoredColor(par1ItemStack);
|
||||
if(storedColor != -1)
|
||||
par3List.add(String.format(StatCollector.translateToLocal("botaniamisc.color"), StatCollector.translateToLocal("botania.color" + storedColor)));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void apply(ItemStack stack, BurstProperties props) {
|
||||
int storedColor = getStoredColor(stack);
|
||||
if(storedColor != -1)
|
||||
props.color = getLensColor(stack);
|
||||
|
||||
|
||||
switch(stack.getItemDamage()) {
|
||||
case 1 : { // Speed
|
||||
props.motionModifier = 2F;
|
||||
@@ -141,28 +147,78 @@ public class ItemLens extends ItemMod implements ILens {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
EntityThrowable entity = (EntityThrowable) burst;
|
||||
|
||||
switch(stack.getItemDamage()) {
|
||||
case 5 : { // Bounce
|
||||
if(!isManaBlock && pos.entityHit == null) {
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if(coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) {
|
||||
EntityThrowable entity = (EntityThrowable) burst;
|
||||
Vector3 currentMovementVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ);
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit);
|
||||
Vector3 normalVector = new Vector3(dir.offsetX, dir.offsetY, dir.offsetZ).normalize();
|
||||
Vector3 movementVec = normalVector.multiply(-2 * currentMovementVec.dotProduct(normalVector)).add(currentMovementVec);
|
||||
|
||||
|
||||
burst.setMotion(movementVec.x, movementVec.y, movementVec.z);
|
||||
entity.isDead = false;
|
||||
dead = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 7 : { // Bore
|
||||
World world = entity.worldObj;
|
||||
int x = pos.blockX;
|
||||
int y = pos.blockY;
|
||||
int z = pos.blockZ;
|
||||
int id = world.getBlockId(x, y, z);
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
Block block = Block.blocksList[id];
|
||||
float hardness = block.getBlockHardness(world, x, y, z);
|
||||
int mana = burst.getMana();
|
||||
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if((coords.posX != x || coords.posY != y || coords.posZ != z) && !isManaBlock && block != null && hardness != -1 && hardness < 50F && (burst.isFake() || mana >= 64)) {
|
||||
List<ItemStack> items = new ArrayList();
|
||||
|
||||
items.addAll(block.getBlockDropped(world, x, y, z, meta, 0));
|
||||
|
||||
if(!burst.hasAlreadyCollidedAt(x, y, z)) {
|
||||
if(!burst.isFake() && !entity.worldObj.isRemote) {
|
||||
world.setBlockToAir(x, y, z);
|
||||
for(ItemStack stack_ : items)
|
||||
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, stack_));
|
||||
}
|
||||
|
||||
if(!burst.isFake())
|
||||
burst.setMana(mana - 64);
|
||||
}
|
||||
|
||||
dead = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 8 : { // Damaging
|
||||
if(pos.entityHit != null && pos.entityHit instanceof EntityLivingBase) {
|
||||
EntityLivingBase living = (EntityLivingBase) pos.entityHit;
|
||||
if(living.hurtTime == 0) {
|
||||
int mana = burst.getMana();
|
||||
if(mana >= 32) {
|
||||
burst.setMana(mana - 32);
|
||||
if(!burst.isFake() && !entity.worldObj.isRemote)
|
||||
living.attackEntityFrom(DamageSource.magic, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dead;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateBurst(IManaBurst burst, ItemStack stack) {
|
||||
int storedColor = getStoredColor(stack);
|
||||
@@ -173,23 +229,23 @@ public class ItemLens extends ItemMod implements ILens {
|
||||
@Override
|
||||
public int getLensColor(ItemStack stack) {
|
||||
int storedColor = getStoredColor(stack);
|
||||
|
||||
|
||||
if(storedColor == -1)
|
||||
return 0xFFFFFF;
|
||||
|
||||
|
||||
if(storedColor == 16) {
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
return world == null ? 0xFFFFFF : Color.HSBtoRGB((float) ((world.getTotalWorldTime() * 2) % 360) / 360F, 1F, 1F);
|
||||
}
|
||||
|
||||
|
||||
float[] color = EntitySheep.fleeceColorTable[storedColor];
|
||||
return new Color(color[0], color[1], color[2]).getRGB();
|
||||
}
|
||||
|
||||
public int getStoredColor(ItemStack stack) {
|
||||
|
||||
public static int getStoredColor(ItemStack stack) {
|
||||
return ItemNBTHelper.getInt(stack, TAG_COLOR, -1);
|
||||
}
|
||||
|
||||
|
||||
public void setLensColor(ItemStack stack, int color) {
|
||||
ItemNBTHelper.setInt(stack, TAG_COLOR, color);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user