Defender render completed
This commit is contained in:
parent
e6a08409da
commit
ff2040a74a
1
.gitignore
vendored
1
.gitignore
vendored
@ -20,3 +20,4 @@ build
|
|||||||
# other
|
# other
|
||||||
eclipse
|
eclipse
|
||||||
run
|
run
|
||||||
|
rundir
|
||||||
|
@ -19,7 +19,7 @@ apply plugin: 'forge'
|
|||||||
|
|
||||||
version = "0.1.8"
|
version = "0.1.8"
|
||||||
group= "fr.jackcartersmith.orbsat" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
group= "fr.jackcartersmith.orbsat" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = "orbsat"
|
archivesBaseName = "OrbitalSatellite"
|
||||||
|
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
@ -49,12 +49,6 @@ dependencies {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
|
||||||
manifest {
|
|
||||||
attributes 'FMLAT': 'OrbitalSatellite_dc.cfg'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
processResources
|
processResources
|
||||||
{
|
{
|
||||||
// this will ensure that this task is redone when the versions change.
|
// this will ensure that this task is redone when the versions change.
|
||||||
|
@ -11,6 +11,7 @@ import fr.jackcartersmith.orbsat.client.handler.ClientEventHandler;
|
|||||||
import fr.jackcartersmith.orbsat.client.handler.ParticleHandler;
|
import fr.jackcartersmith.orbsat.client.handler.ParticleHandler;
|
||||||
import fr.jackcartersmith.orbsat.client.handler.ResourceHandler;
|
import fr.jackcartersmith.orbsat.client.handler.ResourceHandler;
|
||||||
import fr.jackcartersmith.orbsat.client.render.block.RenderDefender;
|
import fr.jackcartersmith.orbsat.client.render.block.RenderDefender;
|
||||||
|
import fr.jackcartersmith.orbsat.client.render.particle.ParticleLaserBeam;
|
||||||
import fr.jackcartersmith.orbsat.client.render.tile.RenderTileDefender;
|
import fr.jackcartersmith.orbsat.client.render.tile.RenderTileDefender;
|
||||||
import fr.jackcartersmith.orbsat.common.CommonProxy;
|
import fr.jackcartersmith.orbsat.common.CommonProxy;
|
||||||
import fr.jackcartersmith.orbsat.common.OSBlocks;
|
import fr.jackcartersmith.orbsat.common.OSBlocks;
|
||||||
@ -19,6 +20,7 @@ import net.minecraft.client.Minecraft;
|
|||||||
import net.minecraft.client.audio.ISound;
|
import net.minecraft.client.audio.ISound;
|
||||||
import net.minecraft.client.particle.EntityFX;
|
import net.minecraft.client.particle.EntityFX;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.client.MinecraftForgeClient;
|
import net.minecraftforge.client.MinecraftForgeClient;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
|
||||||
@ -209,6 +211,28 @@ public class ClientProxy extends CommonProxy {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
//public ParticleLaserBeam energyBeam(World worldObj, double x, double y, double z, double tx, double ty, double tz, int powerFlow, boolean advanced, ParticleLaserBeam oldBeam, boolean render, int beamType) {
|
||||||
|
public ParticleLaserBeam energyBeam(World worldObj, double x, double y, double z, double tx, double ty, double tz, int powerFlow, int pulseLenght, ParticleLaserBeam oldBeam, boolean render, int beamType) {
|
||||||
|
if (!worldObj.isRemote) return null;
|
||||||
|
ParticleLaserBeam beam = oldBeam;
|
||||||
|
boolean inRange = ParticleHandler.isInRange(x, y, z, 50) || ParticleHandler.isInRange(tx, ty, tz, 50);
|
||||||
|
|
||||||
|
if (beam == null || beam.isDead) {
|
||||||
|
if (inRange) {
|
||||||
|
beam = new ParticleLaserBeam(worldObj, x, y, z, tx, ty, tz, pulseLenght, powerFlow, beamType);
|
||||||
|
|
||||||
|
FMLClientHandler.instance().getClient().effectRenderer.addEffect(beam);
|
||||||
|
}
|
||||||
|
} else if (!inRange) {
|
||||||
|
beam.setDead();
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
beam.update(powerFlow, render);
|
||||||
|
}
|
||||||
|
return beam;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isOp(String paramString) {
|
public boolean isOp(String paramString) {
|
||||||
return Minecraft.getMinecraft().theWorld.getWorldInfo().getGameType().isCreative();
|
return Minecraft.getMinecraft().theWorld.getWorldInfo().getGameType().isCreative();
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import org.lwjgl.opengl.GL11;
|
|||||||
import net.minecraft.client.model.ModelBase;
|
import net.minecraft.client.model.ModelBase;
|
||||||
import net.minecraft.client.model.ModelRenderer;
|
import net.minecraft.client.model.ModelRenderer;
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
|
|
||||||
public class ModelDefender extends ModelBase {
|
public class ModelDefender extends ModelBase {
|
||||||
public ModelRenderer Shape1;
|
public ModelRenderer Shape1;
|
||||||
@ -59,10 +58,10 @@ public class ModelDefender extends ModelBase {
|
|||||||
this.setRotateAngle(this.Shape6, 0.0F, 0.0F, 0.0F);
|
this.setRotateAngle(this.Shape6, 0.0F, 0.0F, 0.0F);
|
||||||
this.Shape7 = new ModelRenderer(this, 85, 0);
|
this.Shape7 = new ModelRenderer(this, 85, 0);
|
||||||
this.Shape7.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6);
|
this.Shape7.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6);
|
||||||
this.Shape7.setRotationPoint(0.0F, -3.5F, 0.0F);
|
this.Shape7.setRotationPoint(0.0F, -4.0F, 0.0F);
|
||||||
this.Shape7.setTextureSize(128, 128);
|
this.Shape7.setTextureSize(128, 128);
|
||||||
this.Shape7.mirror = true;
|
this.Shape7.mirror = true;
|
||||||
this.setRotateAngle(this.Shape7, ((float)Math.sin(0)), (float)Math.sin(Math.PI/2), (float)Math.sin(3*Math.PI/2));
|
//this.setRotateAngle(this.Shape7, ((float)Math.sin(0)), (float)Math.sin(Math.PI/2), (float)Math.sin(3*Math.PI/2));
|
||||||
this.Shape8 = new ModelRenderer(this, 10, 26);
|
this.Shape8 = new ModelRenderer(this, 10, 26);
|
||||||
this.Shape8.addBox(-3.0F, 0.0F, -3.0F, 6, 2, 6);
|
this.Shape8.addBox(-3.0F, 0.0F, -3.0F, 6, 2, 6);
|
||||||
this.Shape8.setRotationPoint(0.0F, 20.0F, 0.0F);
|
this.Shape8.setRotationPoint(0.0F, 20.0F, 0.0F);
|
||||||
@ -71,18 +70,17 @@ public class ModelDefender extends ModelBase {
|
|||||||
this.setRotateAngle(this.Shape8, 0.0F, 0.0F, 0.0F);
|
this.setRotateAngle(this.Shape8, 0.0F, 0.0F, 0.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void render() {
|
||||||
public void render(Entity entity, float rotation, float brightness, float x, float y, float z, float scale) {
|
this.Shape1.render(0.0625F);
|
||||||
this.Shape1.render(scale);
|
this.Shape2.render(0.0625F);
|
||||||
this.Shape2.render(scale);
|
this.Shape3.render(0.0625F);
|
||||||
this.Shape3.render(scale);
|
this.Shape4.render(0.0625F);
|
||||||
this.Shape4.render(scale);
|
this.Shape5.render(0.0625F);
|
||||||
this.Shape5.render(scale);
|
this.Shape6.render(0.0625F);
|
||||||
this.Shape6.render(scale);
|
this.Shape8.render(0.0625F);
|
||||||
this.Shape8.render(scale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderCrystal(Entity entity, float rotation, float brightness, float x, float y, float z, float scale) {
|
public void renderCrystal(float brightness) {
|
||||||
float lastBrightnessX = OpenGlHelper.lastBrightnessX;
|
float lastBrightnessX = OpenGlHelper.lastBrightnessX;
|
||||||
float lastBrightnessY = OpenGlHelper.lastBrightnessY;
|
float lastBrightnessY = OpenGlHelper.lastBrightnessY;
|
||||||
|
|
||||||
@ -93,7 +91,7 @@ public class ModelDefender extends ModelBase {
|
|||||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, Math.min(200F, lastBrightnessX + b), Math.min(200F, lastBrightnessY + b));
|
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, Math.min(200F, lastBrightnessX + b), Math.min(200F, lastBrightnessY + b));
|
||||||
GL11.glColor4f(colour*10F, colour*0F, colour*20F, 0.9F);
|
GL11.glColor4f(colour*10F, colour*0F, colour*20F, 0.9F);
|
||||||
this.Shape7.render(scale);
|
this.Shape7.render(0.0625F);
|
||||||
GL11.glDisable(GL11.GL_BLEND);
|
GL11.glDisable(GL11.GL_BLEND);
|
||||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastBrightnessX, lastBrightnessY);
|
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastBrightnessX, lastBrightnessY);
|
||||||
if (brightness > 0F) GL11.glEnable(GL11.GL_LIGHTING);
|
if (brightness > 0F) GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
@ -21,7 +21,6 @@ public class RenderDefender implements IItemRenderer{
|
|||||||
@Override
|
@Override
|
||||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
float scale = (1F / 16F);
|
|
||||||
|
|
||||||
if (type == ItemRenderType.INVENTORY) {
|
if (type == ItemRenderType.INVENTORY) {
|
||||||
GL11.glScaled(0.76, 0.76, 0.76);
|
GL11.glScaled(0.76, 0.76, 0.76);
|
||||||
@ -38,8 +37,8 @@ public class RenderDefender implements IItemRenderer{
|
|||||||
GL11.glRotated(180, 0, 0, 1);
|
GL11.glRotated(180, 0, 0, 1);
|
||||||
|
|
||||||
ResourceHandler.bindResource("textures/models/defender.png");
|
ResourceHandler.bindResource("textures/models/defender.png");
|
||||||
RenderTileDefender.modelDefender.render(null, 1F, 0F, 0F, 0F, 0F, scale);
|
RenderTileDefender.modelDefender.render();
|
||||||
RenderTileDefender.modelDefender.renderCrystal(null, 1F, 1F, 0F, 0F, 0F, scale);
|
RenderTileDefender.modelDefender.renderCrystal(1F);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,235 @@
|
|||||||
|
package fr.jackcartersmith.orbsat.client.render.particle;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
import fr.jackcartersmith.orbsat.client.handler.ResourceHandler;
|
||||||
|
import fr.jackcartersmith.orbsat.common.lib.OSRefs;
|
||||||
|
import fr.jackcartersmith.orbsat.common.utils.Utils;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.particle.EntityFX;
|
||||||
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class ParticleLaserBeam extends EntityFX {
|
||||||
|
/**
|
||||||
|
* Power flow integer Ranges from 0 to 100
|
||||||
|
*/
|
||||||
|
private int flow;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Beam Target X
|
||||||
|
*/
|
||||||
|
private double tX = 0.0D;
|
||||||
|
/**
|
||||||
|
* Beam Target Y
|
||||||
|
*/
|
||||||
|
private double tY = 0.0D;
|
||||||
|
/**
|
||||||
|
* Beam Target Z
|
||||||
|
*/
|
||||||
|
private double tZ = 0.0D;
|
||||||
|
/**
|
||||||
|
* Modified Target X
|
||||||
|
*/
|
||||||
|
//private boolean advanced;
|
||||||
|
private boolean renderParticle = true;
|
||||||
|
private float length = 0.0F;
|
||||||
|
private float rotYaw = 0.0F;
|
||||||
|
private float rotPitch = 0.0F;
|
||||||
|
private float prevYaw = 0.0F;
|
||||||
|
private float prevPitch = 0.0F;
|
||||||
|
private EntityPlayer player;
|
||||||
|
|
||||||
|
//todo make sure not dyrectly up or down on y axis, Set dead when player goes out of range, PaRTICLE eNGINE
|
||||||
|
|
||||||
|
private static ResourceLocation beamTextureBasic = new ResourceLocation(OSRefs.MODID.toLowerCase(), "textures/models/laserBeam.png");
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param offsetMode 0 = no offset, 1 = offset target end, 2 = offset start end, 3 offset both ends
|
||||||
|
*/
|
||||||
|
//public ParticleLaserBeam(World world, double x, double y, double z, double tX, double tY, double tZ, int maxAge, int flow, boolean advanced, int offsetMode) {
|
||||||
|
public ParticleLaserBeam(World world, double x, double y, double z, double tX, double tY, double tZ, int maxAge, int flow, int offsetMode) {
|
||||||
|
super(world, x, y, z, 0.0D, 0.0D, 0.0D);
|
||||||
|
this.particleRed = 1F;
|
||||||
|
this.particleGreen = 1F;
|
||||||
|
this.particleBlue = 1F;
|
||||||
|
this.noClip = true;
|
||||||
|
this.motionX = 0.0D;
|
||||||
|
this.motionY = 0.0D;
|
||||||
|
this.motionZ = 0.0D;
|
||||||
|
this.particleMaxAge = maxAge;
|
||||||
|
this.flow = flow;
|
||||||
|
this.prevYaw = rotationYaw;
|
||||||
|
this.prevPitch = rotPitch;
|
||||||
|
this.setSize(0.2F, 0.2F);
|
||||||
|
//this.advanced = advanced;
|
||||||
|
this.tX = tX;
|
||||||
|
this.tY = tY;
|
||||||
|
this.tZ = tZ;
|
||||||
|
|
||||||
|
if (offsetMode > 0) {
|
||||||
|
double dist = Utils.getDistanceAtoB(x, z, tX, tZ);
|
||||||
|
if (dist == 0) dist = 0.1;
|
||||||
|
double xDist = x - tX;
|
||||||
|
double zDist = z - tZ;
|
||||||
|
double xOff = xDist / dist;
|
||||||
|
double zOff = zDist / dist;
|
||||||
|
if (xOff == 0 && zOff == 0) xOff = 1;
|
||||||
|
//LogHelper.info(xOff + " " + zOff);
|
||||||
|
double offM = 0.4D;
|
||||||
|
|
||||||
|
if (offsetMode == 2 || offsetMode == 3) setPosition(posX - xOff * offM, posY, posZ - zOff * offM);
|
||||||
|
|
||||||
|
if (offsetMode == 1 || offsetMode == 3) {
|
||||||
|
this.tX = tX + xOff * offM;
|
||||||
|
this.tY = tY;
|
||||||
|
this.tZ = tZ + zOff * offM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(int flow, boolean render) {
|
||||||
|
this.renderParticle = render;
|
||||||
|
for (this.flow = flow; this.particleMaxAge - this.particleAge < 4; ++this.particleMaxAge) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate() {
|
||||||
|
//1.570797f
|
||||||
|
// double sin = Math.sin(-1f + (float)(particleAge % 360) / 180f * 1.570797f);
|
||||||
|
// LogHelper.info(sin + " " + particleAge % 360);
|
||||||
|
|
||||||
|
this.prevPosX = this.posX;
|
||||||
|
this.prevPosY = this.posY;
|
||||||
|
this.prevPosZ = this.posZ;
|
||||||
|
|
||||||
|
this.prevYaw = this.rotYaw;
|
||||||
|
this.prevPitch = this.rotPitch;
|
||||||
|
|
||||||
|
float xd = (float) (this.posX - this.tX);
|
||||||
|
float yd = (float) (this.posY - this.tY);
|
||||||
|
float zd = (float) (this.posZ - this.tZ);
|
||||||
|
this.length = MathHelper.sqrt_float(xd * xd + yd * yd + zd * zd);
|
||||||
|
double var7 = (double) MathHelper.sqrt_double((double) (xd * xd + zd * zd));
|
||||||
|
this.rotYaw = (float) (Math.atan2((double) xd, (double) zd) * 180.0D / 3.141592653589793D);
|
||||||
|
this.rotPitch = (float) (Math.atan2((double) yd, var7) * 180.0D / 3.141592653589793D);
|
||||||
|
this.prevYaw = this.rotYaw;
|
||||||
|
this.prevPitch = this.rotPitch;
|
||||||
|
|
||||||
|
|
||||||
|
if (this.particleAge++ >= this.particleMaxAge) {
|
||||||
|
this.setDead();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private EntityPlayer getPlayer() {
|
||||||
|
if (player == null) {
|
||||||
|
player = Minecraft.getMinecraft().thePlayer;
|
||||||
|
}
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||||
|
if (!renderParticle) return;
|
||||||
|
tessellator.draw();
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
//GL11.glPushAttrib(GL11.GL_ATTRIB_STACK_DEPTH);
|
||||||
|
float var9 = 1.0F;
|
||||||
|
float slide = (float) getPlayer().ticksExisted;
|
||||||
|
float size = (float) flow / 100f * 2f; //0.7F;
|
||||||
|
/*
|
||||||
|
if (advanced) Minecraft.getMinecraft().renderEngine.bindTexture(beamTextureAdvanced);
|
||||||
|
else Minecraft.getMinecraft().renderEngine.bindTexture(beamTextureBasic);
|
||||||
|
*/
|
||||||
|
Minecraft.getMinecraft().renderEngine.bindTexture(beamTextureBasic);
|
||||||
|
GL11.glTexParameterf(3553, 10242, 10497.0F);
|
||||||
|
GL11.glTexParameterf(3553, 10243, 10497.0F);
|
||||||
|
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||||
|
float var11 = slide + partialTick;
|
||||||
|
float var12 = -var11 * 0.2F - (float) MathHelper.floor_float(-var11 * 0.1F);
|
||||||
|
GL11.glBlendFunc(770, 1);
|
||||||
|
GL11.glDepthMask(false);
|
||||||
|
float xx = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTick - interpPosX);
|
||||||
|
float yy = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTick - interpPosY);
|
||||||
|
float zz = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTick - interpPosZ);
|
||||||
|
GL11.glTranslated((double) xx, (double) yy, (double) zz);
|
||||||
|
float ry = (float) ((double) this.prevYaw + (double) (this.rotYaw - this.prevYaw) * (double) partialTick);
|
||||||
|
float rp = (float) ((double) this.prevPitch + (double) (this.rotPitch - this.prevPitch) * (double) partialTick);
|
||||||
|
GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
|
||||||
|
GL11.glRotatef(180.0F + ry, 0.0F, 0.0F, -1.0F);
|
||||||
|
GL11.glRotatef(rp, 1.0F, 0.0F, 0.0F);
|
||||||
|
double var44 = -0.15D * (double) size;
|
||||||
|
double var17 = 0.15D * (double) size;
|
||||||
|
|
||||||
|
GL11.glTranslated(0.03, 0, 0);
|
||||||
|
for (int t = 0; t < 2; ++t) {
|
||||||
|
double var29 = (double) (this.length * var9);
|
||||||
|
double var31 = 0D;
|
||||||
|
double var33 = 1D;
|
||||||
|
double var35 = (double) (-1.0F + var12 + (float) t / 3.0F);
|
||||||
|
double var37 = (double) (this.length * var9) + var35;
|
||||||
|
GL11.glRotatef(t * 90.0F, 0.0F, 1.0F, 0.0F);
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setBrightness(200);
|
||||||
|
tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, 1f);
|
||||||
|
tessellator.addVertexWithUV(var44, var29, 0.0D, var33, var37);
|
||||||
|
tessellator.addVertexWithUV(var44, 0.0D, 0.0D, var33, var35);
|
||||||
|
tessellator.addVertexWithUV(var17, 0.0D, 0.0D, var31, var35);
|
||||||
|
tessellator.addVertexWithUV(var17, var29, 0.0D, var31, var37);
|
||||||
|
tessellator.draw();
|
||||||
|
GL11.glRotatef(t * 90.0F, 0.0F, -1.0F, 0.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (ClientEventHandler.playerHoldingWrench) {
|
||||||
|
var44 = -0.15D * (double) 1;
|
||||||
|
var17 = 0.15D * (double) 1;
|
||||||
|
|
||||||
|
//GL11.glColor4f(1f, 1f, 1f, 1f);
|
||||||
|
//GL11.glTranslated(0.1, 0, 0);
|
||||||
|
for (int t = 0; t < 2; ++t) {
|
||||||
|
double var29 = (double) (this.length * var9);
|
||||||
|
double var31 = 0D;
|
||||||
|
double var33 = 1D;
|
||||||
|
double var35 = (double) (-1.0F + var12 + (float) t / 3.0F);
|
||||||
|
double var37 = (double) (this.length * var9) + var35;
|
||||||
|
GL11.glRotatef(t * 90.0F, 0.0F, 1.0F, 0.0F);
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setBrightness(200);
|
||||||
|
tessellator.setColorRGBA_F(0f, 1f, 0f, 1f);
|
||||||
|
tessellator.addVertexWithUV(var44, var29, 0.0D, var33, var37);
|
||||||
|
tessellator.addVertexWithUV(var44, 0.0D, 0.0D, var33, var35);
|
||||||
|
tessellator.addVertexWithUV(var17, 0.0D, 0.0D, var31, var35);
|
||||||
|
tessellator.addVertexWithUV(var17, var29, 0.0D, var31, var37);
|
||||||
|
tessellator.draw();
|
||||||
|
GL11.glRotatef(t * 90.0F, 0.0F, -1.0F, 0.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
//GL11.glDepthMask(true);
|
||||||
|
GL11.glBlendFunc(770, 771);
|
||||||
|
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||||
|
// GL11.glPopAttrib();
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
|
|
||||||
|
ResourceHandler.bindDefaultParticles();
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFlow() {
|
||||||
|
return flow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFlow(int flow) {
|
||||||
|
this.flow = flow;
|
||||||
|
}
|
||||||
|
}
|
@ -4,26 +4,46 @@ import org.lwjgl.opengl.GL11;
|
|||||||
import fr.jackcartersmith.orbsat.client.handler.ResourceHandler;
|
import fr.jackcartersmith.orbsat.client.handler.ResourceHandler;
|
||||||
import fr.jackcartersmith.orbsat.client.model.ModelDefender;
|
import fr.jackcartersmith.orbsat.client.model.ModelDefender;
|
||||||
import fr.jackcartersmith.orbsat.common.tileentities.TileDefender;
|
import fr.jackcartersmith.orbsat.common.tileentities.TileDefender;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
public class RenderTileDefender extends TileEntitySpecialRenderer {
|
public class RenderTileDefender extends TileEntitySpecialRenderer {
|
||||||
public static ModelDefender modelDefender = new ModelDefender();
|
public static ModelDefender modelDefender = new ModelDefender();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) {
|
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
|
GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
|
||||||
|
|
||||||
renderCore((TileDefender) tileEntity, partialTick);
|
renderCore((TileDefender) tileEntity, x, y, z, partialTick);
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renderCore(TileDefender tile, float partialTick) {
|
public void renderCore(TileDefender tile, double x, double y, double z, float partialTick) {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
float scale = (1F / 16F);
|
ResourceHandler.bindResource("textures/models/defender.png");
|
||||||
GL11.glRotated(180, 2, 0, 0);
|
GL11.glRotated(180, 2, 0, 0);
|
||||||
|
RenderTileDefender.modelDefender.render();
|
||||||
|
|
||||||
|
float ticks = ((float)Minecraft.getMinecraft().renderViewEntity.ticksExisted + partialTick) * tile.rotationSpeed;
|
||||||
|
if (tile.getWorldObj() != null)
|
||||||
|
{
|
||||||
|
GL11.glRotatef(ticks % 360.0F, 0.0F, 1.0F, 0.0F);
|
||||||
|
GL11.glRotatef(35.0F, 1.0F, 0.0F, 0.0F);
|
||||||
|
GL11.glRotatef(45.0F, 0.0F, 0.0F, 1.0F);
|
||||||
|
/*
|
||||||
|
GL11.glRotatef(ticks % 360.0F * tile.rotation, 0.0F, 1.0F, 0.0F);
|
||||||
|
GL11.glRotatef(35.0F * tile.rotation, 1.0F, 0.0F, 0.0F);
|
||||||
|
GL11.glRotatef(45.0F * tile.rotation, 0.0F, 0.0F, 1.0F);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glTranslatef(-0.125F,0.125F,0.125F);
|
||||||
|
RenderTileDefender.modelDefender.renderCrystal(tile.crystalBrightness);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
switch (tile.facingDirection) {
|
switch (tile.facingDirection) {
|
||||||
@ -42,9 +62,8 @@ public class RenderTileDefender extends TileEntitySpecialRenderer {
|
|||||||
case 5:
|
case 5:
|
||||||
GL11.glRotated(90, 0, 0, 1);
|
GL11.glRotated(90, 0, 0, 1);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
ResourceHandler.bindResource("textures/models/defender.png");
|
|
||||||
modelDefender.render(null, 0F, 0F, 0F, 0F, 0F, scale);
|
modelDefender.render(null, 0F, 0F, 0F, 0F, 0F, scale);
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
//float rotation = tile.rotation + (partialTick * tile.rotationSpeed);
|
//float rotation = tile.rotation + (partialTick * tile.rotationSpeed);
|
||||||
@ -60,5 +79,6 @@ public class RenderTileDefender extends TileEntitySpecialRenderer {
|
|||||||
GL11.glDisable(GL11.GL_BLEND);
|
GL11.glDisable(GL11.GL_BLEND);
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
|||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import fr.jackcartersmith.orbsat.OrbitalSatellite;
|
import fr.jackcartersmith.orbsat.OrbitalSatellite;
|
||||||
import fr.jackcartersmith.orbsat.client.gui.OSGuiHandler;
|
import fr.jackcartersmith.orbsat.client.gui.OSGuiHandler;
|
||||||
|
import fr.jackcartersmith.orbsat.client.render.particle.ParticleLaserBeam;
|
||||||
import fr.jackcartersmith.orbsat.common.handler.FMLEventHandler;
|
import fr.jackcartersmith.orbsat.common.handler.FMLEventHandler;
|
||||||
import fr.jackcartersmith.orbsat.common.lib.OSConstants;
|
import fr.jackcartersmith.orbsat.common.lib.OSConstants;
|
||||||
import fr.jackcartersmith.orbsat.common.lib.OSRefs;
|
import fr.jackcartersmith.orbsat.common.lib.OSRefs;
|
||||||
@ -16,6 +17,7 @@ import fr.jackcartersmith.orbsat.common.network.TileObjectPacket;
|
|||||||
import fr.jackcartersmith.orbsat.common.tileentities.TileDefender;
|
import fr.jackcartersmith.orbsat.common.tileentities.TileDefender;
|
||||||
import fr.jackcartersmith.orbsat.common.utils.OSLogHelper;
|
import fr.jackcartersmith.orbsat.common.utils.OSLogHelper;
|
||||||
import net.minecraft.client.audio.ISound;
|
import net.minecraft.client.audio.ISound;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class CommonProxy {
|
public class CommonProxy {
|
||||||
public void preInit(FMLPreInitializationEvent event) {
|
public void preInit(FMLPreInitializationEvent event) {
|
||||||
@ -169,6 +171,11 @@ public class CommonProxy {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//public ParticleLaserBeam energyBeam(World worldObj, double x, double y, double z, double tx, double ty, double tz, int powerFlow, boolean advanced, ParticleLaserBeam oldBeam, boolean render, int beamType) {
|
||||||
|
public ParticleLaserBeam energyBeam(World worldObj, double x, double y, double z, double tx, double ty, double tz, int powerFlow, int pulseLenght, ParticleLaserBeam oldBeam, boolean render, int beamType) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void spawnParticle(Object particle, int range) {}
|
public void spawnParticle(Object particle, int range) {}
|
||||||
|
|
||||||
public ISound playISound(ISound sound) {
|
public ISound playISound(ISound sound) {
|
||||||
|
@ -12,7 +12,6 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.util.ChatComponentText;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
@ -108,7 +107,9 @@ public class Defender extends BlockOS {
|
|||||||
TileDefender tile = (TileDefender) world.getTileEntity(x, y, z);
|
TileDefender tile = (TileDefender) world.getTileEntity(x, y, z);
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
player.addChatComponentMessage(new ChatComponentText(Float.toString(tile.rotation)));
|
//Do something here...
|
||||||
|
|
||||||
|
//player.addChatComponentMessage(new ChatComponentText(Float.toString(tile.xAngle)));
|
||||||
//FMLNetworkHandler.openGui(player, OrbitalSatellite.instance, GuiHandler.GUIID_ENERGY_INFUSER, world, x, y, z);
|
//FMLNetworkHandler.openGui(player, OrbitalSatellite.instance, GuiHandler.GUIID_ENERGY_INFUSER, world, x, y, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class OSConstants {
|
|||||||
config.load();
|
config.load();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
enableLog = config.get("LOGGER", "EnableLog", true).getBoolean();
|
enableLog = config.get("Logging", "EnableLog", true).getBoolean();
|
||||||
|
|
||||||
DesignatorCommitRange = config.get("Designator Max Range", "DesignatorCommitRange", 50).getInt();
|
DesignatorCommitRange = config.get("Designator Max Range", "DesignatorCommitRange", 50).getInt();
|
||||||
OverriderMaxCharge = config.get("Max Charge on Blocks", "OverriderMaxCharge", 50000).getInt();
|
OverriderMaxCharge = config.get("Max Charge on Blocks", "OverriderMaxCharge", 50000).getInt();
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package fr.jackcartersmith.orbsat.common.tileentities;
|
package fr.jackcartersmith.orbsat.common.tileentities;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import fr.jackcartersmith.orbsat.OrbitalSatellite;
|
||||||
|
import fr.jackcartersmith.orbsat.client.render.particle.ParticleLaserBeam;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
@ -14,23 +18,67 @@ public class TileDefender extends TileEntity {
|
|||||||
public int facingDirection = ForgeDirection.UP.ordinal();
|
public int facingDirection = ForgeDirection.UP.ordinal();
|
||||||
public boolean running = false;
|
public boolean running = false;
|
||||||
public boolean runningCach = false;
|
public boolean runningCach = false;
|
||||||
private int tick = 0;
|
public int pow = 75;
|
||||||
public float rotation = 0;
|
public float rotationSpeed = 4.0F;
|
||||||
public float rotationSpeed = 0;
|
public float crystalBrightness = 1.0F;
|
||||||
private float targetSpeed = 0;
|
|
||||||
|
|
||||||
//@SideOnly(Side.CLIENT)
|
|
||||||
//private ParticleReactorBeam beam;
|
@SideOnly(Side.CLIENT)
|
||||||
|
private ParticleLaserBeam beam;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
//rotation += 1.0E-2F * (float)this.getCurrentCharge();
|
/*
|
||||||
rotation += 1.0E-1F;
|
if (this.rotation != 1.0F)
|
||||||
|
|
||||||
if ((double)rotation >= Math.PI)
|
|
||||||
{
|
{
|
||||||
rotation = (float)(-Math.PI);
|
if (this.rotation < 1.0F)
|
||||||
|
{
|
||||||
|
this.rotation += Math.max(this.rotation / 10.0F, 0.001F);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((double)this.rotation > 0.999D)
|
||||||
|
{
|
||||||
|
this.rotation = 1.0F;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (worldObj.isRemote)
|
||||||
|
beam = OrbitalSatellite.proxy.energyBeam(worldObj, this.xCoord + 0.52F, this.yCoord, this.zCoord + 0.48F, this.xCoord, this.yCoord + 1024, this.zCoord, pow, 8, beam, true, 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (this.active && this.startUp != 1.0F)
|
||||||
|
{
|
||||||
|
if (this.startUp < 1.0F)
|
||||||
|
{
|
||||||
|
this.startUp += Math.max(this.startUp / 10.0F, 0.001F);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((double)this.startUp > 0.999D)
|
||||||
|
{
|
||||||
|
this.startUp = 1.0F;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.active && this.startUp > 0.0F)
|
||||||
|
{
|
||||||
|
if (this.startUp > 0.0F)
|
||||||
|
{
|
||||||
|
this.startUp -= this.startUp / 10.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((double)this.startUp < 0.001D)
|
||||||
|
{
|
||||||
|
this.startUp = 0.0F;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
targetSpeed = 1F;
|
targetSpeed = 1F;
|
||||||
|
210
src/main/java/fr/jackcartersmith/orbsat/common/utils/Utils.java
Normal file
210
src/main/java/fr/jackcartersmith/orbsat/common/utils/Utils.java
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
package fr.jackcartersmith.orbsat.common.utils;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import cpw.mods.fml.common.registry.GameData;
|
||||||
|
import net.minecraft.command.IEntitySelector;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class Utils {
|
||||||
|
public static IEntitySelector selectLivingBase = new IEntitySelector() {
|
||||||
|
@Override
|
||||||
|
public boolean isEntityApplicable(Entity entity) {
|
||||||
|
return entity instanceof EntityLivingBase;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static IEntitySelector selectPlayer = new IEntitySelector() {
|
||||||
|
@Override
|
||||||
|
public boolean isEntityApplicable(Entity entity) {
|
||||||
|
return entity instanceof EntityPlayer;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static String formatNumber(double value){
|
||||||
|
if (value < 1000D)
|
||||||
|
return String.valueOf(value);
|
||||||
|
else if (value < 1000000D)
|
||||||
|
return String.valueOf(Math.round(value)/1000D) + "K";
|
||||||
|
else if (value < 1000000000D)
|
||||||
|
return String.valueOf(Math.round(value/1000D)/1000D) + "M";
|
||||||
|
else if (value < 1000000000000D)
|
||||||
|
return String.valueOf(Math.round(value/1000000D)/1000D) + "B";
|
||||||
|
else
|
||||||
|
return String.valueOf(Math.round(value/1000000000D)/1000D) + "T";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String formatNumber(long value){
|
||||||
|
if (value < 1000L)
|
||||||
|
return String.valueOf(value);
|
||||||
|
else if (value < 1000000L)
|
||||||
|
return String.valueOf(Math.round(value)/1000D) + "K";
|
||||||
|
else if (value < 1000000000L)
|
||||||
|
return String.valueOf(Math.round(value/1000L)/1000D) + "M";
|
||||||
|
else if (value < 1000000000000L)
|
||||||
|
return String.valueOf(Math.round(value/1000000L)/1000D) + "B";
|
||||||
|
else
|
||||||
|
return String.valueOf(Math.round(value/1000000000L)/1000D) + "T";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add commas to a number e.g. 161253126 > 161,253,126
|
||||||
|
*/
|
||||||
|
public static String addCommas(int value){
|
||||||
|
String rawNumber = String.valueOf(value);
|
||||||
|
String formattedNumber = "";
|
||||||
|
do {
|
||||||
|
int end = rawNumber.length();
|
||||||
|
int start = Math.max(0, end - 3);
|
||||||
|
String part = rawNumber.substring(start, end);
|
||||||
|
rawNumber = rawNumber.substring(0, start);
|
||||||
|
formattedNumber = part + (formattedNumber.length() > 0 ? "," : "") + formattedNumber;
|
||||||
|
|
||||||
|
}while (rawNumber.length() > 0);
|
||||||
|
return formattedNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add commas to a number e.g. 161253126 > 161,253,126
|
||||||
|
*/
|
||||||
|
public static String addCommas(long value){
|
||||||
|
String rawNumber = String.valueOf(value);
|
||||||
|
String formattedNumber = "";
|
||||||
|
do {
|
||||||
|
int end = rawNumber.length();
|
||||||
|
int start = Math.max(0, end - 3);
|
||||||
|
String part = rawNumber.substring(start, end);
|
||||||
|
rawNumber = rawNumber.substring(0, start);
|
||||||
|
formattedNumber = part + (formattedNumber.length() > 0 ? "," : "") + formattedNumber;
|
||||||
|
|
||||||
|
}while (rawNumber.length() > 0);
|
||||||
|
return formattedNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the exact distance between two points in 3D space
|
||||||
|
* @param x1 point A x
|
||||||
|
* @param y1 point A y
|
||||||
|
* @param z1 point A z
|
||||||
|
* @param x2 point B x
|
||||||
|
* @param y2 point B y
|
||||||
|
* @param z2 point B z
|
||||||
|
* @return The distance between point A and point B
|
||||||
|
*/
|
||||||
|
public static double getDistanceAtoB(double x1, double y1, double z1, double x2, double y2, double z2){
|
||||||
|
double dx = x1-x2;
|
||||||
|
double dy = y1-y2;
|
||||||
|
double dz = z1-z2;
|
||||||
|
return Math.sqrt((dx*dx + dy*dy + dz*dz));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the exact distance between two points in 2D space
|
||||||
|
* @param x1 point A x
|
||||||
|
* @param z1 point A z
|
||||||
|
* @param x2 point B x
|
||||||
|
* @param z2 point B z
|
||||||
|
* @return The distance between point A and point B
|
||||||
|
*/
|
||||||
|
public static double getDistanceAtoB(double x1, double z1, double x2, double z2){
|
||||||
|
double dx = x1-x2;
|
||||||
|
double dz = z1-z2;
|
||||||
|
return Math.sqrt((dx*dx + dz*dz ));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getDistanceSq(double x1, double y1, double z1, double x2, double y2, double z2){
|
||||||
|
double dx = x1-x2;
|
||||||
|
double dy = y1-y2;
|
||||||
|
double dz = z1-z2;
|
||||||
|
return dx*dx + dy*dy + dz*dz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getDistanceSq(double x1, double z1, double x2, double z2){
|
||||||
|
double dx = x1-x2;
|
||||||
|
double dz = z1-z2;
|
||||||
|
return dx*dx + dz*dz;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this is a client connected to a remote server.
|
||||||
|
*/
|
||||||
|
public static boolean isConnectedToDedicatedServer()
|
||||||
|
{
|
||||||
|
return FMLCommonHandler.instance().getMinecraftServerInstance() == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get itemstack from name of item or block name.
|
||||||
|
*/
|
||||||
|
public static ItemStack getStackFromName(String name, int meta)
|
||||||
|
{
|
||||||
|
if (name.contains("tile."))
|
||||||
|
{
|
||||||
|
name = name.replace("draconicevolution", "DraconicEvolution").replace("tile.", "");
|
||||||
|
if (GameData.getBlockRegistry().getObject(name) != null) return new ItemStack(GameData.getBlockRegistry().getObject(name), 1, meta);
|
||||||
|
}
|
||||||
|
if (name.contains("item."))
|
||||||
|
{
|
||||||
|
name = name.replace("draconicevolution", "DraconicEvolution").replace("item.", "");
|
||||||
|
if (GameData.getItemRegistry().getObject(name) != null) return new ItemStack(GameData.getItemRegistry().getObject(name), 1, meta);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the blocks an all 6 sides of a block.
|
||||||
|
*/
|
||||||
|
public static void updateNeabourBlocks(World world, int x, int y, int z)
|
||||||
|
{
|
||||||
|
world.notifyBlocksOfNeighborChange(x, y, z, world.getBlock(x, y, z));
|
||||||
|
world.notifyBlocksOfNeighborChange(x - 1, y, z, world.getBlock(x, y, z));
|
||||||
|
world.notifyBlocksOfNeighborChange(x + 1, y, z, world.getBlock(x, y, z));
|
||||||
|
world.notifyBlocksOfNeighborChange(x, y - 1, z, world.getBlock(x, y, z));
|
||||||
|
world.notifyBlocksOfNeighborChange(x, y + 1, z, world.getBlock(x, y, z));
|
||||||
|
world.notifyBlocksOfNeighborChange(x, y, z - 1, world.getBlock(x, y, z));
|
||||||
|
world.notifyBlocksOfNeighborChange(x, y, z + 1, world.getBlock(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine the orientation of a block based on the position of the entity that placed it.
|
||||||
|
*/
|
||||||
|
public static int determineOrientation(int x, int y, int z, EntityLivingBase entity)
|
||||||
|
{
|
||||||
|
if (MathHelper.abs((float) entity.posX - (float) x) < 2.0F && MathHelper.abs((float)entity.posZ - (float)z) < 2.0F)
|
||||||
|
{
|
||||||
|
double d0 = entity.posY + 1.82D - (double)entity.yOffset;
|
||||||
|
|
||||||
|
if (d0 - (double)y > 2.0D) return 0;
|
||||||
|
|
||||||
|
if ((double)y - d0 > 0.0D) return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int l = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||||
|
return l == 0 ? 3 : (l == 1 ? 4 : (l == 2 ? 2 : (l == 3 ? 5 : 0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double round(double number, double multiplier){
|
||||||
|
return Math.round(number * multiplier) / multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getNearestMultiple(int number, int multiple){
|
||||||
|
int result = number;
|
||||||
|
|
||||||
|
if (number < 0) result *= -1;
|
||||||
|
|
||||||
|
if (result % multiple == 0) return number;
|
||||||
|
else if (result % multiple < multiple/2) result = result - result % multiple;
|
||||||
|
else result = result + (multiple - result % multiple);
|
||||||
|
|
||||||
|
if (number < 0) result *= -1;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Simple method to convert a Double object to a primitive int*/
|
||||||
|
public static int toInt(double d) { return (int)d; }
|
||||||
|
}
|
BIN
src/main/resources/assets/orbsat/textures/models/laserBeam.png
Normal file
BIN
src/main/resources/assets/orbsat/textures/models/laserBeam.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Loading…
x
Reference in New Issue
Block a user