use of net.minecraft.item.ItemBow in project Cavern2 by kegare.
the class RandomiteHelper method refreshItems.
public static void refreshItems() {
DROP_ITEMS.clear();
Set<String> oreNames = Sets.newTreeSet();
String[] targetNames = { "treeSapling", "sugarcane", "vine", "slimeball", "enderpearl", "bone", "gunpowder", "string", "torch" };
String[] targetPrefixes = { "gem", "ingot", "nugget", "dust", "crop" };
for (String name : targetNames) {
if (OreDictionary.doesOreNameExist(name)) {
oreNames.add(name);
}
}
for (String name : OreDictionary.getOreNames()) {
for (String prefix : targetPrefixes) {
if (name.startsWith(prefix) && Character.isUpperCase(name.charAt(prefix.length()))) {
oreNames.add(name);
}
}
}
for (String name : oreNames) {
for (ItemStack stack : OreDictionary.getOres(name, false)) {
if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
NonNullList<ItemStack> list = NonNullList.create();
stack.getItem().getSubItems(CreativeTabs.SEARCH, list);
for (ItemStack subStack : list) {
addItem(subStack, 50);
}
} else {
addItem(stack, 50);
}
}
}
for (Item item : Item.REGISTRY) {
if (item == null || item == Items.AIR || item instanceof ItemBlock) {
continue;
}
if (item instanceof ItemFood) {
NonNullList<ItemStack> list = NonNullList.create();
item.getSubItems(CreativeTabs.SEARCH, list);
for (ItemStack stack : list) {
addItem(stack, 15);
}
} else if (item instanceof ItemTool || item instanceof ItemArmor || item instanceof ItemSword || item instanceof ItemBow) {
addItem(new ItemStack(item), 5);
}
}
addItem(ItemCave.EnumType.MINER_ORB.getItemStack(), 1);
}
use of net.minecraft.item.ItemBow in project SilentGems by SilentChaos512.
the class EquipmentTooltips method onRenderTooltip.
@SubscribeEvent
public void onRenderTooltip(RenderTooltipEvent.PostText event) {
ItemStack stack = event.getStack();
Item item = stack.getItem();
boolean isTinkersHarvestTool = isTinkersLoaded && item instanceof slimeknights.tconstruct.library.tools.AoeToolCore;
boolean isTinkersWeapon = isTinkersLoaded && item instanceof slimeknights.tconstruct.library.tools.SwordCore;
boolean isTinkersBow = isTinkersLoaded && item instanceof slimeknights.tconstruct.library.tools.ranged.BowCore;
// Tools (pickaxes, shovels, axes, and more)
if (item instanceof ItemTool || item instanceof ItemHoe || item instanceof ItemShears || item instanceof ItemFishingRod || isTinkersHarvestTool) {
renderBackground(event);
renderForTool(event, stack);
} else // Swords
if (item instanceof ItemSword || isTinkersWeapon) {
boolean isCaster = item instanceof ITool && ToolHelper.getToolTier(stack).ordinal() >= EnumMaterialTier.SUPER.ordinal();
renderBackground(event);
renderForWeapon(event, stack);
} else // Bows
if (item instanceof ItemBow || isTinkersBow) {
renderBackground(event);
renderForBow(event, stack);
} else // Shields
if (item instanceof ItemShield) {
renderBackground(event);
renderForShield(event, stack);
} else // Armor
if (item instanceof ItemArmor) {
renderBackground(event);
renderForArmor(event, stack);
}
// Unknown
}
use of net.minecraft.item.ItemBow in project SilentGems by SilentChaos512.
the class EquipmentTooltips method renderForBow.
private void renderForBow(RenderTooltipEvent.PostText event, ItemStack stack) {
Minecraft mc = Minecraft.getMinecraft();
FontRenderer fontRenderer = event.getFontRenderer();
ItemStack currentEquip = mc.player.getHeldItemMainhand();
boolean itemsComparable = stack.getItem() instanceof ItemBow && currentEquip.getItem() instanceof ItemBow;
double scale = 0.75;
int x = (int) (event.getX() / scale);
int y = (int) ((event.getY() - 16) / scale);
int durability = getDurability(stack, 0);
int equippedDurability = getDurability(currentEquip, durability);
// We don't have anything to get stats for other mods' bows, do we? Guess we have to assume vanilla stats.
// Arrow damage: display actual damage
float arrowDamage = stack.getItem() instanceof ItemGemBow ? 2f + ((ItemGemBow) stack.getItem()).getArrowDamage(stack) : 2f;
float equippedArrowDamage = currentEquip.getItem() instanceof ItemGemBow ? 2f + ((ItemGemBow) currentEquip.getItem()).getArrowDamage(currentEquip) : (currentEquip.getItem() instanceof ItemBow ? 2f : arrowDamage);
// Draw speed: display the draw speed value used in tooltips.
float drawSpeed = stack.getItem() instanceof ItemGemBow ? ((ItemGemBow) stack.getItem()).getDrawSpeedForDisplay(stack) : 1f;
float equippedDrawSpeed = currentEquip.getItem() instanceof ItemGemBow ? ((ItemGemBow) currentEquip.getItem()).getDrawSpeedForDisplay(currentEquip) : (currentEquip.getItem() instanceof ItemBow ? 1f : drawSpeed);
GlStateManager.pushMatrix();
GlStateManager.color(1f, 1f, 1f, 1f);
GlStateManager.scale(scale, scale, scale);
mc.renderEngine.bindTexture(TEXTURE);
// Durability
x = renderStat(mc, fontRenderer, 0, x, y, durability, equippedDurability, StackHelper.isValid(currentEquip));
// Arrow Damage
x = renderStat(mc, fontRenderer, 8, x, y, arrowDamage, equippedArrowDamage, itemsComparable);
// Draw Speed
x = renderStat(mc, fontRenderer, 5, x, y, drawSpeed, equippedDrawSpeed, itemsComparable);
lastWidth = (int) (x * scale - event.getX());
GlStateManager.popMatrix();
}
use of net.minecraft.item.ItemBow in project Wurst-MC-1.12 by Wurst-Imperium.
the class TrajectoriesMod method onRender.
@Override
public void onRender(float partialTicks) {
EntityPlayerSP player = WMinecraft.getPlayer();
// check if player is holding item
ItemStack stack = player.inventory.getCurrentItem();
if (stack == null)
return;
// check if item is throwable
if (!WItem.isThrowable(stack))
return;
boolean usingBow = stack.getItem() instanceof ItemBow;
// calculate starting position
double arrowPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * mc.timer.renderPartialTicks - WMath.cos((float) Math.toRadians(player.rotationYaw)) * 0.16F;
double arrowPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * Minecraft.getMinecraft().timer.renderPartialTicks + player.getEyeHeight() - 0.1;
double arrowPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * Minecraft.getMinecraft().timer.renderPartialTicks - WMath.sin((float) Math.toRadians(player.rotationYaw)) * 0.16F;
// calculate starting motion
float arrowMotionFactor = usingBow ? 1F : 0.4F;
float yaw = (float) Math.toRadians(player.rotationYaw);
float pitch = (float) Math.toRadians(player.rotationPitch);
float arrowMotionX = -WMath.sin(yaw) * WMath.cos(pitch) * arrowMotionFactor;
float arrowMotionY = -WMath.sin(pitch) * arrowMotionFactor;
float arrowMotionZ = WMath.cos(yaw) * WMath.cos(pitch) * arrowMotionFactor;
double arrowMotion = Math.sqrt(arrowMotionX * arrowMotionX + arrowMotionY * arrowMotionY + arrowMotionZ * arrowMotionZ);
arrowMotionX /= arrowMotion;
arrowMotionY /= arrowMotion;
arrowMotionZ /= arrowMotion;
if (usingBow) {
float bowPower = (72000 - player.getItemInUseCount()) / 20F;
bowPower = (bowPower * bowPower + bowPower * 2F) / 3F;
if (bowPower > 1F || bowPower <= 0.1F)
bowPower = 1F;
bowPower *= 3F;
arrowMotionX *= bowPower;
arrowMotionY *= bowPower;
arrowMotionZ *= bowPower;
} else {
arrowMotionX *= 1.5D;
arrowMotionY *= 1.5D;
arrowMotionZ *= 1.5D;
}
// GL settings
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(false);
GL11.glEnable(GL11.GL_LINE_SMOOTH);
GL11.glLineWidth(2);
RenderManager renderManager = mc.getRenderManager();
// draw trajectory line
double gravity = usingBow ? 0.05D : stack.getItem() instanceof ItemPotion ? 0.4D : stack.getItem() instanceof ItemFishingRod ? 0.15D : 0.03D;
Vec3d playerVector = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
GL11.glColor4f(0, 1, 0, 0.75F);
GL11.glBegin(GL11.GL_LINE_STRIP);
for (int i = 0; i < 1000; i++) {
GL11.glVertex3d(arrowPosX - renderManager.renderPosX, arrowPosY - renderManager.renderPosY, arrowPosZ - renderManager.renderPosZ);
arrowPosX += arrowMotionX * 0.1;
arrowPosY += arrowMotionY * 0.1;
arrowPosZ += arrowMotionZ * 0.1;
arrowMotionX *= 0.999D;
arrowMotionY *= 0.999D;
arrowMotionZ *= 0.999D;
arrowMotionY -= gravity * 0.1;
if (WMinecraft.getWorld().rayTraceBlocks(playerVector, new Vec3d(arrowPosX, arrowPosY, arrowPosZ)) != null)
break;
}
GL11.glEnd();
// draw end of trajectory line
double renderX = arrowPosX - renderManager.renderPosX;
double renderY = arrowPosY - renderManager.renderPosY;
double renderZ = arrowPosZ - renderManager.renderPosZ;
GL11.glPushMatrix();
GL11.glTranslated(renderX - 0.5, renderY - 0.5, renderZ - 0.5);
GL11.glColor4f(0F, 1F, 0F, 0.25F);
RenderUtils.drawSolidBox();
GL11.glColor4f(0, 1, 0, 0.75F);
RenderUtils.drawOutlinedBox();
GL11.glPopMatrix();
// GL resets
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(true);
GL11.glDisable(GL11.GL_LINE_SMOOTH);
GL11.glPopMatrix();
}
use of net.minecraft.item.ItemBow in project Wurst-MC-1.12 by Wurst-Imperium.
the class FastBowMod method onUpdate.
@Override
public void onUpdate() {
// check if right-clicking
if (!mc.gameSettings.keyBindUseItem.pressed)
return;
// check fly-kick
if (!WMinecraft.getPlayer().onGround && !WMinecraft.getPlayer().capabilities.isCreativeMode)
return;
// check health
if (WMinecraft.getPlayer().getHealth() <= 0)
return;
// check held item
ItemStack stack = WMinecraft.getPlayer().inventory.getCurrentItem();
if (WItem.isNullOrEmpty(stack) || !(stack.getItem() instanceof ItemBow))
return;
WPlayerController.processRightClick();
for (int i = 0; i < 20; i++) WConnection.sendPacket(new CPacketPlayer(false));
mc.playerController.onStoppedUsingItem(WMinecraft.getPlayer());
}
Aggregations