use of net.minecraft.item.EnumAction in project Bookshelf by Darkhax-Minecraft.
the class ModelArmorExtended method getArmPose.
/**
* Gets the arm pose for a player's hand.
*
* @param stack The stack in the player's hand.
* @param player The player to get info for.
* @return The pose of the player's hand.
*/
private ArmPose getArmPose(ItemStack stack, EntityPlayer player) {
if (stack.isEmpty()) {
return ArmPose.EMPTY;
}
ArmPose pose = ModelBiped.ArmPose.ITEM;
if (player.getItemInUseCount() > 0) {
final EnumAction action = stack.getItemUseAction();
pose = action == EnumAction.BLOCK ? ArmPose.BLOCK : action == EnumAction.BOW ? ArmPose.BOW_AND_ARROW : pose;
}
return pose;
}
use of net.minecraft.item.EnumAction in project Hyperium by HyperiumClient.
the class HyperiumItemRenderer method renderItemInFirstPerson.
public void renderItemInFirstPerson(float partialTicks, float prevEquippedProgress, float equippedProgress, ItemStack itemToRender) {
float f = 1.0F - (prevEquippedProgress + (equippedProgress - prevEquippedProgress) * partialTicks);
EntityPlayerSP entityPlayerSP = mc.thePlayer;
float f1 = entityPlayerSP.getSwingProgress(partialTicks);
float f2 = entityPlayerSP.prevRotationPitch + (entityPlayerSP.rotationPitch - entityPlayerSP.prevRotationPitch) * partialTicks;
float f3 = entityPlayerSP.prevRotationYaw + (entityPlayerSP.rotationYaw - entityPlayerSP.prevRotationYaw) * partialTicks;
((IMixinItemRenderer) parent).callRotateArroundXAndY(f2, f3);
((IMixinItemRenderer) parent).callSetLightMapFromPlayer(entityPlayerSP);
((IMixinItemRenderer) parent).callRotateWithPlayerRotations(entityPlayerSP, partialTicks);
GlStateManager.enableRescaleNormal();
GlStateManager.pushMatrix();
if (itemToRender != null) {
if (itemToRender.getItem() == Items.filled_map) {
((IMixinItemRenderer) parent).callRenderItemMap(entityPlayerSP, f2, f, f1);
} else if ((itemToRender.getItem() instanceof ItemSword) && !mc.thePlayer.isBlocking() && Settings.CUSTOM_SWORD_ANIMATION) {
transformFirstPersonItem(f, f1);
} else if (entityPlayerSP.getItemInUseCount() > 0) {
EnumAction enumaction = itemToRender.getItemUseAction();
switch(enumaction) {
case NONE:
transformFirstPersonItem(f, 0.0F);
break;
case EAT:
case DRINK:
((IMixinItemRenderer) parent).callPerformDrinking(entityPlayerSP, partialTicks);
if (Settings.OLD_EATING) {
transformFirstPersonItem(f, f1);
} else {
transformFirstPersonItem(f, 0.0F);
}
break;
case BLOCK:
if (Settings.OLD_BLOCKHIT) {
transformFirstPersonItem(f, f1);
((IMixinItemRenderer) parent).callDoBlockTransformations();
GlStateManager.scale(0.83f, 0.88f, 0.85f);
GlStateManager.translate(-0.3f, 0.1f, 0.0f);
} else {
transformFirstPersonItem(f, 0f);
((IMixinItemRenderer) parent).callDoBlockTransformations();
}
break;
case BOW:
if (Settings.OLD_BOW) {
transformFirstPersonItem(f, f1);
((IMixinItemRenderer) parent).callDoBowTransformations(partialTicks, entityPlayerSP);
GlStateManager.translate(0.0F, 0.1F, -0.15F);
} else {
transformFirstPersonItem(f, 0.0F);
((IMixinItemRenderer) parent).callDoBowTransformations(partialTicks, entityPlayerSP);
}
}
} else {
((IMixinItemRenderer) parent).callDoItemUsedTransformations(f1);
transformFirstPersonItem(f, f1);
}
parent.renderItem(entityPlayerSP, itemToRender, ItemCameraTransforms.TransformType.FIRST_PERSON);
} else if (!entityPlayerSP.isInvisible()) {
((IMixinItemRenderer) parent).callRenderPlayerArm(entityPlayerSP, f, f1);
}
GlStateManager.popMatrix();
GlStateManager.disableRescaleNormal();
RenderHelper.disableStandardItemLighting();
}
use of net.minecraft.item.EnumAction in project Charset by CharsetMC.
the class CharsetTweakMobEqualizer method upgradeMob.
@SubscribeEvent(priority = EventPriority.LOW)
public void upgradeMob(LivingSpawnEvent.SpecialSpawn event) {
EnumDifficulty difficulty = event.getWorld().getDifficulty();
if (difficulty == null || difficulty.getDifficultyId() <= 1) {
return;
}
if (!(event.getEntityLiving() instanceof EntityMob)) {
return;
}
EntityMob ent = (EntityMob) event.getEntityLiving();
// 2) Should we add more granular setups (like only some elements of armor, but at a higher frequency)?
if (event.getWorld().rand.nextInt(400) > difficulty.getDifficultyId()) {
return;
}
if (!ent.canPickUpLoot())
return;
EntityPlayer template = pickNearPlayer(event);
if (template == null) {
return;
}
int equipmentCount = 0;
ItemStack[] equipmentCopies = new ItemStack[6];
boolean copyArmor = event.getEntity() instanceof IRangedAttackMob || event.getWorld().rand.nextBoolean();
boolean copyWeapon = !(event.getEntity() instanceof IRangedAttackMob) || event.getWorld().rand.nextBoolean();
for (EntityEquipmentSlot slot : EntityEquipmentSlot.values()) {
if (slot.getSlotType() == EntityEquipmentSlot.Type.ARMOR && copyArmor) {
ItemStack is = template.getItemStackFromSlot(slot);
if (!is.isEmpty() && is.getItem().isValidArmor(is, slot, ent)) {
equipmentCopies[slot.ordinal()] = is.copy();
equipmentCount++;
} else {
equipmentCopies[slot.ordinal()] = ItemStack.EMPTY;
}
}
}
List<ItemStack> carriedWeapons = new ArrayList<ItemStack>();
if (copyWeapon) {
ItemStack currentWeapon = ent.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
double currentWeaponDmg = ItemUtils.getAttributeValue(EntityEquipmentSlot.MAINHAND, currentWeapon, SharedMonsterAttributes.ATTACK_DAMAGE);
for (int i = 0; i < 9; i++) {
ItemStack playerWeapon = template.inventory.getStackInSlot(i);
if (playerWeapon.isEmpty() || playerWeapon.getCount() != 1 || playerWeapon.getMaxStackSize() != 1) {
continue;
}
EnumAction act = playerWeapon.getItemUseAction();
if (act != EnumAction.BLOCK && act != EnumAction.NONE && act != EnumAction.BOW) {
continue;
}
double playerWeaponDmg = ItemUtils.getAttributeValue(EntityEquipmentSlot.MAINHAND, playerWeapon, SharedMonsterAttributes.ATTACK_DAMAGE);
if (playerWeaponDmg > currentWeaponDmg) {
carriedWeapons.add(playerWeapon.copy());
}
}
}
if (!carriedWeapons.isEmpty()) {
equipmentCopies[0] = carriedWeapons.get(event.getWorld().rand.nextInt(carriedWeapons.size())).copy();
equipmentCount++;
}
if (equipmentCount <= 0) {
return;
}
event.setCanceled(true);
ent.onInitialSpawn(ent.world.getDifficultyForLocation(new BlockPos(event.getEntity())), null);
// We need to cancel the event so that we can call this before the below happens
ent.setCanPickUpLoot(false);
for (EntityEquipmentSlot slot : EntityEquipmentSlot.values()) {
if (equipmentCopies[slot.ordinal()] != null) {
ent.setItemStackToSlot(slot, equipmentCopies[slot.ordinal()]);
}
ent.setDropChance(slot, 0);
}
}
use of net.minecraft.item.EnumAction in project Wizardry by TeamWizardry.
the class BloodRenderLayer method setModelVisibilities.
private void setModelVisibilities(AbstractClientPlayer clientPlayer) {
ModelPlayer modelplayer = render.getMainModel();
if (clientPlayer.isSpectator()) {
modelplayer.setVisible(true);
modelplayer.bipedHead.showModel = true;
modelplayer.bipedHeadwear.showModel = true;
} else {
ItemStack stackMain = clientPlayer.getHeldItemMainhand();
ItemStack stackOff = clientPlayer.getHeldItemOffhand();
modelplayer.setVisible(false);
modelplayer.bipedHeadwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.HAT);
modelplayer.bipedBodyWear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.JACKET);
modelplayer.bipedLeftLegwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.LEFT_PANTS_LEG);
modelplayer.bipedRightLegwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.RIGHT_PANTS_LEG);
modelplayer.bipedLeftArmwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.LEFT_SLEEVE);
modelplayer.bipedRightArmwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.RIGHT_SLEEVE);
modelplayer.isSneak = clientPlayer.isSneaking();
ArmPose poseMain = ArmPose.EMPTY;
if (!stackMain.isEmpty()) {
poseMain = ArmPose.ITEM;
if (clientPlayer.getItemInUseCount() > 0) {
EnumAction enumaction = stackMain.getItemUseAction();
if (enumaction == EnumAction.BLOCK) {
poseMain = ArmPose.BLOCK;
} else if (enumaction == EnumAction.BOW) {
poseMain = ArmPose.BOW_AND_ARROW;
}
}
}
ArmPose poseOff = ArmPose.EMPTY;
if (!stackOff.isEmpty()) {
poseOff = ArmPose.ITEM;
if (clientPlayer.getItemInUseCount() > 0) {
EnumAction enumaction1 = stackOff.getItemUseAction();
if (enumaction1 == EnumAction.BLOCK) {
poseOff = ArmPose.BLOCK;
}
}
}
if (clientPlayer.getPrimaryHand() == EnumHandSide.RIGHT) {
modelplayer.rightArmPose = poseMain;
modelplayer.leftArmPose = poseOff;
} else {
modelplayer.rightArmPose = poseOff;
modelplayer.leftArmPose = poseMain;
}
}
}
use of net.minecraft.item.EnumAction in project BloodMagic by WayofTime.
the class RenderSentientSpecter method setModelVisibilities.
private void setModelVisibilities(EntitySentientSpecter clientPlayer) {
ModelBiped modelplayer = this.getMainModel();
ItemStack itemstack = clientPlayer.getHeldItemMainhand();
ItemStack itemstack1 = clientPlayer.getHeldItemOffhand();
modelplayer.setVisible(false);
modelplayer.isSneak = clientPlayer.isSneaking();
ModelBiped.ArmPose modelbiped$armpose = ModelBiped.ArmPose.EMPTY;
ModelBiped.ArmPose modelbiped$armpose1 = ModelBiped.ArmPose.EMPTY;
if (!itemstack.isEmpty()) {
modelbiped$armpose = ModelBiped.ArmPose.ITEM;
if (clientPlayer.getItemInUseCount() > 0) {
EnumAction enumaction = itemstack.getItemUseAction();
if (enumaction == EnumAction.BLOCK) {
modelbiped$armpose = ModelBiped.ArmPose.BLOCK;
} else if (enumaction == EnumAction.BOW) {
modelbiped$armpose = ModelBiped.ArmPose.BOW_AND_ARROW;
}
}
}
if (!itemstack1.isEmpty()) {
modelbiped$armpose1 = ModelBiped.ArmPose.ITEM;
if (clientPlayer.getItemInUseCount() > 0) {
EnumAction enumaction1 = itemstack1.getItemUseAction();
if (enumaction1 == EnumAction.BLOCK) {
modelbiped$armpose1 = ModelBiped.ArmPose.BLOCK;
}
}
}
if (clientPlayer.getPrimaryHand() == EnumHandSide.RIGHT) {
modelplayer.rightArmPose = modelbiped$armpose;
modelplayer.leftArmPose = modelbiped$armpose1;
} else {
modelplayer.rightArmPose = modelbiped$armpose1;
modelplayer.leftArmPose = modelbiped$armpose;
}
}
Aggregations