Skip to content

Commit

Permalink
Merge branch 'master' into flybug
Browse files Browse the repository at this point in the history
  • Loading branch information
Alastors authored May 28, 2024
2 parents 93f048f + b4f208e commit 50d3663
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 66 deletions.
90 changes: 53 additions & 37 deletions src/main/java/emt/client/model/ModelSpecialArmor.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
@SideOnly(Side.CLIENT)
public class ModelSpecialArmor extends ModelBiped {

private static ModelSpecialArmor instance;

public ModelRenderer rightWing;
public ModelRenderer leftWing;
public ModelRenderer center;
Expand All @@ -30,41 +32,43 @@ public ModelSpecialArmor(float scale, int type) {
public ModelSpecialArmor(float scale, float offset, int type) {
super(scale, offset, type == 1 ? 128 : 64, type == 0 ? 32 : type == 1 ? 96 : 64);
this.type = type;
switch (this.type) {
case 1:
this.textureWidth = 128;
this.textureHeight = 96;
this.jetpack = new ModelRenderer(this, 16, 69);
this.jetpack.setTextureSize(64, 48);
this.jetpack.addBox(-4.0F, -12.0F, -2.0F, 8, 12 * 2, 4, scale * 2);
this.jetpack.setRotationPoint(0.0F, 0.0F + offset, 0.0F);
break;

case 2:
this.textureWidth = 64;
this.textureHeight = 64;
rightWing = new ModelRenderer(this, 24, 0 + 32);
rightWing.addBox(-11F, -1F, 0F, 11, 13, 1);
rightWing.setRotationPoint(-2F, 0F, 3F);
rightWing.setTextureSize(64, 32);
rightWing.mirror = false;
setRotation(rightWing, 0F, 0.1570796F, 0F);

leftWing = new ModelRenderer(this, 0, 0 + 32);
leftWing.addBox(0F, -1F, 0F, 11, 13, 1);
leftWing.setRotationPoint(2F, 0F, 3F);
leftWing.setTextureSize(64, 32);
leftWing.mirror = true;
setRotation(leftWing, 0F, -0.1570796F, 0F);

center = new ModelRenderer(this, 0, 14 + 32);
center.addBox(0F, 0F, 1F, 8, 14, 1);
center.setRotationPoint(-4F, 0F, 3F);
center.setTextureSize(64, 32);
center.mirror = true;
setRotation(center, 0F, 0F, 0F);
break;
}
this.textureWidth = 128;
this.textureHeight = 96;
this.jetpack = new ModelRenderer(this, 16, 69);
this.jetpack.setTextureSize(64, 48);
this.jetpack.addBox(-4.0F, -12.0F, -2.0F, 8, 12 * 2, 4, scale * 2);
this.jetpack.setRotationPoint(0.0F, 0.0F + offset, 0.0F);

this.textureWidth = 64;
this.textureHeight = 64;
rightWing = new ModelRenderer(this, 24, 0 + 32);
rightWing.addBox(-11F, -1F, 0F, 11, 13, 1);
rightWing.setRotationPoint(-2F, 0F, 3F);
rightWing.setTextureSize(64, 32);
rightWing.mirror = false;
setRotation(rightWing, 0F, 0.1570796F, 0F);

leftWing = new ModelRenderer(this, 0, 0 + 32);
leftWing.addBox(0F, -1F, 0F, 11, 13, 1);
leftWing.setRotationPoint(2F, 0F, 3F);
leftWing.setTextureSize(64, 32);
leftWing.mirror = true;
setRotation(leftWing, 0F, -0.1570796F, 0F);

center = new ModelRenderer(this, 0, 14 + 32);
center.addBox(0F, 0F, 1F, 8, 14, 1);
center.setRotationPoint(-4F, 0F, 3F);
center.setTextureSize(64, 32);
center.mirror = true;
setRotation(center, 0F, 0F, 0F);

}

public static ModelSpecialArmor getInstance() {
if (instance == null) instance = new ModelSpecialArmor();

return instance;
}

private void setRotation(ModelRenderer model, float x, float y, float z) {
Expand Down Expand Up @@ -96,6 +100,7 @@ public void render(Entity entity, float p_78088_2_, float p_78088_3_, float p_78
this.center.render(scale);
this.leftWing.render(scale);
this.rightWing.render(scale);
break;
}
}

Expand All @@ -105,6 +110,9 @@ public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_
if (this.isJumping) {
this.rightWing.rotateAngleY = 0.5f;
this.leftWing.rotateAngleY = -0.5f;
} else {
this.rightWing.rotateAngleY = 0.1570796F;
this.leftWing.rotateAngleY = -0.1570796F;
}

if (this.isSneak) {
Expand All @@ -113,14 +121,22 @@ public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_
this.jetpack.rotateAngleX = 0.5F;
break;
case 2:
this.center.offsetY -= 0.1;
this.rightWing.offsetY -= 0.1;
this.leftWing.offsetY -= 0.1;
this.center.rotateAngleX = 0.5F;
this.rightWing.rotateAngleX = 0.5F;
this.leftWing.rotateAngleX = 0.5F;
break;
}
} else {
switch (this.type) {
case 1:
this.jetpack.rotateAngleX = 0F;
break;
case 2:
this.center.rotateAngleX = 0F;
this.rightWing.rotateAngleX = 0F;
this.leftWing.rotateAngleX = 0F;
break;
}
}
}
}
25 changes: 21 additions & 4 deletions src/main/java/emt/client/model/ModelWings.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ModelWings extends ModelBiped {

@SideOnly(Side.CLIENT)
private static ModelWings instance = null;

public boolean isJumping = false;
ModelRenderer rightWing;
ModelRenderer leftWing;
Expand Down Expand Up @@ -41,6 +47,12 @@ public ModelWings() {
this.bipedBody.addChild(center);
}

public static ModelWings getInstance() {
if (instance == null) instance = new ModelWings();

return instance;
}

@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
this.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
Expand All @@ -55,20 +67,25 @@ private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleZ = z;
}

public void setRotationAngles(float f, float f1, float pt, float f3, float f4, float f5, Entity entity) {
public void setRotationAngles(float limbSwing, float limbSwingAmount, float playerTicksExisted,
float playerRotationYawHead, float playerRotationPitch, float f5, Entity entity) {

if (isJumping) {
this.rightWing.rotateAngleY = 0.5f;
this.leftWing.rotateAngleY = -0.5f;
} else {
this.rightWing.rotateAngleY = 0.1570796F;
this.leftWing.rotateAngleY = -0.1570796F;
}

if (entity.isSneaking()) {
this.center.offsetY -= 0.1;
this.rightWing.offsetY -= 0.1;
this.leftWing.offsetY -= 0.1;
this.center.rotateAngleX = 0.5F;
this.rightWing.rotateAngleX = 0.5F;
this.leftWing.rotateAngleX = 0.5F;
} else {
this.center.rotateAngleX = 0.0F;
this.rightWing.rotateAngleX = 0;
this.leftWing.rotateAngleX = 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -390,22 +390,23 @@ public int getTier(ItemStack itemStack) {
@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(EntityLivingBase entity, ItemStack stack, int armorSlot) {
try {
if (entity instanceof EntityPlayer) {
byte wing = stack.stackTagCompound.getByte("wing");
if (wing == JETPACK) {
ModelSpecialArmor mbm = new ModelSpecialArmor(1, 1);
return mbm;
} else if (wing != 0) {
ModelSpecialArmor mbm = new ModelSpecialArmor(1, 2);
mbm.isJumping = stack.stackTagCompound.getBoolean("isJumping");
return mbm;
if (entity instanceof EntityPlayer && stack != null && stack.stackTagCompound != null) {
byte wing = stack.stackTagCompound.getByte("wing");
if (wing == JETPACK) {
ModelSpecialArmor.getInstance().type = 1;
} else if (wing != 0) {
ModelSpecialArmor.getInstance().type = 2;
if (stack.stackTagCompound.hasKey("isJumping")) {
ModelSpecialArmor.getInstance().isJumping = stack.stackTagCompound.getBoolean("isJumping");
}
} else {
ModelSpecialArmor.getInstance().type = 0;
}
} catch (NullPointerException e) {
new ModelSpecialArmor(1, 0);
} else {
ModelSpecialArmor.getInstance().type = 0;
}
return new ModelSpecialArmor(1, 0);

return ModelSpecialArmor.getInstance();
}

@SuppressWarnings("unchecked")
Expand Down
21 changes: 9 additions & 12 deletions src/main/java/emt/item/armor/wings/ItemFeatherWing.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,13 @@ public String getArmorTexture(ItemStack stack, Entity entity, int slot, String t
@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(EntityLivingBase entity, ItemStack stack, int armorSlot) {
try {
if (entity instanceof EntityPlayer) {
ModelWings mw = new ModelWings();
mw.isJumping = stack.stackTagCompound.getBoolean("isJumping");
return mw;
}
} catch (NullPointerException e) {
return new ModelWings();
if (entity instanceof EntityPlayer && stack != null
&& stack.stackTagCompound != null
&& stack.stackTagCompound.hasKey("isJumping")) {
ModelWings.getInstance().isJumping = stack.stackTagCompound.getBoolean("isJumping");
}
return new ModelWings();

return ModelWings.getInstance();
}

@Override
Expand All @@ -72,12 +69,12 @@ public void useWings(EntityPlayer player, ItemStack stack, World world, float mo
int amount) {
NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(stack);

boolean isJmuping = nbtData.getBoolean("isJumping");
boolean isJumping = nbtData.getBoolean("isJumping");
boolean isHolding = nbtData.getBoolean("isHolding");

nbtData.setBoolean("isJumping", IC2.keyboard.isJumpKeyDown(player));

if (isJmuping) {
if (isJumping) {
byte f = nbtData.getByte("f");
nbtData.setBoolean("isHolding", true);
if (IC2.keyboard.isSneakKeyDown(player)) nbtData.setByte("f", (byte) (0));
Expand Down Expand Up @@ -108,7 +105,7 @@ public void useWings(EntityPlayer player, ItemStack stack, World world, float mo
nbtData.setByte("f", (byte) 0);
}

if (isJmuping && !player.onGround && player.motionY < 0) {
if (isJumping && !player.onGround && player.motionY < 0) {
player.motionY *= f1;
}

Expand Down

0 comments on commit 50d3663

Please sign in to comment.