From b422b7b82a14d55f4cfe2da8e758ec37a5389c3c Mon Sep 17 00:00:00 2001 From: Vasco Lavos Date: Sat, 1 Feb 2014 18:09:41 +0000 Subject: [PATCH] Some balance and lens work - Impleneted the Bounce Lens. --- .../common/block/tile/TileSpreader.java | 68 +++++++++---------- .../common/entity/EntityManaBurst.java | 23 ++----- .../vazkii/botania/common/item/ItemLens.java | 35 ++++++++-- 3 files changed, 69 insertions(+), 57 deletions(-) diff --git a/MODSRC/vazkii/botania/common/block/tile/TileSpreader.java b/MODSRC/vazkii/botania/common/block/tile/TileSpreader.java index cd18e4004..455a21af7 100644 --- a/MODSRC/vazkii/botania/common/block/tile/TileSpreader.java +++ b/MODSRC/vazkii/botania/common/block/tile/TileSpreader.java @@ -85,9 +85,9 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector ManaNetworkEvent.addCollector(this); added = true; } - + boolean redstone = false; - + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { TileEntity tileAt = worldObj.getBlockTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ); if(tileAt instanceof IManaPool) { @@ -100,12 +100,12 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector recieveMana(manaToRemove); } } - + int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); if(redstoneSide > 0) redstone = true; } - + if(!redstone) tryShootBurst(); } @@ -127,7 +127,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector if(cmp.hasKey(TAG_KNOWN_MANA)) knownMana = cmp.getInteger(TAG_KNOWN_MANA); - + if(worldObj != null && worldObj.isRemote) { EntityManaBurst fakeBurst = getBurst(true); TileEntity receiver = fakeBurst.getCollidedTile(true); @@ -175,7 +175,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector double angle = y * 180; rotationY = -(float) angle; - + EntityManaBurst fakeBurst = getBurst(true); TileEntity receiver = fakeBurst.getCollidedTile(true); if(receiver != null && receiver instanceof IManaReceiver) @@ -199,7 +199,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector if(receiver != null) { forceCheckReceiver(); - + if(receiver != null) { if(canShootBurst && receiver.canRecieveManaFromBursts() && !receiver.isFull()) { EntityManaBurst burst = getBurst(false); @@ -213,7 +213,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector } } } - + public void forceCheckReceiver() { EntityManaBurst fakeBurst = getBurst(true); TileEntity receiver = fakeBurst.getCollidedTile(true); @@ -224,19 +224,19 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector public EntityManaBurst getBurst(boolean fake) { EntityManaBurst burst = new EntityManaBurst(worldObj, this, fake); - + int maxMana = 160; int color = 0x00FF00; - int ticksBeforeManaLoss = 100; - float manaLossPerTick = 2F; + int ticksBeforeManaLoss = 60; + float manaLossPerTick = 4F; float motionModifier = 1F; float gravity = 0F; BurstProperties props = new BurstProperties(maxMana, ticksBeforeManaLoss, manaLossPerTick, gravity, motionModifier, color); - + ItemStack lens = getStackInSlot(0); if(lens != null) ((ILens) lens.getItem()).apply(lens, props); - + burst.setSourceLens(lens); if(getCurrentMana() >= props.maxMana || fake) { burst.setColor(props.color); @@ -279,7 +279,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector String name = ModBlocks.spreader.getLocalizedName(); int color = 0x6600FF00; HUDHandler.drawSimpleManaHUD(color, knownMana, MAX_MANA, name, res); - + ItemStack lens = getStackInSlot(0); if(lens != null) { GL11.glEnable(GL11.GL_BLEND); @@ -288,7 +288,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector int width = 16 + mc.fontRenderer.getStringWidth(lensName) / 2; int x = res.getScaledWidth() / 2 - width; int y = res.getScaledHeight() / 2 + 50; - + mc.fontRenderer.drawStringWithShadow(lensName, x + 20, y + 5, color); GL11.glDisable(GL11.GL_DEPTH_TEST); new RenderItem().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, lens, x, y); @@ -296,25 +296,23 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); } - + if(receiver != null) { TileEntity receiverTile = (TileEntity) receiver; ItemStack recieverStack = new ItemStack(worldObj.getBlockId(receiverTile.xCoord, receiverTile.yCoord, receiverTile.zCoord), 1, receiverTile.getBlockMetadata()); - if(lens != null) { - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - String stackName = recieverStack.getDisplayName(); - int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2; - int x = res.getScaledWidth() / 2 - width; - int y = res.getScaledHeight() / 2 + 30; - - mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color); - GL11.glDisable(GL11.GL_DEPTH_TEST); - new RenderItem().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recieverStack, x, y); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - } + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + String stackName = recieverStack.getDisplayName(); + int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2; + int x = res.getScaledWidth() / 2 - width; + int y = res.getScaledHeight() / 2 + 30; + + mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color); + GL11.glDisable(GL11.GL_DEPTH_TEST); + new RenderItem().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recieverStack, x, y); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); } GL11.glColor4f(1F, 1F, 1F, 1F); @@ -322,7 +320,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector @Override public void onClientDisplayTick() { - if(worldObj != null && worldObj.getWorldVec3Pool() != null) { + if(worldObj != null) { EntityManaBurst burst = getBurst(true); burst.getCollidedTile(false); } @@ -337,17 +335,17 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector public String getInvName() { return LibBlockNames.SPREADER; } - + @Override public int getInventoryStackLimit() { return 1; } - + @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { return itemstack.getItem() instanceof ILens; } - + @Override public void onInventoryChanged() { forceCheckReceiver(); diff --git a/MODSRC/vazkii/botania/common/entity/EntityManaBurst.java b/MODSRC/vazkii/botania/common/entity/EntityManaBurst.java index 3642590bd..fef038b39 100644 --- a/MODSRC/vazkii/botania/common/entity/EntityManaBurst.java +++ b/MODSRC/vazkii/botania/common/entity/EntityManaBurst.java @@ -161,23 +161,8 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst { rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F; rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F; - float f2 = 0.99F; float f3 = getGravityVelocity(); - - if(isInWater()) { - for (int k = 0; k < 4; ++k) - { - float f4 = 0.25F; - worldObj.spawnParticle("bubble", posX - motionX * (double)f4, posY - motionY * (double)f4, posZ - motionZ * (double)f4, motionX, motionY, motionZ); - } - - f2 = 0.8F; - } - - motionX *= (double)f2; - motionY *= (double)f2; - motionZ *= (double)f2; - motionY -= (double)f3; + motionY -= f3; setPosition(posX, posY, posZ); } @@ -270,7 +255,11 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst { int mana = getMana(); int maxMana = getStartingMana(); float size = (float) mana / (float) maxMana; + if(fake) { + if(getMana() == getStartingMana()) + size = 2F; + if(!noParticles) Botania.proxy.sparkleFX(worldObj, posX, posY, posZ, r, g, b, 0.4F * size, 1, true); } else Botania.proxy.wispFX(worldObj, posX, posY, posZ, r, g, b, 0.2F * size, (float) -motionX * 0.01F, (float) -motionY * 0.01F, (float) -motionZ * 0.01F); @@ -284,7 +273,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst { TileEntity tile = worldObj.getBlockTileEntity(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); ChunkCoordinates coords = getBurstSourceChunkCoordinates(); - if((!fake || noParticles) && tile != null && (tile.xCoord != coords.posX || tile.yCoord != coords.posY || tile.zCoord != coords.posZ)) + if(tile != null && (tile.xCoord != coords.posX || tile.yCoord != coords.posY || tile.zCoord != coords.posZ)) collidedTile = tile; if(tile == null || tile.xCoord != coords.posX || tile.yCoord != coords.posY || tile.zCoord != coords.posZ) { diff --git a/MODSRC/vazkii/botania/common/item/ItemLens.java b/MODSRC/vazkii/botania/common/item/ItemLens.java index 29c9f654b..08153a22e 100644 --- a/MODSRC/vazkii/botania/common/item/ItemLens.java +++ b/MODSRC/vazkii/botania/common/item/ItemLens.java @@ -19,15 +19,19 @@ import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; 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.Icon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.mana.BurstProperties; import vazkii.botania.api.mana.ILens; import vazkii.botania.client.core.helper.IconHelper; +import vazkii.botania.client.core.helper.Vector3; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibItemIDs; import vazkii.botania.common.lib.LibItemNames; @@ -109,20 +113,25 @@ public class ItemLens extends ItemMod implements ILens { switch(stack.getItemDamage()) { case 1 : { // Speed props.motionModifier = 2F; - props.maxMana *= 0.75F; - props.ticksBeforeManaLoss *= 0.5F; + props.maxMana *= 0.5F; + props.ticksBeforeManaLoss /= 3F; + props.manaLossPerTick *= 2F; break; } case 2 : { // Potency props.maxMana *= 2; + props.motionModifier *= 0.85F; + props.manaLossPerTick *= 2F; break; } case 3 : { // Resistance - props.ticksBeforeManaLoss *= 2; + props.ticksBeforeManaLoss *= 2.25; + props.motionModifier *= 0.8F; break; } case 4 : { // Efficiency - props.manaLossPerTick /= 2F; + props.manaLossPerTick /= 5F; + props.ticksBeforeManaLoss *= 1.1F; break; } case 6 : { // Gravity @@ -134,7 +143,23 @@ public class ItemLens extends ItemMod implements ILens { @Override public void collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, ItemStack stack) { - // NO-OP + switch(stack.getItemDamage()) { + case 5 : { + 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; + } + } + } + } } @Override