
littlemonge
Members-
Posts
21 -
Joined
-
Last visited
Everything posted by littlemonge
-
The entity i am trying to render it just an entity like ItemEntity, it is an entity that is created when player drops an item. There is not a way to do it easy?
-
Can you bring me an example for method 1? Thanks a lot for answering
-
Here is my render Class : package littlemonge.rpgcraft.render; import com.mojang.blaze3d.matrix.MatrixStack; import littlemonge.rpgcraft.entity.DiamoniteEntity; import littlemonge.rpgcraft.utils.ResourceLocationReference; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.util.ResourceLocation; public class DiamoniteEntityRenderer extends EntityRenderer<DiamoniteEntity> { public DiamoniteEntityRenderer(EntityRendererManager renderManagerIn) { super(renderManagerIn); } @Override public ResourceLocation getEntityTexture(DiamoniteEntity entity) { return new ResourceLocation(ResourceLocationReference.DIAMONITE_MODEL); } @Override public void render(DiamoniteEntity entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn) { matrixStackIn.push(); matrixStackIn.scale(1f, 1f, 1f); matrixStackIn.translate(0.5d, 0.5D, 0.5D); matrixStackIn.rotate(Vector3f.YP.rotationDegrees(360)); matrixStackIn.pop(); super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn); } } where is the mistake¿?
-
Im not having any exception.
-
I did what you says but i can only see the hitboxes. Could it be a problem with the path to the "png" with the texture?
-
ok no matter, I almost have it, the problem now is that the entity is invisible.
-
have I to impl "IRenderFactory"?
-
Here is the renderer : package littlemonge.rpgcraft.render; import littlemonge.rpgcraft.entity.DiamoniteEntity; import littlemonge.rpgcraft.utils.ResourceLocationReference; import net.minecraft.client.renderer.culling.ClippingHelperImpl; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; public class DiamoniteEntityRenderer<T extends Entity> extends EntityRenderer<DiamoniteEntity> { public DiamoniteEntityRenderer(EntityRendererManager renderManager) { super(renderManager); } @Override public ResourceLocation getEntityTexture(DiamoniteEntity entity) { return new ResourceLocation(ResourceLocationReference.DIAMONITE_MODEL); } @Override public boolean shouldRender(DiamoniteEntity livingEntityIn, ClippingHelperImpl camera, double camX, double camY, double camZ) { return false; } } And this line its not working for me.
-
Could you send an example of a Renderer please?
-
Yes, but I want to add some logic to ItemEntity, that's why I created the class. The class "DiamoniteEntity" its the custom ItemEntity for my custom DiamoniteItem
-
Can't use minecraft basic renderer? The entity is very simple, it is just a custom entity for an object when you throw it on the ground.
-
Hi , Im having some troubles working with entities... Here is my custom entity class : package littlemonge.rpgcraft.entity; import littlemonge.rpgcraft.entity.base.RpgCraftBaseEntity; import littlemonge.rpgcraft.item.DiamoniteItem; import littlemonge.rpgcraft.utils.Utils; import net.minecraft.block.Blocks; import net.minecraft.entity.EntityType; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class DiamoniteEntity extends RpgCraftBaseEntity { public static EntityType<DiamoniteEntity> ENTITY_TYPE; private int driedProgress = 0; public DiamoniteEntity(EntityType<? extends DiamoniteEntity> type, World world) { super(type, world); } public DiamoniteEntity(final World w, final double x, final double y, final double z, final ItemStack is) { super(ENTITY_TYPE, w, x, y, z, is); this.setNoDespawn(); } @Override public void tick() { super.tick(); final ItemStack itemStack = this.getItem(); final DiamoniteItem diamonite = (DiamoniteItem) itemStack.getItem(); if(this.onGround && (Utils.findBlockUnderEntity(this).equals(Blocks.MAGMA_BLOCK))){ if(Utils.isClient()) { driedProgress++; }else { driedProgress += 0.5; } } if(driedProgress % 10 == 0 ) { ItemStack newItem = diamonite.triggerDry(itemStack.copy()); this.setItem(newItem); } } } Here is where I register the entity : package littlemonge.rpgcraft.init; import littlemonge.rpgcraft.entity.DiamoniteEntity; import littlemonge.rpgcraft.utils.Reference; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityClassification; import net.minecraft.entity.EntityType; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.ObjectHolder; @Mod.EventBusSubscriber(modid = Reference.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) @ObjectHolder(Reference.MODID) public final class ModEntities { @SubscribeEvent public static void registerEntitites(RegistryEvent.Register<EntityType<?>> event) { init(); event.getRegistry().registerAll(DiamoniteEntity.ENTITY_TYPE); } private static void init() { DiamoniteEntity.ENTITY_TYPE = createEntityType(EntityType.Builder .<DiamoniteEntity>create(DiamoniteEntity::new, EntityClassification.MISC).size(0.25F, 0.25F) .setTrackingRange(64).setUpdateInterval(20).setShouldReceiveVelocityUpdates(false), Reference.DIAMONITE_ENTITY); } @SuppressWarnings("rawtypes") public static <T extends Entity> EntityType<T> createEntityType(EntityType.Builder builder, String name) { EntityType<T> type = (EntityType<T>) builder.build(Reference.MODID + '.' + name).setRegistryName(name); return type; } } And here its the crash : java.lang.NullPointerException: null at net.minecraft.client.renderer.entity.EntityRendererManager.shouldRender(EntityRendererManager.java:232) ~[forge-1.15.2-31.0.14_mapped_snapshot_20200131-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.WorldRenderer.getViewVector(WorldRenderer.java:940) ~[forge-1.15.2-31.0.14_mapped_snapshot_20200131-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.renderWorld(GameRenderer.java:612) ~[forge-1.15.2-31.0.14_mapped_snapshot_20200131-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.updateCameraAndRender(GameRenderer.java:434) ~[forge-1.15.2-31.0.14_mapped_snapshot_20200131-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:957) ~[forge-1.15.2-31.0.14_mapped_snapshot_20200131-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:554) ~[forge-1.15.2-31.0.14_mapped_snapshot_20200131-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:177) ~[forge-1.15.2-31.0.14_mapped_snapshot_20200131-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_231] {} at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_231] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_231] {} at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_231] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.15.2-31.0.14_mapped_snapshot_20200131-1.15.1-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-5.0.0-milestone.4.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-5.0.0-milestone.4.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-5.0.0-milestone.4.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-5.0.0-milestone.4.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-5.0.0-milestone.4.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:102) [forge-1.15.2-31.0.14_mapped_snapshot_20200131-1.15.1-recomp.jar:?] Can somebody please help me to find why im having a nullpointer? Thanks in advance.
-
Okey i change it thank you!
-
My enchantment its a tool repairing enchantment like mending but instead of working with experience it works with time ,every 30 sec (1200 minecraft tick),it repairs a tool use enchanted with it. So i done this on my tool class : @Override public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if (EnchantmentHelper.getEnchantments(stack).get(ModEnchantments.evil_mending) != null) { if (this.ticks == REPAIR_TIME_IN_SECONDS * TICKS_PER_SECOND) { this.ticks = 0; if (stack.isDamaged()) { stack.setDamage(stack.getDamage() - 1); } } else { ticks++; } } super.inventoryTick(stack, worldIn, entityIn, itemSlot, isSelected); }
-
Okey , so in my case I can made a method on Enchantment subclass and call it from tool class on every tick I want?
-
My question is if the Enchantment subclass its only for overriding properties or is it also to contain enchantment logic?
-
I have a custom class but i add the enchantment code on my custom tool class because is an enchantment for tools , in my enchantment subclass there is only the overrides of EnchantMent base properties.
-
I was looking for how enchantment logic are made on minecraft code. I found classes like "LoyaltyEnchantment" , "EfficiencyEnchantment" , and more classes like "StuffEnchatment" all of them inheriting from Enchantment class, so my question is where to add enchatment logic code from custom enchantment? Because no one of these classes has that code. Thanks in advance, regards
-
[SOLVED] [1.15.2] Adding enchantment a tool by default.
littlemonge replied to littlemonge's topic in Modder Support
Okey thanks!! -
[SOLVED] [1.15.2] Adding enchantment a tool by default.
littlemonge replied to littlemonge's topic in Modder Support
ok thanks for the quick reply , something else? -
[SOLVED] [1.15.2] Adding enchantment a tool by default.
littlemonge posted a topic in Modder Support
I'm new on modding and i have a question. I'm trying to add an enchantment to a custom tool by default , I've already done it but I think its not the best way. Here is my code: package littlemonge.rpgcraft.item.tools.icite; import java.util.List; import javax.annotation.Nullable; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.IItemTier; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.PickaxeItem; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.ListNBT; import net.minecraft.util.NonNullList; import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public class IcitePickaxeItem extends PickaxeItem { public IcitePickaxeItem(IItemTier tier, int attackDamageIn, float attackSpeedIn, Properties builder, String name) { super(tier, attackDamageIn, attackSpeedIn, builder); this.setRegistryName(name); } @Override public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) { super.fillItemGroup(group, items); for (ItemStack stack : items) { if (stack.getItem().equals(this)) { stack.addEnchantment(Enchantments.SILK_TOUCH, 1); } } } public void onCreated(ItemStack stack, World worldIn, PlayerEntity playerIn) { addSilkTouch(stack); } public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { addSilkTouch(stack); super.inventoryTick(stack, worldIn, entityIn, itemSlot, isSelected); } @OnlyIn(Dist.CLIENT) public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) { addSilkTouch(stack); super.addInformation(stack, worldIn, tooltip, flagIn); ItemStack.addEnchantmentTooltips(tooltip, getEnchantments(stack)); } public static ListNBT getEnchantments(ItemStack stack) { CompoundNBT compoundnbt = stack.getTag(); return compoundnbt != null ? compoundnbt.getList("StoredEnchantments", 10) : new ListNBT(); } private void addSilkTouch(ItemStack stack) { if (!stack.isEnchanted()) { stack.addEnchantment(Enchantments.SILK_TOUCH, 1); } else { if (EnchantmentHelper.getEnchantments(stack).get(Enchantments.SILK_TOUCH) == null) { stack.addEnchantment(Enchantments.SILK_TOUCH, 1); } } } } Thanks in advance, regards.