mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-27 23:45:57 +00:00
Lotsa cleanup
This commit is contained in:
1 parent
4610f1e617
commit
c904244bcc
102 files changed
+1282
-1351
No files matched your search
@@ -10,8 +10,6 @@
|
||||
*/
|
||||
package vazkii.botania.common.item;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
@@ -21,6 +19,9 @@ import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.api.lexicon.multiblock.Multiblock;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
@@ -32,7 +33,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemSextant extends ItemMod {
|
||||
|
||||
|
||||
private static final String TAG_SOURCE_X = "sourceX";
|
||||
private static final String TAG_SOURCE_Y = "sourceY";
|
||||
private static final String TAG_SOURCE_Z = "sourceZ";
|
||||
@@ -41,7 +42,7 @@ public class ItemSextant extends ItemMod {
|
||||
setUnlocalizedName(LibItemNames.SEXTANT);
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
|
||||
return EnumAction.bow;
|
||||
@@ -56,7 +57,7 @@ public class ItemSextant extends ItemMod {
|
||||
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
|
||||
if(getMaxItemUseDuration(stack) - count < 10)
|
||||
return;
|
||||
|
||||
|
||||
int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0);
|
||||
int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1);
|
||||
int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0);
|
||||
@@ -65,10 +66,10 @@ public class ItemSextant extends ItemMod {
|
||||
Vector3 source = new Vector3(x, y, z);
|
||||
|
||||
double radius = calculateRadius(stack, player);
|
||||
|
||||
|
||||
if(count % 10 == 0)
|
||||
for(int i = 0; i < 360; i++) {
|
||||
float radian = (float) ((double) i * Math.PI / 180);
|
||||
float radian = (float) (i * Math.PI / 180);
|
||||
double xp = x + Math.cos(radian) * radius;
|
||||
double zp = z + Math.sin(radian) * radius;
|
||||
Botania.proxy.wispFX(world, xp + 0.5, source.y + 1, zp + 0.5, 0F, 1F, 1F, 0.3F, -0.01F);
|
||||
@@ -76,21 +77,22 @@ public class ItemSextant extends ItemMod {
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time) {
|
||||
double radius = calculateRadius(stack, player);
|
||||
if(radius > 1) {
|
||||
int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0);
|
||||
int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1);
|
||||
int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0);
|
||||
if(y != -1)
|
||||
Botania.proxy.setMultiblock(world, x, y, z, radius, Blocks.cobblestone);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time) {
|
||||
double radius = calculateRadius(stack, player);
|
||||
if(radius > 1) {
|
||||
int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0);
|
||||
int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1);
|
||||
int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0);
|
||||
if(y != -1)
|
||||
Botania.proxy.setMultiblock(world, x, y, z, radius, Blocks.cobblestone);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
|
||||
Botania.proxy.removeSextantMultiblock();
|
||||
|
||||
|
||||
if(!par3EntityPlayer.isSneaking()) {
|
||||
MovingObjectPosition pos = ToolCommons.raytraceFromEntity(par2World, par3EntityPlayer, false, 128);
|
||||
if(pos != null && pos.entityHit == null) {
|
||||
@@ -100,47 +102,47 @@ public class ItemSextant extends ItemMod {
|
||||
ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Z, pos.blockZ);
|
||||
}
|
||||
} else ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Y, -1);
|
||||
|
||||
|
||||
par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack));
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
public static double calculateRadius(ItemStack stack, EntityPlayer player) {
|
||||
|
||||
public static double calculateRadius(ItemStack stack, EntityPlayer player) {
|
||||
int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0);
|
||||
int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1);
|
||||
int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0);
|
||||
World world = player.worldObj;
|
||||
Vector3 source = new Vector3(x, y, z);
|
||||
Botania.proxy.wispFX(world, source.x + 0.5, source.y + 1, source.z + 0.5, 1F, 0F, 0F, 0.2F, -0.1F);
|
||||
|
||||
|
||||
Vector3 centerVec = Vector3.fromEntityCenter(player);
|
||||
Vector3 diffVec = source.copy().subtract(centerVec);
|
||||
Vector3 lookVec = new Vector3(player.getLookVec());
|
||||
double mul = diffVec.y / lookVec.y;
|
||||
lookVec.multiply(mul).add(centerVec);
|
||||
|
||||
|
||||
lookVec.x = net.minecraft.util.MathHelper.floor_double(lookVec.x);
|
||||
lookVec.z = net.minecraft.util.MathHelper.floor_double(lookVec.z);
|
||||
|
||||
|
||||
return MathHelper.pointDistancePlane(source.x, source.z, lookVec.x, lookVec.z);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) {
|
||||
ItemStack onUse = player.getItemInUse();
|
||||
int time = player.getItemInUseCount();
|
||||
|
||||
|
||||
if(onUse == stack && stack.getItem().getMaxItemUseDuration(stack) - time >= 10) {
|
||||
double radius = calculateRadius(stack, player);
|
||||
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
|
||||
int x = resolution.getScaledWidth() / 2 + 30;
|
||||
int y = resolution.getScaledHeight() / 2;
|
||||
|
||||
|
||||
String s = "" + (int) radius;
|
||||
font.drawStringWithShadow(s, x - font.getStringWidth(s) / 2, y - 4, 0xFFFFFF);
|
||||
|
||||
|
||||
if(radius > 0) {
|
||||
radius += 4;
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
@@ -148,7 +150,7 @@ public class ItemSextant extends ItemMod {
|
||||
GL11.glBegin(GL11.GL_LINE_STRIP);
|
||||
GL11.glColor4f(0F, 1F, 1F, 1F);
|
||||
for(int i = 0; i < 361; i++) {
|
||||
float radian = (float) ((double) i * Math.PI / 180);
|
||||
float radian = (float) (i * Math.PI / 180);
|
||||
double xp = x + Math.cos(radian) * radius;
|
||||
double yp = y + Math.sin(radian) * radius;
|
||||
GL11.glVertex2d(xp, yp);
|
||||
@@ -160,12 +162,12 @@ public class ItemSextant extends ItemMod {
|
||||
}
|
||||
|
||||
public static class MultiblockSextant extends Multiblock {
|
||||
|
||||
|
||||
@Override
|
||||
public Multiblock[] createRotations() {
|
||||
return new Multiblock[] { this };
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user