Skip to content

Commit 42ed354

Browse files
committed
Polish armor code
Set bonuses will also now be instantly removed upon the removal of a full set instead of being left at a few seconds.
1 parent 4b6e9f4 commit 42ed354

File tree

2 files changed

+52
-45
lines changed

2 files changed

+52
-45
lines changed

src/main/java/drzhark/mocreatures/MoCTools.java

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import net.minecraft.init.Items;
3838
import net.minecraft.init.MobEffects;
3939
import net.minecraft.init.SoundEvents;
40-
import net.minecraft.inventory.EntityEquipmentSlot;
4140
import net.minecraft.item.Item;
4241
import net.minecraft.item.ItemFood;
4342
import net.minecraft.item.ItemSeeds;
@@ -700,43 +699,6 @@ public static void destroyBlast(Entity entity, double d, double d1, double d2, f
700699
}
701700
}
702701

703-
public static void updatePlayerArmorEffects(EntityPlayer player) {
704-
if (!MoCreatures.proxy.armorSetEffects) return;
705-
706-
Item boots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET).getItem(); // Boots
707-
Item legs = player.getItemStackFromSlot(EntityEquipmentSlot.LEGS).getItem(); // Leggings
708-
Item plate = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem(); // Chestplate
709-
Item helmet = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).getItem(); // Helmet
710-
711-
// Dark Scorpion Armor Set Effect - Night Vision
712-
if (boots == MoCItems.scorpBootsCave && legs == MoCItems.scorpLegsCave && plate == MoCItems.scorpPlateCave && helmet == MoCItems.scorpHelmetCave) {
713-
player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, 300, 0, true, false));
714-
return;
715-
}
716-
717-
// Fire Scorpion Armor Set Effect - Fire Resistance
718-
if (boots == MoCItems.scorpBootsNether && legs == MoCItems.scorpLegsNether && plate == MoCItems.scorpPlateNether && helmet == MoCItems.scorpHelmetNether) {
719-
player.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 300, 0, true, false));
720-
return;
721-
}
722-
723-
// Frost Scorpion Armor Set Effect - Resistance
724-
if (boots == MoCItems.scorpBootsFrost && legs == MoCItems.scorpLegsFrost && plate == MoCItems.scorpPlateFrost && helmet == MoCItems.scorpHelmetFrost) {
725-
player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 300, 0, true, false));
726-
return;
727-
}
728-
729-
// Earth Scorpion Armor Set Effect - Speed II
730-
if (boots == MoCItems.scorpBootsDirt && legs == MoCItems.scorpLegsDirt && plate == MoCItems.scorpPlateDirt && helmet == MoCItems.scorpHelmetDirt) {
731-
player.addPotionEffect(new PotionEffect(MobEffects.SPEED, 300, 1, true, false));
732-
}
733-
734-
// Undead Scorpion Armor Set Effect - Strength
735-
if (boots == MoCItems.scorpBootsUndead && legs == MoCItems.scorpLegsUndead && plate == MoCItems.scorpPlateUndead && helmet == MoCItems.scorpHelmetUndead) {
736-
player.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 300, 0, true, false));
737-
}
738-
}
739-
740702
public static IBlockState destroyRandomBlockWithIBlockState(Entity entity, double distance) {
741703
int l = (int) (distance * distance * distance);
742704
for (int i = 0; i < l; i++) {

src/main/java/drzhark/mocreatures/item/MoCItemArmor.java

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
import net.minecraft.client.util.ITooltipFlag;
1111
import net.minecraft.entity.Entity;
1212
import net.minecraft.entity.player.EntityPlayer;
13+
import net.minecraft.init.MobEffects;
1314
import net.minecraft.inventory.EntityEquipmentSlot;
15+
import net.minecraft.item.Item;
1416
import net.minecraft.item.ItemArmor;
1517
import net.minecraft.item.ItemStack;
18+
import net.minecraft.potion.PotionEffect;
1619
import net.minecraft.util.text.Style;
1720
import net.minecraft.util.text.TextComponentTranslation;
1821
import net.minecraft.util.text.TextFormatting;
@@ -24,7 +27,6 @@
2427
import java.util.List;
2528

2629
public class MoCItemArmor extends ItemArmor {
27-
2830
public MoCItemArmor(String name, ItemArmor.ArmorMaterial materialIn, int renderIndex, EntityEquipmentSlot equipmentSlotIn) {
2931
super(materialIn, renderIndex, equipmentSlotIn);
3032
this.setCreativeTab(MoCreatures.tabMoC);
@@ -35,64 +37,75 @@ public MoCItemArmor(String name, ItemArmor.ArmorMaterial materialIn, int renderI
3537
@Override
3638
public String getArmorTexture(ItemStack itemstack, Entity entity, EntityEquipmentSlot slot, String type) {
3739
String tempArmorTexture = "croc_1.png";
40+
3841
if ((itemstack.getItem() == MoCItems.helmetCroc) || (itemstack.getItem() == MoCItems.plateCroc) || (itemstack.getItem() == MoCItems.bootsCroc)) {
3942
tempArmorTexture = "croc_1.png";
4043
}
44+
4145
if (itemstack.getItem() == MoCItems.legsCroc) {
4246
tempArmorTexture = "croc_2.png";
4347
}
4448

4549
if ((itemstack.getItem() == MoCItems.helmetFur) || (itemstack.getItem() == MoCItems.chestFur) || (itemstack.getItem() == MoCItems.bootsFur)) {
4650
tempArmorTexture = "fur_1.png";
4751
}
52+
4853
if (itemstack.getItem() == MoCItems.legsFur) {
4954
tempArmorTexture = "fur_2.png";
5055
}
5156

5257
if ((itemstack.getItem() == MoCItems.helmetHide) || (itemstack.getItem() == MoCItems.chestHide) || (itemstack.getItem() == MoCItems.bootsHide)) {
5358
tempArmorTexture = "hide_1.png";
5459
}
60+
5561
if (itemstack.getItem() == MoCItems.legsHide) {
5662
tempArmorTexture = "hide_2.png";
5763
}
5864

5965
if ((itemstack.getItem() == MoCItems.scorpHelmetDirt) || (itemstack.getItem() == MoCItems.scorpPlateDirt) || (itemstack.getItem() == MoCItems.scorpBootsDirt)) {
6066
tempArmorTexture = "scorpd_1.png";
6167
}
68+
6269
if (itemstack.getItem() == MoCItems.scorpLegsDirt) {
6370
tempArmorTexture = "scorpd_2.png";
6471
}
6572

6673
if ((itemstack.getItem() == MoCItems.scorpHelmetFrost) || (itemstack.getItem() == MoCItems.scorpPlateFrost) || (itemstack.getItem() == MoCItems.scorpBootsFrost)) {
6774
tempArmorTexture = "scorpf_1.png";
6875
}
76+
6977
if (itemstack.getItem() == MoCItems.scorpLegsFrost) {
7078
tempArmorTexture = "scorpf_2.png";
7179
}
7280

7381
if ((itemstack.getItem() == MoCItems.scorpHelmetCave) || (itemstack.getItem() == MoCItems.scorpPlateCave) || (itemstack.getItem() == MoCItems.scorpBootsCave)) {
7482
tempArmorTexture = "scorpc_1.png";
7583
}
84+
7685
if (itemstack.getItem() == MoCItems.scorpLegsCave) {
7786
tempArmorTexture = "scorpc_2.png";
7887
}
7988

8089
if ((itemstack.getItem() == MoCItems.scorpHelmetNether) || (itemstack.getItem() == MoCItems.scorpPlateNether) || (itemstack.getItem() == MoCItems.scorpBootsNether)) {
8190
tempArmorTexture = "scorpn_1.png";
8291
}
92+
8393
if (itemstack.getItem() == MoCItems.scorpLegsNether) {
8494
tempArmorTexture = "scorpn_2.png";
8595
}
8696

8797
if ((itemstack.getItem() == MoCItems.scorpHelmetUndead) || (itemstack.getItem() == MoCItems.scorpPlateUndead) || (itemstack.getItem() == MoCItems.scorpBootsUndead)) {
8898
tempArmorTexture = "scorpu_1.png";
8999
}
100+
90101
if (itemstack.getItem() == MoCItems.scorpLegsUndead) {
91102
tempArmorTexture = "scorpu_2.png";
92103
}
104+
93105
if ((itemstack.getItem() == MoCItems.helmetSilver) || (itemstack.getItem() == MoCItems.chestSilver) || (itemstack.getItem() == MoCItems.bootsSilver)) {
94106
tempArmorTexture = "silver_1.png";
95107
}
108+
96109
if (itemstack.getItem() == MoCItems.legsSilver) {
97110
tempArmorTexture = "silver_2.png";
98111
}
@@ -105,12 +118,39 @@ public String getArmorTexture(ItemStack itemstack, Entity entity, EntityEquipmen
105118
*/
106119
@Override
107120
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
108-
if (player.ticksExisted % 40 == 0) {
109-
player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
110-
ItemStack stack = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
111-
if (!stack.isEmpty() && stack.getItem() instanceof MoCItemArmor) {
112-
MoCTools.updatePlayerArmorEffects(player);
113-
}
121+
if (!MoCreatures.proxy.armorSetEffects) return;
122+
123+
Item boots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET).getItem(); // Boots
124+
Item legs = player.getItemStackFromSlot(EntityEquipmentSlot.LEGS).getItem(); // Leggings
125+
Item plate = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem(); // Chestplate
126+
Item helmet = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).getItem(); // Helmet
127+
128+
// Dark Scorpion Armor Set Effect - Night Vision
129+
if (boots == MoCItems.scorpBootsCave && legs == MoCItems.scorpLegsCave && plate == MoCItems.scorpPlateCave && helmet == MoCItems.scorpHelmetCave) {
130+
player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, 2, 0, true, false));
131+
return;
132+
}
133+
134+
// Fire Scorpion Armor Set Effect - Fire Resistance
135+
if (boots == MoCItems.scorpBootsNether && legs == MoCItems.scorpLegsNether && plate == MoCItems.scorpPlateNether && helmet == MoCItems.scorpHelmetNether) {
136+
player.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 2, 0, true, false));
137+
return;
138+
}
139+
140+
// Frost Scorpion Armor Set Effect - Resistance
141+
if (boots == MoCItems.scorpBootsFrost && legs == MoCItems.scorpLegsFrost && plate == MoCItems.scorpPlateFrost && helmet == MoCItems.scorpHelmetFrost) {
142+
player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 2, 0, true, false));
143+
return;
144+
}
145+
146+
// Earth Scorpion Armor Set Effect - Speed II
147+
if (boots == MoCItems.scorpBootsDirt && legs == MoCItems.scorpLegsDirt && plate == MoCItems.scorpPlateDirt && helmet == MoCItems.scorpHelmetDirt) {
148+
player.addPotionEffect(new PotionEffect(MobEffects.SPEED, 2, 1, true, false));
149+
}
150+
151+
// Undead Scorpion Armor Set Effect - Strength
152+
if (boots == MoCItems.scorpBootsUndead && legs == MoCItems.scorpLegsUndead && plate == MoCItems.scorpPlateUndead && helmet == MoCItems.scorpHelmetUndead) {
153+
player.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 2, 0, true, false));
114154
}
115155
}
116156

@@ -120,26 +160,31 @@ public void addInformation(ItemStack stack, @Nullable World worldIn, List<String
120160
if ((this == MoCItems.scorpHelmetDirt) || (this == MoCItems.scorpPlateDirt) || (this == MoCItems.scorpLegsDirt) || (this == MoCItems.scorpBootsDirt)) {
121161
tooltip.add(new TextComponentTranslation("info.mocreatures.setbonus").setStyle(new Style().setColor(TextFormatting.GRAY)).getFormattedText());
122162
tooltip.add(" " + new TextComponentTranslation("info.mocreatures.setbonusscorp1").setStyle(new Style().setColor(TextFormatting.BLUE)).getFormattedText());
163+
tooltip.add("");
123164
}
124165

125166
if ((this == MoCItems.scorpHelmetFrost) || (this == MoCItems.scorpPlateFrost) || (this == MoCItems.scorpLegsFrost) || (this == MoCItems.scorpBootsFrost)) {
126167
tooltip.add(new TextComponentTranslation("info.mocreatures.setbonus").setStyle(new Style().setColor(TextFormatting.GRAY)).getFormattedText());
127168
tooltip.add(" " + new TextComponentTranslation("info.mocreatures.setbonusscorp2").setStyle(new Style().setColor(TextFormatting.BLUE)).getFormattedText());
169+
tooltip.add("");
128170
}
129171

130172
if ((this == MoCItems.scorpHelmetNether) || (this == MoCItems.scorpPlateNether) || (this == MoCItems.scorpLegsNether) || (this == MoCItems.scorpBootsNether)) {
131173
tooltip.add(new TextComponentTranslation("info.mocreatures.setbonus").setStyle(new Style().setColor(TextFormatting.GRAY)).getFormattedText());
132174
tooltip.add(" " + new TextComponentTranslation("info.mocreatures.setbonusscorp3").setStyle(new Style().setColor(TextFormatting.BLUE)).getFormattedText());
175+
tooltip.add("");
133176
}
134177

135178
if ((this == MoCItems.scorpHelmetCave) || (this == MoCItems.scorpPlateCave) || (this == MoCItems.scorpLegsCave) || (this == MoCItems.scorpBootsCave)) {
136179
tooltip.add(new TextComponentTranslation("info.mocreatures.setbonus").setStyle(new Style().setColor(TextFormatting.GRAY)).getFormattedText());
137180
tooltip.add(" " + new TextComponentTranslation("info.mocreatures.setbonusscorp4").setStyle(new Style().setColor(TextFormatting.BLUE)).getFormattedText());
181+
tooltip.add("");
138182
}
139183

140184
if ((this == MoCItems.scorpHelmetUndead) || (this == MoCItems.scorpPlateUndead) || (this == MoCItems.scorpLegsUndead) || (this == MoCItems.scorpBootsUndead)) {
141185
tooltip.add(new TextComponentTranslation("info.mocreatures.setbonus").setStyle(new Style().setColor(TextFormatting.GRAY)).getFormattedText());
142186
tooltip.add(" " + new TextComponentTranslation("info.mocreatures.setbonusscorp5").setStyle(new Style().setColor(TextFormatting.BLUE)).getFormattedText());
187+
tooltip.add("");
143188
}
144189
}
145190
}

0 commit comments

Comments
 (0)