Jump to content

Recommended Posts

Posted

I have a few problems I can't seem to fix in my mod, hopefully someone else can tell me whats wrong. :P

 

Custom EntityItem Problem

 

 

I'm trying to create a custom EntityItem, so that when you throw an item on the ground it doesn't disappear in fire or when hitting a cactus. So, I created this class:

 

import net.minecraft.src.DamageSource;
import net.minecraft.src.EntityItem;
import net.minecraft.src.ItemStack;
import net.minecraft.src.World;
public class InvEntityItem extends EntityItem {

public InvEntityItem(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack){

super(par1World, par2, par4, par6, par8ItemStack);
}

public InvEntityItem(World par1world){

super(par1world);
}

protected void dealFireDamage(int par1)
{
}

public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
{
         return false;
}
}

 

To replace the EntityItem, and added these functions to the item whose drop I wanted to modify:

 

public boolean hasCustomEntity(ItemStack stack)
{
         return true;
}

public Entity createEntity(World world, Entity location, ItemStack itemstack)
{
         return new InvEntityItem(world, location.posX, location.posY, location.posZ, itemstack);
}

 

Thought this would do the trick, however once ingame and pressing q to drop the item, the client crashes and I receive this error report:

 

java.lang.StackOverflowError

at sun.security.provider.ByteArrayAccess.i2bBig4(Unknown Source)

at sun.security.provider.SHA.implDigest(Unknown Source)

at sun.security.provider.DigestBase.engineDigest(Unknown Source)

at sun.security.provider.DigestBase.engineDigest(Unknown Source)

at java.security.MessageDigest$Delegate.engineDigest(Unknown Source)

at java.security.MessageDigest.digest(Unknown Source)

at sun.security.provider.SecureRandom.engineNextBytes(Unknown Source)

at java.security.SecureRandom.nextBytes(Unknown Source)

at java.util.UUID.randomUUID(Unknown Source)

at net.minecraft.src.Entity.generatePersistentID(Entity.java:2207)

at net.minecraftforge.common.ForgeInternalHandler.onEntityJoinWorld(ForgeInternalHandler.java:19)

at net.minecraftforge.event.ASMEventHandler_0_ForgeInternalHandler_onEntityJoinWorld_EntityJoinWorldEvent.invoke(.dynamic)

at net.minecraftforge.event.ASMEventHandler.invoke(ASMEventHandler.java:35)

at net.minecraftforge.event.EventBus.post(EventBus.java:103)

at net.minecraft.src.World.spawnEntityInWorld(World.java:1365)

at net.minecraftforge.common.ForgeInternalHandler.onEntityJoinWorld(ForgeInternalHandler.java:37)

at net.minecraftforge.event.ASMEventHandler_0_ForgeInternalHandler_onEntityJoinWorld_EntityJoinWorldEvent.invoke(.dynamic)

at net.minecraftforge.event.ASMEventHandler.invoke(ASMEventHandler.java:35)

at net.minecraftforge.event.EventBus.post(EventBus.java:103)

at net.minecraft.src.World.spawnEntityInWorld(World.java:1365)

at net.minecraftforge.common.ForgeInternalHandler.onEntityJoinWorld(ForgeInternalHandler.java:37)

 

It repeats that last sequence of errors over and over for a long time.

 

I know that a StackOverflow error is caused by overflowing the stack (no, really?) and is usually a result of poorly handled recursion, but I have no idea where the problem is, and it seems none of my actual code is cited in the error report. Anyone have any ideas about whats happening here?

 

 

Custom Texture Problem

 

 

Also, I'm having a problem setting a custom texture. I made the png file and put it in the minecraft.jar, then set up my code according to this guide: http://www.minecraftforge.net/wiki/How_to_use_infinite_terrain_and_sprite_indexes

 

I get no errors when I run it, but instead of the item using my custom texture which is in slot 0, its a leather helmet. So i know its not using the right texture file, but have no idea why...

 

edit: Figured out the problem. I was using renderSnowball to render an EntityItem with a custom texture, but it turns out that renderSnowball doesn't use the texture file of what you pass to it, it only uses the default texture file. So, I just made a copy of the class and had it use my custom texture file instead, and problem solved.

 

 

 

Block Movement Problem

 

 

I created an item that I want to move a block one block up when right-clicking. To that effect, I wrote this code:

 

public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){

  if(Minecraft.getMinecraft().objectMouseOver!=null)
          {
           int x=Minecraft.getMinecraft().objectMouseOver.blockX;
           int y=Minecraft.getMinecraft().objectMouseOver.blockY;
           int z=Minecraft.getMinecraft().objectMouseOver.blockZ;
          
           int id = par2World.getBlockId(x, y, z);
          
                
          
                par2World.setBlockWithNotify(x, y, z, 0);
                par2World.setBlockWithNotify(x, y+1, z, id);
          
          }

 

The problem is, when testing it in game, the behavior is pretty weird. Sometimes it functions correctly, but a lot of the time it does various other things such as not moving the block but making it flicker between air and regular texture, moving the block but not changing the position it was in to air, and moving the block as well as the block behind it. I have no idea what could be causing these things to happen.

 

 

I would appreciate any and all help.  :)

Posted

1)

This method:

public Entity createEntity(World world, Entity location, ItemStack itemstack)
{
         return new EntityItem(world, location.posX, location.posY, location.posZ, itemstack);
}

 

MUST return an instance of your new EntityItem, NOT the original EntityItem!

 

2) Make sure the path is correct. It must have a slash at the beginning. If that doesn't work, use setTextureFile(path) on an instance of your item / block, like:

Block custom = new Block(blockID, 0, Material.wood);
custom.setTextureFile("/Path/File.png");

 

3) That code doesn't work in any way on a server. I would first make sure the code is executed only client-side with the Proxy system and then use packets for this.

 

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

1)

This method:

public Entity createEntity(World world, Entity location, ItemStack itemstack)
{
         return new EntityItem(world, location.posX, location.posY, location.posZ, itemstack);
}

 

MUST return an instance of your new EntityItem, NOT the original EntityItem!

 

2) Make sure the path is correct. It must have a slash at the beginning. If that doesn't work, use setTextureFile(path) on an instance of your item / block, like:

Block custom = new Block(blockID, 0, Material.wood);
custom.setTextureFile("/Path/File.png");

 

3) That code doesn't work in any way on a server. I would first make sure the code is executed only client-side with the Proxy system and then use packets for this.

 

Ah, for the first one I forgot I left it like that. I changed it to a regular EntityItem to see if it would work after it crashed when using my custom one, and it still crashed while returning the regular EntityItem.

 

The second one I just fixed. I was using renderSnowball to render a projectile, and I figured out that it only uses the default texture file and not one from its arguments, so I copied it to a new class and changed its texture file.

 

For the third one, I'm still not too experienced and don't know what you mean by using packets. Also, could you suggest a better way of doing the code if it doesn't work on servers? I'd prefer it to work more like pistons or maybe sand/gravel, but haven't really been able to figure out how those classes work...

Posted

1) Thats caused because you use a EntityItem subclass, which you shouldn't, but i've just added support for that.

3) Check your locations, see ItemBlock, the position you get is NOT the position of the block, it's the position NEXT to it, based on the side hit.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

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

    • So, we have a 5 player server running the Hexxit modpack, with the sole addition of one extra mod, CustomNPCs. Something about CustomNPCs doesn't play nice with the server. Only three players are playing it, all of them have CustomNPCs installed in their own game files, and we have CustomNPCs installed in our server. We can all hold the tools and use the custom recipes added by the mod or by players using the NPC spawner tool. However, I'm the only one who can actually use them. If either other player uses them, they immediately crash and are booted off the server. I can make NPCs, the NPCs can detect them and attack them, all that, but they cannot see them, nor can they interact with them in any way. What could be causing this? I will add, as far as I know, I'm the only one to have run the modpack in single player as well as in multiplayer, I believe the other two have only run it in multiplayer for the server. Could this possibly be part of the problem? Any help would be appreciated.
    • Hello, Thank you so much for the suggestion, I will create a post.
    • You're using the wrong FACING property in Mechanism#getStateForPlacement, BlockStateProperties.FACING instead of Mechanism.FACING, HorizontalDirectionalBlock.FACING or BlockStateProperties.HORIZONTAL_FACING (which all refer to the same value). The former includes all six Direction values, the latter only includes the four horizontal values.
    • quiero que me digan como hago para instalar bien el java y forge nada mas hasta el momento lo hice pero java no ejecuta el forge   
    • Mod Idea: Server-Specific Mod Disabler & Anti-Cheat Helper Overview: This mod allows players to seamlessly play on Minecraft servers without worrying about banned or incompatible mods. It automatically disables specific mods based on the server's configuration, ensuring that players are only using allowed mods. Additionally, it provides a safeguard against hacking mods by instantly blocking them from being used, promoting fair gameplay on multiplayer servers. Key Features: 1. Server-Specific Mod Disabling: Automatic Mod Detection: The mod will automatically detect which mods are allowed or blocked on a particular server. Server Configurable Lists: Server admins can maintain a list of banned or whitelisted mods, which will be dynamically applied when a player joins. Player Customization: Players can choose whether the mod should automatically disable specific mods when joining servers, or allow them to be used based on the server's settings. 2. Anti-Cheat and Hack Protection: Instant Hack Detection: The mod will automatically identify and block known hacking mods when joining a server. If a player attempts to join with a hacking mod, the server can receive an alert, and the mod will prevent the player from joining until the mod is removed. Real-Time Monitoring: The mod will continuously monitor the player's mods while on the server, ensuring that no banned or suspicious mods are activated. 3. Community-Driven Mod Management: Custom Blocklists and Whitelists: Server admins can manage custom mod lists directly through a configuration file or via an in-game interface. These lists would allow mods to be either whitelisted, banned, or marked for temporary disabling. Integration with Modding Communities: The mod can gather mod compatibility reports from other players, sharing knowledge about which mods work together and which are problematic. 4. Player-Friendly Experience: Less Hassle for Players: With this mod, players no longer need to manually disable or enable mods when switching between servers. The mod takes care of everything for them. Seamless Gameplay: Players can freely switch between servers with different rules and mod requirements without worrying about compatibility issues or getting banned for using the wrong mods. 5. Open-Source and Extensible: Community Contributions: The mod will be open-source, allowing the Minecraft community to contribute by adding new features, bug fixes, and support for more mods. Customizable for Future Versions: The mod will be updated to support future Minecraft versions, ensuring long-term usability. Additional Ideas for Future Expansion: 1. Integration with Minecraft Servers (Optional): Server-Side Mod Configuration: In addition to client-side mod management, server owners can opt to install a server-side version of this mod, which can enforce mod restrictions for all players. Server Feedback System: When a mod is disabled, the server can automatically provide feedback to the player about why it was disabled and whether they need to install an alternative. 2. Donation and Support System: Monetization for Future Development: The mod could offer a donation-based system or a paid premium version with advanced features like real-time support or a larger mod compatibility database. Community Support: Players could report issues directly through the mod, ensuring faster resolutions and support from the mod development community. Benefits: 1. For Players: No Need for Constant Mod Configuration: Players no longer need to manually switch between different mod sets based on the server they join. Reduced Risk of Getting Banned: The mod automatically prevents the use of banned or incompatible mods, reducing the risk of being kicked or banned from servers. Hassle-Free Experience: The mod removes the need for players to learn about different server mod policies, providing a smoother experience overall. 2. For Server Owners: Simplified Server Management: Server admins no longer need to constantly monitor which mods players are using. The mod ensures players are only using compliant mods. Better Anti-Cheat Measures: Server owners can trust that hacking mods will be automatically blocked, improving server security. Easy Integration: With a simple configuration file, server owners can quickly set up their mod policies and get started. 3. For the Minecraft Community: Encourages Fair Play: The mod promotes fair gameplay by automatically preventing the use of cheating mods, ensuring a better multiplayer environment. Better Mod Compatibility: As the mod grows, it can help players and server owners discover which mods are compatible with others, making the modding ecosystem more reliable. Potential Challenges and Solutions: 1. Resistance from Players Using Hacking Mods: Solution: Allow server admins to configure a warning system where players can receive notifications about the mod being blocked before they are kicked. This gives them a chance to fix their setup. 2. Keeping Mod Lists Up-to-Date: Solution: Implement a community-driven reporting system where players and server owners can submit their mod lists, keeping the database current with new mods and changes in mod compatibility. 3. Cross-Platform Compatibility: Solution: Ensure that the mod is built to support both Java and Bedrock editions (if applicable) by using cross-platform modding tools and making the mod adaptable to both versions. Conclusion: This mod has the potential to significantly improve the Minecraft multiplayer experience by making it easier for players to manage mods and preventing hacks from ruining gameplay. By focusing on server-specific mod management and providing automated protection from cheating mods, this mod could change how Minecraft servers handle modding and create a safer, more enjoyable experience for everyone involved.
  • Topics

×
×
  • Create New...

Important Information

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