Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand Action(IForgeAction&IForgeArmPose) #46

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions patches/minecraft/net/minecraft/client/model/ModelBiped.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--- before/net/minecraft/client/model/ModelBiped.java
+++ after/net/minecraft/client/model/ModelBiped.java
@@ -267,6 +267,8 @@
this.field_178723_h.field_78795_f = (float)(-Math.PI / 2) + this.field_78116_c.field_78795_f;
this.field_178724_i.field_78795_f = (float)(-Math.PI / 2) + this.field_78116_c.field_78795_f;
}
+ this.field_187075_l.setRotationAnglesLeftHand(this,p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, p_78087_7_);
+ this.field_187076_m.setRotationAnglesRightHand(this,p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, p_78087_7_);

func_178685_a(this.field_78116_c, this.field_178720_f);
}
@@ -321,11 +323,20 @@
}

@SideOnly(Side.CLIENT)
- public static enum ArmPose
+ public static enum ArmPose implements net.minecraftforge.client.model.IForgeArmPose
{
EMPTY,
ITEM,
BLOCK,
BOW_AND_ARROW;
+ //=======FORGE START=======//
+ private final net.minecraftforge.client.model.IForgeArmPose pose;
+ ArmPose(net.minecraftforge.client.model.IForgeArmPose poseIn){pose = poseIn;}
+ ArmPose(){this(net.minecraftforge.client.model.IForgeArmPose.EMPTY);}
+ @Override
+ public void setRotationAnglesLeftHand(net.minecraft.client.model.ModelBiped modelBiped, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, net.minecraft.entity.Entity entityIn) {pose.setRotationAnglesLeftHand(modelBiped, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);}
+ @Override
+ public void setRotationAnglesRightHand(net.minecraft.client.model.ModelBiped modelBiped, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, net.minecraft.entity.Entity entityIn) {pose.setRotationAnglesRightHand(modelBiped, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);}
+ //=======FORGE END=========//
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,21 @@
}

private void func_177137_d(AbstractClientPlayer p_177137_1_)
@@ -128,6 +130,11 @@
@@ -104,6 +106,7 @@
if (p_177137_1_.func_184605_cv() > 0)
{
EnumAction enumaction = itemstack.func_77975_n();
+ modelbiped$armpose = enumaction.getBipedArmPose();

if (enumaction == EnumAction.BLOCK)
{
@@ -123,11 +126,17 @@
if (p_177137_1_.func_184605_cv() > 0)
{
EnumAction enumaction1 = itemstack1.func_77975_n();
+ modelbiped$armpose1 = enumaction1.getBipedArmPose();

if (enumaction1 == EnumAction.BLOCK)
{
modelbiped$armpose1 = ModelBiped.ArmPose.BLOCK;
}
Expand All @@ -36,15 +50,15 @@
}
}

@@ -149,7 +156,6 @@
@@ -149,7 +158,6 @@
return p_110775_1_.func_110306_p();
}

- @Override
public void func_82422_c()
{
GlStateManager.func_179109_b(0.0F, 0.1875F, 0.0F);
@@ -161,11 +167,9 @@
@@ -161,11 +169,9 @@
GlStateManager.func_179152_a(0.9375F, 0.9375F, 0.9375F);
}

Expand All @@ -58,7 +72,7 @@
{
Scoreboard scoreboard = p_188296_1_.func_96123_co();
ScoreObjective scoreobjective = scoreboard.func_96539_a(2);
@@ -221,12 +225,7 @@
@@ -221,12 +227,7 @@
{
if (p_77039_1_.func_70089_S() && p_77039_1_.func_70608_bn())
{
Expand All @@ -72,7 +86,7 @@
}
else
{
@@ -252,11 +251,11 @@
@@ -252,11 +253,11 @@
double d0 = p_77043_1_.field_70159_w * p_77043_1_.field_70159_w + p_77043_1_.field_70179_y * p_77043_1_.field_70179_y;
double d1 = vec3d.field_72450_a * vec3d.field_72450_a + vec3d.field_72449_c * vec3d.field_72449_c;

Expand Down
22 changes: 15 additions & 7 deletions patches/minecraft/net/minecraft/entity/EntityLivingBase.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,15 @@
public void func_184206_a(DataParameter<?> p_184206_1_)
{
super.func_184206_a(p_184206_1_);
@@ -2785,51 +2756,26 @@
@@ -2776,6 +2747,7 @@
{
if (!p_184584_1_.func_190926_b() && this.func_184587_cr())
{
+ p_184584_1_.func_77975_n().updateItemUse(p_184584_1_,p_184584_2_);
if (p_184584_1_.func_77975_n() == EnumAction.DRINK)
{
this.func_184185_a(SoundEvents.field_187664_bz, 0.5F, this.field_70170_p.field_73012_v.nextFloat() * 0.1F + 0.9F);
@@ -2785,51 +2757,26 @@
{
for (int i = 0; i < p_184584_2_; ++i)
{
Expand Down Expand Up @@ -1520,7 +1528,7 @@
}
}
}
@@ -2839,7 +2785,10 @@
@@ -2839,7 +2786,10 @@
if (!this.field_184627_bm.func_190926_b() && this.func_184587_cr())
{
this.func_184584_a(this.field_184627_bm, 16);
Expand All @@ -1532,7 +1540,7 @@
this.func_184602_cy();
}
}
@@ -2863,7 +2812,8 @@
@@ -2863,7 +2813,8 @@
{
if (!this.field_184627_bm.func_190926_b())
{
Expand All @@ -1542,7 +1550,7 @@
}

this.func_184602_cy();
@@ -2873,7 +2823,7 @@
@@ -2873,7 +2824,7 @@
{
if (!this.field_70170_p.field_72995_K)
{
Expand All @@ -1551,7 +1559,7 @@
}

this.field_184627_bm = ItemStack.field_190927_a;
@@ -2967,13 +2917,13 @@
@@ -2967,13 +2918,13 @@

for (int j = 0; j < 128; ++j)
{
Expand All @@ -1568,7 +1576,7 @@
world.func_175688_a(EnumParticleTypes.PORTAL, d3, d4, d5, (double)f, (double)f1, (double)f2);
}

@@ -2991,6 +2941,31 @@
@@ -2991,6 +2942,31 @@
return true;
}

Expand Down Expand Up @@ -1600,7 +1608,7 @@
public boolean func_190631_cK()
{
return true;
@@ -2999,5 +2974,31 @@
@@ -2999,5 +2975,31 @@
@SideOnly(Side.CLIENT)
public void func_191987_a(BlockPos p_191987_1_, boolean p_191987_2_)
{
Expand Down
27 changes: 27 additions & 0 deletions patches/minecraft/net/minecraft/item/EnumAction.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--- before/net/minecraft/item/EnumAction.java
+++ after/net/minecraft/item/EnumAction.java
@@ -1,10 +1,23 @@
package net.minecraft.item;

-public enum EnumAction
+public enum EnumAction implements net.minecraftforge.common.IForgeAction
{
NONE,
EAT,
DRINK,
BLOCK,
BOW;
+ //========FORGE START========//
+ private final net.minecraftforge.common.IForgeAction action;
+ EnumAction(net.minecraftforge.common.IForgeAction actionIn){action=actionIn;}
+ EnumAction(){this(net.minecraftforge.common.IForgeAction.EMPTY);}
+ @Override
+ public void updateItemUse(ItemStack stack, int eatingParticleCount) {
+ action.updateItemUse(stack,eatingParticleCount);
+ }
+ @net.minecraftforge.fml.relauncher.SideOnly(net.minecraftforge.fml.relauncher.Side.CLIENT)
+ @Override
+ public net.minecraft.client.model.ModelBiped.ArmPose getBipedArmPose() {
+ return action.getBipedArmPose();
+ }
}
8 changes: 8 additions & 0 deletions src/main/java/net/minecraftforge/client/EnumHelperClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@

import com.cleanroommc.hackery.enums.EnumHackery;
import net.minecraft.client.audio.MusicTicker;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.Util.EnumOS;
import net.minecraft.world.GameType;
import net.minecraft.client.settings.GameSettings.Options;
import net.minecraftforge.client.model.IForgeArmPose;
import net.minecraftforge.common.util.EnumHelper;

import javax.annotation.Nullable;
Expand All @@ -39,6 +41,12 @@ public class EnumHelperClient extends EnumHelper
{MusicTicker.MusicType.class, SoundEvent.class, int.class, int.class}
};

public static ModelBiped.ArmPose addArmPose(String name, IForgeArmPose pose){
return EnumHackery.addEnumEntry(ModelBiped.ArmPose.class, name,
new Class<?>[]{IForgeArmPose.class},
new Object[]{pose});
}

@Nullable
public static GameType addGameType(String name, int id, String displayName, String shortName)
{
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/net/minecraftforge/client/model/IForgeArmPose.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package net.minecraftforge.client.model;

import net.minecraft.client.model.ModelBiped;
import net.minecraft.entity.Entity;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public interface IForgeArmPose {
IForgeArmPose EMPTY = new IForgeArmPose() {};
default void setRotationAnglesLeftHand(ModelBiped modelBiped,float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {
}
default void setRotationAnglesRightHand(ModelBiped modelBiped,float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {
}
}
25 changes: 25 additions & 0 deletions src/main/java/net/minecraftforge/common/IForgeAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.minecraftforge.common;

import net.minecraft.client.model.ModelBiped;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public interface IForgeAction {
IForgeAction EMPTY = new IForgeAction() {};

/**
* @return The ArmPose used for render.<br>
* for example {@link ModelBiped.ArmPose#BOW_AND_ARROW} for {@link net.minecraft.init.Items#BOW}
*/
@SideOnly(Side.CLIENT)
default ModelBiped.ArmPose getBipedArmPose(){
return ModelBiped.ArmPose.ITEM;
}

/**
* @param stack the stack is being used by player.
* @param eatingParticleCount count.<br>Use finish:16.<br>When the usage time does not exceed 25 ticks, one tick of every 4 ticks is 4, and the rest is 0
*/
default void updateItemUse(ItemStack stack, int eatingParticleCount){}
}
8 changes: 8 additions & 0 deletions src/main/java/net/minecraftforge/common/util/EnumHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.common.base.Predicate;
import com.google.common.collect.Lists;

import net.minecraftforge.common.IForgeAction;
import net.minecraftforge.fml.common.EnhancedRuntimeException;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraft.block.BlockPressurePlate.Sensitivity;
Expand Down Expand Up @@ -86,6 +87,13 @@ public static EnumAction addAction(String name)
return EnumHackery.addEnumEntry(EnumAction.class, name);
}
@Nullable
public static EnumAction addAction(String name, IForgeAction action)
{
return EnumHackery.addEnumEntry(EnumAction.class, name,
new Class<?>[]{IForgeAction.class},
new Object[]{action});
}
@Nullable
public static ArmorMaterial addArmorMaterial(String name, String textureName, int durability, int[] reductionAmounts, int enchantability, SoundEvent soundOnEquip, float toughness)
{
return EnumHackery.addEnumEntry(ArmorMaterial.class, name,
Expand Down