Jump to content

Help with porting BlockPhysics mod from 1.6.2 to 1.12.


st4s1k

Recommended Posts

Hi, my name is Stanislav. I'm new to modding, but I'm familiar with Java (a little bit, to be objective). This is my first encounter with modding to be fair.

I am trying to port a very old mod called BlockPhysics from version 1.6.2 to version 1.12. I know it is tricky and hard, but I want to try anyway, because the creator seems to quit modding.
Here is the mod on github: https://github.com/vidplace7/BlockPhysics

There was about 1000 errors in a class file that I'm trying to repair now, and now there are about 500, so there is some (small) progress x)
There are many fields/methods or even data-types in the old forge/minecraft that are missing int the new versions of this two.

Here are some of them:

EntityTracker#movingblocks    // no such field
World#setBlock()    // no such method
Facing    // no such class
EntityfallingBlock#bpdata    // no such field in this class
EntityfallingBlock#slideDir    // no such field in this class
Block#getOrientation(int)    // no such method
Block#isIndirectlyPowered(World, int, int, int, int)	// no such method
ItemStack#stackSize    // no such field
Item#redstone    // no such field
Explosion#explosionSize    // no such field
EnchantmentProtection#func_92092_a(Entity, double)    // some obfuscated method (from github: https://github.com/vidplace7/BlockPhysics/blob/master/src/blockphysics/BlockPhysics.java)
ExtendedBlockStorage#getExtBlockID()    // no such method
ExtendedBlockStorage#getExtBlockMetadata()    // no such method
World#moveTickList // no such field

Maybe you could help me. I would appreciate it very much.

I figured out some minor issues, like "Block.grass" should be changed to "Blocks.GRASS", or method names have changed, I always check for similar methods, or instead of coordinates a method may ask for BlockPos, those are not a big deal.

Thank you.

Edited by st4s1k
Link to comment
Share on other sites

I’m pretty sure someone already ported it. You can use MCP to find the changed mappings on espernet or on discord.

The Block+Mets system was changed to the BlockState system in 1.8. Also models & everything related to rendering changed

  • Like 1

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)

Link to comment
Share on other sites

28 minutes ago, Cadiboo said:

I’m pretty sure someone already ported it. You can use MCP to find the changed mappings on espernet or on discord.

The Block+Mets system was changed to the BlockState system in 1.8. Also models & everything related to rendering changed

Yes, it seems like there are some similar mods, not sure that they are completely the same, but maybe something that will satisfy me, because I just wanted a block physics mod for my server =D

Thank you!

Link to comment
Share on other sites

14 hours ago, st4s1k said:

Nope... It looks like it's a scam... https://www.minecraftresource.com/block-physics-mod/

 

Hate pages like this :D

If it’s not from CurseForge/minecraft forums it’s probably a scam

Edited by diesieben07
removed link
  • Like 1

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)

Link to comment
Share on other sites

Do you know, how can I replace this deprecated method?
 

if ( par1Block.getRenderType() == 18) {

 

Also, you said that :

Quote

everything related to rendering changed

Where can I get informed more about rendering?

There is a datatype that I cannot find replacement to:

RenderBlocks
Edited by st4s1k
Link to comment
Share on other sites

Currently I'm "porting" in e very primitive way:

class xWorld extends World {

   protected xWorld(ISaveHandler saveHandlerIn, WorldInfo info, WorldProvider providerIn, Profiler profilerIn, boolean client) {
      super(saveHandlerIn, info, providerIn, profilerIn, client);
   }

   public boolean setBlock(int x, int y, int z, Block block, int meta, int flags) {
      BlockPos blockPos = new BlockPos(x, y, z);

      return setBlockState(
            blockPos,
            block.getDefaultState(),
            flags
      );
   }

   public Block getBlock(int x, int y, int z) {
      return getBlockState(new BlockPos(x, y, z)).getBlock();
   }

   public int getBlockMetadata(int x, int y, int z) {
      return getBlock(x, y, z).getMetaFromState(getBlockState(new BlockPos(x, y, z)));
   }

   public TileEntity getTileEntity(int x, int y, int z) {
      return super.getTileEntity(new BlockPos(x, y, z));
   }

   public void removeTileEntity(int x, int y, int z) {
      super.removeTileEntity(new BlockPos(x, y, z));
   }

   @Override
   protected IChunkProvider createChunkProvider() {
      return this.createChunkProvider();
   }

   @Override
   protected boolean isChunkLoaded(int x, int z, boolean allowEmpty) {
      return this.isChunkLoaded(x, z, allowEmpty);
   }
}

 

What do you think?

Edited by st4s1k
Link to comment
Share on other sites

1 minute ago, diesieben07 said:

I am not sure what you are trying to accomplish there. Custom world classes are a pretty bad idea, unless we are talking about fake worlds, which are difficult to make.

It's just a wrapping class which maps old methods to the new ones.

Link to comment
Share on other sites

3 minutes ago, diesieben07 said:

Yeah, but it's not going to do anything, since nobody will use this class.

Actually, I have changed all "World" (case sensitive) occurrences to xWorld (custom), in the *.java file I'm editing now. Using find and replace. Also I took care of imports, because it got changed too, so I changed it back.

 

for example:

public static boolean setBlockBPdata( final xWorld world, final int par1, final int par2, final int par3, final int par4 )
{
   if (par1 >= -30000000 && par3 >= -30000000 && par1 < 30000000 && par3 < 30000000)
   {
      if (par2 < 0)
      {
         return false;
      }
      else if (par2 >= 256)
      {
         return false;
      }
      else
      {
         final Chunk chunk = world.getChunkFromChunkCoords(par1 >> 4, par3 >> 4);
         final int j1 = par1 & 15;
         final int k1 = par3 & 15;
         return (Boolean) BlockPhysics.asmHelper.invoke(chunk, "setBlockBPdata", j1, par2, k1, par4);
      }
   }
   else
   {
      return false;
   }
}
Edited by st4s1k
Link to comment
Share on other sites

Just now, diesieben07 said:

It's not necessarily "bad practice", it just doesn't work.

Well this method and class are located in the same class:

public class BlockPhysics

 

Also xWorld extends World and World objects can be assigned to xWorld objects without conflict, if understand you correctly.

Link to comment
Share on other sites

Just now, diesieben07 said:

Items.REDSTONE.

Thanks
 

 

1 minute ago, diesieben07 said:

If xWorld extends World that means any xWorld can be assigned to a World. The opposite (what you said) is not true.

Example:

class Shape

class Rectangle extends Shape

 

Every Rectangle is a Shape, but not every Shape is a Rectangle.

 

You're right. I don't have any conflict because all methods are used inside the same class.

Link to comment
Share on other sites

I noticed that World.playSound method is empty:

public void playSound(double x, double y, double z, SoundEvent soundIn, SoundCategory category, float volume, float pitch, boolean distanceDelay)
{
}

 

Do you know why is that?

I'm trying to replace this method:

xworld.playSoundEffect(i + 0.5F, j + 0.5F, k + 0.5F, block.stepSound.getBreakSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
Link to comment
Share on other sites

I have some problems with converting TileEntityPiston constructor, can somebody help me?:

 

for (int i = par5; i > 1; i--)
{
   final int xxf =  xx - Facing.offsetsXForSide[par6];
   final int yyf =  yy - Facing.offsetsYForSide[par6];
   final int zzf =  zz - Facing.offsetsZForSide[par6];

   final ResourceLocation var12 = Block.REGISTRY.getNameForObject(par1World.getBlock(xxf, yyf, zzf));
   int var13 = par1World.getBlockMetadata(xxf, yyf, zzf);
   final int bpmeta = BlockPhysics.getBlockBPdata(par1World, xxf, yyf, zzf);

   final Block bb = Block.REGISTRY.getObject(var12);

   if ( bb == Blocks.PISTON || bb == Blocks.STICKY_PISTON ) {
      var13 = var13 & 7;
   }


   final TileEntityPiston tePiston = new TileEntityPiston(bb, var13, par6, true, false);

   final TileEntityPiston tePiston = new TileEntityPiston(
         par1World.getBlockState(new BlockPos(xxf, yyf, zzf)),
         pistonFacingIn,  /* I don't know where to get this value */
         true,
         false
   );

   // ...

}
Edited by st4s1k
Link to comment
Share on other sites

Trying to replace Facing with EnumFacing. Unfortunately it is not a Forge class, so there is no mentioning about it anywhere really.

Do you know which function should be used instead?

image.png.b2496e185054462dff27551bbf3f9242.png

 

Only on some strange site:

https://www.programcreek.com/java-api-examples/index.php@source_dir=flex-blazeds-master/modules/core/src/flex/messaging/cluster/?class=net.minecraft.util.Facing&amp;method=offsetsZForSide

Edited by st4s1k
Link to comment
Share on other sites

31 minutes ago, loordgek said:

you get the facing form the blockstate

 

but something else, BlockPhysics is using a lot of ASM hacks.

do you know how ASM works if not please stop.

No I don't know how ASM works. What should I stop, and why "please" ? I can stop asking for help if this is what you want.

Link to comment
Share on other sites

Ok, I found the answer, ty:

public static boolean canmove(final xWorld world, final int i, final int j, final int k, final BlockPistonBase par1block)
{
   EnumFacing orient = BlockPistonBase.getFacing(world.getBlockMetadata(i, j, k));

   final int i2 = i + Facing.offsetsXForSide[orient];
   final int j2 = j + Facing.offsetsYForSide[orient];
   final int k2 = k + orient.getFrontOffsetZ();
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • https://pastebin.com/VwpAW6PX My game crashes upon launch when trying to implement the Oculus mod to this mod compilation, above is the crash report, I do not know where to begin to attempt to fix this issue and require assistance.
    • https://youtube.com/shorts/gqLTSMymgUg?si=5QOeSvA4TTs-bL46
    • CubeHaven is a SMP server with unique features that can't be found on the majority of other servers! Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132 3 different stores: - CubeHaven Store: Our store to purchase using real money. - Bitcoin Store: Store for Bitcoin. Bitcoin can be earned from playing the server. Giving options for players if they want to spend real money or grind to obtain exclusive packages. - Black Market: A hidden store for trading that operates outside our traditional stores, like custom enchantments, exclusive items and more. Some of our features include: Rank Up: Progress through different ranks to unlock new privileges and perks. 📈 Skills: RPG-style skill system that enhances your gaming experience! 🎮 Leaderboards: Compete and shine! Top players are rewarded weekly! 🏆 Random Teleporter: Travel instantly across different worlds with a click! 🌐 Custom World Generation: Beautifully generated world. 🌍 Dungeons: Explore challenging and rewarding dungeons filled with treasures and monsters. 🏰 Kits: Unlock ranks and gain access to various kits. 🛠️ Fishing Tournament: Compete in a friendly fishing tournament! 🎣 Chat Games: Enjoy games right within the chat! 🎲 Minions: Get some help from your loyal minions. 👥 Piñata Party: Enjoy a festive party with Piñatas! 🎉 Quests: Over 1000 quests that you can complete! 📜 Bounty Hunter: Set a bounty on a player's head. 💰 Tags: Displayed on nametags, in the tab list, and in chat. 🏷️ Coinflip: Bet with other players on coin toss outcomes, victory, or defeat! 🟢 Invisible & Glowing Frames: Hide your frames for a cleaner look or apply a glow to it for a beautiful look. 🔲✨[ Player Warp: Set your own warp points for other players to teleport to. 🌟 Display Shop: Create your own shop and sell to other players! 🛒 Item Skins: Customize your items with unique skins. 🎨 Pets: Your cute loyal companion to follow you wherever you go! 🐾 Cosmetics: Enhance the look of your character with beautiful cosmetics! 💄 XP-Bottle: Store your exp safely in a bottle for later use! 🍶 Chest & Inventory Sorting: Keep your items neatly sorted in your inventory or chest! 📦 Glowing: Stand out from other players with a colorful glow! ✨ Player Particles: Over 100 unique particle effects to show off. 🎇 Portable Inventories: Over virtual inventories with ease. 🧳 And a lot more! Become part of our growing community today! Discord: https://cubehaven.net/discord Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132
    • # Problematic frame: # C [libopenal.so+0x9fb4d] It is always the same issue - this refers to the Linux OS - so your system may prevent Java from working   I am not familiar with Linux - check for similar/related issues  
  • Topics

×
×
  • Create New...

Important Information

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