Jump to content

Help with porting BlockPhysics mod from 1.6.2 to 1.12.


Recommended Posts

Posted (edited)

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
Posted

Also an error:

Inconvertible types; cannot cast 'net.minecraft.entity.item.EntityFallingBlock' to 'net.minecraft.entity.item.EntityTNTPrimed'

 

Posted

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)

Posted
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!

Posted (edited)

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

 

Hate pages like this :D

Edited by diesieben07
removed link
Posted (edited)
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)

Posted (edited)

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
Posted (edited)

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
Posted
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.

Posted (edited)
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
Posted

Is it in general a bad practice? Will it affect the performance? Should I just start a new project and try to implement the logic from the old mod into the new mod, based on new version of forge?

Posted
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.

Posted
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.

Posted

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);
Posted (edited)

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
Posted (edited)

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
Posted
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.

Posted
35 minutes ago, loordgek said:

you get the facing form the blockstate

I checked IBlockState and interfaces it extends IBlockBehaviors and IBlockProperties, and there is no mentioning of EnumFacing whatsoever.

Posted

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();
Posted

 

29 minutes ago, st4s1k said:

EnumFacing orient = BlockPistonBase.getFacing(world.getBlockMetadata(i, j, k));

that works but that is not the normal way

 

you should do it like so

EnumFacing orient = state.getValue(BlockDirectional.FACING);

 

  • Like 1
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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