- 51
- 8
- 5
Как мне запретить игроку вручную надевать или снимать броню? Даже в творческом
Вот моя броня
Вот моя броня
Java:
package com.nymoo.afp.common.items;
import com.nymoo.afp.common.tabs.TabPowerArmor;
import com.nymoo.afp.common.render.model.armor.ModelPowerArmor;
import com.nymoo.afp.ElementsAFP;
import com.nymoo.afp.common.utils.PowerArmorUtil;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ElementsAFP.ModElement.Tag
public class ArmorX03 extends ElementsAFP.ModElement {
@GameRegistry.ObjectHolder("afp:x03_helmet")
public static final Item helmet = null;
@GameRegistry.ObjectHolder("afp:x03_chestplate")
public static final Item body = null;
@GameRegistry.ObjectHolder("afp:x03_leggings")
public static final Item legs = null;
@GameRegistry.ObjectHolder("afp:x03_boots")
public static final Item boots = null;
@SideOnly(Side.CLIENT)
private ModelPowerArmor helmetModel;
@SideOnly(Side.CLIENT)
private ModelPowerArmor chestplateModel;
@SideOnly(Side.CLIENT)
private ModelPowerArmor chestplateModelJet;
@SideOnly(Side.CLIENT)
private ModelPowerArmor leggingsModel;
@SideOnly(Side.CLIENT)
private ModelPowerArmor bootsModel;
public ArmorX03(ElementsAFP instance) {
super(instance, 1);
}
@Override
public void initElements() {
ItemArmor.ArmorMaterial enuma = EnumHelper.addArmorMaterial("x03", "minecraft:diamond", 69, new int[]{20, 24, 30, 19}, 0,
(net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("")), 4f);
elements.items.add(() -> new ItemArmor(enuma, 0, EntityEquipmentSlot.HEAD) {
@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(EntityLivingBase living, ItemStack stack, EntityEquipmentSlot slot, ModelBiped defaultModel) {
if (helmetModel == null) {
helmetModel = new ModelPowerArmor(0, "x03", false);
}
return helmetModel;
}
}.setTranslationKey("x03_helmet").setRegistryName("x03_helmet").setCreativeTab(TabPowerArmor.tab));
elements.items.add(() -> new ItemArmor(enuma, 0, EntityEquipmentSlot.CHEST) {
@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(EntityLivingBase living, ItemStack stack, EntityEquipmentSlot slot, ModelBiped defaultModel) {
boolean jetpack = stack.hasTagCompound() && stack.getTagCompound().getBoolean("jetpack");
if (jetpack) {
if (chestplateModelJet == null) {
chestplateModelJet = new ModelPowerArmor(1, "x03", true);
}
return chestplateModelJet;
} else {
if (chestplateModel == null) {
chestplateModel = new ModelPowerArmor(1, "x03", false);
}
return chestplateModel;
}
}
}.setTranslationKey("x03_chestplate").setRegistryName("x03_chestplate").setCreativeTab(TabPowerArmor.tab));
elements.items.add(() -> new ItemArmor(enuma, 0, EntityEquipmentSlot.LEGS) {
@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(EntityLivingBase living, ItemStack stack, EntityEquipmentSlot slot, ModelBiped defaultModel) {
if (leggingsModel == null) {
leggingsModel = new ModelPowerArmor(2, "x03", false);
}
return leggingsModel;
}
}.setTranslationKey("x03_leggings").setRegistryName("x03_leggings").setCreativeTab(TabPowerArmor.tab));
elements.items.add(() -> new ItemArmor(enuma, 0, EntityEquipmentSlot.FEET) {
@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(EntityLivingBase living, ItemStack stack, EntityEquipmentSlot slot, ModelBiped defaultModel) {
if (bootsModel == null) {
bootsModel = new ModelPowerArmor(3, "x03", false);
}
return bootsModel;
}
}.setTranslationKey("x03_boots").setRegistryName("x03_boots").setCreativeTab(TabPowerArmor.tab));
}
@SideOnly(Side.CLIENT)
@Override
public void registerModels(ModelRegistryEvent event) {
ModelLoader.setCustomModelResourceLocation(helmet, 0, new ModelResourceLocation("afp:x03/x03_helmet", "inventory"));
ModelLoader.setCustomModelResourceLocation(legs, 0, new ModelResourceLocation("afp:x03/x03_leggings", "inventory"));
ModelLoader.setCustomModelResourceLocation(boots, 0, new ModelResourceLocation("afp:x03/x03_boots", "inventory"));
ModelLoader.setCustomMeshDefinition(body, stack -> {
boolean jetpack = stack.getTagCompound() != null && stack.getTagCompound().getBoolean("jetpack");
String modelPath = jetpack ? "afp:x03/x03_j_chestplate" : "afp:x03/x03_chestplate";
return new ModelResourceLocation(modelPath, "inventory");
});
ModelLoader.registerItemVariants(
body,
new ModelResourceLocation("afp:x03/x03_chestplate", "inventory"),
new ModelResourceLocation("afp:x03/x03_j_chestplate", "inventory")
);
}
}
Последнее редактирование: