deleted duplicated check, using callList for rendering shield, cleanup.

This commit is contained in:
fewizz committed 2016-04-03 20:23:55 +03:00
1 parent f2fb61feb0
commit 3fdaf92d12
8 files changed
+60 -86

No files matched your search

@@ -1,12 +1,15 @@
package emt.client.renderer;
import static org.lwjgl.opengl.GL11.*;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import emt.ModInformation;
import emt.entity.EntityLaser;
import emt.entity.EntityShield;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
@@ -16,24 +19,29 @@ import net.minecraft.util.ResourceLocation;
public class RenderShield extends Render {
private static final ResourceLocation shieldTexture = new ResourceLocation(ModInformation.texturePath, "textures/models/shield.png");
private static final float[] values = new float[6912];
static int glCallList;
static {
glCallList = GLAllocation.generateDisplayLists(3);
GL11.glPushMatrix();
GL11.glNewList(glCallList, GL11.GL_COMPILE);
Tessellator tessellator = Tessellator.instance;
float sin1;
float cos1;
float sin2;
float cos2;
float hsin1 = 0;
float hcos1 = 1;
float hsin1 = -1;
float hcos1 = 0;
float hsin2;
float hcos2;
int i = 0;
for (float h = 0; h < 360; h += 15) {
tessellator.startDrawingQuads();
for (float h = -90; h < 90; h += 15) {
sin1 = 0;
cos1 = 1;
@@ -44,23 +52,10 @@ public class RenderShield extends Render {
sin2 = MathHelper.sin((float) Math.toRadians(angle + 15));
cos2 = MathHelper.cos((float) Math.toRadians(angle + 15));
values[i] = sin1 * hcos1 * 2;
values[i + 1] = hsin1 * 2;
values[i + 2] = cos1 * hcos1 * 2;
values[i + 3] = sin1 * hcos2 * 2;
values[i + 4] = hsin2 * 2;
values[i + 5] = cos1 * hcos2 * 2;
values[i + 6] = sin2 * hcos2 * 2;
values[i + 7] = hsin2 * 2;
values[i + 8] = cos2 * hcos2 * 2;
values[i + 9] = sin2 * hcos1 * 2;
values[i + 10] = hsin1 * 2;
values[i + 11] = cos2 * hcos1 * 2;
i += 12;
tessellator.addVertexWithUV(sin1 * hcos1 * 2, hsin1 * 2, cos1 * hcos1 * 2, 1, 1);
tessellator.addVertexWithUV(sin1 * hcos2 * 2, hsin2 * 2, cos1 * hcos2 * 2, 1, 0);
tessellator.addVertexWithUV(sin2 * hcos2 * 2, hsin2 * 2, cos2 * hcos2 * 2, 0, 0);
tessellator.addVertexWithUV(sin2 * hcos1 * 2, hsin1 * 2, cos2 * hcos1 * 2, 0, 1);
sin1 = sin2;
cos1 = cos2;
@@ -69,11 +64,13 @@ public class RenderShield extends Render {
hsin1 = hsin2;
hcos1 = hcos2;
}
tessellator.draw();
GL11.glEndList();
}
public void doRender(Entity entityShield, double x, double y, double z, float par8, float par9) {
this.bindEntityTexture(entityShield);
Tessellator tessellator = Tessellator.instance;
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0);
@@ -82,25 +79,17 @@ public class RenderShield extends Render {
glPushAttrib(GL_LIGHTING);
glDisable(GL_LIGHTING);
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
glPushMatrix();
if (((EntityShield) entityShield).owner != null && !Minecraft.getMinecraft().thePlayer.getDisplayName().equals(((EntityShield) entityShield).owner.getDisplayName()))
if (((EntityShield) entityShield).owner != null && !Minecraft.getMinecraft().thePlayer.getDisplayName().equals(((EntityShield) entityShield).owner.getDisplayName())) {
glTranslated(x, y, z);
tessellator.startDrawingQuads();
for (int v = 0; v < values.length; v += 12) {
tessellator.addVertexWithUV(values[v], values[v + 1], values[v + 2], 1, 1);
tessellator.addVertexWithUV(values[v + 3], values[v + 4], values[v + 5], 1, 0);
tessellator.addVertexWithUV(values[v + 6], values[v + 7], values[v + 8], 0, 0);
tessellator.addVertexWithUV(values[v + 9], values[v + 10], values[v + 11], 0, 1);
}
tessellator.draw();
GL11.glCallList(this.glCallList);
glPopMatrix();
glPopAttrib();
glDisable(GL12.GL_RESCALE_NORMAL);
glEnable(GL_DEPTH_TEST);
}
@Override
@@ -149,7 +149,7 @@ public class ItemDiamondChainsaw extends ItemAxe implements IElectricItem {
if (!nbt.hasKey("shearsMode")) {
nbt.setBoolean("shearsMode", true);
}
if (!nbt.getBoolean("shearsMode")) {
nbt.setBoolean("shearsMode", true);
@@ -196,6 +196,34 @@ public class ItemDiamondChainsaw extends ItemAxe implements IElectricItem {
return false;
}
@Override
public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity) {
NBTTagCompound nbt = StackUtil.getOrCreateNbtData(itemstack);
if (!nbt.hasKey("shearsMode")) {
nbt.setBoolean("shearsMode", true);
}
if (!nbt.getBoolean("shearsMode") || entity.worldObj.isRemote) {
return false;
}
if (entity instanceof IShearable) {
IShearable target = (IShearable) entity;
if (target.isShearable(itemstack, entity.worldObj, (int) entity.posX, (int) entity.posY, (int) entity.posZ)) {
ArrayList<ItemStack> drops = target.onSheared(itemstack, entity.worldObj, (int) entity.posX, (int) entity.posY, (int) entity.posZ, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack));
Random rand = new Random();
for (ItemStack stack : drops) {
EntityItem ent = entity.entityDropItem(stack, 1.0F);
ent.motionY += rand.nextFloat() * 0.05F;
ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
}
}
return true;
}
return false;
}
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int i, boolean flag) {
if (entity instanceof EntityLivingBase) {
@@ -93,11 +93,6 @@ public class ItemThaumiumDrill extends ItemPickaxe implements IElectricItem {
return true;
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) {
return EMTRandomHelper.placeTorch(stack, player, world, x, y, z, side, xOffset, yOffset, zOffset);
}
@Override
public boolean isRepairable() {
return false;
@@ -117,8 +112,6 @@ public class ItemThaumiumDrill extends ItemPickaxe implements IElectricItem {
return EMTConfigHandler.enchanting;
}
/* IC2 API METHODS */
@Override
public boolean canProvideEnergy(ItemStack itemStack) {
return false;
@@ -45,13 +45,6 @@ public class EMTClientEventHandler {
}
}
if (audio != null && curItem != lastItem) {
audio.stop();
audio.remove();
audio = null;
IC2.audioManager.playOnce(player, PositionSpec.Hand, "Tools/Chainsaw/ChainsawStop.ogg", true, IC2.audioManager.getDefaultVolume());
}
if (audio != null && curItem != lastItem) {
audio.stop();
audio.remove();
+6 -6
View File
@@ -8,7 +8,7 @@ public class EMTConfigHandler {
public static Configuration config;
// sections
/** Sections */
public static String RANDOM = "Random Configs";
public static String RESEARCH = "Research";
public static String VALUES = "Numeric Values";
@@ -21,7 +21,7 @@ public class EMTConfigHandler {
public static int inventoryBaubleProdution;
public static int wandChargeFocusCost;
// values
/** Values */
public static double wandChargerConsumption;
public static double compressedSolarOutput;
public static double doubleCompressedSolarOutput;
@@ -31,7 +31,7 @@ public class EMTConfigHandler {
public static double quantumBootsJump;
public static double tripleCompressedSolarOutput;
// essentias
/** Essentias */
public static double fireOutput;
public static double waterOutput;
public static double airOutput;
@@ -40,7 +40,7 @@ public class EMTConfigHandler {
public static double entropyOutput;
public static double outputCap;
// random stuff
/** random stuff */
public static boolean impactOfRain;
public static boolean capesOn;
public static boolean toolsInBore;
@@ -50,11 +50,11 @@ public class EMTConfigHandler {
public static boolean oneRingSpawn;
public static boolean removeAmberAndCinnabarMacerating;
// loot chance
/** Loot chance */
public static int chanceOneRing;
public static int chanceTaintedMjolnir;
// research
/** Research */
public static boolean thaumiumDrillResearch;
public static boolean thaumiumChainsawResearch;
public static boolean thaumiumOmnitoolResearch;
+1 -5
View File
@@ -13,14 +13,10 @@ public class EMTCreativeTab extends CreativeTabs {
setBackgroundImageName("emt.png");
}
@Override
public ItemStack getIconItemStack() {
return new ItemStack(EMTBlocks.electricCloud);
}
@Override
public Item getTabIconItem() {
return new Item();
return EMTItems.electricThorHammer;
}
@Override
@@ -16,31 +16,6 @@ import java.util.Locale;
public class EMTRandomHelper {
public static boolean placeTorch(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) {
for (int i = 0; i < player.inventory.mainInventory.length; i++) {
ItemStack torchStack = player.inventory.mainInventory[i];
if (torchStack == null || !torchStack.getUnlocalizedName().toLowerCase(Locale.US).contains("torch"))
continue;
Item item = torchStack.getItem();
if (!(item instanceof ItemBlock))
continue;
int oldMeta = torchStack.getItemDamage();
int oldSize = torchStack.stackSize;
boolean result = torchStack.tryPlaceItemIntoWorld(player, world, x, y, z, side, xOffset, yOffset, zOffset);
if (player.capabilities.isCreativeMode) {
torchStack.setItemDamage(oldMeta);
torchStack.stackSize = oldSize;
}
else if (torchStack.stackSize <= 0) {
ForgeEventFactory.onPlayerDestroyItem(player, torchStack);
player.inventory.mainInventory[i] = null;
}
if (result)
return true;
}
return false;
}
public static ItemStack getChargedItem(Item item, int charge) {
ItemStack stack = new ItemStack(item);
ElectricItem.manager.charge(stack, charge, charge, true, false);