Jump to content

[1.11] Jetpack


abused_master

Recommended Posts

Hey y'all, im back, again

This time im working on a jetpack, yes a jetpack

Iv made the item, made it implement IEnergyContainerItem for power, made the model, and rendered it, all that stuff, but how can i make it so when the player is pressing space bar he gets jetpack flight, not creative flight, but ones like Redstone Arsenal had, and the player had to keep his hand on space otherwise he could fall and die

 

Link to comment
Share on other sites

Actually it would probably be better to detect when the button is pressed, then set a boolean to true and send a packet to make the boolean true on the server, this way you don't have the Player moved wrongly or some other alert message going in the server console. And then when it is released send a packet setting it to false and set it to false.

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

Actually it would probably be better to detect when the button is pressed, then set a boolean to true and send a packet to make the boolean true on the server, this way you don't have the Player moved wrongly or some other alert message going in the server console. And then when it is released send a packet setting it to false and set it to false.

Probably but again im terrible with packets, which is why with everything iv made i haven't used em, ill learn them but idk about rn

Link to comment
Share on other sites

would this be correct?

    @Override
    public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
        double x = player.posX;
        double y = player.posX;
        double z = player.posX;
        player.addVelocity(x, y, z);
        super.onArmorTick(world, player, itemStack);
    }

Link to comment
Share on other sites

would this be correct?

    @Override
    public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
        double x = player.posX;
        double y = player.posX;
        double z = player.posX;
        player.addVelocity(x, y, z);
        super.onArmorTick(world, player, itemStack);
    }

No x, y, z are different from velocity. Velocity is speed and direction, x, y, z are positions.

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

yeah i just got that, putting on the jetpack lags  the f*** outta me, RIP minecraft

so what values would i put in to make it how i want?

player.addVelocity(0, 0.2/** Running speed 0.1 walking speed*/, 0);

Also you may want to add a cap, y velocity.

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

yeah i just got that, putting on the jetpack lags  the f*** outta me, RIP minecraft

so what values would i put in to make it how i want?

player.addVelocity(0, 0.2/** Running speed 0.1 walking speed*/, 0);

Also you may want to add a cap, y velocity.

I see, thank you, so i just have to set it to detect the energy stored and if the player is pressing the space bar, and use energy, which should be easy :D

Link to comment
Share on other sites

I got all that stuff sorted but there are 2 problems,

#1 going up is too fast, would i change the

            
player.addVelocity(0, 0.2, 0);
to
player.addVelocity(0, 0.1, 0);

#2 the moment the player touches the ground he takes a ton of damage, even if its just 1 block above, a few more and he is dead, how can i fix that?

 

Link to comment
Share on other sites

I got all that stuff sorted but there are 2 problems,

#1 going up is too fast, would i change the

            
player.addVelocity(0, 0.2, 0);
to
player.addVelocity(0, 0.1, 0);

#2 the moment the player touches the ground he takes a ton of damage, even if its just 1 block above, a few more and he is dead, how can i fix that?

Could you post code so I can see what you tried.

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

    @Override
    public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
        if(KeybindHandler.keybind.isKeyDown()) {
            player.addVelocity(0, 0.2, 0);
        }
        super.onArmorTick(world, player, itemStack);
    }

or do u want my entire class code?

Link to comment
Share on other sites

    @Override
    public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
        if(KeybindHandler.keybind.isKeyDown()) {
            player.addVelocity(0, 0.2, 0);
        }
        super.onArmorTick(world, player, itemStack);
    }

or do u want my entire class code?

nah that is good, but i would add an if else statement like

if (player.motionY >= someVelocity) {
     // Do stuff
} else {
     // Add velocity
}

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

To avoid damage, you need to set the player's fall distance back to 0.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

To avoid damage, you need to set the player's fall distance back to 0.

how can i do that?

player.fallDistance = 0;

?

Two ways either Subscribe to the LivingFallEvent or litterally in your onArmorTick constantly set it to 0.

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

To avoid damage, you need to set the player's fall distance back to 0.

how can i do that?

player.fallDistance = 0;

?

Two ways either Subscribe to the LivingFallEvent or litterally in your onArmorTick constantly set it to 0.

All right ill take care of that in a bit, but running into a bit of a problem,

when i charge up the jetpack in my inventory it also charges all the jetpacks in the world, how do i fix that?

 

Link to comment
Share on other sites

To avoid damage, you need to set the player's fall distance back to 0.

how can i do that?

player.fallDistance = 0;

?

Two ways either Subscribe to the LivingFallEvent or litterally in your onArmorTick constantly set it to 0.

All right ill take care of that in a bit, but running into a bit of a problem,

when i charge up the jetpack in my inventory it also charges all the jetpacks in the world, how do i fix that?

Make a ItemStack capability for energy items.

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

so

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

?

or am is that completely wrong and i have to do something else

Post your whole class.

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

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);
    }
}

 

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.