Jump to content

Recommended Posts

Posted

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.

Posted
  On 7/23/2020 at 7:38 AM, littlemonge said:

it is just a custom entity for an object when you throw it on the ground

Expand  

An ItemEntity, Minecraft (or Forge, idk) makes one for your items automatically.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Posted
  On 7/23/2020 at 7:42 AM, Novârch said:

An ItemEntity, Minecraft (or Forge, idk) makes one for your items automatically.

Expand  

 

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

Posted

I'm not sure if you need to create one, but it won't be hard since you said your entity is just another version of ItemEntity (just look into renderer/entity/ItemRenderer).

and use 

RenderingRegistry.registerEntityRenderingHandler(entitytype, rendererf)

to register your renderer

Posted

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

 

  On 7/23/2020 at 9:14 AM, poopoodice said:

I'm not sure if you need to create one, but it won't be hard since you said your entity is just another version of ItemEntity (just look into renderer/entity/ItemRenderer).

and use 

RenderingRegistry.registerEntityRenderingHandler(entitytype, rendererf)

to register your renderer

Expand  

And this line its not working for me.

Posted
  On 7/23/2020 at 10:52 AM, littlemonge said:

And this line its not working for me.

Expand  

Please don't tell me you copied it word for word.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Posted
  On 7/23/2020 at 1:47 PM, littlemonge said:

ok no matter, I almost have it, the problem now is that the entity is invisible.

Expand  

Try overriding Entity#createSpawnPacket in your entity and return NetworkHooks#getEntitySpawningPacket from it.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Posted

firstly:

	@Override
	public boolean shouldRender(DiamoniteEntity livingEntityIn, ClippingHelperImpl camera, double camX, double camY,
			double camZ) {
		return false;
	}

secondly, you don't have any "render" method

 

@Override
public void render(...)

but isn't your entity bsaed on the ItemEntity? See how ItemRenderer does it.

  Quote

ItemEntity (just look into renderer/entity/ItemRenderer)

Expand  

 

Posted
  On 7/23/2020 at 2:57 PM, littlemonge said:

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?

Expand  

To check this, search your log for "FileNotFound" string. Likely will output only FileNotFoundException's stacktraces. All you need is to check comments after each - if minecraft can't find some texture that he needs, there would be a report about it.

 

You will likely find one about version checker file, don't care about that.

Everything said above may be absolutely wrong. No rights reserved.

Posted
  On 7/24/2020 at 10:57 AM, Dzuchun said:

To check this, search your log for "FileNotFound" string. Likely will output only FileNotFoundException's stacktraces. All you need is to check comments after each - if minecraft can't find some texture that he needs, there would be a report about it.

 

You will likely find one about version checker file, don't care about that.

Expand  

Im not having any exception.

Posted

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¿?

Posted (edited)
  On 7/27/2020 at 8:54 AM, littlemonge said:

matrixStackIn.push();

matrixStackIn.scale(1f, 1f, 1f);

matrixStackIn.translate(0.5d, 0.5D, 0.5D);

matrixStackIn.rotate(Vector3f.YP.rotationDegrees(360));

matrixStackIn.pop();

Expand  

This actually renders nothing. Superclass method renders name label, as I understood, so I predict your entity is not rendered at all.

There are two ways how to render things (they do the same, but differ at usage).

 

1) Create a model for your entity. Model should have a separate render method which invokes ModelRenderer#render, that actually does rendering.

Advantage: you may not perform rendering itself; drawback: you'll need to understand how this all works (but that's easy with a ton of examples from vanilla Minecraft and some experimenting).

 

2) Preform rendering with "bare hands" - using GL11 methods directly or some predefined sequences.

Advantage: you may render most mind-blowing things that could ever come to your head; drawback: you'll need to study OpenGL a bit (well, depends on rendering complexity).

 

Read sign.

Edited by Dzuchun

Everything said above may be absolutely wrong. No rights reserved.

  • 3 weeks later...
Posted
  On 7/27/2020 at 12:10 PM, Dzuchun said:

This actually renders nothing. Superclass method renders name label, as I understood, so I predict your entity is not rendered at all.

There are two ways how to render things (they do the same, but differ at usage).

 

1) Create a model for your entity. Model should have a separate render method which invokes ModelRenderer#render, that actually does rendering.

Advantage: you may not perform rendering itself; drawback: you'll need to understand how this all works (but that's easy with a ton of examples from vanilla Minecraft and some experimenting).

 

2) Preform rendering with "bare hands" - using GL11 methods directly or some predefined sequences.

Advantage: you may render most mind-blowing things that could ever come to your head; drawback: you'll need to study OpenGL a bit (well, depends on rendering complexity).

 

Read sign.

Expand  

Can you bring me an example for method 1?

Thanks a lot for answering

 

Posted (edited)
  On 8/14/2020 at 8:21 AM, littlemonge said:

Can you bring me an example for method 1?

Expand  

CowModel class and, I think, all the classes implementing EntityModel class (not sure)

 

Also, check blockbench.

Edited by Dzuchun

Everything said above may be absolutely wrong. No rights reserved.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi, I have a problem in minecraft java (only in forge 1.20.1), When I start the game after a moment the game crashed with code 1 this only in forge 1.20.1 , I tried to reinstall java, Upgrade java to 17, update the drivers to the latest version, downgrade the drivers to the pervious version, deleting .minecraft and reinstall it , but none of these ways working.   here is the log:   [Launcher] Launching Minecraft... I'm hiding! mods after C:\Users\Windows\AppData\Roaming\.minecraft\mods\tl_skin_cape_forge_1.20_1.20.1-1.32.jar [InnerMinecraftServersImpl]  search changers of the servers read servers from servers.dat [] [InnerMinecraftServersImpl]  prepare inner servers save servers to servers.dat [Launcher] Game skin type: TLAUNCHER [Launcher] Starting Minecraft Forge 1.20.1... [Launcher] Launching in: C:\Users\Windows\AppData\Roaming\.minecraft Starting garbage collector: 96 / 227 MB Garbage collector completed: 60 / 214 MB [Launcher] Processing post-launch actions. Assist launch: true =============================================================================================== [05:29:03] [main/INFO]: ModLauncher running: args [--username, *********, --version, Forge 1.20.1, --gameDir, C:\Users\Windows\AppData\Roaming\.minecraft, --assetsDir, C:\Users\Windows\AppData\Roaming\.minecraft\assets, --assetIndex, 5, --uuid, *************************************, --accessToken, вќ„вќ„вќ„вќ„вќ„вќ„вќ„вќ„, --clientId, null, --xuid, null, --userType, mojang, --versionType, modified, --width, 925, --height, 530, --launchTarget, forgeclient, --fml.forgeVersion, 47.3.22, --fml.mcVersion, 1.20.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20230612.114412] [05:29:04] [main/INFO]: ModLauncher 10.0.9+10.0.9+main.dcd20f30 starting: java version 17.0.12 by Oracle Corporation; OS Windows 10 arch amd64 version 10.0 [05:29:15] [main/INFO]: Loading ImmediateWindowProvider fmlearlywindow [05:29:24] [main/INFO]: Trying GL version 4.6 [05:29:60] [main/INFO]: Requested GL version 4.6 got version 4.6 [05:29:67] [main/INFO]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/Windows/AppData/Roaming/.minecraft/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar%23100!/ Service=ModLauncher Env=CLIENT FATAL ERROR in native method: Thread[pool-2-thread-1,5,main]: No context is current or a function that is not available in the current context was called. The JVM will abort execution.     at org.lwjgl.opengl.GL11C.nglGetString(org.lwjgl.opengl@3.3.1+7/Native Method)     at org.lwjgl.opengl.GL11C.glGetString(org.lwjgl.opengl@3.3.1+7/GL11C.java:978)     at net.minecraftforge.fml.earlydisplay.DisplayWindow.initRender(fmlearlydisplay@1.20.1-47.3.22/DisplayWindow.java:209)     at net.minecraftforge.fml.earlydisplay.DisplayWindow.lambda$start$5(fmlearlydisplay@1.20.1-47.3.22/DisplayWindow.java:292)     at net.minecraftforge.fml.earlydisplay.DisplayWindow$$Lambda$437/0x000001fab120a618.run(fmlearlydisplay@1.20.1-47.3.22/Unknown Source)     at java.util.concurrent.Executors$RunnableAdapter.call(java.base@17.0.12/Executors.java:539)     at java.util.concurrent.FutureTask.run(java.base@17.0.12/FutureTask.java:264)     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(java.base@17.0.12/ScheduledThreadPoolExecutor.java:304)     at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@17.0.12/ThreadPoolExecutor.java:1136)     at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@17.0.12/ThreadPoolExecutor.java:635)     at java.lang.Thread.run(java.base@17.0.12/Thread.java:842) Here I am! [VersionManager] Refreshing versions locally... [VersionManager] Versions has been refreshed (6 ms) [Launcher] Launcher exited. [Launcher] Minecraft closed with exit code: 1 flush now [Launcher] [Crash] Signature "Bad video drivers" matches! [Crash] Signature "Bad video drivers" matches! [Launcher] [Crash] Crash has been recognized! [Crash] Crash has been recognized! flush now
    • https://mclo.gs/9Byd16j Hi, I've had my BetterMC world for a couple days now (1.19.2 vers & Fabric loader) but recently whenever I try to open the profile the minecraft launcher crashes and provides this error code. I've checked both this forum and google and haven't found any similar problems or solution to my problem. I'm not the best at reading crash logs but I gathered that there's an issue with fabric possibly, so I re-downloaded the same one on the modpack, then the latest version for 1.19.2 fabric and the issue still occurred. What can I do now?
    • it works now but idk why lmao. i removed terrablender and it didnt work. i then left it for a couple of days and, when i came back, updated the mods that needed updating because "what's the worst that could happen". i then tried launching it and now it works. i genuenly have no clue what i did to make it work, othen than updating the mods. so, thanks for your help
  • Topics

×
×
  • Create New...

Important Information

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