Jump to content

[1.11] Jetpack


abused_master

Recommended Posts

public class LeadJetpack extends ItemArmor implements IEnergyContainerItem {

    public EnergyStorage storage = new EnergyStorage(100000);

    ModelLeadJetpack pack;


    public LeadJetpack(ArmorMaterial materialIn, int renderIndexIn, EntityEquipmentSlot equipmentSlotIn) {
        super(materialIn, renderIndexIn, equipmentSlotIn);
        this.setCreativeTab(TechExpansion.TechExpansion);
        this.setMaxStackSize(1);
        this.setUnlocalizedName("lead_jetpack");
    }

    @SideOnly(Side.CLIENT)
    public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, net.minecraft.client.model.ModelBiped _default)
    {
        return ModelLeadJetpack.INSTANCE;
    }

    @Nullable
    @Override
    public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) {
        return super.getArmorTexture(stack, entity, slot, type);
    }

    @Override
    public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
        if(KeybindHandler.keybind.isKeyDown() && storage.getEnergyStored() > 200) {
            storage.setEnergyStored(storage.getEnergyStored() - 50);
            player.addVelocity(0, 0.1, 0);
            player.fallDistance = 0;
        }
        super.onArmorTick(world, player, itemStack);
    }

    @Override
    public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
        return storage.receiveEnergy(maxReceive, simulate);
    }

    @Override
    public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
        return 0;
    }

    @Override
    public int getEnergyStored(ItemStack container) {
        return storage.getEnergyStored();
    }

    @Override
    public int getMaxEnergyStored(ItemStack container) {
        return storage.getMaxEnergyStored();
    }

    @Nullable
    @Override
    public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
        return super.initCapabilities(stack, nbt);
    }
}

I think you will want to create a new one and then in the methods you need to call the super if it doesn't match yours. IE

@Override
public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) {
	ICapabilityProvider superProvider = super.initCapabilities(stack, nbt);
	return new ICapabilityProvider() {

		@Override
		public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
			return capability == yourCapability ? true : superProvider.hasCapability(capability, facing);
		}

		@Override
		public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
			return capability == yourCapability ? yourCapability : superProvider.getCapability(capability, facing);
		}
	};
}

I don't see how you could incorporate facing into an Item, but...ehh.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

yourCapability? do i have to create my own capability? and if so how?

Yes you will have to create your own capability. The forge documentation is a little low, but there are examples out there Choonster has some example on his github. There is also this which helped me understand what I need for a capability specifically.

https://github.com/Choonster?tab=repositories

http://www.planetminecraft.com/blog/forge-tutorial-capability-system/

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.