Better particle rendering, bubbles when scuba tank is active, improved jetpack hover mode to disable when player is grounded

This commit is contained in:
aidancbrady 2016-03-05 18:28:52 -05:00
parent 4e41b46df7
commit 13996faacb
4 changed files with 128 additions and 17 deletions

View file

@ -15,6 +15,7 @@ import mekanism.api.IClientTicker;
import mekanism.api.MekanismConfig.client;
import mekanism.api.gas.GasStack;
import mekanism.client.sound.SoundHandler;
import mekanism.common.CommonPlayerTickHandler;
import mekanism.common.KeySync;
import mekanism.common.Mekanism;
import mekanism.common.item.ItemFlamethrower;
@ -34,6 +35,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.StringUtils;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
@ -310,7 +312,7 @@ public class ClientTickHandler
flamethrower.useGas(mc.thePlayer.getCurrentEquippedItem());
}
}
if(isJetpackOn(mc.thePlayer))
{
ItemJetpack jetpack = (ItemJetpack)mc.thePlayer.getEquipmentInSlot(3).getItem();
@ -330,7 +332,10 @@ public class ClientTickHandler
}
else if(mc.thePlayer.motionY < 0)
{
mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0);
if(!CommonPlayerTickHandler.isOnGround(mc.thePlayer))
{
mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0);
}
}
}
else {
@ -340,7 +345,10 @@ public class ClientTickHandler
}
else if(mc.gameSettings.keyBindSneak.getIsKeyPressed() && mc.currentScreen == null)
{
mc.thePlayer.motionY = Math.max(mc.thePlayer.motionY - 0.15D, -0.2D);
if(!CommonPlayerTickHandler.isOnGround(mc.thePlayer))
{
mc.thePlayer.motionY = Math.max(mc.thePlayer.motionY - 0.15D, -0.2D);
}
}
}
@ -355,17 +363,26 @@ public class ClientTickHandler
ItemScubaTank tank = (ItemScubaTank)mc.thePlayer.getEquipmentInSlot(3).getItem();
final int max = 300;
tank.useGas(mc.thePlayer.getEquipmentInSlot(3));
GasStack received = tank.useGas(mc.thePlayer.getEquipmentInSlot(3), max-mc.thePlayer.getAir());
if(received != null)
{
mc.thePlayer.setAir(mc.thePlayer.getAir()+received.amount);
if(mc.thePlayer.getAir() == max)
}
if(mc.thePlayer.getAir() == max)
{
for(Object obj : mc.thePlayer.getActivePotionEffects())
{
mc.thePlayer.clearActivePotions();
if(obj instanceof PotionEffect)
{
for(int i = 0; i < 9; i++)
{
((PotionEffect)obj).onUpdate(mc.thePlayer);
}
}
}
}
}
@ -392,7 +409,7 @@ public class ClientTickHandler
ItemStack stack = player.inventory.armorInventory[2];
if(stack != null)
if(stack != null && !player.capabilities.isCreativeMode)
{
if(stack.getItem() instanceof ItemJetpack)
{
@ -406,6 +423,15 @@ public class ClientTickHandler
}
else if(jetpack.getMode(stack) == JetpackMode.HOVER)
{
if((!mc.gameSettings.keyBindJump.getIsKeyPressed() && !mc.gameSettings.keyBindSneak.getIsKeyPressed()) || (mc.gameSettings.keyBindJump.getIsKeyPressed() && mc.gameSettings.keyBindSneak.getIsKeyPressed()) || mc.currentScreen != null)
{
return !player.onGround;
}
else if(mc.gameSettings.keyBindSneak.getIsKeyPressed() && mc.currentScreen == null)
{
return !player.onGround;
}
return true;
}
}

View file

@ -9,6 +9,7 @@ import mekanism.api.MekanismAPI;
import mekanism.api.Pos3D;
import mekanism.client.render.particle.EntityJetpackFlameFX;
import mekanism.client.render.particle.EntityJetpackSmokeFX;
import mekanism.client.render.particle.EntityScubaBubbleFX;
import mekanism.common.Mekanism;
import mekanism.common.item.ItemFlamethrower;
import mekanism.common.item.ItemJetpack;
@ -17,7 +18,6 @@ import mekanism.common.util.MekanismUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.particle.EntityBubbleFX;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -128,18 +128,21 @@ public class RenderTickHandler
vLeft.xPos -= 0.43;
vLeft.yPos -= 0.55;
vLeft.zPos -= 0.54;
vLeft.rotatePitch(p.isSneaking() ? 25 : 0);
vLeft.rotateYaw(p.renderYawOffset);
Pos3D vRight = new Pos3D();
vRight.xPos += 0.43;
vRight.yPos -= 0.55;
vRight.zPos -= 0.54;
vRight.rotatePitch(p.isSneaking() ? 25 : 0);
vRight.rotateYaw(p.renderYawOffset);
Pos3D vCenter = new Pos3D();
vCenter.xPos = (rand.nextFloat() - 0.5F) * 0.4F;
vCenter.yPos -= 0.86;
vCenter.zPos -= 0.30;
vCenter.rotatePitch(p.isSneaking() ? 25 : 0);
vCenter.rotateYaw(p.renderYawOffset);
Pos3D rLeft = vLeft.clone().scale(random);
@ -189,11 +192,11 @@ public class RenderTickHandler
float xRand = (rand.nextFloat() - 0.5F) * 0.08F;
float yRand = (rand.nextFloat() - 0.5F) * 0.05F;
Pos3D vec = new Pos3D(0, 0, 0.4).rotate(p.rotationYawHead, p.rotationPitch);
Pos3D vec = new Pos3D(0.4, 0.4, 0.4).multiply(new Pos3D(p.getLook(90))).translate(0, -0.2, 0);
Pos3D motion = vec.clone().scale(0.2).translate(new Pos3D(p.motionX, p.motionY, p.motionZ));
Pos3D v = playerPos.clone().translate(vec);
spawnAndSetParticle("bubble", world, v.xPos, v.yPos, v.zPos, motion.xPos, motion.yPos, motion.zPos);
spawnAndSetParticle("bubble", world, v.xPos, v.yPos, v.zPos, motion.xPos, motion.yPos + 0.2, motion.zPos);
}
}
}
@ -265,7 +268,7 @@ public class RenderTickHandler
}
else if(s.equals("bubble"))
{
fx = new EntityBubbleFX(world, x, y, z, velX, velY, velZ);
fx = new EntityScubaBubbleFX(world, x, y, z, velX, velY, velZ);
}
mc.effectRenderer.addEffect(fx);

View file

@ -0,0 +1,41 @@
package mekanism.client.render.particle;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityBubbleFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.World;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class EntityScubaBubbleFX extends EntityBubbleFX
{
private static Minecraft mc = FMLClientHandler.instance().getClient();
public EntityScubaBubbleFX(World world, double posX, double posY, double posZ, double velX, double velY, double velZ)
{
super(world, posX, posY, posZ, velX, velY, velZ);
particleScale = (rand.nextFloat()*0.2F)+0.5F;
particleMaxAge *= 2;
}
@Override
public void onUpdate()
{
super.onUpdate();
particleAge++;
}
@Override
public void renderParticle(Tessellator p_70539_1_, float p_70539_2_, float p_70539_3_, float p_70539_4_, float p_70539_5_, float p_70539_6_, float p_70539_7_)
{
if(particleAge > 0)
{
particleAlpha = Math.min(1, (particleAge+p_70539_2_)/20F);
super.renderParticle(p_70539_1_, p_70539_2_, p_70539_3_, p_70539_4_, p_70539_5_, p_70539_6_, p_70539_7_);
}
}
}

View file

@ -9,10 +9,14 @@ import mekanism.common.item.ItemJetpack;
import mekanism.common.item.ItemJetpack.JetpackMode;
import mekanism.common.item.ItemScubaTank;
import mekanism.common.util.MekanismUtils;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
@ -70,7 +74,10 @@ public class CommonPlayerTickHandler
}
else if(player.motionY < 0)
{
player.motionY = Math.min(player.motionY + 0.15D, 0);
if(!isOnGround(player))
{
player.motionY = Math.min(player.motionY + 0.15D, 0);
}
}
}
else {
@ -80,7 +87,10 @@ public class CommonPlayerTickHandler
}
else if(Mekanism.keyMap.has(player, KeySync.DESCEND))
{
player.motionY = Math.max(player.motionY - 0.15D, -0.2D);
if(!isOnGround(player))
{
player.motionY = Math.max(player.motionY - 0.15D, -0.2D);
}
}
}
}
@ -107,14 +117,36 @@ public class CommonPlayerTickHandler
if(received != null)
{
player.setAir(player.getAir()+received.amount);
if(player.getAir() == max)
}
if(player.getAir() == max)
{
for(Object obj : player.getActivePotionEffects())
{
player.clearActivePotions();
if(obj instanceof PotionEffect)
{
for(int i = 0; i < 9; i++)
{
((PotionEffect)obj).onUpdate(player);
}
}
}
}
}
}
public static boolean isOnGround(EntityPlayer player)
{
int x = MathHelper.floor_double(player.posX);
int y = (int)Math.round(player.posY-player.yOffset - 1);
int z = MathHelper.floor_double(player.posZ);
Block b = player.worldObj.getBlock(x, y, z);
AxisAlignedBB box = b.getCollisionBoundingBoxFromPool(player.worldObj, x, y, z);
AxisAlignedBB playerBox = player.boundingBox.copy().offset(0, -0.01, 0);
return box != null && playerBox.intersectsWith(box);
}
public boolean isJetpackOn(EntityPlayer player)
{
@ -134,6 +166,15 @@ public class CommonPlayerTickHandler
}
else if(jetpack.getMode(stack) == JetpackMode.HOVER)
{
if((!Mekanism.keyMap.has(player, KeySync.ASCEND) && !Mekanism.keyMap.has(player, KeySync.DESCEND)) || (Mekanism.keyMap.has(player, KeySync.ASCEND) && Mekanism.keyMap.has(player, KeySync.DESCEND)))
{
return !player.onGround;
}
else if(Mekanism.keyMap.has(player, KeySync.DESCEND))
{
return !player.onGround;
}
return true;
}
}