Conflicts:
	src/main/java/crazypants/enderio/machine/reservoir/BlockReservoir.java
This commit is contained in:
tterrag1098 committed 2014-08-05 02:02:06 -04:00
commit 4872486aec
8 files changed
+127 -28

No files matched your search

@@ -51,7 +51,7 @@ public class LiquidSettings extends BaseSettingsPanel {
private EnderLiquidConduit eConduit;
private boolean isEnder;
private int filterX = 59;
private int filterY = 59;
private int filterY = 63;
private Rectangle filterBounds = new Rectangle(filterX, filterY, 90, 18);
private GuiToolTip[] filterToolTips;
@@ -123,8 +123,8 @@ public class LiquidSettings extends BaseSettingsPanel {
rsB.onGuiInit();
colorB.onGuiInit();
} else {
gui.removeButton(rsB);
gui.removeButton(colorB);
rsB.detach();
colorB.detach();
}
if(isEnder && isFilterVisible()) {
@@ -194,7 +194,7 @@ public class LiquidSettings extends BaseSettingsPanel {
fr.drawString(filterStr, x, y, ColorUtil.getRGB(Color.DARK_GRAY));
x = gui.getGuiLeft() + filterX;
y = customTop + filterY;
y = gui.getGuiTop() + filterY;
GL11.glColor3f(1, 1, 1);
RenderUtil.bindTexture("enderio:textures/gui/externalConduitConnection.png");
gui.drawTexturedModalRect(x, y, 24, 238, 90, 18);
@@ -172,6 +172,10 @@ public final class Config {
public static double darkSteelGliderVerticalSpeed = -0.05;
public static double darkSteelGliderVerticalSpeedSprinting = -0.15;
public static int darkSteelSwimCost = 15;
public static int darkSteelNightVisionCost = 15;
public static int darkSteelSoundLocatorCost = 10;
public static int darkSteelSoundLocatorRange = 40;
public static int darkSteelSoundLocatorLifespan = 40;
@@ -462,6 +466,12 @@ public final class Config {
darkSteelFallDistanceCost = config.get(sectionDarkSteel.name, "darkSteelFallDistanceCost", darkSteelFallDistanceCost,
"Amount of power used (RF) per block height of fall distance damage negated.").getInt(darkSteelFallDistanceCost);
darkSteelSwimCost = config.get(sectionDarkSteel.name, "darkSteelSwimCost", darkSteelSwimCost,
"Number of levels required for the 'Swim' upgrade.").getInt(darkSteelSwimCost);
darkSteelNightVisionCost = config.get(sectionDarkSteel.name, "darkSteelNightVisionCost", darkSteelNightVisionCost,
"Number of levels required for the 'Night Vision' upgrade.").getInt(darkSteelNightVisionCost);
darkSteelGliderCost = config.get(sectionDarkSteel.name, "darkSteelGliderCost", darkSteelGliderCost,
"Number of levels required for the 'Glider' upgrade.").getInt(darkSteelGliderCost);
darkSteelGliderHorizontalSpeed = config.get(sectionDarkSteel.name, "darkSteelGliderHorizontalSpeed", darkSteelGliderHorizontalSpeed,
@@ -11,6 +11,8 @@ import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.MovementInput;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@@ -48,8 +50,11 @@ public class DarkSteelController {
private boolean wasJumping;
private int jumpCount;
private int ticksSinceLastJump;
//private boolean isGlideActive = false;
private Map<String, Boolean> glideActiveMap = new HashMap<String, Boolean>();
private boolean nightVisionActive = false;
private boolean removeNightvision = false;
private DarkSteelController() {
PacketHandler.INSTANCE.registerMessage(PacketDarkSteelPowerPacket.class, PacketDarkSteelPowerPacket.class, PacketHandler.nextID(), Side.SERVER);
@@ -74,8 +79,6 @@ public class DarkSteelController {
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
EntityPlayer player = event.player;
if(event.phase == Phase.START) {
//boots
updateStepHeightAndFallDistance(player);
@@ -87,16 +90,31 @@ public class DarkSteelController {
updateSword(player);
updateGlide(player);
updateSwim(player);
}
}
private void updateSwim(EntityPlayer player) {
ItemStack boots = player.getEquipmentInSlot(1);
SwimUpgrade upgrade = SwimUpgrade.loadFromItem(boots);
if(upgrade == null) {
return;
}
if(player.isInWater()) {
player.motionX *= 1.1;
player.motionZ *= 1.1;
}
}
private void updateGlide(EntityPlayer player) {
if(!isGlideActive(player) || !isGliderUpgradeEquipped(player)) {
return;
}
if(!player.onGround && player.motionY < 0 && !player.isSneaking()) {
if(!player.onGround && player.motionY < 0 && !player.isSneaking() && !player.isInWater()) {
double horizontalSpeed = Config.darkSteelGliderHorizontalSpeed;
double verticalSpeed = Config.darkSteelGliderVerticalSpeed;
@@ -164,23 +182,23 @@ public class DarkSteelController {
}
IAttributeInstance moveInst = player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.movementSpeed);
if(moveInst.getModifier(walkModifiers[0].getID()) != null) {
if(moveInst.getModifier(walkModifiers[0].getID()) != null) {
moveInst.removeModifier(walkModifiers[0]); //any will so as they all have the same UID
} else if(moveInst.getModifier(sprintModifiers[0].getID()) != null) {
} else if(moveInst.getModifier(sprintModifiers[0].getID()) != null) {
moveInst.removeModifier(sprintModifiers[0]);
}
}
ItemStack leggings = player.getEquipmentInSlot(2);
SpeedUpgrade speedUpgrade = SpeedUpgrade.loadFromItem(leggings);
if(leggings != null && leggings.getItem() == EnderIO.itemDarkSteelLeggings && speedUpgrade != null) {
double horzMovement = Math.abs(player.distanceWalkedOnStepModified - player.prevDistanceWalkedModified);
double horzMovement = Math.abs(player.distanceWalkedModified - player.prevDistanceWalkedModified);
double costModifier = player.isSprinting() ? Config.darkSteelSprintPowerCost : Config.darkSteelWalkPowerCost;
costModifier = costModifier + (costModifier * speedUpgrade.walkMultiplier);
int cost = (int) (horzMovement * costModifier);
int totalEnergy = getPlayerEnergy(player, EnderIO.itemDarkSteelLeggings);
if(totalEnergy > 0) {
if(totalEnergy > 0) {
usePlayerEnergy(player, EnderIO.itemDarkSteelLeggings, cost);
if(player.isSprinting()) {
moveInst.applyModifier(sprintModifiers[speedUpgrade.level - 1]);
@@ -284,7 +302,11 @@ public class DarkSteelController {
jumpCount = 0;
}
ticksSinceLastJump++;
updateNightvision(player);
}
}
@SideOnly(Side.CLIENT)
@@ -308,5 +330,32 @@ public class DarkSteelController {
}
}
private void updateNightvision(EntityPlayer player) {
if(isNightVisionUpgradeEquipped(player) && nightVisionActive) {
player.addPotionEffect(new PotionEffect(Potion.nightVision.getId(), 210, 0, true));
}
if(!isNightVisionUpgradeEquipped(player) && nightVisionActive) {
nightVisionActive = false;
removeNightvision = true;
}
if(removeNightvision) {
player.removePotionEffect(Potion.nightVision.getId());
removeNightvision = false;
}
}
public boolean isNightVisionUpgradeEquipped(EntityPlayer player) {
ItemStack helmet = player.getEquipmentInSlot(4);
return NightVisionUpgrade.loadFromItem(helmet) != null;
}
public void setNightVisionActive(boolean isNightVisionActive) {
if(nightVisionActive && !isNightVisionActive) {
removeNightvision = true;
}
this.nightVisionActive = isNightVisionActive;
}
}
@@ -36,6 +36,8 @@ public class DarkSteelRecipeManager {
upgrades.add(SpeedUpgrade.SPEED_THREE);
upgrades.add(GliderUpgrade.INSTANCE);
upgrades.add(SoundDetectorUpgrade.INSTANCE);
upgrades.add(SwimUpgrade.INSTANCE);
upgrades.add(NightVisionUpgrade.INSTANCE);
}
@SubscribeEvent
@@ -107,10 +107,12 @@ public class ItemDarkSteelArmor extends ItemArmor implements IEnergyContainerIte
SpeedUpgrade.SPEED_THREE.writeToItem(is);
} else if(armorType == 3) {
JumpUpgrade.JUMP_THREE.writeToItem(is);
SwimUpgrade.INSTANCE.writeToItem(is);
} else if(armorType == 1) {
GliderUpgrade.INSTANCE.writeToItem(is);
} else if(armorType == 0) {
SoundDetectorUpgrade.INSTANCE.writeToItem(is);
NightVisionUpgrade.INSTANCE.writeToItem(is);
}
par3List.add(is);
@@ -30,17 +30,23 @@ public class KeyTracker {
private KeyBinding soundDetectorKey;
private boolean isSoundDectorActive = false;
private KeyBinding nightVisionKey;
private boolean isNightVisionActive = false;
public KeyTracker() {
glideKey = new KeyBinding("Glider Toggle", Keyboard.KEY_G, "Dark Steel Armor");
ClientRegistry.registerKeyBinding(glideKey);
soundDetectorKey = new KeyBinding("Sound Locator", Keyboard.KEY_L, "Dark Steel Armor");
ClientRegistry.registerKeyBinding(soundDetectorKey);
nightVisionKey = new KeyBinding("Night Vision", Keyboard.KEY_P, "Dark Steel Armor");
ClientRegistry.registerKeyBinding(nightVisionKey);
}
@SubscribeEvent
public void onKeyInput(KeyInputEvent event) {
handleGlide();
handleSoundDetector();
handleNightVision();
}
private void handleSoundDetector() {
@@ -79,6 +85,24 @@ public class KeyTracker {
PacketHandler.INSTANCE.sendToServer(new PacketGlideState(isGlideActive));
}
}
private void handleNightVision() {
if(!DarkSteelController.instance.isNightVisionUpgradeEquipped(Minecraft.getMinecraft().thePlayer)) {
isNightVisionActive = false;
return;
}
if(nightVisionKey.getIsKeyPressed()) {
isNightVisionActive = !isNightVisionActive;
String message;
if(isNightVisionActive) {
message = Lang.localize("darksteel.upgrade.nightVision.enabled");
} else {
message = Lang.localize("darksteel.upgrade.nightVision.disabled");
}
Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentTranslation(message));
DarkSteelController.instance.setNightVisionActive(isNightVisionActive);
}
}
public boolean isGlideActive() {
return isGlideActive;
@@ -15,8 +15,9 @@ public class TileCrusher extends AbstractPoweredTaskEntity {
protected IGrindingMultiplier gb;
protected int currGbUse = 0;
protected int lastSendGbScaled = 0;
private boolean useGrindingBall;
public TileCrusher() {
super(new SlotDefinition(2, 4));
@@ -44,29 +45,28 @@ public class TileCrusher extends AbstractPoweredTaskEntity {
if(gb == null) {
return 0;
}
float res = 1 - (float)currGbUse / (float)gb.getDurationMJ();
return (int)(res * scale);
float res = 1 - (float) currGbUse / (float) gb.getDurationMJ();
return (int) (res * scale);
}
@Override
protected double usePower() {
double res = super.usePower();
if(gb != null) {
if(gb != null && useGrindingBall) {
currGbUse += res;
int newScaled = getBallDurationScaled(16);
if(newScaled != lastSendGbScaled) {
PacketHandler.sendToAllAround(new PacketGrindingBall(this), this);
lastSendGbScaled = newScaled;
}
if(currGbUse > gb.getDurationMJ()) {
currGbUse = 0;
gb = null;
}
}
if(gb == null ) {
if(gb == null) {
gb = CrusherRecipeManager.getInstance().getGrindballFromStack(inventory[1]);
if(gb != null) {
decrStackSize(1, 1);
@@ -81,11 +81,11 @@ public class TileCrusher extends AbstractPoweredTaskEntity {
IPoweredTask ct = currentTask;
super.taskComplete();
//run it again if the ball says so
if(gb != null && !CrusherRecipeManager.getInstance().isExcludedFromBallBonus(ct.getInputs())) {
if(gb != null && useGrindingBall) {
float chance = random.nextFloat();
float mul = gb.getGrindingMultiplier() - 1;
while(mul > 0) {
if(chance <= mul){
while (mul > 0) {
if(chance <= mul) {
currentTask = ct;
super.taskComplete();
}
@@ -97,9 +97,15 @@ public class TileCrusher extends AbstractPoweredTaskEntity {
@Override
protected IPoweredTask createTask(IMachineRecipe nextRecipe, float chance) {
PoweredTask res;
useGrindingBall = false;
if(gb != null) {
res = new PoweredTask(nextRecipe, chance * gb.getChanceMultiplier(), getInputs());
res.setRequiredEnergy(res.getRequiredEnergy() * gb.getPowerMultiplier());
useGrindingBall = !CrusherRecipeManager.getInstance().isExcludedFromBallBonus(getInputs());
if(useGrindingBall) {
res = new PoweredTask(nextRecipe, chance * gb.getChanceMultiplier(), getInputs());
res.setRequiredEnergy(res.getRequiredEnergy() * gb.getPowerMultiplier());
} else {
res = new PoweredTask(nextRecipe, chance, getInputs());
}
} else {
res = new PoweredTask(nextRecipe, chance, getInputs());
}
@@ -120,7 +126,7 @@ public class TileCrusher extends AbstractPoweredTaskEntity {
GrindingMultiplierNBT.writeToNBT(gb, nbtRoot);
}
nbtRoot.setInteger("currGbUse", currGbUse);
lastSendGbScaled = getBallDurationScaled(16);
}