use of net.silentchaos512.gems.handler.PlayerDataHandler.PlayerData in project SilentGems by SilentChaos512.
the class GuiChaosBar method onRenderGameOverlay.
@SubscribeEvent
public void onRenderGameOverlay(RenderGameOverlayEvent.Pre event) {
if (event.getType() != ElementType.AIR) {
return;
}
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.player;
currentTime = ClientTickHandler.ticksInGame;
if (player.capabilities.isCreativeMode || (!GemsConfig.CHAOS_BAR_SHOW_ALWAYS && currentTime > lastUpdateTime + POPUP_TIME)) {
return;
}
int width = event.getResolution().getScaledWidth();
int height = event.getResolution().getScaledHeight();
PlayerData data = PlayerDataHandler.get(player);
int chaos = data.getCurrentChaos();
int maxChaos = data.getMaxChaos();
int chaosHalves = (int) (20f * chaos / maxChaos);
int rowHeight = 10;
int left = width / 2 + 10;
int top = height - GuiIngameForge.right_height;
GuiIngameForge.right_height += rowHeight;
final int textureX = 0;
final int textureY = 23;
final int textureWidth = 9;
final int textureHeight = 9;
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
mc.renderEngine.bindTexture(TEXTURE);
for (int i = 9; i >= 0; --i) {
int row = MathHelper.ceil((i + 1) / 10f) - 1;
int x = left + i % 10 * 8;
int y = top - row * rowHeight;
GlStateManager.color(1f, 1f, 1f, 1f);
drawTexturedModalRect(x, y, textureX + 2 * textureWidth, textureY, textureWidth, textureHeight);
Color color = new Color();
float hue = ((currentTime + COLOR_CHANGE_STEP * i) % COLOR_CHANGE_DELAY) / COLOR_CHANGE_DELAY;
color.fromHSB(hue, 0.6f, 1f);
GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, 1f);
if (i * 2 + 1 < chaosHalves) {
drawTexturedModalRect(x, y, textureX, textureY, textureWidth, textureHeight);
} else if (i * 2 + 1 == chaosHalves) {
drawTexturedModalRect(x, y, textureX + textureWidth, textureY, textureWidth, textureHeight);
}
}
GlStateManager.color(1f, 1f, 1f, 1f);
mc.renderEngine.bindTexture(Gui.ICONS);
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
use of net.silentchaos512.gems.handler.PlayerDataHandler.PlayerData in project SilentGems by SilentChaos512.
the class GuiCrosshairs method renderOverlay.
public void renderOverlay(RenderGameOverlayEvent event, int type, ToolSkill skill) {
int cost = skill.getCost(null, Minecraft.getMinecraft().player, BlockPos.ORIGIN);
PlayerData data = PlayerDataHandler.get(Minecraft.getMinecraft().player);
if (data != null && data.getCurrentChaos() < cost)
GlStateManager.color(1f, 0f, 0f, 1f);
else
GlStateManager.color(1f, 1f, 1f, 1f);
mc.getTextureManager().bindTexture(TEXTURE_CROSSHAIRS);
GlStateManager.enableBlend();
renderCrosshairs(event.getPartialTicks(), event.getResolution(), type);
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.color(1f, 1f, 1f, 1f);
}
use of net.silentchaos512.gems.handler.PlayerDataHandler.PlayerData in project SilentGems by SilentChaos512.
the class ItemChaosOrb method onUpdate.
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
if (worldIn.isRemote || worldIn.getTotalWorldTime() % 20 != 0) {
return;
}
if (entityIn instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entityIn;
PlayerData data = PlayerDataHandler.get(player);
// Send Chaos to player
int amount = extractCharge(stack, data.getChaosChargeSpeed(), true);
amount = data.sendChaos(amount);
extractCharge(stack, amount, false);
// Damage from player send?
int breakTries = amount / PlayerData.CHAOS_MAX_TRANSFER;
for (int i = 0; i < breakTries; ++i) {
if (amount > 0 && SilentGems.random.nextFloat() < getBreakChance(stack)) {
damageOrb(stack, player);
break;
}
}
// Try recharge player's items?
if (isItemSendEnabled(stack)) {
int totalSentToItems = 0;
for (ItemStack itemstack : ChaosUtil.getChaosStorageItems(player)) {
if (itemstack.getItem() != this && itemstack.getItem() instanceof IChaosStorage) {
int toSend = Math.min(getCharge(stack), MAX_ITEM_SEND);
totalSentToItems += ((IChaosStorage) itemstack.getItem()).receiveCharge(itemstack, toSend, false);
}
}
extractCharge(stack, totalSentToItems, false);
// Damage from item send? (lower damage chance)
breakTries = totalSentToItems / MAX_ITEM_SEND;
for (int i = 0; i < breakTries; ++i) {
if (SilentGems.random.nextFloat() < getBreakChance(stack) / 3) {
damageOrb(stack, player);
break;
}
}
}
}
}
use of net.silentchaos512.gems.handler.PlayerDataHandler.PlayerData in project SilentGems by SilentChaos512.
the class SkillAreaMiner method onGetBreakSpeed.
@Override
public void onGetBreakSpeed(PlayerEvent.BreakSpeed event) {
PlayerData data = PlayerDataHandler.get(event.getEntityPlayer());
int cost = event.getEntityPlayer().capabilities.isCreativeMode ? 0 : CHAOS_COST;
if (data.chaos >= cost) {
event.setNewSpeed(event.getNewSpeed() * DIG_SPEED_MULTIPLIER);
}
}
use of net.silentchaos512.gems.handler.PlayerDataHandler.PlayerData in project SilentGems by SilentChaos512.
the class SkillLumberjack method activate.
@Override
public boolean activate(ItemStack tool, EntityPlayer player, BlockPos pos) {
World world = player.world;
IBlockState state = world.getBlockState(pos);
// Must be an axe
if (state == null || state.getBlock() == null) {
return false;
}
// Must be super tool with special enabled.
if (ToolHelper.getToolTier(tool).ordinal() < EnumMaterialTier.SUPER.ordinal() || !ToolHelper.isSpecialAbilityEnabled(tool)) {
return false;
}
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
if (state.getBlock().isWood(world, pos) || state.getMaterial() == Material.SPONGE) {
if (detectTree(world, x, y, z, state.getBlock())) {
// Don't allow in creative mode.
if (player.capabilities.isCreativeMode) {
return false;
}
// Does player have enough chaos?
PlayerData data = PlayerDataHandler.get(player);
int cost = getCost(tool, player, pos);
if (data.chaos >= cost) {
data.drainChaos(cost);
} else {
String msg = SilentGems.localizationHelper.getLocalizedString("skill", "all.insufficientChaos");
ChatHelper.sendStatusMessage(player, msg, true);
return false;
}
ToolSoul soul = SoulManager.getSoul(tool);
TreeBreakResult result = new TreeBreakResult();
result.soul = soul;
breakTree(result, world, x, y, z, x, y, z, tool, state, player);
ToolHelper.incrementStatBlocksMined(tool, result.blocksBroken);
if (soul != null)
soul.addXp(result.xpEarned, tool, player);
return true;
}
}
return false;
}
Aggregations