
moyas1009
Members-
Posts
10 -
Joined
-
Last visited
Everything posted by moyas1009
-
Capability Resets On Rejoining World [1.16.5]
moyas1009 replied to moyas1009's topic in Modder Support
Yeah its definitely saving, but you were right, I checked my readNBT method and I was using the wrong setter method, It works now, thanks -
Hi, I'm having a problem, I implemented a capability but whenever I leave and rejoin the world it resets to the default value, I've tried copying player data from the playerclone event. Should I copy the data over on another event or what should I do so it persists?
-
Hi, I am making a new layer for the Player model, I have already gotten the layer to render in. My question is how do I make it so the layer has a texture because out of all the things I've tried none have worked. Any help would be greatly appreciated
-
Hi, I'm making a layer that goes over the player's head, so far I've gotten the model to render correctly but I don't know what to put in the json so that the texture renders or if I should even make a json in the first place, any help is greatly appreciated
-
Hi, I managed to Render a new Layer over the players head, couple issues though, first, it has no texture. Second, It doesnt move attached to the player. Any idea how to solve it? @Override public void render(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, T entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { matrixStackIn.push(); matrixStackIn.translate(0.0D, -0.0D, -0.00D); this.getEntityModel().copyModelAttributesTo((EntityModel<T>) this.MODEL); this.MODEL.setRotationAngles(entitylivingbaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch); IVertexBuilder ivertexbuilder = ItemRenderer.getBuffer(bufferIn, this.MODEL.getRenderType(TEXTURE_DOJUTSU), false, false); this.MODEL.render(matrixStackIn, ivertexbuilder, packedLightIn, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F); matrixStackIn.pop(); } Render Method for the Layer public class DojutsuModel extends BipedModel<LivingEntity> { private final ModelRenderer Head; public DojutsuModel(float size) { super(size, 0, 32, 32); Head = new ModelRenderer(this); Head.setRotationPoint(0.0F, 0.0F, 0.0F); setRotationAngle(Head, -0.1047F, 0.0873F, 0.0F); Head.setTextureOffset(0, 0).addBox(-4.0F, -8.0F, -4.0F, 8.0F, 8.0F, 8.0F, 0.0F, false); bipedBody.addChild(Head); } //@Override //public void setRotationAngles(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch){ //previously the render function, render code was moved to a method below //} @Override public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){ Head.render(matrixStack, buffer, packedLight, packedOverlay); } public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { modelRenderer.rotateAngleX = x; modelRenderer.rotateAngleY = y; modelRenderer.rotateAngleZ = z; } Model
-
That was the problem, thanks, don't know how I didn't get that before lol
-
Hi, I would like to know where I need to register the handler of the attachCapabilities event, I tried with the @Mod.EventBusSubscriber annotation and that didn't work so where should I register it ?
-
So what should i do?
-
So do I need to subscribe it in my main class or what ?
-
Hi, don't know what I'm doing wrong I'm trying to attach a capability to a player IChakra package com.moyas1009.mnarutomod.capabilities; public interface IChakra { public void consume(float points); public void fill(float points); public void set(float points); public float getChakra(); } Chakra package com.moyas1009.mnarutomod.capabilities; public class Chakra implements IChakra { private float chakra = 250F; @Override public void consume(float points) { this.chakra -= points; if (this.chakra < 0.0f) { this.chakra = 0.0f; } } @Override public void fill(float points) { this.chakra += points; } @Override public void set(float points) { this.chakra = points; } @Override public float getChakra() { return chakra; } } ChakraCapability package com.moyas1009.mnarutomod.capabilities; import net.minecraft.nbt.FloatNBT; import net.minecraft.util.Direction; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.common.capabilities.ICapabilitySerializable; import net.minecraftforge.common.util.LazyOptional; import javax.annotation.Nonnull; import javax.annotation.Nullable; public class ChakraCapability implements ICapabilitySerializable<FloatNBT> { @CapabilityInject(IChakra.class) public static final Capability<Chakra> CHAKRA_CAPABILITY = null; private LazyOptional<Chakra> instance = LazyOptional.of(CHAKRA_CAPABILITY::getDefaultInstance); public static void register() { CapabilityManager.INSTANCE.register(IChakra.class, new ChakraStorage(), Chakra::new); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { return CHAKRA_CAPABILITY.orEmpty(cap, instance); } @Override public FloatNBT serializeNBT() { return (FloatNBT) CHAKRA_CAPABILITY.getStorage().writeNBT(CHAKRA_CAPABILITY, instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional cannot be empty")), null); } @Override public void deserializeNBT(FloatNBT nbt) { CHAKRA_CAPABILITY.getStorage().readNBT(CHAKRA_CAPABILITY, instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional cannot be empty")), null, nbt); } } ChakraStorage package com.moyas1009.mnarutomod.capabilities; import net.minecraft.command.arguments.NBTCompoundTagArgument; import net.minecraft.command.arguments.NBTTagArgument; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.FloatNBT; import net.minecraft.nbt.INBT; import net.minecraft.util.Direction; import net.minecraftforge.common.capabilities.Capability; import javax.annotation.Nullable; public class ChakraStorage implements Capability.IStorage<IChakra> { @Nullable @Override public INBT writeNBT(Capability<IChakra> capability, IChakra instance, Direction side) { return FloatNBT.valueOf(instance.getChakra()); } @Override public void readNBT(Capability<IChakra> capability, IChakra instance, Direction side, INBT nbt) { if (!(instance instanceof Chakra)) throw new IllegalArgumentException("Can not deserialize to an instance that isn't the default implementation"); instance.set(((FloatNBT)nbt).getFloat()); } } CapabilityHandler @Mod.EventBusSubscriber(modid = NarutoMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class CapabilityHandler { public static final ResourceLocation PLAYER_CHAKRA = new ResourceLocation(NarutoMod.MOD_ID, "chakra"); @SubscribeEvent public void attachCapability(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof PlayerEntity) event.addCapability(PLAYER_CHAKRA, new ChakraCapability()); Logger logger = LogManager.getLogger(); logger.log(Level.DEBUG, "It fires"); } } My problem is whenever I create a world to test there doesn't seem to be a capability attatched to my player, I check the nbt tags with the /data command and with an nbt editor and the capability doesn't show up