mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-19 03:49:31 +00:00
Soul binder now requires XP for recipes.
This commit is contained in:
1 parent
03440d5970
commit
adcbb1010b
24 files changed
+421
-42
No files matched your search
@@ -274,9 +274,14 @@ public final class Config {
|
||||
public static int soulBinderLevelTwoPowerPerTickRF = 1000;
|
||||
public static int soulBinderLevelThreePowerPerTickRF = 2000;
|
||||
public static int soulBinderBrokenSpawnerRF = 2500000;
|
||||
public static int soulBinderBrokenSpawnerLevels = 15;
|
||||
public static int soulBinderReanimationRF = 100000;
|
||||
public static int soulBinderReanimationLevels = 10;
|
||||
public static int soulBinderEnderCystalRF = 100000;
|
||||
public static int soulBinderEnderCystalLevels = 10;
|
||||
public static int soulBinderAttractorCystalRF = 100000;
|
||||
public static int soulBinderAttractorCystalLevels = 10;
|
||||
|
||||
|
||||
public static boolean powerConduitCanDifferentTiersConnect = false;
|
||||
public static int powerConduitTierOneRF = 640;
|
||||
@@ -304,7 +309,6 @@ public final class Config {
|
||||
public static int spawnGuardRangeLevelThree = 128;
|
||||
public static int spawnGuardPowerPerTickLevelThree = 1000;
|
||||
|
||||
|
||||
public static void load(FMLPreInitializationEvent event) {
|
||||
|
||||
FMLCommonHandler.instance().bus().register(new Config());
|
||||
@@ -783,6 +787,15 @@ public final class Config {
|
||||
"The number of RF required to create an ender crystal.").getInt(soulBinderEnderCystalRF);
|
||||
soulBinderAttractorCystalRF = config.get(sectionSoulBinder.name, "soulBinderAttractorCystalRF", soulBinderAttractorCystalRF,
|
||||
"The number of RF required to create an attractor crystal.").getInt(soulBinderAttractorCystalRF);
|
||||
|
||||
soulBinderAttractorCystalLevels = config.get(sectionSoulBinder.name, "soulBinderAttractorCystalLevels", soulBinderAttractorCystalLevels,
|
||||
"The number of levels required to create an attractor crystal.").getInt(soulBinderAttractorCystalLevels);
|
||||
soulBinderEnderCystalLevels = config.get(sectionSoulBinder.name, "soulBinderEnderCystalLevels", soulBinderEnderCystalLevels,
|
||||
"The number of levels required to create an ender crystal.").getInt(soulBinderEnderCystalLevels);
|
||||
soulBinderReanimationLevels = config.get(sectionSoulBinder.name, "soulBinderReanimationLevels", soulBinderReanimationLevels,
|
||||
"The number of levels required to re-animate a mob head.").getInt(soulBinderReanimationLevels);
|
||||
soulBinderBrokenSpawnerLevels = config.get(sectionSoulBinder.name, "soulBinderBrokenSpawnerLevels", soulBinderBrokenSpawnerLevels,
|
||||
"The number of levels required to change the type of a broken spawner.").getInt(soulBinderBrokenSpawnerLevels);
|
||||
|
||||
sliceAndSpliceLevelOnePowerPerTickRF = config.get(sectionPower.name, "sliceAndSpliceLevelOnePowerPerTickRF", sliceAndSpliceLevelOnePowerPerTickRF,
|
||||
"The number of RF/t consumed by an unupgraded Slice'N'Splice").getInt(sliceAndSpliceLevelOnePowerPerTickRF);
|
||||
|
||||
@@ -36,8 +36,9 @@ public class IconButtonEIO extends GuiButton {
|
||||
texture = IconEIO.TEXTURE;
|
||||
this.xOrigin = x;
|
||||
this.yOrigin = y;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setToolTip(String... tooltipText) {
|
||||
if(toolTip == null) {
|
||||
toolTip = new GuiToolTip(new Rectangle(xOrigin, yOrigin, width, height), tooltipText);
|
||||
@@ -97,6 +98,9 @@ public class IconButtonEIO extends GuiButton {
|
||||
@SuppressWarnings("synthetic-access")
|
||||
@Override
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
|
||||
if(toolTip != null) {
|
||||
toolTip.setVisible(visible);
|
||||
}
|
||||
if(visible) {
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
@@ -25,7 +25,7 @@ import crazypants.enderio.machine.tank.PacketTank;
|
||||
import crazypants.enderio.machine.tank.TileTank;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.xp.PacketExperianceContainer;
|
||||
import crazypants.enderio.xp.PacketGiveXP;
|
||||
import crazypants.enderio.xp.PacketGivePlayerXP;
|
||||
import crazypants.util.FluidUtil;
|
||||
import crazypants.util.Util;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class BlockKillerJoe extends AbstractMachineBlock<TileKillerJoe> {
|
||||
public static BlockKillerJoe create() {
|
||||
PacketHandler.INSTANCE.registerMessage(PacketNutrientLevel.class, PacketNutrientLevel.class, PacketHandler.nextID(), Side.CLIENT);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketSwing.class, PacketSwing.class, PacketHandler.nextID(), Side.CLIENT);
|
||||
PacketGiveXP.register();
|
||||
PacketGivePlayerXP.register();
|
||||
PacketExperianceContainer.register();
|
||||
|
||||
BlockKillerJoe res = new BlockKillerJoe();
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -20,11 +21,13 @@ import crazypants.enderio.machine.generator.zombie.ContainerZombieGenerator;
|
||||
import crazypants.enderio.machine.generator.zombie.TileZombieGenerator;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.xp.PacketGiveXP;
|
||||
import crazypants.enderio.xp.ExperienceBarRenderer;
|
||||
import crazypants.enderio.xp.PacketGivePlayerXP;
|
||||
import crazypants.gui.GuiToolTip;
|
||||
import crazypants.render.ColorUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.util.Lang;
|
||||
import crazypants.util.SoundUtil;
|
||||
|
||||
public class GuiKillerJoe extends GuiMachineBase {
|
||||
|
||||
@@ -71,9 +74,11 @@ public class GuiKillerJoe extends GuiMachineBase {
|
||||
protected void actionPerformed(GuiButton b) {
|
||||
super.actionPerformed(b);
|
||||
if(b.id == XP_ID) {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketGiveXP(joe, 1));
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketGivePlayerXP(joe, 1));
|
||||
SoundUtil.playClientSoundFX("random.orb", joe);
|
||||
} else if(b.id == XP10_ID) {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketGiveXP(joe, 10));
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketGivePlayerXP(joe, 10));
|
||||
SoundUtil.playClientSoundFX("random.orb", joe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,17 +118,8 @@ public class GuiKillerJoe extends GuiMachineBase {
|
||||
int y = guiTop + 11;
|
||||
if(joe.fuelTank.getFluidAmount() > 0) {
|
||||
RenderUtil.renderGuiTank(joe.fuelTank.getFluid(), joe.fuelTank.getCapacity(), joe.fuelTank.getFluidAmount(), x, y, zLevel, 15, 47);
|
||||
}
|
||||
|
||||
String s = joe.getContainer().getExperienceLevel() + "";
|
||||
drawCenteredString(Minecraft.getMinecraft().fontRenderer, s, sx + xSize/2, sy + 50, 8453920);
|
||||
|
||||
RenderUtil.bindTexture("enderio:textures/gui/killerJoe.png");
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
int xpScaled = joe.getContainer().getXpBarScaled(63);
|
||||
drawTexturedModalRect(sx + 56, sy + 62, 192, 0, xpScaled, 3);
|
||||
|
||||
|
||||
}
|
||||
ExperienceBarRenderer.render(this, sx + 56, sy + 62, 65, joe.getContainer());
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,12 @@ public abstract class AbstractSoulBinderRecipe implements IMachineRecipe, ISoulB
|
||||
private int energyRequired;
|
||||
private String uid;
|
||||
private Class<?> entityClass;
|
||||
private int xpRequired;
|
||||
|
||||
|
||||
protected AbstractSoulBinderRecipe(int energyRequired, String uid, Class<?> entityClass) {
|
||||
protected AbstractSoulBinderRecipe(int energyRequired, int xpRequired, String uid, Class<?> entityClass) {
|
||||
this.energyRequired = energyRequired;
|
||||
this.xpRequired = xpRequired;
|
||||
this.uid = uid;
|
||||
this.entityClass = entityClass;
|
||||
}
|
||||
@@ -32,6 +34,11 @@ public abstract class AbstractSoulBinderRecipe implements IMachineRecipe, ISoulB
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExperienceRequired() {
|
||||
return xpRequired;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyRequired(MachineRecipeInput... inputs) {
|
||||
|
||||
@@ -24,12 +24,16 @@ import crazypants.enderio.machine.painter.GuiPainter;
|
||||
import crazypants.enderio.machine.painter.PainterContainer;
|
||||
import crazypants.enderio.machine.painter.TileEntityPainter;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.xp.PacketDrainPlayerXP;
|
||||
import crazypants.enderio.xp.PacketExperianceContainer;
|
||||
|
||||
public class BlockSoulBinder extends AbstractMachineBlock<TileSoulBinder> {
|
||||
|
||||
public static int renderId;
|
||||
|
||||
public static BlockSoulBinder create() {
|
||||
public static BlockSoulBinder create() {
|
||||
PacketDrainPlayerXP.register();
|
||||
PacketExperianceContainer.register();
|
||||
BlockSoulBinder result = new BlockSoulBinder();
|
||||
result.init();
|
||||
return result;
|
||||
@@ -67,7 +71,7 @@ public class BlockSoulBinder extends AbstractMachineBlock<TileSoulBinder> {
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileSoulBinder) {
|
||||
return new GuiSoulBinder(player.inventory, (AbstractMachineEntity) te);
|
||||
return new GuiSoulBinder(player.inventory, (TileSoulBinder) te);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ContainerSoulBinder extends AbstractMachineContainer {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return tileEntity.isItemValidForSlot(1, itemStack);
|
||||
}
|
||||
}
|
||||
});
|
||||
addSlotToContainer(new Slot(tileEntity, 2, 112, 34) {
|
||||
@Override
|
||||
|
||||
@@ -1,22 +1,63 @@
|
||||
package crazypants.enderio.machine.soul;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
|
||||
import crazypants.enderio.gui.IconButtonEIO;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.GuiMachineBase;
|
||||
import crazypants.enderio.machine.painter.PainterContainer;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.xp.ExperienceBarRenderer;
|
||||
import crazypants.enderio.xp.PacketDrainPlayerXP;
|
||||
import crazypants.enderio.xp.XpUtil;
|
||||
import crazypants.render.ColorUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.util.SoundUtil;
|
||||
import crazypants.vecmath.Vector4f;
|
||||
|
||||
public class GuiSoulBinder extends GuiMachineBase {
|
||||
|
||||
private AbstractMachineEntity tileEntity;
|
||||
private static final int PLAYER_XP_ID = 985162394;
|
||||
|
||||
public GuiSoulBinder(InventoryPlayer par1InventoryPlayer, AbstractMachineEntity te) {
|
||||
private TileSoulBinder tileEntity;
|
||||
|
||||
private IconButtonEIO usePlayerXP;
|
||||
|
||||
public GuiSoulBinder(InventoryPlayer par1InventoryPlayer, TileSoulBinder te) {
|
||||
super(te, new ContainerSoulBinder(par1InventoryPlayer, te));
|
||||
tileEntity = te;
|
||||
usePlayerXP = new IconButtonEIO(this, PLAYER_XP_ID, 125, 57, IconEIO.XP);
|
||||
usePlayerXP.visible = false;
|
||||
usePlayerXP.setToolTip("Use Player XP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
usePlayerXP.onGuiInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton b) {
|
||||
super.actionPerformed(b);
|
||||
if(b.id == PLAYER_XP_ID) {
|
||||
int xp = XpUtil.getPlayerXP(Minecraft.getMinecraft().thePlayer);
|
||||
if(xp > 0) {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketDrainPlayerXP(tileEntity, tileEntity.getCurrentlyRequiredLevel()));
|
||||
SoundUtil.playClientSoundFX("random.orb", tileEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,9 +75,16 @@ public class GuiSoulBinder extends GuiMachineBase {
|
||||
int i1;
|
||||
|
||||
i1 = tileEntity.getProgressScaled(24);
|
||||
drawTexturedModalRect(k + 80, l + 34, 176, 14, i1 + 1, 16);
|
||||
drawTexturedModalRect(k + 80, l + 34, 176, 14, i1 + 1, 16);
|
||||
|
||||
boolean needsXp = tileEntity.getCurrentlyRequiredLevel() > 0 && tileEntity.getCurrentlyRequiredLevel() > tileEntity.getContainer().getExperienceLevel();
|
||||
usePlayerXP.visible = needsXp;
|
||||
|
||||
ExperienceBarRenderer.render(this, getGuiLeft() + 56, getGuiTop() + 68, 65, tileEntity.getContainer(), tileEntity.getCurrentlyRequiredLevel());
|
||||
|
||||
RenderUtil.bindTexture("enderio:textures/gui/soulFuser.png");
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,4 +14,6 @@ public interface ISoulBinderRecipe {
|
||||
|
||||
int getEnergyRequired();
|
||||
|
||||
int getExperienceRequired();
|
||||
|
||||
}
|
||||
@@ -13,7 +13,7 @@ public class SoulBinderAttractorCystalRecipe extends AbstractSoulBinderRecipe {
|
||||
public static SoulBinderAttractorCystalRecipe instance = new SoulBinderAttractorCystalRecipe();
|
||||
|
||||
private SoulBinderAttractorCystalRecipe() {
|
||||
super(Config.soulBinderAttractorCystalRF, "SoulBinderAttractorCystalRecipe", EntityVillager.class);
|
||||
super(Config.soulBinderAttractorCystalRF, Config.soulBinderAttractorCystalLevels, "SoulBinderAttractorCystalRecipe", EntityVillager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,7 +13,7 @@ public class SoulBinderEnderCystalRecipe extends AbstractSoulBinderRecipe {
|
||||
public static SoulBinderEnderCystalRecipe instance = new SoulBinderEnderCystalRecipe();
|
||||
|
||||
private SoulBinderEnderCystalRecipe() {
|
||||
super(Config.soulBinderEnderCystalRF, "SoulBinderEnderCystalRecipe", EntityEnderman.class);
|
||||
super(Config.soulBinderEnderCystalRF,Config.soulBinderEnderCystalLevels, "SoulBinderEnderCystalRecipe", EntityEnderman.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,7 @@ public class SoulBinderReanimationRecipe extends AbstractSoulBinderRecipe {
|
||||
public static SoulBinderReanimationRecipe instance = new SoulBinderReanimationRecipe();
|
||||
|
||||
private SoulBinderReanimationRecipe() {
|
||||
super(Config.soulBinderReanimationRF, "SoulBinderReanimationRecipe", EntityZombie.class);
|
||||
super(Config.soulBinderReanimationRF, Config.soulBinderReanimationLevels, "SoulBinderReanimationRecipe", EntityZombie.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,6 +26,11 @@ public class SoulBinderSpawnerRecipe implements IMachineRecipe, ISoulBinderRecip
|
||||
return Config.soulBinderBrokenSpawnerRF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExperienceRequired() {
|
||||
return Config.soulBinderBrokenSpawnerLevels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipe(MachineRecipeInput... inputs) {
|
||||
int validCount = 0;
|
||||
|
||||
@@ -4,6 +4,12 @@ import java.util.List;
|
||||
|
||||
import scala.xml.persistent.SetStorage;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.config.Config;
|
||||
@@ -12,12 +18,17 @@ import crazypants.enderio.machine.IMachineRecipe;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.enderio.machine.SlotDefinition;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.power.BasicCapacitor;
|
||||
import crazypants.enderio.power.Capacitors;
|
||||
import crazypants.enderio.power.ICapacitor;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
import crazypants.enderio.xp.ExperienceContainer;
|
||||
import crazypants.enderio.xp.IHaveExperience;
|
||||
import crazypants.enderio.xp.PacketExperianceContainer;
|
||||
import crazypants.enderio.xp.XpUtil;
|
||||
|
||||
public class TileSoulBinder extends AbstractPoweredTaskEntity {
|
||||
public class TileSoulBinder extends AbstractPoweredTaskEntity implements IHaveExperience, IFluidHandler {
|
||||
|
||||
public static final int POWER_PER_TICK_ONE = Config.soulBinderLevelOnePowerPerTickRF;
|
||||
private static final BasicCapacitor CAP_ONE = new BasicCapacitor(POWER_PER_TICK_ONE * 2,
|
||||
@@ -33,11 +44,18 @@ public class TileSoulBinder extends AbstractPoweredTaskEntity {
|
||||
|
||||
private ICapacitor capacitor;
|
||||
|
||||
private ExperienceContainer xpCont = new ExperienceContainer(XpUtil.getExperienceForLevel(40));
|
||||
|
||||
public TileSoulBinder() {
|
||||
super(new SlotDefinition(2, 2, 1));
|
||||
capacitor = CAP_ONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExperienceContainer getContainer() {
|
||||
return xpCont;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMachineName() {
|
||||
return ModObject.blockSoulBinder.unlocalisedName;
|
||||
@@ -47,6 +65,53 @@ public class TileSoulBinder extends AbstractPoweredTaskEntity {
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean processTasks(boolean redstoneChecksPassed) {
|
||||
if(xpCont.isDirty()) {
|
||||
PacketHandler.sendToAllAround(new PacketExperianceContainer(this), this);
|
||||
xpCont.setDirty(false);
|
||||
}
|
||||
return super.processTasks(redstoneChecksPassed);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IMachineRecipe canStartNextTask(float chance) {
|
||||
IMachineRecipe recipe = super.canStartNextTask(chance);
|
||||
if(recipe == null) {
|
||||
return null;
|
||||
}
|
||||
int xpRequired = ((ISoulBinderRecipe)recipe).getExperienceRequired();
|
||||
if(xpCont.getExperienceTotal() >= xpRequired) {
|
||||
return recipe;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getCurrentlyRequiredLevel() {
|
||||
if(currentTask != null) {
|
||||
return -1;
|
||||
}
|
||||
IMachineRecipe nextRecipe = MachineRecipeRegistry.instance.getRecipeForInputs(getMachineName(), getRecipeInputs());
|
||||
if(! (nextRecipe instanceof ISoulBinderRecipe)) {
|
||||
return -1;
|
||||
}
|
||||
return ((ISoulBinderRecipe)nextRecipe).getExperienceRequired();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean startNextTask(IMachineRecipe nextRecipe, float chance) {
|
||||
int xpRequired = ((ISoulBinderRecipe)nextRecipe).getExperienceRequired();
|
||||
if(xpCont.getExperienceLevel() < xpRequired) {
|
||||
return false;
|
||||
}
|
||||
if(super.startNextTask(nextRecipe, chance)) {
|
||||
xpCont.drain(ForgeDirection.UNKNOWN, XpUtil.getLiquidForLevel(xpRequired), true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isMachineItemValidForSlot(int slot, ItemStack item) {
|
||||
@@ -73,7 +138,6 @@ public class TileSoulBinder extends AbstractPoweredTaskEntity {
|
||||
return MachineRecipeRegistry.instance.getRecipeForInputs(getMachineName(), inputs) != null;
|
||||
}
|
||||
return false;
|
||||
//return SoulBinderSpawnerRecipe.instance.isValidInput(new MachineRecipeInput(slot, item));
|
||||
}
|
||||
|
||||
public void setCapacitor(Capacitors capacitorType) {
|
||||
@@ -117,8 +181,49 @@ public class TileSoulBinder extends AbstractPoweredTaskEntity {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return xpCont.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
return xpCont.fill(from, resource,doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return xpCont.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return xpCont.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return xpCont.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return xpCont.getTankInfo(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCommon(NBTTagCompound nbtRoot) {
|
||||
super.readCommon(nbtRoot);
|
||||
xpCont.readFromNBT(nbtRoot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCommon(NBTTagCompound nbtRoot) {
|
||||
super.writeCommon(nbtRoot);
|
||||
xpCont.writeToNBT(nbtRoot);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package crazypants.enderio.xp;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import crazypants.render.ColorUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
|
||||
public class ExperienceBarRenderer {
|
||||
|
||||
public static void render(Gui gui, int x, int y, int length, ExperienceContainer xpCont) {
|
||||
render(gui, x, y, length, xpCont, -1);
|
||||
}
|
||||
|
||||
public static void render(Gui gui, int x, int y, int length, ExperienceContainer xpCont, int required) {
|
||||
|
||||
String text = xpCont.getExperienceLevel() + "";
|
||||
int color = 8453920;
|
||||
boolean shadow = true;
|
||||
if(required > 0) {
|
||||
text += "/" + required;
|
||||
if(required > xpCont.getExperienceLevel()) {
|
||||
color = ColorUtil.getRGB(1f,0,0.1f);
|
||||
shadow = false;
|
||||
}
|
||||
}
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
int strX = x + length/2 - fr.getStringWidth(text) / 2;
|
||||
fr.drawString(text, strX, y-11, color, shadow);
|
||||
|
||||
RenderUtil.bindTexture("enderio:textures/gui/widgets.png");
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
int xpScaled = xpCont.getXpBarScaled(length -2);
|
||||
|
||||
// x, y, u, v, width, height
|
||||
//start of 'slot'
|
||||
gui.drawTexturedModalRect(x,y,80,141,1,5);
|
||||
gui.drawTexturedModalRect(x + 1,y,81,141,length-2,5);
|
||||
gui.drawTexturedModalRect(x + length - 1,y,205,141,1,5);
|
||||
|
||||
RenderUtil.renderQuad2D(x + 1, y + 1, 0, xpScaled, 3, ColorUtil.getRGB(0, 127, 14));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
|
||||
@@ -24,6 +26,10 @@ public class ExperienceContainer {
|
||||
public ExperienceContainer(int maxStored) {
|
||||
maxXp = maxStored;
|
||||
}
|
||||
|
||||
public int getMaximumExperiance() {
|
||||
return maxXp;
|
||||
}
|
||||
|
||||
public int getExperienceLevel() {
|
||||
return experienceLevel;
|
||||
@@ -78,11 +84,11 @@ public class ExperienceContainer {
|
||||
|
||||
public void givePlayerXp(EntityPlayer player, int levels) {
|
||||
for (int i = 0; i < levels && experienceTotal > 0; i++) {
|
||||
givePlayerXp(player);
|
||||
givePlayerXpLevel(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void givePlayerXp(EntityPlayer player) {
|
||||
public void givePlayerXpLevel(EntityPlayer player) {
|
||||
int currentXP = XpUtil.getPlayerXP(player);
|
||||
int nextLevelXP = XpUtil.getExperienceForLevel(player.experienceLevel + 1) + 1;
|
||||
int requiredXP = nextLevelXP - currentXP;
|
||||
@@ -97,6 +103,18 @@ public class ExperienceContainer {
|
||||
addExperience(newXp);
|
||||
}
|
||||
|
||||
|
||||
public void drainPlayerXpToReachLevel(EntityPlayer player, int level) {
|
||||
int targetXP = XpUtil.getExperienceForLevel(level);
|
||||
int requiredXP = targetXP - experienceTotal;
|
||||
if(requiredXP <= 0) {
|
||||
return;
|
||||
}
|
||||
int drainXP = Math.min(requiredXP, XpUtil.getPlayerXP(player));
|
||||
addExperience(drainXP);
|
||||
XpUtil.addPlayerXP(player, -drainXP);
|
||||
}
|
||||
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
if(resource == null || !canDrain(from, resource.getFluid())) {
|
||||
return null;
|
||||
@@ -106,7 +124,7 @@ public class ExperienceContainer {
|
||||
|
||||
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
int available = XpUtil.experianceToLiquid(experienceTotal);
|
||||
int available = getFluidAmount();
|
||||
int canDrain = Math.min(available, maxDrain);
|
||||
if(doDrain) {
|
||||
int newXp = experienceTotal - XpUtil.liquidToExperiance(canDrain);
|
||||
@@ -118,11 +136,42 @@ public class ExperienceContainer {
|
||||
return new FluidStack(EnderIO.fluidXpJuice, canDrain);
|
||||
}
|
||||
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return fluid != null && fluid.getID() == EnderIO.fluidXpJuice.getID();
|
||||
}
|
||||
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
if(resource == null) {
|
||||
return 0;
|
||||
}
|
||||
if(!canFill(from, resource.getFluid())) {
|
||||
return 0;
|
||||
}
|
||||
int canFill = Math.min(resource.amount, getMaxFluidAmount() - getFluidAmount());
|
||||
if(doFill) {
|
||||
addExperience(XpUtil.liquidToExperiance(canFill));
|
||||
}
|
||||
return canFill;
|
||||
}
|
||||
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return fluid != null && fluid.getID() == EnderIO.fluidXpJuice.getID();
|
||||
}
|
||||
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return new FluidTankInfo[] {
|
||||
new FluidTankInfo(new FluidStack(EnderIO.fluidXpJuice, getFluidAmount()), getMaxFluidAmount())
|
||||
};
|
||||
}
|
||||
|
||||
private int getMaxFluidAmount() {
|
||||
return XpUtil.experianceToLiquid(maxXp);
|
||||
}
|
||||
|
||||
private int getFluidAmount() {
|
||||
return XpUtil.experianceToLiquid(experienceTotal);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbtRoot) {
|
||||
experienceLevel = nbtRoot.getInteger("experienceLevel");
|
||||
experienceTotal = nbtRoot.getInteger("experienceTotal");
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package crazypants.enderio.xp;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import crazypants.enderio.network.MessageTileEntity;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
|
||||
public class PacketDrainPlayerXP extends MessageTileEntity<TileEntity> implements IMessageHandler<PacketDrainPlayerXP, IMessage> {
|
||||
|
||||
private static boolean isRegistered = false;
|
||||
|
||||
public static void register() {
|
||||
if(!isRegistered) {
|
||||
PacketHandler.INSTANCE.registerMessage(PacketDrainPlayerXP.class, PacketDrainPlayerXP.class, PacketHandler.nextID(), Side.SERVER);
|
||||
isRegistered = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int targetLevel;
|
||||
|
||||
public PacketDrainPlayerXP() {
|
||||
}
|
||||
|
||||
public PacketDrainPlayerXP(TileEntity tile, int targetLevel) {
|
||||
super(tile);
|
||||
this.targetLevel = targetLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeShort((short)targetLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
targetLevel = buf.readShort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketDrainPlayerXP message, MessageContext ctx) {
|
||||
EntityPlayer player = ctx.getServerHandler().playerEntity;
|
||||
TileEntity tile = message.getTileEntity(player.worldObj);
|
||||
if (tile instanceof IHaveExperience) {
|
||||
IHaveExperience xpTile = (IHaveExperience)tile;
|
||||
xpTile.getContainer().drainPlayerXpToReachLevel(player, message.targetLevel);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+5
-5
@@ -10,13 +10,13 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import crazypants.enderio.network.MessageTileEntity;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
|
||||
public class PacketGiveXP extends MessageTileEntity<TileEntity> implements IMessageHandler<PacketGiveXP, IMessage> {
|
||||
public class PacketGivePlayerXP extends MessageTileEntity<TileEntity> implements IMessageHandler<PacketGivePlayerXP, IMessage> {
|
||||
|
||||
private static boolean isRegistered = false;
|
||||
|
||||
public static void register() {
|
||||
if(!isRegistered) {
|
||||
PacketHandler.INSTANCE.registerMessage(PacketGiveXP.class, PacketGiveXP.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketGivePlayerXP.class, PacketGivePlayerXP.class, PacketHandler.nextID(), Side.SERVER);
|
||||
isRegistered = true;
|
||||
}
|
||||
}
|
||||
@@ -24,10 +24,10 @@ public class PacketGiveXP extends MessageTileEntity<TileEntity> implements IMess
|
||||
|
||||
int levels;
|
||||
|
||||
public PacketGiveXP() {
|
||||
public PacketGivePlayerXP() {
|
||||
}
|
||||
|
||||
public PacketGiveXP(TileEntity tile, int levels) {
|
||||
public PacketGivePlayerXP(TileEntity tile, int levels) {
|
||||
super(tile);
|
||||
this.levels = levels;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class PacketGiveXP extends MessageTileEntity<TileEntity> implements IMess
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketGiveXP message, MessageContext ctx) {
|
||||
public IMessage onMessage(PacketGivePlayerXP message, MessageContext ctx) {
|
||||
EntityPlayer player = ctx.getServerHandler().playerEntity;
|
||||
TileEntity tile = message.getTileEntity(player.worldObj);
|
||||
if (tile instanceof IHaveExperience) {
|
||||
@@ -28,6 +28,14 @@ public class XpUtil {
|
||||
return experianceToLiquid(getExperienceForLevel(level));
|
||||
}
|
||||
|
||||
// public static int getTotalExperienceForLevel(int level) {
|
||||
// int res = 0;
|
||||
// for(int i=0;i<level;i++) {
|
||||
// res += getExperienceForLevel(i+1);
|
||||
// }
|
||||
// return res;
|
||||
// }
|
||||
|
||||
public static int getExperienceForLevel(int level) {
|
||||
if (level == 0) { return 0; }
|
||||
if (level > 0 && level < 16) {
|
||||
|
||||
@@ -17,6 +17,8 @@ public class GuiToolTip {
|
||||
private int lastMouseX = -1;
|
||||
|
||||
private int lastMouseY = -1;
|
||||
|
||||
private boolean visible = true;
|
||||
|
||||
public GuiToolTip(Rectangle bounds, String... lines) {
|
||||
this.bounds = bounds;
|
||||
@@ -39,6 +41,14 @@ public class GuiToolTip {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
public Rectangle getBounds() {
|
||||
return bounds;
|
||||
}
|
||||
@@ -65,7 +75,10 @@ public class GuiToolTip {
|
||||
lastMouseY = mouseY;
|
||||
}
|
||||
|
||||
public boolean shouldDraw() {
|
||||
public boolean shouldDraw() {
|
||||
if(!visible) {
|
||||
return false;
|
||||
}
|
||||
updateText();
|
||||
if(mouseOverStart == 0) {
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package crazypants.util;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SoundUtil {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void playClientSoundFX(String name, TileEntity te) {
|
||||
World world = Minecraft.getMinecraft().thePlayer.worldObj;
|
||||
Minecraft.getMinecraft().theWorld.playSound(te.xCoord + 0.5, te.yCoord + 0.5, te.zCoord + 0.5, name, 0.1F, 0.5F * ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.8F),true);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user