mirror of
https://github.com/GTNewHorizons/Electro-Magic-Tools.git
synced 2026-11-22 21:09:49 +00:00
progress...
This commit is contained in:
1 parent
3fdaf92d12
commit
58e387e761
8 files changed
+236
-19
No files matched your search
@@ -1,14 +1,64 @@
|
||||
package emt.client.renderer;
|
||||
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import emt.entity.EntityElectroBall;
|
||||
import emt.util.EMTRandomHelper.Bolt;
|
||||
import emt.util.EMTRandomHelper.Point;
|
||||
|
||||
public class RenderElectroBall extends Render {
|
||||
|
||||
@Override
|
||||
public void doRender(Entity entity, double x, double y, double z, float p1, float p2) {
|
||||
EntityElectroBall ball = (EntityElectroBall) entity;
|
||||
|
||||
if (ball != null && ball.entityPositions != null) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
glPushMatrix();
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_FOG);
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glTranslated(x, y, z);
|
||||
|
||||
for (Point pos : ball.entityPositions) {
|
||||
double trX = pos.x - entity.posX;
|
||||
double trY = pos.y - entity.posY;
|
||||
double trZ = pos.z - entity.posZ;
|
||||
|
||||
for (int i = 0; i < ball.bolts.length; i++) {
|
||||
Bolt bolt = ball.bolts[i];
|
||||
|
||||
glPushMatrix();
|
||||
glTranslated(trX, trY, trZ);
|
||||
glRotatef(bolt.angleZ, 0, 0, 1);
|
||||
glRotatef(bolt.angleY, 0, 1, 0);
|
||||
glLineWidth(2);
|
||||
|
||||
tessellator.startDrawing(GL_LINE_STRIP);
|
||||
tessellator.setColorRGBA(255, 255, 255, 255);
|
||||
tessellator.addVertex(0, 0, 0);
|
||||
for (Point point : bolt.points) {
|
||||
tessellator.addVertex((point.x / 10f), (point.y / 10f), (point.z / 10f));
|
||||
}
|
||||
tessellator.draw();
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
glPopMatrix();
|
||||
glEnable(GL_FOG);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -85,7 +85,7 @@ public class RenderShield extends Render {
|
||||
glTranslated(x, y, z);
|
||||
}
|
||||
|
||||
GL11.glCallList(this.glCallList);
|
||||
glCallList(this.glCallList);
|
||||
|
||||
glPopMatrix();
|
||||
glPopAttrib();
|
||||
|
||||
@@ -1,23 +1,131 @@
|
||||
package emt.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import emt.util.EMTRandomHelper.Bolt;
|
||||
import emt.util.EMTRandomHelper.Point;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.projectile.EntityFireball;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
public class EntityElectroBall extends EntityFireball {
|
||||
public class EntityElectroBall extends Entity {
|
||||
public EntityLivingBase shootingEntity;
|
||||
public Bolt[] bolts = new Bolt[20];
|
||||
public Point[] entityPositions;
|
||||
public boolean onGround = false;
|
||||
private int ticksAlive;
|
||||
private int ticksInAir;
|
||||
public double accelerationX;
|
||||
public double accelerationY;
|
||||
public double accelerationZ;
|
||||
public static final int searchRadius = 16;
|
||||
public static final float length = 10f;
|
||||
public static final float dist = 1f;
|
||||
public static final float height = 4f;
|
||||
|
||||
public EntityElectroBall(World world, EntityLivingBase shootingEntity, double rotX, double rotY, double rotZ) {
|
||||
this(world, shootingEntity);
|
||||
|
||||
rotX += this.rand.nextGaussian() * 0.4D;
|
||||
rotY += this.rand.nextGaussian() * 0.4D;
|
||||
rotZ += this.rand.nextGaussian() * 0.4D;
|
||||
double len = (double) MathHelper.sqrt_double((rotX * rotX) + (rotY * rotY) + (rotZ * rotZ));
|
||||
this.accelerationX = rotX / len * 0.1D;
|
||||
this.accelerationY = rotY / len * 0.1D;
|
||||
this.accelerationZ = rotZ / len * 0.1D;
|
||||
}
|
||||
|
||||
public EntityElectroBall(World world, EntityLivingBase shootingEntity) {
|
||||
this(world);
|
||||
|
||||
this.shootingEntity = shootingEntity;
|
||||
this.setLocationAndAngles(shootingEntity.posX, shootingEntity.posY, shootingEntity.posZ, shootingEntity.rotationYaw, shootingEntity.rotationPitch);
|
||||
}
|
||||
|
||||
public EntityElectroBall(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntityElectroBall(World world, EntityLivingBase player, double rotX, double rotY, double rotZ) {
|
||||
super(world, player, rotX, rotY, rotZ);
|
||||
this.setSize(1.0F, 1.0F);
|
||||
this.ignoreFrustumCheck = true;
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
this.yOffset = 0.0F;
|
||||
this.motionX = this.motionY = this.motionZ = 0.0D;
|
||||
|
||||
for (int i = 0; i < bolts.length; i++) {
|
||||
bolts[i] = new Bolt(dist, length, height);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onImpact(MovingObjectPosition mop) {
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
for (int i = 0; i < bolts.length; i++) {
|
||||
bolts[i].regenerate();
|
||||
}
|
||||
|
||||
ArrayList<Entity> entities = new ArrayList();
|
||||
|
||||
int chunkSize = ((searchRadius - 1) >> 4) + 1;
|
||||
|
||||
for (int chX = -chunkSize; chX < chunkSize; chX++) {
|
||||
for (int chZ = -chunkSize; chZ < chunkSize; chZ++) {
|
||||
Chunk chunk = worldObj.getChunkFromChunkCoords(chX + (int) (this.posX / 16), chZ + (int) (this.posZ / 16));
|
||||
|
||||
if (chunk.isChunkLoaded && chunk.hasEntities) {
|
||||
for (int i = 0; i < chunk.entityLists.length; i++) {
|
||||
for (int k = 0; k < chunk.entityLists[i].size(); k++) {
|
||||
Entity entity = (Entity) chunk.entityLists[i].get(k);
|
||||
double width = entity.posX - this.posX;
|
||||
double height = entity.posY - this.posY;
|
||||
double length = entity.posZ - this.posZ;
|
||||
|
||||
if (MathHelper.sqrt_double((width * width) + (length * length) + (height * height)) <= searchRadius) {
|
||||
entities.add(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entityPositions = new Point[entities.size()];
|
||||
for (int i = 0; i < entities.size(); i++) {
|
||||
Entity entity = entities.get(i);
|
||||
entity.performHurtAnimation();
|
||||
entityPositions[i] = new Point(entity.posX, entity.posY, entity.posZ);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getBrightnessForRender(float p_70070_1_) {
|
||||
return 240;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean isInRangeToRender3d(double x, double y, double z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound p_70037_1_) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound p_70014_1_) {
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,6 @@ public class EntityShield extends Entity {
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
this.dataWatcher.addObject(11, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package emt.init;
|
||||
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import emt.ElectroMagicTools;
|
||||
import emt.entity.EntityArcher;
|
||||
import emt.entity.EntityElectroBall;
|
||||
import emt.entity.EntityLaser;
|
||||
import emt.entity.EntityShield;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -15,7 +17,6 @@ public class EMTEntities {
|
||||
private static int entityIDs = 0;
|
||||
|
||||
private static int getUniqueEntityID() {
|
||||
|
||||
do {
|
||||
startEID++;
|
||||
}
|
||||
@@ -31,12 +32,10 @@ public class EMTEntities {
|
||||
}
|
||||
|
||||
public static void registerEMTEntities() {
|
||||
|
||||
cpw.mods.fml.common.registry.EntityRegistry.registerModEntity(EntityLaser.class, "laser", entityIDs++, ElectroMagicTools.instance, 80, 3, true);
|
||||
|
||||
cpw.mods.fml.common.registry.EntityRegistry.registerModEntity(EntityArcher.class, "archer", entityIDs++, ElectroMagicTools.instance, 80, 3, true);
|
||||
EntityRegistry.registerModEntity(EntityLaser.class, "laser", entityIDs++, ElectroMagicTools.instance, 80, 3, true);
|
||||
EntityRegistry.registerModEntity(EntityArcher.class, "archer", entityIDs++, ElectroMagicTools.instance, 80, 3, true);
|
||||
registerEntityEgg(EntityArcher.class, 0x99111F, 0xE5685);
|
||||
|
||||
cpw.mods.fml.common.registry.EntityRegistry.registerModEntity(EntityShield.class, "shield", entityIDs++, ElectroMagicTools.instance, 80, 3, true);
|
||||
EntityRegistry.registerModEntity(EntityShield.class, "shield", entityIDs++, ElectroMagicTools.instance, 80, 3, true);
|
||||
EntityRegistry.registerModEntity(EntityElectroBall.class, "electroBall", entityIDs++, ElectroMagicTools.instance, 80, 3, true);
|
||||
}
|
||||
}
|
||||
@@ -17,24 +17,24 @@ public class ItemNoNameFocus extends ItemBaseFocus {
|
||||
public ItemNoNameFocus() {
|
||||
super("noName");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getFocusColor(ItemStack stack) {
|
||||
return 0xFFFF00;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSortingHelper(ItemStack itemstack) {
|
||||
return "NONAME";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack onFocusRightClick(ItemStack stack, World world, EntityPlayer player, MovingObjectPosition paramMovingObjectPosition) {
|
||||
if(!world.isRemote) {
|
||||
if (!world.isRemote) {
|
||||
float rotX = (-MathHelper.sin(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI)) * 100;
|
||||
float rotY = (-MathHelper.sin(player.rotationPitch / 180.0F * (float) Math.PI)) * 100;
|
||||
float rotZ = (MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI)) * 100;
|
||||
world.spawnEntityInWorld(new EntityElectroBall(world, player, rotX, rotY, rotZ));
|
||||
world.spawnEntityInWorld(new EntityElectroBall(world, player));
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package emt.proxy;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderFireball;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RenderSnowMan;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
@@ -29,5 +30,6 @@ public class ClientProxy extends CommonProxy {
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityArcher.class, new RenderSnowMan());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityShield.class, new RenderShield());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityElectroBall.class, new RenderElectroBall());
|
||||
RenderManager.instance.entityRenderMap.put(EntityElectroBall.class, new RenderElectroBall());
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
public class EMTRandomHelper {
|
||||
|
||||
@@ -21,4 +23,61 @@ public class EMTRandomHelper {
|
||||
ElectricItem.manager.charge(stack, charge, charge, true, false);
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static class Bolt {
|
||||
Random rnd = new Random();
|
||||
public ArrayList<Point> points = new ArrayList<Point>();
|
||||
public float angleZ = 0;
|
||||
public float angleY = 0;
|
||||
float dist = 0;
|
||||
float length = 0;
|
||||
float height = 0;
|
||||
|
||||
public Bolt(float dist, float length, float height) {
|
||||
this.dist = dist;
|
||||
this.length = (length / 2f) + (rnd.nextInt((int) (length / 2f)));
|
||||
this.height = height;
|
||||
|
||||
regenerate(this.dist, this.length, this.height);
|
||||
}
|
||||
|
||||
public void regenerate() {
|
||||
regenerate(dist, length, height);
|
||||
}
|
||||
|
||||
public void regenerate(float dist, float length, float height) {
|
||||
points.clear();
|
||||
|
||||
angleZ = rnd.nextInt(360);
|
||||
angleY = rnd.nextInt(360);
|
||||
|
||||
for (int i = 0; i < length / dist; i++) {
|
||||
float x = i * dist;
|
||||
float prevY = i == 0 ? 0 : points.get(i - 1).y;
|
||||
float prevZ = i == 0 ? 0 : points.get(i - 1).z;
|
||||
float y = prevY + (rnd.nextInt((int) height) - (height / 2));
|
||||
float z = prevZ + (rnd.nextInt((int) height) - (height / 2));
|
||||
|
||||
points.add(new Point(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Point {
|
||||
public float x = 0;
|
||||
public float y = 0;
|
||||
public float z = 0;
|
||||
|
||||
public Point(float x, float y, float z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public Point(double x, double y, double z) {
|
||||
this.x = (float) x;
|
||||
this.y = (float) y;
|
||||
this.z = (float) z;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user