mirror of
https://github.com/GTNewHorizons/Electro-Magic-Tools.git
synced 2026-11-13 17:04:02 +00:00
1 parent
0e82f8617b
commit
6c0f4cffa0
8 files changed
+66
-169
No files matched your search
@@ -39,7 +39,6 @@ public class ItemElectricBootsTraveller extends ItemArmor implements IElectricIt
|
||||
public float speedBonus = 0.055F;
|
||||
public float jumpBonus = 0.3F;
|
||||
public double transferLimit = 100;
|
||||
public boolean speedBoostActive = false;
|
||||
|
||||
public ItemElectricBootsTraveller(ArmorMaterial material, int par3, int par4) {
|
||||
super(material, par3, par4);
|
||||
@@ -116,11 +115,6 @@ public class ItemElectricBootsTraveller extends ItemArmor implements IElectricIt
|
||||
|
||||
@Override
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
|
||||
if (Keys.instance.isBoostKeyDown(player) && Keys.instance.isModeSwitchKeyDown(player))
|
||||
{
|
||||
speedBoostActive = !speedBoostActive;
|
||||
}
|
||||
|
||||
if ((!player.capabilities.isFlying) && (player.moveForward > 0.0F)) {
|
||||
if ((player.worldObj.isRemote) && (!player.isSneaking())) {
|
||||
if (!Thaumcraft.instance.entityEventHandler.prevStep.containsKey(Integer.valueOf(player.getEntityId()))) {
|
||||
@@ -128,7 +122,8 @@ public class ItemElectricBootsTraveller extends ItemArmor implements IElectricIt
|
||||
}
|
||||
player.stepHeight = 1.0F;
|
||||
}
|
||||
if (speedBoostActive && ((player.onGround || player.capabilities.isFlying) && player.moveForward > 0F)) {
|
||||
|
||||
if (((player.onGround || player.capabilities.isFlying) && player.moveForward > 0F)) {
|
||||
player.moveFlying(0F, 1F, speedBonus);
|
||||
player.jumpMovementFactor = jumpBonus;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import emt.EMT;
|
||||
import emt.EMT;
|
||||
import emt.util.EMTConfigHandler;
|
||||
import ic2.api.item.ElectricItem;
|
||||
import ic2.api.item.IC2Items;
|
||||
import ic2.api.util.Keys;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -52,21 +54,6 @@ public class ItemNanoGoggles extends ItemElectricGoggles {
|
||||
|
||||
@Override
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
|
||||
if (EMTConfigHandler.nightVisionOff == false) {
|
||||
if (ElectricItem.manager.canUse(itemStack, 1 / 1000)) {
|
||||
|
||||
int x = MathHelper.floor_double(player.posX);
|
||||
int z = MathHelper.floor_double(player.posZ);
|
||||
int y = MathHelper.floor_double(player.posY);
|
||||
|
||||
int lightlevel = player.worldObj.getBlockLightValue(x, y, z);
|
||||
if (lightlevel >= 0)
|
||||
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 300, -3));
|
||||
ElectricItem.manager.use(itemStack, 1 / 1000, player);
|
||||
}
|
||||
else {
|
||||
player.addPotionEffect(new PotionEffect(Potion.blindness.id, 300, 0, true));
|
||||
}
|
||||
}
|
||||
IC2Items.getItem("nightvisionGoggles").getItem().onArmorTick(world, player, itemStack);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,9 @@ import emt.EMT;
|
||||
import emt.EMT;
|
||||
import emt.util.EMTConfigHandler;
|
||||
import ic2.api.item.ElectricItem;
|
||||
import ic2.api.item.IC2Items;
|
||||
import ic2.core.IC2;
|
||||
import ic2.core.util.Keyboard;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -16,10 +19,13 @@ import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class ItemQuantumGoggles extends ItemNanoGoggles {
|
||||
|
||||
@@ -62,48 +68,40 @@ public class ItemQuantumGoggles extends ItemNanoGoggles {
|
||||
return 4;
|
||||
}
|
||||
|
||||
// MUAHAHAHA
|
||||
@Override
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
|
||||
int refill = player.getAir();
|
||||
if (ElectricItem.manager.canUse(itemStack, 1000) && refill < 100) {
|
||||
player.setAir(refill + 200);
|
||||
ElectricItem.manager.use(itemStack, 1000, null);
|
||||
}
|
||||
try {
|
||||
Field f;
|
||||
f = Keyboard.class.getDeclaredField("playerKeys");
|
||||
f.setAccessible(true);
|
||||
Map<EntityPlayer, Set<Enum>> playerKeys = (Map<EntityPlayer, Set<Enum>>) f.get(IC2.keyboard);
|
||||
|
||||
Iterator i$ = (new LinkedList(player.getActivePotionEffects())).iterator();
|
||||
do {
|
||||
if (!i$.hasNext()) {
|
||||
break;
|
||||
}
|
||||
{
|
||||
PotionEffect effect = (PotionEffect) i$.next();
|
||||
int id = effect.getPotionID();
|
||||
Integer cost = (Integer) potionCost.get(Integer.valueOf(id));
|
||||
if (cost != null) {
|
||||
cost = Integer.valueOf(cost.intValue() * (effect.getAmplifier() + 1));
|
||||
if (ElectricItem.manager.canUse(itemStack, cost.intValue())) {
|
||||
ElectricItem.manager.use(itemStack, cost.intValue(), null);
|
||||
ItemStack milk = (new ItemStack(Items.milk_bucket));
|
||||
player.curePotionEffects(milk);
|
||||
Enum hub = null;
|
||||
Set<Enum> set = playerKeys.get(player);
|
||||
|
||||
if (set != null) {
|
||||
for (Enum e : set) {
|
||||
if (e.ordinal() == 6) {
|
||||
hub = e;
|
||||
}
|
||||
}
|
||||
set.remove(hub);
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
|
||||
if (EMTConfigHandler.nightVisionOff == false) {
|
||||
if (ElectricItem.manager.canUse(itemStack, 1 / 1000)) {
|
||||
int x = MathHelper.floor_double(player.posX);
|
||||
int z = MathHelper.floor_double(player.posZ);
|
||||
int y = MathHelper.floor_double(player.posY);
|
||||
int lightlevel = player.worldObj.getBlockLightValue(x, y, z);
|
||||
if (lightlevel >= 0)
|
||||
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 300, -3));
|
||||
ElectricItem.manager.use(itemStack, 1 / 1000, player);
|
||||
}
|
||||
else {
|
||||
player.addPotionEffect(new PotionEffect(Potion.blindness.id, 300, 0, true));
|
||||
IC2Items.getItem("quantumHelmet").getItem().onArmorTick(world, player, itemStack);
|
||||
|
||||
if (hub != null) {
|
||||
set.add(hub);
|
||||
}
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,14 +24,14 @@ import java.util.Map;
|
||||
|
||||
public class ItemSolarHelmetRevealing extends ItemQuantumGoggles {
|
||||
|
||||
private int ticker;
|
||||
/*private int ticker;
|
||||
private int generating;
|
||||
private int genDay;
|
||||
private int genNight;
|
||||
private boolean sunIsUp;
|
||||
private boolean skyIsVisible;
|
||||
private boolean noSunWorld;
|
||||
private boolean dampPlace;
|
||||
private boolean dampPlace;*/
|
||||
private int genDay;
|
||||
private int genNight;
|
||||
|
||||
private static final Map potionCost = new HashMap();
|
||||
|
||||
@@ -41,9 +41,9 @@ public class ItemSolarHelmetRevealing extends ItemQuantumGoggles {
|
||||
this.setMaxDamage(27);
|
||||
this.setMaxStackSize(1);
|
||||
this.setCreativeTab(EMT.TAB);
|
||||
//this.maxCharge = 20000000; //REALLY?
|
||||
this.genDay = 256;
|
||||
this.genNight = 128;
|
||||
// this.maxCharge = 20000000; //REALLY?
|
||||
this.genDay = 65536;
|
||||
this.genNight = 4096;
|
||||
maxCharge = 20000000;
|
||||
visDiscount = 7;
|
||||
tier = 4;
|
||||
@@ -76,120 +76,37 @@ public class ItemSolarHelmetRevealing extends ItemQuantumGoggles {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void onArmorTick(World worldObj, EntityPlayer player, ItemStack itemStack) {
|
||||
if (EMTConfigHandler.nightVisionOff == false) {
|
||||
if (ElectricItem.manager.canUse(itemStack, 1 / 1000)) {
|
||||
|
||||
int x = MathHelper.floor_double(player.posX);
|
||||
int z = MathHelper.floor_double(player.posZ);
|
||||
int y = MathHelper.floor_double(player.posY);
|
||||
|
||||
int lightlevel = player.worldObj.getBlockLightValue(x, y, z);
|
||||
if (lightlevel >= 0)
|
||||
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 300, -3));
|
||||
ElectricItem.manager.use(itemStack, 1 / 1000, player);
|
||||
}
|
||||
else {
|
||||
player.addPotionEffect(new PotionEffect(Potion.blindness.id, 300, 0, true));
|
||||
}
|
||||
}
|
||||
|
||||
int refill = player.getAir();
|
||||
if (ElectricItem.manager.canUse(itemStack, 1000) && refill < 100) {
|
||||
player.setAir(refill + 200);
|
||||
ElectricItem.manager.use(itemStack, 1000, null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
Iterator i$ = (new LinkedList(player.getActivePotionEffects())).iterator();
|
||||
do {
|
||||
if (!i$.hasNext()) {
|
||||
break;
|
||||
}
|
||||
{
|
||||
PotionEffect effect = (PotionEffect) i$.next();
|
||||
int id = effect.getPotionID();
|
||||
Integer cost = (Integer) potionCost.get(Integer.valueOf(id));
|
||||
if (cost != null) {
|
||||
cost = Integer.valueOf(cost.intValue() * (effect.getAmplifier() + 1));
|
||||
if (ElectricItem.manager.canUse(itemStack, cost.intValue())) {
|
||||
ElectricItem.manager.use(itemStack, cost.intValue(), null);
|
||||
ItemStack milk = (new ItemStack(Items.milk_bucket));
|
||||
player.curePotionEffects(milk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
super.onArmorTick(worldObj, player, itemStack);
|
||||
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
checkForSun(player);
|
||||
if (this.generating > 0) {
|
||||
int energyLeft = this.generating;
|
||||
|
||||
if(worldObj.canBlockSeeTheSky((int)player.posX, (int)player.posY + 1, (int)player.posZ) && !worldObj.isRaining()) {
|
||||
double enerj = (worldObj.isDaytime() ? (double)genDay : (double) genNight) / 12000D;
|
||||
|
||||
for (int i = 0; i < player.inventory.armorInventory.length; i++) {
|
||||
if (energyLeft > 0) {
|
||||
if (enerj > 0) {
|
||||
if ((player.inventory.armorInventory[i] != null) && (player.inventory.armorInventory[i].getItem() instanceof IElectricItem)) {
|
||||
double sentPacket = ElectricItem.manager.charge(player.inventory.armorInventory[i], energyLeft, 4, false, false);
|
||||
energyLeft -= sentPacket;
|
||||
double sentPacket = ElectricItem.manager.charge(player.inventory.armorInventory[i], enerj ,4, false, false);
|
||||
enerj -= sentPacket;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < player.inventory.mainInventory.length; j++) {
|
||||
if (energyLeft > 0) {
|
||||
if (enerj > 0) {
|
||||
if ((player.inventory.mainInventory[j] != null) && (player.inventory.mainInventory[j].getItem() instanceof IElectricItem)) {
|
||||
double sentPacket = ElectricItem.manager.charge(player.inventory.mainInventory[j], energyLeft, 4, false, false);
|
||||
energyLeft -= sentPacket;
|
||||
double sentPacket = ElectricItem.manager.charge(player.inventory.mainInventory[j], enerj, 4, false, false);
|
||||
enerj -= sentPacket;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int checkForSun(EntityPlayer player) {
|
||||
if (this.ticker++ % tickRate() == 0) {
|
||||
updateVisibility(player);
|
||||
}
|
||||
if ((this.sunIsUp) && (this.skyIsVisible)) {
|
||||
this.generating = (0 + this.genDay);
|
||||
return this.generating;
|
||||
}
|
||||
if (this.skyIsVisible) {
|
||||
this.generating = (0 + this.genNight);
|
||||
return this.generating;
|
||||
}
|
||||
this.generating = 0;
|
||||
return this.generating;
|
||||
}
|
||||
|
||||
public void updateVisibility(EntityPlayer player) {
|
||||
this.dampPlace = (player.worldObj.getWorldChunkManager().getBiomeGenAt((int) player.posX, (int) player.posZ).getIntRainfall() > 0);
|
||||
this.noSunWorld = player.worldObj.provider.hasNoSky;
|
||||
Boolean rainWeather = Boolean.valueOf((this.dampPlace) && ((player.worldObj.isRaining()) || (player.worldObj.isThundering())));
|
||||
if ((!player.worldObj.isDaytime()) || (rainWeather.booleanValue())) {
|
||||
this.sunIsUp = false;
|
||||
}
|
||||
else {
|
||||
this.sunIsUp = true;
|
||||
}
|
||||
if ((!player.worldObj.canBlockSeeTheSky((int) player.posX, (int) player.posY + 1, (int) player.posZ)) || (this.noSunWorld)) {
|
||||
this.skyIsVisible = false;
|
||||
}
|
||||
else {
|
||||
this.skyIsVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static int tickRate() {
|
||||
return 128;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user