use of uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability.IPlayerStats in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class GuiOverlay method RenderGameOverlayEvent.
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void RenderGameOverlayEvent(RenderGameOverlayEvent event) {
if (event.getType() == ElementType.TEXT) {
Minecraft mc = Minecraft.getMinecraft();
int screenWidth = event.getResolution().getScaledWidth();
int screenHeight = event.getResolution().getScaledHeight();
IPlayerStats STATS = mc.player.getCapability(ModCapabilities.PLAYER_STATS, null);
IDriveState DRIVE = mc.player.getCapability(ModCapabilities.DRIVE_STATE, null);
if (showExp) {
String reqExp = String.valueOf(STATS.getExpNeeded(STATS.getLevel(), STATS.getExperience()));
mc.fontRenderer.drawString("Next LV", 5, 5, 0xFFFFFF);
mc.fontRenderer.drawString(reqExp, 5, 5 + mc.fontRenderer.FONT_HEIGHT, 0xFFFFFF);
if (timeExp + 4 <= (int) Minecraft.getSystemTime() / 1000)
showExp = false;
}
if (showMunny) {
if (!showExp) {
GL11.glPushMatrix();
GL11.glTranslatef(1, 1, 0);
mc.fontRenderer.drawString("Munny Get!", 5, 5, 0xFFFFFF);
mc.fontRenderer.drawString(munnyGet + "", 5, 5 + mc.fontRenderer.FONT_HEIGHT, 0xFFFFFF);
GL11.glPopMatrix();
} else {
mc.fontRenderer.drawString("Munny Get!", 5, 5 + mc.fontRenderer.FONT_HEIGHT + 10, 0xFFFFFF);
mc.fontRenderer.drawString(munnyGet + "", 5, 5 + (mc.fontRenderer.FONT_HEIGHT * 2) + 10, 0xFFFFFF);
}
if (timeMunny + 4 <= (int) Minecraft.getSystemTime() / 1000)
showMunny = false;
}
if (showLevelUp) {
ResourceLocation texture = new ResourceLocation(Reference.MODID, "textures/gui/levelup.png");
GL11.glPushMatrix();
{
int height = (mc.fontRenderer.FONT_HEIGHT - 3) * STATS.getMessages().size();
GL11.glEnable(GL11.GL_BLEND);
GL11.glColor4ub((byte) MainConfig.client.hud.interfaceColour[0], (byte) MainConfig.client.hud.interfaceColour[1], (byte) MainConfig.client.hud.interfaceColour[2], (byte) 255);
GL11.glPushMatrix();
{
mc.renderEngine.bindTexture(texture);
int width = event.getResolution().getScaledWidth();
GL11.glPushMatrix();
{
GL11.glTranslatef((width - 153.6f - 2), 0, 0);
GL11.glScalef(0.6f, 0.6f, 1);
drawTexturedModalRect(0, 0, 0, 0, 256, 36);
}
GL11.glPopMatrix();
GL11.glPushMatrix();
{
GL11.glTranslatef(width - ((mc.fontRenderer.getStringWidth("LEVEL UP!")) * 0.75f) - 115, 4, 0);
GL11.glScalef(0.75f, 0.75f, 1);
drawString(mc.fontRenderer, "LEVEL UP!" + TextFormatting.ITALIC, 0, 0, Color.decode(String.format("#%02x%02x%02x", (byte) MainConfig.client.hud.interfaceColour[0], (byte) MainConfig.client.hud.interfaceColour[1], (byte) MainConfig.client.hud.interfaceColour[2])).hashCode());
}
GL11.glPopMatrix();
GL11.glPushMatrix();
{
GL11.glPushMatrix();
{
GL11.glTranslatef(width - ((mc.fontRenderer.getStringWidth("LV. ")) * 0.75f) - 90, 4, 0);
GL11.glScalef(0.75f, 0.75f, 1);
drawString(mc.fontRenderer, "LV.", 0, 0, 0xE3D000);
}
GL11.glPopMatrix();
GL11.glPushMatrix();
{
GL11.glTranslatef(width - 256.0f * 0.75f + ((mc.fontRenderer.getStringWidth("999")) * 0.75f) + 88, 4, 0);
GL11.glScalef(0.75f, 0.75f, 1);
drawString(mc.fontRenderer, "" + STATS.getLevel(), 0, 0, 0xFFFFFF);
}
GL11.glPopMatrix();
GL11.glPushMatrix();
{
GL11.glTranslatef(width - ((mc.fontRenderer.getStringWidth(mc.player.getDisplayNameString())) * 0.75f) - 7, 4, 0);
GL11.glScalef(0.75f, 0.75f, 1);
drawString(mc.fontRenderer, mc.player.getDisplayNameString(), 0, 0, 0xFFFFFF);
}
GL11.glPopMatrix();
}
GL11.glPopMatrix();
}
GL11.glPopMatrix();
GL11.glColor4ub((byte) MainConfig.client.hud.interfaceColour[0], (byte) MainConfig.client.hud.interfaceColour[1], (byte) MainConfig.client.hud.interfaceColour[2], (byte) 255);
GL11.glPushMatrix();
{
mc.renderEngine.bindTexture(texture);
int width = event.getResolution().getScaledWidth();
GL11.glTranslatef((width - 256.0f * 0.6f - 2), 36.0f * 0.6f, 0);
GL11.glScalef(0.6f, height, 1);
drawTexturedModalRect(0, 0, 0, 36, 256, 1);
}
GL11.glPopMatrix();
GL11.glColor4ub((byte) MainConfig.client.hud.interfaceColour[0], (byte) MainConfig.client.hud.interfaceColour[1], (byte) MainConfig.client.hud.interfaceColour[2], (byte) 255);
GL11.glPushMatrix();
{
mc.renderEngine.bindTexture(texture);
int width = event.getResolution().getScaledWidth();
GL11.glTranslatef((width - 256.0f * 0.6f - 2), height + (36.0f * 0.6f), 0);
GL11.glScalef(0.6f, 0.6f, 1);
drawTexturedModalRect(0, 0, 0, 37, 256, 14);
}
GL11.glPopMatrix();
GL11.glColor4ub((byte) MainConfig.client.hud.interfaceColour[0], (byte) MainConfig.client.hud.interfaceColour[1], (byte) MainConfig.client.hud.interfaceColour[2], (byte) 255);
for (int i = 0; i < STATS.getMessages().size(); i++) {
GL11.glPushMatrix();
{
int width = event.getResolution().getScaledWidth();
String message = STATS.getMessages().get(i).toString();
GL11.glTranslatef((width - 256.0f * 0.8f + (mc.fontRenderer.getStringWidth("Maximum HP Increased!")) * 0.8f), mc.fontRenderer.FONT_HEIGHT * 0.8f * i + 23, 0);
GL11.glTranslatef(-35, 0, 0);
GL11.glScalef(0.8f, 0.8f, 1);
drawString(mc.fontRenderer, Utils.translateToLocal(message), 0, 0, 0xFFFFFF);
}
GL11.glPopMatrix();
}
GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) 255);
}
GL11.glPopMatrix();
if (timeLevelUp + levelSeconds <= (int) Minecraft.getSystemTime() / 1000)
showLevelUp = false;
}
if (showDriveLevelUp) {
byte[] driveColor = new byte[] { (byte) 255, (byte) 255, (byte) 255 };
switch(// mc.player.getCapability(ModCapabilities.DRIVE_STATE, null).getActiveDriveName()
driveForm) {
case Strings.Form_Valor:
driveColor[0] = (byte) 255;
driveColor[1] = (byte) 0;
driveColor[2] = (byte) 0;
break;
case Strings.Form_Wisdom:
driveColor[0] = (byte) 0;
driveColor[1] = (byte) 0;
driveColor[2] = (byte) 255;
break;
case Strings.Form_Limit:
driveColor[0] = (byte) 153;
driveColor[1] = (byte) 76;
driveColor[2] = (byte) 255;
break;
case Strings.Form_Master:
driveColor[0] = (byte) 255;
driveColor[1] = (byte) 185;
driveColor[2] = (byte) 25;
break;
case Strings.Form_Final:
driveColor[0] = (byte) 230;
driveColor[1] = (byte) 230;
driveColor[2] = (byte) 230;
break;
}
ResourceLocation texture = new ResourceLocation(Reference.MODID, "textures/gui/levelup.png");
GL11.glPushMatrix();
{
int height = (mc.fontRenderer.FONT_HEIGHT - 3) * DRIVE.getMessages().size();
GL11.glEnable(GL11.GL_BLEND);
GL11.glColor4ub(driveColor[0], driveColor[1], driveColor[2], (byte) 255);
GL11.glPushMatrix();
{
mc.renderEngine.bindTexture(texture);
int width = event.getResolution().getScaledWidth();
int sHeight = event.getResolution().getScaledHeight();
GL11.glPushMatrix();
{
GL11.glTranslatef(2, sHeight / 3, 0);
GL11.glScalef(0.6f, 0.6f, 1);
drawTexturedModalRect(0, 0, 0, 0, 256, 36);
}
GL11.glPopMatrix();
GL11.glPushMatrix();
{
GL11.glTranslatef(6, sHeight / 3 + 5, 0);
GL11.glScalef(0.75f, 0.75f, 1);
drawString(mc.fontRenderer, "LEVEL UP!" + TextFormatting.ITALIC, 0, 0, Color.decode(String.format("#%02x%02x%02x", (byte) MainConfig.client.hud.interfaceColour[0], (byte) MainConfig.client.hud.interfaceColour[1], (byte) MainConfig.client.hud.interfaceColour[2])).hashCode());
}
GL11.glPopMatrix();
GL11.glPushMatrix();
{
GL11.glPushMatrix();
{
GL11.glTranslatef(2 + (mc.fontRenderer.getStringWidth("LV. ") * 0.75f) + 38, sHeight / 3 + 4, 0);
GL11.glScalef(0.75f, 0.75f, 1);
drawString(mc.fontRenderer, "LV.", 0, 0, 0xE3D000);
}
GL11.glPopMatrix();
GL11.glPushMatrix();
{
GL11.glTranslatef(2 * 0.75f + (mc.fontRenderer.getStringWidth("999") * 0.75f) + 50, sHeight / 3 + 4, 0);
GL11.glScalef(0.75f, 0.75f, 1);
drawString(mc.fontRenderer, "" + DRIVE.getDriveLevel(driveForm), 0, 0, 0xFFFFFF);
}
GL11.glPopMatrix();
GL11.glPushMatrix();
{
GL11.glTranslatef(150 - (mc.fontRenderer.getStringWidth(Utils.translateToLocal(driveForm)) * 0.75f), sHeight / 3 + 4, 0);
GL11.glScalef(0.75f, 0.75f, 1);
drawString(mc.fontRenderer, Utils.translateToLocal(driveForm), 0, 0, 0xFFFFFF);
}
GL11.glPopMatrix();
}
GL11.glPopMatrix();
}
GL11.glPopMatrix();
GL11.glColor4ub(driveColor[0], driveColor[1], driveColor[2], (byte) 255);
GL11.glPushMatrix();
{
mc.renderEngine.bindTexture(texture);
int width = event.getResolution().getScaledWidth();
int sHeight = event.getResolution().getScaledHeight();
GL11.glTranslatef(2.0f * 0.6f + 1, sHeight / 3 + 36.0f * 0.6f, 0);
GL11.glScalef(0.6f, height, 1);
drawTexturedModalRect(0, 0, 0, 36, 256, 1);
}
GL11.glPopMatrix();
GL11.glColor4ub(driveColor[0], driveColor[1], driveColor[2], (byte) 255);
GL11.glPushMatrix();
{
mc.renderEngine.bindTexture(texture);
int width = event.getResolution().getScaledWidth();
int sHeight = event.getResolution().getScaledHeight();
GL11.glTranslatef(2, sHeight / 3 + height + (36.0f * 0.6f), 0);
GL11.glScalef(0.6f, 0.6f, 1);
drawTexturedModalRect(0, 0, 0, 37, 256, 14);
}
GL11.glPopMatrix();
GL11.glColor4ub(driveColor[0], driveColor[1], driveColor[2], (byte) 255);
for (int i = 0; i < DRIVE.getMessages().size(); i++) {
GL11.glPushMatrix();
{
int width = event.getResolution().getScaledWidth();
int sHeight = event.getResolution().getScaledHeight();
String message = DRIVE.getMessages().get(i).toString();
GL11.glTranslatef(2 * 0.8f + 50, sHeight / 3 + mc.fontRenderer.FONT_HEIGHT * 0.8f * i + 21, 0);
GL11.glTranslatef(-35, 0, 0);
GL11.glScalef(0.8f, 0.8f, 1);
drawString(mc.fontRenderer, Utils.translateToLocalFormatted(message), 0, 0, 0xFFFFFF);
}
GL11.glPopMatrix();
}
GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) 255);
}
GL11.glPopMatrix();
if (timeDriveLevelUp + levelSeconds <= (int) Minecraft.getSystemTime() / 1000)
showDriveLevelUp = false;
}
}
}
use of uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability.IPlayerStats in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class BlockSavePoint method updateState.
private void updateState(World world, BlockPos pos) {
List list = world.getEntitiesWithinAABBExcludingEntity((Entity) null, new AxisAlignedBB(pos.add(0, 0, 0), pos.add(1, 1, 1)));
if (!list.isEmpty())
for (int i = 0; i < list.size(); i++) {
Entity e = (Entity) list.get(i);
if (e instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) e;
IPlayerStats STATS = player.getCapability(ModCapabilities.PLAYER_STATS, null);
// System.out.println(player.getBedLocation());
// System.out.println(pos.getX());
boolean samePos;
BlockPos bedPos;
if (player.getBedLocation() == null) {
IFirstTimeJoin originalPos = player.getCapability(ModCapabilities.FIRST_TIME_JOIN, null);
bedPos = new BlockPos(originalPos.getPosX(), originalPos.getPosY(), originalPos.getPosZ());
} else {
bedPos = player.getBedLocation();
}
samePos = bedPos.getX() == pos.getX() && bedPos.getY() == pos.getY() && bedPos.getZ() == pos.getZ();
if (player.isSneaking() && !samePos) {
player.setSpawnChunk(pos, true, 0);
player.setSpawnPoint(pos, true);
TextHelper.sendFormattedChatMessage("Spawn point saved!", TextFormatting.GREEN, player);
world.playSound((EntityPlayer) null, player.getPosition(), ModSounds.savespawn, SoundCategory.BLOCKS, 1.0f, 1.0f);
}
if (player.getHealth() < player.getMaxHealth() || STATS.getMP() < STATS.getMaxMP()) {
player.heal(1);
STATS.addMP(2);
if (player.getFoodStats().getFoodLevel() < 20)
player.getFoodStats().addStats(4, 0);
if (timeHealed + 1 <= (int) Minecraft.getSystemTime() / 1000) {
world.playSound((EntityPlayer) null, player.getPosition(), ModSounds.savepoint, SoundCategory.BLOCKS, 1.0f, 1.0f);
PacketDispatcher.sendToAllAround(new SpawnCureParticles(pos, true), player, 64.0D);
}
PacketDispatcher.sendTo(new SyncMagicData(player.getCapability(ModCapabilities.MAGIC_STATE, null), STATS), (EntityPlayerMP) player);
}
}
}
world.scheduleUpdate(new BlockPos(pos), this, this.tickRate(world));
}
use of uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability.IPlayerStats in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class CapabilityEvents method onEntityConstructing.
@SubscribeEvent
public void onEntityConstructing(AttachCapabilitiesEvent<Entity> event) {
if (event.getObject() instanceof EntityPlayer) {
event.addCapability(new ResourceLocation(Reference.MODID, "IOrganizationXIII"), new ICapabilitySerializable<NBTTagCompound>() {
OrganizationXIIICapability.IOrganizationXIII inst = ModCapabilities.ORGANIZATION_XIII.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
return capability == ModCapabilities.ORGANIZATION_XIII;
}
@Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
return capability == ModCapabilities.ORGANIZATION_XIII ? (T) inst : null;
}
@Override
public NBTTagCompound serializeNBT() {
return (NBTTagCompound) ModCapabilities.ORGANIZATION_XIII.getStorage().writeNBT(ModCapabilities.ORGANIZATION_XIII, inst, null);
}
@Override
public void deserializeNBT(NBTTagCompound nbt) {
ModCapabilities.ORGANIZATION_XIII.getStorage().readNBT(ModCapabilities.ORGANIZATION_XIII, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "IMunny"), new ICapabilitySerializable<NBTPrimitive>() {
MunnyCapability.IMunny inst = ModCapabilities.MUNNY.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.MUNNY;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.MUNNY ? (T) inst : null;
}
@Override
public NBTPrimitive serializeNBT() {
return (NBTPrimitive) ModCapabilities.MUNNY.getStorage().writeNBT(ModCapabilities.MUNNY, inst, null);
}
@Override
public void deserializeNBT(NBTPrimitive nbt) {
ModCapabilities.MUNNY.getStorage().readNBT(ModCapabilities.MUNNY, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "ICheatMode"), new ICapabilitySerializable<NBTPrimitive>() {
CheatModeCapability.ICheatMode inst = ModCapabilities.CHEAT_MODE.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.CHEAT_MODE;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.CHEAT_MODE ? (T) inst : null;
}
@Override
public NBTPrimitive serializeNBT() {
return (NBTPrimitive) ModCapabilities.CHEAT_MODE.getStorage().writeNBT(ModCapabilities.CHEAT_MODE, inst, null);
}
@Override
public void deserializeNBT(NBTPrimitive nbt) {
ModCapabilities.CHEAT_MODE.getStorage().readNBT(ModCapabilities.CHEAT_MODE, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "IPlayerStats"), new ICapabilitySerializable<NBTTagCompound>() {
PlayerStatsCapability.IPlayerStats inst = ModCapabilities.PLAYER_STATS.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.PLAYER_STATS;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.PLAYER_STATS ? (T) inst : null;
}
@Override
public NBTTagCompound serializeNBT() {
return (NBTTagCompound) ModCapabilities.PLAYER_STATS.getStorage().writeNBT(ModCapabilities.PLAYER_STATS, inst, null);
}
@Override
public void deserializeNBT(NBTTagCompound nbt) {
ModCapabilities.PLAYER_STATS.getStorage().readNBT(ModCapabilities.PLAYER_STATS, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "ISummonKeyblade"), new ICapabilitySerializable<NBTTagCompound>() {
SummonKeybladeCapability.ISummonKeyblade inst = ModCapabilities.SUMMON_KEYBLADE.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.SUMMON_KEYBLADE;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.SUMMON_KEYBLADE ? (T) inst : null;
}
@Override
public NBTTagCompound serializeNBT() {
return (NBTTagCompound) ModCapabilities.SUMMON_KEYBLADE.getStorage().writeNBT(ModCapabilities.SUMMON_KEYBLADE, inst, null);
}
@Override
public void deserializeNBT(NBTTagCompound nbt) {
ModCapabilities.SUMMON_KEYBLADE.getStorage().readNBT(ModCapabilities.SUMMON_KEYBLADE, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "IMagicState"), new ICapabilitySerializable<NBTTagCompound>() {
MagicStateCapability.IMagicState inst = ModCapabilities.MAGIC_STATE.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.MAGIC_STATE;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.MAGIC_STATE ? (T) inst : null;
}
@Override
public NBTTagCompound serializeNBT() {
return (NBTTagCompound) ModCapabilities.MAGIC_STATE.getStorage().writeNBT(ModCapabilities.MAGIC_STATE, inst, null);
}
@Override
public void deserializeNBT(NBTTagCompound nbt) {
ModCapabilities.MAGIC_STATE.getStorage().readNBT(ModCapabilities.MAGIC_STATE, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "IDriveState"), new ICapabilitySerializable<NBTTagCompound>() {
DriveStateCapability.IDriveState inst = ModCapabilities.DRIVE_STATE.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.DRIVE_STATE;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.DRIVE_STATE ? (T) inst : null;
}
@Override
public NBTTagCompound serializeNBT() {
return (NBTTagCompound) ModCapabilities.DRIVE_STATE.getStorage().writeNBT(ModCapabilities.DRIVE_STATE, inst, null);
}
@Override
public void deserializeNBT(NBTTagCompound nbt) {
ModCapabilities.DRIVE_STATE.getStorage().readNBT(ModCapabilities.DRIVE_STATE, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "IFirstTimeJoin"), new ICapabilitySerializable<NBTTagCompound>() {
FirstTimeJoinCapability.IFirstTimeJoin inst = ModCapabilities.FIRST_TIME_JOIN.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.FIRST_TIME_JOIN;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.FIRST_TIME_JOIN ? (T) inst : null;
}
@Override
public NBTTagCompound serializeNBT() {
return (NBTTagCompound) ModCapabilities.FIRST_TIME_JOIN.getStorage().writeNBT(ModCapabilities.FIRST_TIME_JOIN, inst, null);
}
@Override
public void deserializeNBT(NBTTagCompound nbt) {
ModCapabilities.FIRST_TIME_JOIN.getStorage().readNBT(ModCapabilities.FIRST_TIME_JOIN, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "ISynthesisRecipe"), new ICapabilitySerializable<NBTTagCompound>() {
SynthesisRecipeCapability.ISynthesisRecipe inst = ModCapabilities.SYNTHESIS_RECIPES.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.SYNTHESIS_RECIPES;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.SYNTHESIS_RECIPES ? (T) inst : null;
}
@Override
public NBTTagCompound serializeNBT() {
return (NBTTagCompound) ModCapabilities.SYNTHESIS_RECIPES.getStorage().writeNBT(ModCapabilities.SYNTHESIS_RECIPES, inst, null);
}
@Override
public void deserializeNBT(NBTTagCompound nbt) {
ModCapabilities.SYNTHESIS_RECIPES.getStorage().readNBT(ModCapabilities.SYNTHESIS_RECIPES, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "ISynthesisMaterial"), new ICapabilitySerializable<NBTTagCompound>() {
SynthesisMaterialCapability.ISynthesisMaterial inst = ModCapabilities.SYNTHESIS_MATERIALS.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.SYNTHESIS_MATERIALS;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.SYNTHESIS_MATERIALS ? (T) inst : null;
}
@Override
public NBTTagCompound serializeNBT() {
return (NBTTagCompound) ModCapabilities.SYNTHESIS_MATERIALS.getStorage().writeNBT(ModCapabilities.SYNTHESIS_MATERIALS, inst, null);
}
@Override
public void deserializeNBT(NBTTagCompound nbt) {
ModCapabilities.SYNTHESIS_MATERIALS.getStorage().readNBT(ModCapabilities.SYNTHESIS_MATERIALS, inst, null, nbt);
}
});
}
}
use of uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability.IPlayerStats in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class EntityEvents method onPlayerTick.
@SubscribeEvent
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
EntityPlayer player = event.player;
if (player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getMember() == Utils.OrgMember.NONE) {
if (!ItemStack.areItemStacksEqual(player.inventory.armorInventory.get(0), ItemStack.EMPTY) && player.inventory.armorInventory.get(1) != ItemStack.EMPTY && player.inventory.armorInventory.get(2) != ItemStack.EMPTY && player.inventory.armorInventory.get(3) != ItemStack.EMPTY) {
boolean isWearingOrgArmor = player.inventory.armorInventory.get(0).getItem() instanceof ItemOrganizationRobe && player.inventory.armorInventory.get(1).getItem() instanceof ItemOrganizationRobe && player.inventory.armorInventory.get(2).getItem() instanceof ItemOrganizationRobe && player.inventory.armorInventory.get(3).getItem() instanceof ItemOrganizationRobe;
// boolean isWearingXemnasArmor = player.inventory.armorInventory.get(0).getItem() == ModItems.Xemnas_Boots && player.inventory.armorInventory.get(1).getItem() == ModItems.Xemnas_Leggings && player.inventory.armorInventory.get(2).getItem() == ModItems.Xemnas_Chestplate && player.inventory.armorInventory.get(3).getItem() == ModItems.Xemnas_Helmet;
if (isWearingOrgArmor) {
if (!player.world.isRemote) {
if (!player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getOpenedGUI()) {
player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).setOpenedGUI(true);
PacketDispatcher.sendTo(new OpenOrgGUI(), (EntityPlayerMP) player);
}
}
}
} else {
if (player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getMember() == Utils.OrgMember.NONE)
player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).setOpenedGUI(false);
}
}
if (player.getCapability(ModCapabilities.Xemnas, null).getMember() == Utils.OrgMember.NONE) {
if (!ItemStack.areItemStacksEqual(player.inventory.armorInventory.get(0), ItemStack.EMPTY) && player.inventory.armorInventory.get(1) != ItemStack.EMPTY && player.inventory.armorInventory.get(2) != ItemStack.EMPTY && player.inventory.armorInventory.get(3) != ItemStack.EMPTY) {
boolean isWearingXemnasArmor = player.inventory.armorInventory.get(0).getItem() == ModItems.Xemnas_Boots && player.inventory.armorInventory.get(1).getItem() == ModItems.Xemnas_Leggings && player.inventory.armorInventory.get(2).getItem() == ModItems.Xemnas_Chestplate && player.inventory.armorInventory.get(3).getItem() == ModItems.Xemnas_Helmet;
if (isWearingXemnasArmor) {
if (!player.world.isRemote) {
if (!player.getCapability(ModCapabilities.Xemnas, null).getOpenedGUI()) {
player.getCapability(ModCapabilities.Xemnas, null).setOpenedGUI(true);
PacketDispatcher.sendTo(new OpenOrgGUI(), (EntityPlayerMP) player);
}
}
}
} else {
if (player.getCapability(ModCapabilities.Xemnas, null).getMember() == Utils.OrgMember.NONE)
player.getCapability(ModCapabilities.Xemnas, null).setOpenedGUI(false);
}
}
// Choices
IPlayerStats STATS = player.getCapability(ModCapabilities.PLAYER_STATS, null);
if (!event.player.world.isRemote) {
if (player.dimension == ModDimensions.diveToTheHeartID) {
if (player.getPosition().getX() == -13 && player.getPosition().getZ() == -1 && player.getPosition().getY() == 66) {
if (!STATS.getChoice1().equals(Strings.Choice_Shield)) {
STATS.setChoice1(Strings.Choice_Shield);
TextComponentTranslation shield = new TextComponentTranslation("Shield");
shield.getStyle().setColor(TextFormatting.YELLOW);
player.sendMessage(shield);
}
} else if (player.getPosition().getX() == 11 && player.getPosition().getZ() == -1 && player.getPosition().getY() == 66) {
if (!STATS.getChoice1().equals(Strings.Choice_Staff)) {
STATS.setChoice1(Strings.Choice_Staff);
TextComponentTranslation staff = new TextComponentTranslation("Staff");
staff.getStyle().setColor(TextFormatting.YELLOW);
player.sendMessage(staff);
}
} else if (player.getPosition().getX() == -1 && player.getPosition().getZ() == -13 && player.getPosition().getY() == 66) {
if (!STATS.getChoice1().equals(Strings.Choice_Sword)) {
STATS.setChoice1(Strings.Choice_Sword);
TextComponentTranslation sword = new TextComponentTranslation("Sword");
sword.getStyle().setColor(TextFormatting.YELLOW);
player.sendMessage(sword);
}
} else if (player.getPosition().getX() == -1 && player.getPosition().getZ() == +10 && player.getPosition().getY() == 65) {
if (((EntityPlayer) player).dimension == ModDimensions.diveToTheHeartID) {
if (!STATS.getChoice1().equals("") && !STATS.getChoice1().equals("door")) {
// if (!player.world.isRemote) {
switch(STATS.getChoice1()) {
case Strings.Choice_Shield:
STATS.addDefense(2);
break;
case Strings.Choice_Staff:
STATS.addMagic(2);
break;
case Strings.Choice_Sword:
STATS.addStrength(2);
break;
}
PacketDispatcher.sendTo(new SyncLevelData(STATS), (EntityPlayerMP) player);
new TeleporterOverworld(event.player.world.getMinecraftServer().getServer().getWorld(0)).teleport((player), player.world);
// }
} else {
if (!STATS.getChoice1().equals("door")) {
TextComponentTranslation needChoice = new TextComponentTranslation("You must make a choice");
needChoice.getStyle().setColor(TextFormatting.RED);
player.sendMessage(needChoice);
STATS.setChoice1("door");
}
}
}
}
} else if (player.dimension == ModDimensions.traverseTownID) {
if (player.getPosition().getX() == 193 && player.getPosition().getZ() == 161 && player.getPosition().getY() == 6) {
new TeleporterOverworld(event.player.world.getMinecraftServer().getServer().getWorld(0)).teleport((player), player.world);
}
}
}
DriveStateCapability.IDriveState DS = event.player.getCapability(ModCapabilities.DRIVE_STATE, null);
if (!DS.getInDrive())
if (STATS.getMP() <= 0 || STATS.getRecharge()) {
STATS.setRecharge(true);
if (STATS.getMP() != STATS.getMaxMP()) {
STATS.addMP(0.1);
if (STATS.getMP() > STATS.getMaxMP())
STATS.setMP(STATS.getMaxMP());
} else {
STATS.setMP(STATS.getMaxMP());
STATS.setRecharge(false);
if (event.side.isServer()) {
PacketDispatcher.sendTo(new SyncMagicData(event.player.getCapability(ModCapabilities.MAGIC_STATE, null), event.player.getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) event.player);
}
}
}
if (!DS.getActiveDriveName().equals("none") && DriveFormRegistry.isDriveFormRegistered(DS.getActiveDriveName())) {
DriveFormRegistry.get(DS.getActiveDriveName()).update(event.player);
}
List<Entity> entities = event.player.world.getEntitiesWithinAABBExcludingEntity(event.player, event.player.getEntityBoundingBox().grow(16.0D, 10.0D, 16.0D).offset(-8.0D, -5.0D, -8.0D));
List<Entity> bossEntities = event.player.world.getEntitiesWithinAABBExcludingEntity(event.player, event.player.getEntityBoundingBox().grow(150.0D, 100.0D, 150.0D).offset(-75.0D, -50.0D, -75.0D));
if (!bossEntities.isEmpty()) {
for (int i = 0; i < bossEntities.size(); i++) {
if (bossEntities.get(i) instanceof EntityDragon || bossEntities.get(i) instanceof EntityWither) {
isBoss = true;
break;
} else {
isBoss = false;
}
}
} else {
isBoss = false;
}
if (!entities.isEmpty()) {
for (int i = 0; i < entities.size(); i++) {
if (entities.get(i) instanceof EntityMob) {
isHostiles = true;
break;
} else {
isHostiles = false;
}
}
} else {
isHostiles = false;
}
}
use of uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability.IPlayerStats in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class ItemEvents method onEntityItemPickUp.
@SubscribeEvent
public void onEntityItemPickUp(EntityItemPickupEvent event) {
IPlayerStats STATS = event.getEntityPlayer().getCapability(ModCapabilities.PLAYER_STATS, null);
IDriveState DRIVE = event.getEntityPlayer().getCapability(ModCapabilities.DRIVE_STATE, null);
if (event.getItem().getItem().getItem() instanceof ItemMunny) {
final MunnyCapability.IMunny munny = event.getEntityPlayer().getCapability(ModCapabilities.MUNNY, null);
MunnyPickup packet = new MunnyPickup(event.getItem().getItem());
event.getItem().getItem().setCount(event.getItem().getItem().getCount() - 1);
;
munny.addMunny(event.getItem().getItem().getTagCompound().getInteger("amount"));
PacketDispatcher.sendTo(new SyncMunnyData(munny), (EntityPlayerMP) event.getEntityPlayer());
PacketDispatcher.sendTo(new ShowOverlayPacket("munny", event.getItem().getItem().getTagCompound().getInteger("amount")), (EntityPlayerMP) event.getEntityPlayer());
} else if (event.getItem().getItem().getItem() instanceof ItemHpOrb) {
if (!ItemStack.areItemStacksEqual(event.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND), ItemStack.EMPTY))
if (event.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.EmptyBottle)
return;
HpOrbPickup packet = new HpOrbPickup(event.getItem().getItem());
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
if (event.getEntityPlayer().getHealth() >= event.getEntityPlayer().getMaxHealth()) {
event.getItem().getItem().setCount(event.getItem().getItem().getCount() - 1);
;
return;
}
if (event.getEntityPlayer().getHealth() < event.getEntityPlayer().getMaxHealth() - 1)
event.getEntityPlayer().heal(2);
else
event.getEntityPlayer().heal(1);
event.getItem().getItem().setCount(event.getItem().getItem().getCount() - 1);
;
}
} else if (event.getItem().getItem().getItem() == ModItems.DriveOrb) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
event.getItem().getItem().setCount(event.getItem().getItem().getCount() - 1);
;
DRIVE.addDP(event.getItem().getItem().getTagCompound().getInteger("amount"));
EntityPlayer player = event.getEntityPlayer();
PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
PacketDispatcher.sendTo(new SyncDriveInventory(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) event.getEntityPlayer());
}
} else if (event.getItem().getItem().getItem() == ModItems.MagicOrb) {
double mp = STATS.getMP();
if (!ItemStack.areItemStacksEqual(event.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND), ItemStack.EMPTY))
if (event.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.EmptyBottle)
return;
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
event.getItem().getItem().setCount(event.getItem().getItem().getCount() - 1);
;
STATS.addMP(event.getItem().getItem().getTagCompound().getInteger("amount"));
PacketDispatcher.sendTo(new SyncMagicData(event.getEntityPlayer().getCapability(ModCapabilities.MAGIC_STATE, null), STATS), (EntityPlayerMP) event.getEntityPlayer());
}
} else if (event.getItem().getItem().getItem() instanceof ItemSynthesisMaterial) {
for (int i = 0; i < event.getEntityPlayer().inventory.getSizeInventory(); i++) {
if (!ItemStack.areItemStacksEqual(event.getEntityPlayer().inventory.getStackInSlot(i), ItemStack.EMPTY)) {
if (event.getEntityPlayer().inventory.getStackInSlot(i).getItem() == ModItems.SynthesisBagL) {
IItemHandler inv = event.getEntityPlayer().inventory.getStackInSlot(i).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
addSynthesisMaterialToBag(inv, event);
} else if (event.getEntityPlayer().inventory.getStackInSlot(i).getItem() == ModItems.SynthesisBagM) {
IItemHandler inv = event.getEntityPlayer().inventory.getStackInSlot(i).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
addSynthesisMaterialToBag(inv, event);
}
if (event.getEntityPlayer().inventory.getStackInSlot(i).getItem() == ModItems.SynthesisBagS) {
IItemHandler inv = event.getEntityPlayer().inventory.getStackInSlot(i).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
addSynthesisMaterialToBag(inv, event);
}
}
}
}
}
Aggregations