Ok, so since I can't get any help on the Forge Forums since '1.12.2 is no longer a supported format', I came here. Hopefully, someone may be able to help me out. if not, oh well.
Basically, for my mod that I'm making, I have a block called 'Fairysteel Block'. I've created a 'FairysteelBlock' class for it and set some stuff up, here it is:
- BlockInit Code
public class BlockInit {
public static final List<Block> BLOCKS = new ArrayList<Block>();
public static final Block FAIRYSTEEL_BLOCK = new FairysteelBlock("fairysteel_block", Material.IRON);
- FairysteelBlock Class Code
public class FairysteelBlock extends Block implements IHasModel {
public FairysteelBlock(String name, Material material) {
super(material);
setUnlocalizedName(name);
setRegistryName(name);
setCreativeTab(CrimsonMatter.CRIMSONMATTERTAB);
setHardness(60);
setResistance(75);
setLightLevel(10);
setLightOpacity(1);
setDefaultSlipperiness(0f);
setHarvestLevel("pickaxe", 7);
setSoundType(SoundType.METAL);
BlockInit.BLOCKS.add(this);
ItemInit.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
}
@Override
public boolean isFullBlock(IBlockState state) {
return true;
}
@Override
public boolean isFullCube(IBlockState state) {
return true;
}
@Override
public void registerModels() {
CrimsonMatter.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory");
}
}
But here, what happens is whenever the player walks or runs over or beside the block, they get pushed far away, kinda as if they teleported. Here's a video demonstrating. I've compared it to another block I have called Mystical Stone, although that block works on the BlockBase file I have, I haven't set up a specific class for it.
Does anyone know how to fix this? It's really frustrating.
P.S. I know that IHasModel isn't something you should use (I'm not sure why, though, if you could, please explain), and I'm working on removing it soon. I'm following TurtyWurty's modding tutorial, and he covers that later in the series.
As to your problem, this is just a guess here (since I'm using 1.15.2) but I think it's the problem with the slipperiness being set to 0. The value is between 0 and 1 with the default value (in 1.15.2 at least) being 0.6. Looking through the Minecraft code documentation, I found this entry about slipperiness:
Note that entities may reduce slipperiness by a certain factor of their own;
* for {@link net.minecraft.entity.EntityLivingBase}, this is {@code .91}.
* {@link net.minecraft.entity.item.EntityItem} uses {@code .98}, and
* {@link net.minecraft.entity.projectile.EntityFishHook} uses {@code .92}.
I believe this hasn't changed in a while since the class names are wrong, anyways, looking through the code I see that there is a point where they divide by the slipperiness^3 and since yours is 0, it's dividing by 0. Looking into it, for java, when dividing by a non-integer 0 you get infinity and that big number is getting applied to your velocity.
So the fix should be a simple as increasing the slipperiness to something other than 0.
First off, thanks for the reply! It really means a lot.
Second, I think you were right. I couldn't figure out exactly what the slipperiness should have been, so I just deleted that line. Now it works perfectly. Thanks for pointing that out.
Ok, so since I can't get any help on the Forge Forums since '1.12.2 is no longer a supported format', I came here. Hopefully, someone may be able to help me out. if not, oh well.
Basically, for my mod that I'm making, I have a block called 'Fairysteel Block'. I've created a 'FairysteelBlock' class for it and set some stuff up, here it is:
- BlockInit Code
- FairysteelBlock Class Code
- .json Files code
Normally, the block should work fine (Right?).
But here, what happens is whenever the player walks or runs over or beside the block, they get pushed far away, kinda as if they teleported. Here's a video demonstrating. I've compared it to another block I have called Mystical Stone, although that block works on the BlockBase file I have, I haven't set up a specific class for it.
https://streamable.com/rx2p3a
Does anyone know how to fix this? It's really frustrating.
P.S. I know that IHasModel isn't something you should use (I'm not sure why, though, if you could, please explain), and I'm working on removing it soon. I'm following TurtyWurty's modding tutorial, and he covers that later in the series.
If you can help me out, thanks!
Bubbly[/b]
For your IHasModel question, a quick google search netted this post: https://www.minecraftforge.net/forum/topic/67657-a-question-about-ihasmodel/
As to your problem, this is just a guess here (since I'm using 1.15.2) but I think it's the problem with the slipperiness being set to 0. The value is between 0 and 1 with the default value (in 1.15.2 at least) being 0.6. Looking through the Minecraft code documentation, I found this entry about slipperiness:
I believe this hasn't changed in a while since the class names are wrong, anyways, looking through the code I see that there is a point where they divide by the slipperiness^3 and since yours is 0, it's dividing by 0. Looking into it, for java, when dividing by a non-integer 0 you get infinity and that big number is getting applied to your velocity.
So the fix should be a simple as increasing the slipperiness to something other than 0.
My Mods:
- Happy Coding -
First off, thanks for the reply! It really means a lot.
Second, I think you were right. I couldn't figure out exactly what the slipperiness should have been, so I just deleted that line. Now it works perfectly. Thanks for pointing that out.
Bubbly[/b]