Everything posted by Nozzomi
-
[SOLVED] [1.15.2] Capability#getDefaultInstance is returning null
It's as the title says; I'm having trouble with my capabilities :( Here are the classes that are relevant: Main class Capability class log:
-
Has anyone used Floobits to collaborate with another person to develop a mod?
I'm not sure if this is the right place for this (might belong in general discussion), but the question is in the title. If so, I would like to know how it went down, complications, and etc. Will my friend have to rebuild the project after importing it? Also, how does it work with git if only one end is commiting to the rep?
-
[Solved][1.14] Adding to the player HUD
@desht @Oscarita25 Thanks guys! It worked out!
-
[Solved][1.14] Adding to the player HUD
I am trying to add something like a mana bar to the player's HUD but can't find a way to do so. From looking at a ton of different examples (i.e. RWTema's Monk Mod and coolAlias' Tutorial-Demo), a lot of things has changed since 1.12, and I'm not sure what to extend because some files are unable to be viewed. Currently, I am trying to use the RenderGameOverlayEvent.Post event to get the overlay to render, but extending either AbstractGui or IngameGui lead to some problems. It seems that drawTexturedModalRect() is gone and nowhere to be seen. From all the examples I think I need to do something with the Tessellator and TextureAtlasSprite classes. Could anyone give me a hint or lead me in the right direction?
-
[1.12.2] Stop the player from opening their inventory
Is there any way for me to stop a player from opening their inventory? I've tried to use the PlayerContainerEvent.Open to catch whenever the player opened their inventory, but it seems that canceling that event doesn't really do any good. Do any of you guys have suggestions for ways to do this?
-
[1.12.2] Damage on sword keeps resetting
So, I have coded a sword which has an ability to teleport behind an entity when right-clicking, and that will cause damage to the sword. However, whenever I hit with the sword or right-click after pausing for a while, the durability will go back up to what it was before I vigorously used it (for testing). Here is the code: package io.nozzomi.improvisedarmory.items.swords; import java.util.List; import javax.annotation.Nullable; import io.nozzomi.improvisedarmory.Main; import io.nozzomi.improvisedarmory.init.ModItems; import io.nozzomi.improvisedarmory.util.IHasModel; import io.nozzomi.improvisedarmory.util.Utilities; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.IItemPropertyGetter; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class SwordTrickery extends ItemSword implements IHasModel { public int cooldown = 0; public int overCooldown = 0; public int stage = 0; public SwordTrickery() { super(ModItems.MATERIAL_TRICKERY); this.setUnlocalizedName("sword_trickery"); this.setRegistryName("sword_trickery"); this.setCreativeTab(Main.tabImprovised); this.addPropertyOverride(new ResourceLocation("onCooldown"), new IItemPropertyGetter() { @SideOnly(Side.CLIENT) @Override public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) { return stage; } }); ModItems.ITEMS.add(this); } @Override public void registerModels() { Main.proxy.registerItemRenderer(this, 0, "inventory"); } @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack item = player.getHeldItem(hand); Entity e = Utilities.getMouseOver(5); if(e != null && e instanceof EntityLiving) { Vec3d aim = e.getLookVec(); if(world.isAirBlock(new BlockPos(e.posX - aim.x * 2, e.posY, e.posZ - aim.z * 2)) || !world.isBlockFullCube(new BlockPos(e.posX - aim.x * 2, e.posY, e.posZ - aim.z * 2))) { if(cooldown <= 0) { if(!player.capabilities.isCreativeMode) { item.damageItem(20*stage, player); } player.setPositionAndRotation(e.posX - aim.x * 2, e.posY, e.posZ - aim.z * 2, e.rotationYaw, player.rotationPitch); cooldown = 20; overCooldown = 1200; stage += stage < 4 ? 1 : 0; } } } return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, item); } @Override public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) { tooltip.add("Current Stage: 0"); } @Override public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { switch(stage) { case 0: stack.damageItem(1, attacker); break; case 1: stack.damageItem(5, attacker); break; case 2: stack.damageItem(15, attacker); break; case 3: stack.damageItem(30, attacker); break; case 4: stack.damageItem(50, attacker); break; default: stack.damageItem(1, attacker); break; } return true; } @Override public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if(cooldown != 0) cooldown--; if(overCooldown != 0) overCooldown--; if(overCooldown == 0 && stage != 0) stage = 0; } }
IPS spam blocked by CleanTalk.