mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-27 23:45:55 +00:00
Refactor DS upgrade classes, add system for upgrade rendering
This commit is contained in:
1 parent
23a8a8b312
commit
66de4cf20d
27 files changed
+309
-99
No files matched your search
@@ -21,11 +21,11 @@ import crazypants.enderio.conduit.ConduitDisplayMode;
|
||||
import crazypants.enderio.item.PacketMagnetState.SlotType;
|
||||
import crazypants.enderio.item.darksteel.DarkSteelController;
|
||||
import crazypants.enderio.item.darksteel.DarkSteelItems;
|
||||
import crazypants.enderio.item.darksteel.JumpUpgrade;
|
||||
import crazypants.enderio.item.darksteel.PacketUpgradeState;
|
||||
import crazypants.enderio.item.darksteel.SoundDetector;
|
||||
import crazypants.enderio.item.darksteel.SoundDetectorUpgrade;
|
||||
import crazypants.enderio.item.darksteel.SpeedUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.JumpUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.SoundDetectorUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.SpeedUpgrade;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.thaumcraft.GogglesOfRevealingUpgrade;
|
||||
import crazypants.util.BaublesUtil;
|
||||
|
||||
@@ -10,11 +10,16 @@ import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.ai.attributes.IAttributeInstance;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovementInput;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
@@ -23,6 +28,15 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.item.darksteel.upgrade.EnergyUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.GliderUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.IDarkSteelUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.IRenderUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.JumpUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.NightVisionUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.SolarUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.SpeedUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.SwimUpgrade;
|
||||
import crazypants.enderio.machine.solar.TileEntitySolarPanel;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.util.Util;
|
||||
@@ -263,16 +277,16 @@ public class DarkSteelController {
|
||||
|
||||
double horzMovement = Math.abs(player.distanceWalkedModified - player.prevDistanceWalkedModified);
|
||||
double costModifier = player.isSprinting() ? Config.darkSteelSprintPowerCost : Config.darkSteelWalkPowerCost;
|
||||
costModifier = costModifier + (costModifier * speedUpgrade.walkMultiplier);
|
||||
costModifier = costModifier + (costModifier * speedUpgrade.getWalkMultiplier());
|
||||
int cost = (int) (horzMovement * costModifier);
|
||||
int totalEnergy = getPlayerEnergy(player, DarkSteelItems.itemDarkSteelLeggings);
|
||||
|
||||
if(totalEnergy > 0) {
|
||||
usePlayerEnergy(player, DarkSteelItems.itemDarkSteelLeggings, cost);
|
||||
if(player.isSprinting()) {
|
||||
moveInst.applyModifier(sprintModifiers[speedUpgrade.level - 1]);
|
||||
moveInst.applyModifier(sprintModifiers[speedUpgrade.getLevel() - 1]);
|
||||
} else {
|
||||
moveInst.applyModifier(walkModifiers[speedUpgrade.level - 1]);
|
||||
moveInst.applyModifier(walkModifiers[speedUpgrade.getLevel() - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -367,11 +381,56 @@ public class DarkSteelController {
|
||||
jumpCount = 0;
|
||||
}
|
||||
ticksSinceLastJump++;
|
||||
|
||||
|
||||
updateNightvision(player);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onPlayerRender(RenderPlayerEvent.Specials.Post event) {
|
||||
if (event.entityLiving.getActivePotionEffect(Potion.invisibility) != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player = event.entityPlayer;
|
||||
ItemStack[] armors = player.inventory.armorInventory;
|
||||
|
||||
dispatchRenders(armors, event, false);
|
||||
|
||||
float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * event.partialRenderTick;
|
||||
float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * event.partialRenderTick;
|
||||
float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * event.partialRenderTick;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(yawOffset, 0, -1, 0);
|
||||
GL11.glRotatef(yaw - 270, 0, 1, 0);
|
||||
GL11.glRotatef(pitch, 0, 0, 1);
|
||||
dispatchRenders(armors, event, true);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void dispatchRenders(ItemStack[] armors, RenderPlayerEvent event, boolean head) {
|
||||
for (int i = 0; i < armors.length; i++) {
|
||||
ItemStack stack = armors[i];
|
||||
if (stack != null) {
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (item instanceof IDarkSteelItem) {
|
||||
for (IDarkSteelUpgrade upg : DarkSteelRecipeManager.instance.getUpgrades()) {
|
||||
if (upg.hasUpgrade(stack)) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
IRenderUpgrade render = upg.getRender();
|
||||
if (render != null) {
|
||||
upg.getRender().render(event, stack, head);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -386,7 +445,7 @@ public class DarkSteelController {
|
||||
|
||||
int requiredPower = Config.darkSteelBootsJumpPowerCost * (int) Math.pow(jumpCount + 1, 2.5);
|
||||
int availablePower = getPlayerEnergy(player, DarkSteelItems.itemDarkSteelBoots);
|
||||
if(availablePower > 0 && requiredPower <= availablePower && jumpCount < jumpUpgrade.level) {
|
||||
if(availablePower > 0 && requiredPower <= availablePower && jumpCount < jumpUpgrade.getLevel()) {
|
||||
jumpCount++;
|
||||
player.motionY += 0.15 * Config.darkSteelBootsJumpModifier * jumpCount;
|
||||
ticksSinceLastJump = 0;
|
||||
|
||||
@@ -18,6 +18,19 @@ import com.google.common.collect.ImmutableList;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.item.darksteel.upgrade.ApiaristArmorUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.EnergyUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.GliderUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.IDarkSteelUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.JumpUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.NaturalistEyeUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.NightVisionUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.SolarUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.SoundDetectorUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.SpeedUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.SpoonUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.SwimUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.TravelUpgrade;
|
||||
import crazypants.enderio.material.Alloy;
|
||||
import crazypants.enderio.thaumcraft.GogglesOfRevealingUpgrade;
|
||||
import crazypants.enderio.thaumcraft.ThaumcraftCompat;
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
package crazypants.enderio.item.darksteel;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
|
||||
public class GliderUpgrade extends AbstractUpgrade {
|
||||
|
||||
private static String UPGRADE_NAME = "glide";
|
||||
|
||||
public static final GliderUpgrade INSTANCE = new GliderUpgrade();
|
||||
|
||||
public static GliderUpgrade loadFromItem(ItemStack stack) {
|
||||
if(stack == null) {
|
||||
return null;
|
||||
}
|
||||
if(stack.stackTagCompound == null) {
|
||||
return null;
|
||||
}
|
||||
if(!stack.stackTagCompound.hasKey(KEY_UPGRADE_PREFIX + UPGRADE_NAME)) {
|
||||
return null;
|
||||
}
|
||||
return new GliderUpgrade((NBTTagCompound) stack.stackTagCompound.getTag(KEY_UPGRADE_PREFIX + UPGRADE_NAME));
|
||||
}
|
||||
|
||||
|
||||
public GliderUpgrade(NBTTagCompound tag) {
|
||||
super(UPGRADE_NAME, tag);
|
||||
}
|
||||
|
||||
public GliderUpgrade() {
|
||||
super(UPGRADE_NAME, "enderio.darksteel.upgrade.glider", new ItemStack(DarkSteelItems.itemGliderWing,1,1), Config.darkSteelGliderCost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAddToItem(ItemStack stack) {
|
||||
if(stack == null || stack.getItem() != DarkSteelItems.itemDarkSteelChestplate) {
|
||||
return false;
|
||||
}
|
||||
GliderUpgrade up = loadFromItem(stack);
|
||||
if(up == null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeUpgradeToNBT(NBTTagCompound upgradeRoot) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,6 +30,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.gui.IAdvancedTooltipProvider;
|
||||
import crazypants.enderio.item.darksteel.upgrade.ApiaristArmorUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.EnergyUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.IDarkSteelUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.NaturalistEyeUpgrade;
|
||||
import crazypants.enderio.thaumcraft.GogglesOfRevealingUpgrade;
|
||||
import crazypants.util.ItemUtil;
|
||||
import crazypants.util.Lang;
|
||||
@@ -61,6 +65,7 @@ public class ItemDarkSteelArmor extends ItemArmor implements IEnergyContainerIte
|
||||
|
||||
static {
|
||||
FMLCommonHandler.instance().bus().register(DarkSteelController.instance);
|
||||
MinecraftForge.EVENT_BUS.register(DarkSteelController.instance);
|
||||
MinecraftForge.EVENT_BUS.register(DarkSteelRecipeManager.instance);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.gui.IAdvancedTooltipProvider;
|
||||
import crazypants.enderio.item.darksteel.upgrade.EnergyUpgrade;
|
||||
import crazypants.enderio.machine.farm.farmers.HarvestResult;
|
||||
import crazypants.enderio.machine.farm.farmers.TreeHarvestUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
@@ -30,6 +30,9 @@ import crazypants.enderio.api.teleport.IItemOfTravel;
|
||||
import crazypants.enderio.api.teleport.TravelSource;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.gui.IAdvancedTooltipProvider;
|
||||
import crazypants.enderio.item.darksteel.upgrade.EnergyUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.SpoonUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.TravelUpgrade;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.enderio.teleport.TravelController;
|
||||
import crazypants.util.ItemUtil;
|
||||
|
||||
@@ -27,6 +27,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.gui.IAdvancedTooltipProvider;
|
||||
import crazypants.enderio.item.darksteel.upgrade.EnergyUpgrade;
|
||||
import crazypants.enderio.machine.farm.farmers.HarvestResult;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.ItemUtil;
|
||||
|
||||
@@ -35,6 +35,8 @@ import crazypants.enderio.api.teleport.IItemOfTravel;
|
||||
import crazypants.enderio.api.teleport.TravelSource;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.gui.IAdvancedTooltipProvider;
|
||||
import crazypants.enderio.item.darksteel.upgrade.EnergyUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.TravelUpgrade;
|
||||
import crazypants.enderio.teleport.TravelController;
|
||||
import crazypants.util.ItemUtil;
|
||||
import crazypants.util.Lang;
|
||||
@@ -293,7 +295,7 @@ public class ItemDarkSteelSword extends ItemSword implements IEnergyContainerIte
|
||||
if(eu != null) {
|
||||
eu.writeToItem(sword);
|
||||
|
||||
if(eu.energy > Config.darkSteelSwordPowerUsePerHit) {
|
||||
if(eu.getEnergy() > Config.darkSteelSwordPowerUsePerHit) {
|
||||
extractEnergy(player.getCurrentEquippedItem(), Config.darkSteelSwordPowerUsePerHit, false);
|
||||
String name = EntityList.getEntityString(entity);
|
||||
if(entity instanceof EntityEnderman || ENDERZOO_ENDERMINY.equals(name)) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.minecraftforge.client.IItemRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import crazypants.enderio.item.darksteel.upgrade.EnergyUpgrade;
|
||||
import crazypants.render.ColorUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.vecmath.Vector4f;
|
||||
|
||||
+6
-1
@@ -1,4 +1,4 @@
|
||||
package crazypants.enderio.item.darksteel;
|
||||
package crazypants.enderio.item.darksteel.upgrade;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -90,6 +90,11 @@ public abstract class AbstractUpgrade implements IDarkSteelUpgrade {
|
||||
public String getUnlocalizedName() {
|
||||
return unlocName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRenderUpgrade getRender() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasUpgrade(ItemStack stack) {
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package crazypants.enderio.item.darksteel;
|
||||
package crazypants.enderio.item.darksteel.upgrade;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.item.darksteel.ItemDarkSteelArmor;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
+2
-1
@@ -1,4 +1,4 @@
|
||||
package crazypants.enderio.item.darksteel;
|
||||
package crazypants.enderio.item.darksteel.upgrade;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -13,6 +13,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.gui.TooltipAddera;
|
||||
import crazypants.enderio.item.darksteel.IDarkSteelItem;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.enderio.material.Material;
|
||||
import crazypants.util.Lang;
|
||||
@@ -0,0 +1,93 @@
|
||||
package crazypants.enderio.item.darksteel.upgrade;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.item.darksteel.DarkSteelController;
|
||||
import crazypants.enderio.item.darksteel.DarkSteelItems;
|
||||
import crazypants.render.RenderUtil;
|
||||
import static org.lwjgl.opengl.GL11.glDepthMask;
|
||||
|
||||
public class GliderUpgrade extends AbstractUpgrade {
|
||||
|
||||
private static String UPGRADE_NAME = "glide";
|
||||
|
||||
public static final GliderUpgrade INSTANCE = new GliderUpgrade();
|
||||
|
||||
private final Render render = new Render();
|
||||
|
||||
public static GliderUpgrade loadFromItem(ItemStack stack) {
|
||||
if(stack == null) {
|
||||
return null;
|
||||
}
|
||||
if(stack.stackTagCompound == null) {
|
||||
return null;
|
||||
}
|
||||
if(!stack.stackTagCompound.hasKey(KEY_UPGRADE_PREFIX + UPGRADE_NAME)) {
|
||||
return null;
|
||||
}
|
||||
return new GliderUpgrade((NBTTagCompound) stack.stackTagCompound.getTag(KEY_UPGRADE_PREFIX + UPGRADE_NAME));
|
||||
}
|
||||
|
||||
|
||||
public GliderUpgrade(NBTTagCompound tag) {
|
||||
super(UPGRADE_NAME, tag);
|
||||
}
|
||||
|
||||
public GliderUpgrade() {
|
||||
super(UPGRADE_NAME, "enderio.darksteel.upgrade.glider", new ItemStack(DarkSteelItems.itemGliderWing,1,1), Config.darkSteelGliderCost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAddToItem(ItemStack stack) {
|
||||
if(stack == null || stack.getItem() != DarkSteelItems.itemDarkSteelChestplate) {
|
||||
return false;
|
||||
}
|
||||
GliderUpgrade up = loadFromItem(stack);
|
||||
if(up == null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRenderUpgrade getRender() {
|
||||
return render;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeUpgradeToNBT(NBTTagCompound upgradeRoot) {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private class Render implements IRenderUpgrade {
|
||||
|
||||
private EntityItem item = new EntityItem(Minecraft.getMinecraft().theWorld);
|
||||
private ItemStack glider = new ItemStack(DarkSteelItems.itemGliderWing, 1, 1);
|
||||
|
||||
private Render() {
|
||||
item.setEntityItemStack(glider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(RenderPlayerEvent event, ItemStack stack, boolean head) {
|
||||
if (!head && DarkSteelController.instance.isGlideActive(event.entityPlayer)) {
|
||||
RenderUtil.bindItemTexture();
|
||||
glDepthMask(true);
|
||||
item.hoverStart = 0;
|
||||
GL11.glTranslatef(-0, 1, 0.25f);
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glScalef(3, 3, 3);
|
||||
RenderManager.instance.renderEntityWithPosYaw(item, 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-2
@@ -1,5 +1,9 @@
|
||||
package crazypants.enderio.item.darksteel;
|
||||
package crazypants.enderio.item.darksteel.upgrade;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.gui.IAdvancedTooltipProvider;
|
||||
|
||||
@@ -20,7 +24,11 @@ public interface IDarkSteelUpgrade extends IAdvancedTooltipProvider {
|
||||
void removeFromItem(ItemStack stack);
|
||||
|
||||
ItemStack getUpgradeItem();
|
||||
|
||||
|
||||
String getUpgradeItemName();
|
||||
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
IRenderUpgrade getRender();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package crazypants.enderio.item.darksteel.upgrade;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
|
||||
public interface IRenderUpgrade {
|
||||
|
||||
void render(RenderPlayerEvent event, ItemStack stack, boolean head);
|
||||
|
||||
}
|
||||
+12
-9
@@ -1,12 +1,12 @@
|
||||
package crazypants.enderio.item.darksteel;
|
||||
package crazypants.enderio.item.darksteel.upgrade;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.item.darksteel.DarkSteelItems;
|
||||
|
||||
public class JumpUpgrade extends AbstractUpgrade {
|
||||
|
||||
@@ -18,7 +18,7 @@ public class JumpUpgrade extends AbstractUpgrade {
|
||||
public static JumpUpgrade JUMP_TWO = new JumpUpgrade("enderio.darksteel.upgrade.jump_two", 2, Config.darkSteelJumpTwoCost);
|
||||
public static JumpUpgrade JUMP_THREE = new JumpUpgrade("enderio.darksteel.upgrade.jump_three", 3, Config.darkSteelJumpThreeCost);
|
||||
|
||||
protected short level;
|
||||
private short level;
|
||||
|
||||
public static boolean isEquipped(EntityPlayer player) {
|
||||
ItemStack boots = player.getEquipmentInSlot(1);
|
||||
@@ -40,12 +40,12 @@ public class JumpUpgrade extends AbstractUpgrade {
|
||||
|
||||
public JumpUpgrade(NBTTagCompound tag) {
|
||||
super(UPGRADE_NAME, tag);
|
||||
level = tag.getShort(KEY_LEVEL);
|
||||
this.level = tag.getShort(KEY_LEVEL);
|
||||
}
|
||||
|
||||
public JumpUpgrade(String unlocName,int level, int levelCost) {
|
||||
public JumpUpgrade(String unlocName, int level, int levelCost) {
|
||||
super(UPGRADE_NAME, unlocName, new ItemStack(Blocks.piston), levelCost);
|
||||
this.level = (short)level;
|
||||
this.level = (short) level;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,9 +55,9 @@ public class JumpUpgrade extends AbstractUpgrade {
|
||||
}
|
||||
JumpUpgrade up = loadFromItem(stack);
|
||||
if(up == null) {
|
||||
return level == 1;
|
||||
return getLevel() == 1;
|
||||
}
|
||||
return up.level == level - 1;
|
||||
return up.getLevel() == getLevel() - 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,10 @@ public class JumpUpgrade extends AbstractUpgrade {
|
||||
|
||||
@Override
|
||||
public void writeUpgradeToNBT(NBTTagCompound upgradeRoot) {
|
||||
upgradeRoot.setShort(KEY_LEVEL, level);
|
||||
upgradeRoot.setShort(KEY_LEVEL, getLevel());
|
||||
}
|
||||
|
||||
public short getLevel() {
|
||||
return level;
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -1,8 +1,10 @@
|
||||
package crazypants.enderio.item.darksteel;
|
||||
package crazypants.enderio.item.darksteel.upgrade;
|
||||
|
||||
import static crazypants.enderio.item.darksteel.upgrade.AbstractUpgrade.KEY_UPGRADE_PREFIX;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.enderio.config.Config;
|
||||
import static crazypants.enderio.item.darksteel.AbstractUpgrade.KEY_UPGRADE_PREFIX;
|
||||
import crazypants.enderio.item.darksteel.DarkSteelItems;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
+2
-1
@@ -1,4 +1,4 @@
|
||||
package crazypants.enderio.item.darksteel;
|
||||
package crazypants.enderio.item.darksteel.upgrade;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.PotionHelper;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.item.darksteel.DarkSteelItems;
|
||||
|
||||
public class NightVisionUpgrade extends AbstractUpgrade {
|
||||
|
||||
+45
-1
@@ -1,11 +1,24 @@
|
||||
package crazypants.enderio.item.darksteel;
|
||||
package crazypants.enderio.item.darksteel.upgrade;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.PotionHelper;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.item.darksteel.DarkSteelItems;
|
||||
import crazypants.render.RenderUtil;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.glDepthMask;
|
||||
|
||||
public class SolarUpgrade extends AbstractUpgrade {
|
||||
|
||||
@@ -15,6 +28,8 @@ public class SolarUpgrade extends AbstractUpgrade {
|
||||
|
||||
public static final SolarUpgrade SOLAR_ONE = new SolarUpgrade("enderio.darksteel.upgrade.solar_one", (byte) 1, Config.darkSteelSolarOneCost);
|
||||
public static final SolarUpgrade SOLAR_TWO = new SolarUpgrade("enderio.darksteel.upgrade.solar_two", (byte) 2, Config.darkSteelSolarTwoCost);
|
||||
|
||||
private Render render = new Render();
|
||||
|
||||
public static SolarUpgrade loadFromItem(ItemStack stack) {
|
||||
if(stack == null) {
|
||||
@@ -86,4 +101,33 @@ public class SolarUpgrade extends AbstractUpgrade {
|
||||
public int getRFPerSec() {
|
||||
return level == 1 ? Config.darkSteelSolarOneGen : Config.darkSteelSolarTwoGen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRenderUpgrade getRender() {
|
||||
return render;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private class Render implements IRenderUpgrade {
|
||||
|
||||
private EntityItem item = new EntityItem(Minecraft.getMinecraft().theWorld);
|
||||
private ItemStack panel1 = new ItemStack(EnderIO.blockSolarPanel, 1, 0);
|
||||
private ItemStack panel2 = new ItemStack(EnderIO.blockSolarPanel, 1, 1);
|
||||
|
||||
@Override
|
||||
public void render(RenderPlayerEvent event, ItemStack stack, boolean head) {
|
||||
if (head) {
|
||||
RenderUtil.bindItemTexture();
|
||||
glDepthMask(true);
|
||||
item.hoverStart = 0;
|
||||
GL11.glTranslated(0, -0.08, 0);
|
||||
GL11.glTranslated(0, (event.entityPlayer != Minecraft.getMinecraft().thePlayer ? 1.62F : 0F) - event.entityPlayer.getDefaultEyeHeight() + (event.entityPlayer.isSneaking() ? 0.0625 : 0), 0);
|
||||
GL11.glRotated(180, 1, 0, 0);
|
||||
GL11.glScalef(2.1f, 2.1f, 2.1f);
|
||||
byte level = loadFromItem(stack).level;
|
||||
item.setEntityItemStack(level == 0 ? panel1 : panel2);
|
||||
RenderManager.instance.renderEntityWithPosYaw(item, 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
package crazypants.enderio.item.darksteel;
|
||||
package crazypants.enderio.item.darksteel.upgrade;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.item.darksteel.DarkSteelItems;
|
||||
|
||||
public class SoundDetectorUpgrade extends AbstractUpgrade {
|
||||
|
||||
+17
-12
@@ -1,15 +1,12 @@
|
||||
package crazypants.enderio.item.darksteel;
|
||||
package crazypants.enderio.item.darksteel.upgrade;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionHelper;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.material.Material;
|
||||
import crazypants.util.Util;
|
||||
import crazypants.enderio.item.darksteel.DarkSteelItems;
|
||||
|
||||
public class SpeedUpgrade extends AbstractUpgrade {
|
||||
|
||||
@@ -35,8 +32,8 @@ public class SpeedUpgrade extends AbstractUpgrade {
|
||||
public static SpeedUpgrade SPEED_TWO = new SpeedUpgrade("enderio.darksteel.upgrade.speed_two", 2, Config.darkSteelSpeedTwoCost);
|
||||
public static SpeedUpgrade SPEED_THREE = new SpeedUpgrade("enderio.darksteel.upgrade.speed_three", 3, Config.darkSteelSpeedThreeCost);
|
||||
|
||||
protected short level;
|
||||
protected float walkMultiplier;
|
||||
private short level;
|
||||
private float walkMultiplier;
|
||||
protected float sprintMultiplier;
|
||||
|
||||
public static boolean isEquipped(EntityPlayer player) {
|
||||
@@ -67,7 +64,7 @@ public class SpeedUpgrade extends AbstractUpgrade {
|
||||
|
||||
public SpeedUpgrade(NBTTagCompound tag) {
|
||||
super(UPGRADE_NAME, tag);
|
||||
level = tag.getShort(KEY_LEVEL);
|
||||
this.level = tag.getShort(KEY_LEVEL);
|
||||
}
|
||||
|
||||
public SpeedUpgrade(String unlocName, int level, int levelCost) {
|
||||
@@ -82,9 +79,9 @@ public class SpeedUpgrade extends AbstractUpgrade {
|
||||
}
|
||||
SpeedUpgrade up = loadFromItem(stack);
|
||||
if(up == null) {
|
||||
return level == 1;
|
||||
return getLevel() == 1;
|
||||
}
|
||||
return up.level == level - 1;
|
||||
return up.getLevel() == getLevel() - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,7 +98,15 @@ public class SpeedUpgrade extends AbstractUpgrade {
|
||||
|
||||
@Override
|
||||
public void writeUpgradeToNBT(NBTTagCompound upgradeRoot) {
|
||||
upgradeRoot.setShort(KEY_LEVEL, level);
|
||||
upgradeRoot.setFloat(KEY_MULTIPLIER, walkMultiplier);
|
||||
upgradeRoot.setShort(KEY_LEVEL, getLevel());
|
||||
upgradeRoot.setFloat(KEY_MULTIPLIER, getWalkMultiplier());
|
||||
}
|
||||
|
||||
public short getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public float getWalkMultiplier() {
|
||||
return walkMultiplier;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
package crazypants.enderio.item.darksteel;
|
||||
package crazypants.enderio.item.darksteel.upgrade;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.item.darksteel.DarkSteelItems;
|
||||
import crazypants.enderio.material.Material;
|
||||
|
||||
public class SpoonUpgrade extends AbstractUpgrade {
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
package crazypants.enderio.item.darksteel;
|
||||
package crazypants.enderio.item.darksteel.upgrade;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.item.darksteel.DarkSteelItems;
|
||||
|
||||
public class SwimUpgrade extends AbstractUpgrade {
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
package crazypants.enderio.item.darksteel;
|
||||
package crazypants.enderio.item.darksteel.upgrade;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.item.darksteel.DarkSteelItems;
|
||||
import crazypants.enderio.material.Material;
|
||||
|
||||
public class TravelUpgrade extends AbstractUpgrade {
|
||||
@@ -6,8 +6,8 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.item.darksteel.AbstractUpgrade;
|
||||
import crazypants.enderio.item.darksteel.DarkSteelItems;
|
||||
import crazypants.enderio.item.darksteel.upgrade.AbstractUpgrade;
|
||||
|
||||
public class GogglesOfRevealingUpgrade extends AbstractUpgrade {
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.item.darksteel.IDarkSteelUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.IDarkSteelUpgrade;
|
||||
import crazypants.enderio.item.skull.BlockEndermanSkull.SkullType;
|
||||
import crazypants.enderio.material.Alloy;
|
||||
import crazypants.enderio.material.BlockFusedQuartz;
|
||||
|
||||
Reference in new issue
Block a user