Rough look implementation of the power system, not transfering power yet :P

This commit is contained in:
Vasco Lavos committed 2014-01-26 18:10:20 +00:00
1 parent 392a6d914a
commit 0a23199bab
4 files changed
+63 -13

No files matched your search

@@ -73,6 +73,7 @@ public class ClientProxy extends CommonProxy {
public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m, boolean fake) {
FXSparkle sparkle = new FXSparkle(world, x, y, z, size, r, g, b, m);
sparkle.fake = fake;
// sparkle.noClip = true;
Minecraft.getMinecraft().effectRenderer.addEffect(sparkle);
}
+1 -1
View File
@@ -54,7 +54,7 @@ public class FXWisp extends EntityFX
EntityLivingBase renderentity = FMLClientHandler.instance().getClient().renderViewEntity;
int visibleDistance = 50;
if (!FMLClientHandler.instance().getClient().gameSettings.fancyGraphics) visibleDistance=25;
if (renderentity.getDistance(posX, posY, posZ)>visibleDistance) particleMaxAge=0;
if (renderentity == null || renderentity.getDistance(posX, posY, posZ)>visibleDistance) particleMaxAge=0;
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
@@ -31,6 +31,7 @@ import vazkii.botania.api.internal.ManaNetworkEvent;
import vazkii.botania.api.mana.IManaCollector;
import vazkii.botania.client.core.helper.Vector3;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.entity.EntityManaBurst;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
@@ -113,6 +114,8 @@ public class TileSpreader extends TileMod implements IManaCollector {
PacketDispatcher.sendPacketToPlayer(new Packet132TileEntityData(xCoord, yCoord, zCoord, -999, nbttagcompound), (Player) player);
}
worldObj.playSoundAtEntity(player, "random.orb", 1F, 1F);
if(!worldObj.isRemote)
worldObj.spawnEntityInWorld(new EntityManaBurst(worldObj, this, false, 0x00FF00));
} else {
MovingObjectPosition pos = raytraceFromEntity(worldObj, player, true, 5);
if(pos != null && pos.hitVec != null && !worldObj.isRemote) {
@@ -14,6 +14,7 @@ package vazkii.botania.common.entity;
import java.awt.Color;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
@@ -22,32 +23,69 @@ import vazkii.botania.common.block.tile.TileSpreader;
public class EntityManaBurst extends EntityThrowable {
boolean fake;
int color;
private static final String TAG_COLOR = "color";
boolean fake = false;
public EntityManaBurst(World world) {
super(world);
setSize(0F, 0F);
dataWatcher.addObject(25, 0);
dataWatcher.setObjectWatched(25);
}
public EntityManaBurst(World par1World, TileSpreader spreader, boolean fake, int color) {
super(par1World);
this(par1World);
this.fake = fake;
this.color = color;
setSize(0F, 0F);
setLocationAndAngles(spreader.xCoord, spreader.yCoord, spreader.zCoord, 0, 0);
rotationYaw = spreader.rotationX;
setLocationAndAngles(spreader.xCoord + 0.5, spreader.yCoord + 0.5, spreader.zCoord + 0.5, 0, 0);
rotationYaw = -(spreader.rotationX + 90F);
rotationPitch = spreader.rotationY;
float f = 0.4F;
this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
this.motionY = (double)(-MathHelper.sin((this.rotationPitch + this.func_70183_g()) / 180.0F * (float)Math.PI) * f);
this.motionX = -(double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f) / 2D;
this.motionZ = -(double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f) / 2D;
this.motionY = -(double)(-MathHelper.sin((this.rotationPitch + this.func_70183_g()) / 180.0F * (float)Math.PI) * f) / 2D;
posX += motionX * 5;
posY += motionY * 5;
posZ += motionZ * 5;
setColor(color);
}
@Override
public void onUpdate() {
super.onUpdate();
particles();
if(ticksExisted > 100)
setDead();
}
@Override
public void writeEntityToNBT(NBTTagCompound par1nbtTagCompound) {
super.writeEntityToNBT(par1nbtTagCompound);
par1nbtTagCompound.setInteger(TAG_COLOR, getColor());
}
@Override
public void readEntityFromNBT(NBTTagCompound par1nbtTagCompound) {
super.readEntityFromNBT(par1nbtTagCompound);
setColor(par1nbtTagCompound.getInteger(TAG_COLOR));
}
public void particles() {
Color color = new Color(this.color);
if(!worldObj.isRemote)
return;
Color color = new Color(getColor());
float r = (float) color.getRed() / 255F;
float g = (float) color.getGreen() / 255F;
float b = (float) color.getBlue() / 255F;
if(fake)
Botania.proxy.sparkleFX(worldObj, posX, posY, posZ, r, g, b, 1F, 0, true);
else Botania.proxy.wispFX(worldObj, posX, posY, posZ, r, g, b, 1F);
else Botania.proxy.wispFX(worldObj, posX, posY, posZ, r, g, b, 0.5F * (float) (100 - ticksExisted) / 100F, (float) -motionX * 0.01F, (float) -motionY * 0.01F, (float) -motionZ * 0.01F);
}
@Override
@@ -62,4 +100,12 @@ public class EntityManaBurst extends EntityThrowable {
return 0F;
}
int getColor() {
return dataWatcher.getWatchableObjectInt(25);
}
void setColor(int color) {
dataWatcher.updateObject(25, color);
}
}