Jump to content

Recommended Posts

Posted (edited)

entity get shadow size is missing I used this for rendering entities in inventory based on the item's nbt similar to nei and that's how I scaled the entity for open gl based on that shadow size. How am I suppose to do this in 1.12.2 with no IItemRender and no shadow size?

 

yes this is missing no workaround for object orientation just hard code shadowsize = ent.height / 2.0F;

Edited by jredfox
Posted
On 4/11/2018 at 3:21 AM, diesieben07 said:

Render::shadowSize stores the value.

The renderer hashmaps even in post init appear to be empty I tried running this is my proxies post init

and it printed for the hashMaps:"[ ]"
 

public static void populateShadowSizes() 
	{
		System.out.println("Cacheing Shadow Sizes");
		RenderingRegistry rinstance = (RenderingRegistry) ReflectionUtil.getObject(null,RenderingRegistry.class, "INSTANCE");
		Map<Class<? extends Entity>, Render<? extends Entity>> entityRenderersOld = (Map<Class<? extends Entity>, Render<? extends Entity>>)ReflectionUtil.getObject(rinstance, RenderingRegistry.class, "entityRenderersOld");
		JavaUtil.printMap(entityRenderersOld);
		//populate list
		Map<Class<? extends Entity>, IRenderFactory<? extends Entity>> facRenders = (Map<Class<? extends Entity>, IRenderFactory<? extends Entity>>) ReflectionUtil.getObject(rinstance, RenderingRegistry.class, "entityRenderers");
		RenderManager rmanager = Minecraft.getMinecraft().getRenderManager();
		for(Class<? extends Entity> clazz : facRenders.keySet())
			entityRenderersOld.put(clazz, facRenders.get(clazz).createRenderFor(rmanager));
		
		for(Class clazz : entityRenderersOld.keySet())
		{
			ResourceLocation loc = EntityList.getKey(clazz);
			Render render = entityRenderersOld.get(clazz);
			Float shadowSize = (Float) ReflectionUtil.getObject(render, Render.class, MCPMappings.getField(Render.class, "shadowSize"));
			entShadows.put(loc,shadowSize);
		}
		for(ResourceLocation loc : entShadows.keySet())
			System.out.println(loc  + " shadowSize:" + entShadows.get(loc));
	}

 

Posted

RenderingRegistry is just temporary storage for mod entity renderers/factories during the startup process, RenderManager#entityRenderMap stores the actual instances used to render entities during gameplay.

  • Thanks 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
15 hours ago, Choonster said:

RenderingRegistry is just temporary storage for mod entity renderers/factories during the startup process, RenderManager#entityRenderMap stores the actual instances used to render entities during gameplay.

during post init those maps are always empty then? I should be grabbing them from the render manager during post init?

Posted
3 hours ago, jredfox said:

during post init those maps are always empty then? I should be grabbing them from the render manager during post init?

 

They won't be empty if there are mods that have used the RenderingRegistry methods, but they'll never have the Vanilla instances and the Render instances you create from the IRenderFactory instances won't be the same ones that are used to render the entities during gameplay. It's best to use the ones stored in RenderManager.

 

Mods that use the non-deprecated IRenderFactory registration method of RenderingRegistry will have their Render instances added to the RenderManager instance when it's created between preInit and init. Mods that use the deprecated Render registration method of RenderingRegistry will have their Render instances added to the RenderManager instance after postInit.

 

If you really want to support the mods that are still using the deprecated method two years after it was replaced (it was deprecated with this commit and meant to be removed in 1.9), you could lazy-load the shadow sizes for each class when they're required rather than loading them all at startup.

  • Thanks 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
On 4/14/2018 at 6:37 PM, Choonster said:

 

They won't be empty if there are mods that have used the RenderingRegistry methods, but they'll never have the Vanilla instances and the Render instances you create from the IRenderFactory instances won't be the same ones that are used to render the entities during gameplay. It's best to use the ones stored in RenderManager.

 

Mods that use the non-deprecated IRenderFactory registration method of RenderingRegistry will have their Render instances added to the RenderManager instance when it's created between preInit and init. Mods that use the deprecated Render registration method of RenderingRegistry will have their Render instances added to the RenderManager instance after postInit.

 

If you really want to support the mods that are still using the deprecated method two years after it was replaced (it was deprecated with this commit and meant to be removed in 1.9), you could lazy-load the shadow sizes for each class when they're required rather than loading them all at startup.

Ok it appears there is a major issue in 1.7.10 and below entity shadow size was always for vanilla mobs this.height/2. it is simply not the case here what should I be looking for in later versions? I used it in past for render like nei on mob spawners. I printed was that entity.height/2 == size it said false
 

minecraft:ender_dragon:0.5 false

 

Posted
31 minutes ago, jredfox said:

Ok it appears there is a major issue in 1.7.10 and below entity shadow size was always for vanilla mobs this.height/2. it is simply not the case here what should I be looking for in later versions? I used it in past for render like nei on mob spawners. I printed was that entity.height/2 == size it said false
 


minecraft:ender_dragon:0.5 false

 

 

That's what Entity#getShadowSize returned, but that method no longer exists; if you compare the 1.7.10 and 1.12.2 implementations of Render#renderShadow, you'll see that they're fairly similar but the entity's shadow size is no longer used.

 

The Render#shadowSize field is 0.5 for RenderDragon in both 1.7.10 and 1.12.2.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
50 minutes ago, Choonster said:

 

That's what Entity#getShadowSize returned, but that method no longer exists; if you compare the 1.7.10 and 1.12.2 implementations of Render#renderShadow, you'll see that they're fairly similar but the entity's shadow size is no longer used.

 

The Render#shadowSize field is 0.5 for RenderDragon in both 1.7.10 and 1.12.2.

but, the entity.getShadowSize() for ender dragon was like 1.5 or something. so I can't use that data for what I need anymore I will just hardcode it for 1.12.2+ thanks anyways.

  • 3 months later...
Posted
On 4/12/2018 at 5:56 PM, jredfox said:

Entity

 

On 4/14/2018 at 6:37 PM, Choonster said:

 

They won't be empty if there are mods that have used the RenderingRegistry methods, but they'll never have the Vanilla instances and the Render instances you create from the IRenderFactory instances won't be the same ones that are used to render the entities during gameplay. It's best to use the ones stored in RenderManager.

 

Mods that use the non-deprecated IRenderFactory registration method of RenderingRegistry will have their Render instances added to the RenderManager instance when it's created between preInit and init. Mods that use the deprecated Render registration method of RenderingRegistry will have their Render instances added to the RenderManager instance after postInit.

 

If you really want to support the mods that are still using the deprecated method two years after it was replaced (it was deprecated with this commit and meant to be removed in 1.9), you could lazy-load the shadow sizes for each class when they're required rather than loading them all at startup.

Ok first off if I cache the sizes is it the same as entity.getShadowSize() in versions <= 1.7.10? If it is how am I suppose to support the depreciated version which fires after post init on load complete then? I prefer to have everything added depreciated or not.

I need this code for rendering entities and scaling them based on their shadow size in item blocks with mob spawners

Posted (edited)
On 8/7/2018 at 9:50 AM, jabelar said:

Why shadow size instead of the actual width of the entity?

because nei render code for mob spawners goes based upon shadow size to adjust the scale size for bigger entities without the new dynamic scaling that I don't entirely agree with or like.

Edited by jredfox
Posted
On 4/16/2018 at 4:39 AM, Choonster said:

 

That's what Entity#getShadowSize returned, but that method no longer exists; if you compare the 1.7.10 and 1.12.2 implementations of Render#renderShadow, you'll see that they're fairly similar but the entity's shadow size is no longer used.

 

The Render#shadowSize field is 0.5 for RenderDragon in both 1.7.10 and 1.12.2.

I know the fields are not the same the dragon render is 4.0 in 1.7.10 and 0.5 in the render manager. What am I suppose to do?\


Also the entity dragon is the same size as a blaze so this is not reliable for what I needed the shadow sizes on based on 1.7.10 getShadowSize()

[17:13:42] [main/INFO] [STDOUT]: [com.EvilNotch.lib.minecraft.proxy.ClientProxy:onLoadComplete:105]: EntityBlaze,0.5
[17:13:42] [main/INFO] [STDOUT]: [com.EvilNotch.lib.minecraft.proxy.ClientProxy:onLoadComplete:105]: EntityDragon,0.5
        float scale = 0.4375F;
        if(EntityUtil.getShadowSize(entity) > 1.5)
            scale = 0.1F;

where the scale for rendering the entities in the item block mob spawner would become smaller
 

Posted
1 hour ago, jredfox said:

because nei render code for mob spawners goes based upon shadow size to adjust the scale size for bigger entities without the new dynamic scaling that I don't entirely agree with or like.

This is a ridiculous statement. Why not just make your own way of scaling the entities that is possible in the recent versions of Minecraft and is more stable. What if there was a modded entity that was bigger than the Ender Dragon and the shadow size represented that, and a scale size of .1 did not successfully shrink the entity enough.

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.

Posted (edited)
4 hours ago, Animefan8888 said:

This is a ridiculous statement. Why not just make your own way of scaling the entities that is possible in the recent versions of Minecraft and is more stable. What if there was a modded entity that was bigger than the Ender Dragon and the shadow size represented that, and a scale size of .1 did not successfully shrink the entity enough.

I like nei and older render I am porting older render code. Dynamic scaling will be an option eventually but, till everything else is done I am not even going to consider it especially since in the items it would be barley see able unless I increased the scale and developed my own dynamic scaling.

99% of entities didn't override the method anyways for the shadow size meaning it's going to work most of the time entity.height/2 to get it's size. The code is ported from nei and older versions using their equations so I am confident that it won't break and if a giant massive mob shows up I like to see it render.

Anyways looking at the Render.class I don't see why they removed it the entire part when rendering shadows is gone seems stupid to not have that anymore since it was part of the equation for rendering and now it's completely gone.

Edited by jredfox
Posted

Just add the old method in through a core mod or something. Your core modding everything else I don’t see how this is different

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted (edited)

Honestly fox - If you're already porting code, then you could do it completly. And evaluating a scale isn't hard math... 

 

float scale = desiredSize/Math.max(height,width);

 

Will scale it down to desired size (I'm unsure which one's your problem, or if you're maybe rotating it, so it supports both height and width (cause it's 3 dimensional you propably want to take z-axis in account to... I haven't put much thought into it) ) . 

Edited by Major Tuvok
A scaling method
Posted
On 8/11/2018 at 1:36 AM, Cadiboo said:

Just add the old method in through a core mod or something. Your core modding everything else I don’t see how this is different

the point of adding the method back has to be done with forge since mods have to override it when necessary that's the only part I was worried about.

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

    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
    • Do you use features of inventory profiles next (ipnext) or is there a change without it?
    • Remove rubidium - you are already using embeddium, which is a fork of rubidium
  • Topics

×
×
  • Create New...

Important Information

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