Posted April 1, 20205 yr Hello, I have troubles while trying to register a new TileEntityType. I get the error : Cannot access com.mojang.datafixers.types.Type for this sample : @SubscribeEvent public static void onTileEntitiesTypeRegistry(final RegistryEvent.Register<TileEntityType<?>> entitiesRegistryEvent) { TileEntityType<?> type = TileEntityType.Builder.create(NIHayTileEntity::new, blockNIHay).build(null); entitiesRegistryEvent.getRegistry().register(e); } I get the error on the first line of the function, where type is initialized. My TileEntity : public class NIHayTileEntity extends TileEntity { public NIHayTileEntity() { super(NatureImprovedMod.tileEntityNIHay); } } I've taken the example of the FurnaceTileEntity, but it seems that ITileEntityProvider was marked as deprecated. I can't figure why. public class NIHayBlock extends Block implements ITileEntityProvider { public NIHayBlock() { super(Properties.create(Material.LEAVES).sound(SoundType.PLANT).hardnessAndResistance(0.25f)); } @Override public TileEntity createNewTileEntity(IBlockReader worldIn) { return new NIHayTileEntity(); } } Can you help me please ? Addendum : Edited April 2, 20205 yr by Orionss
April 1, 20205 yr 8 minutes ago, Orionss said: TileEntityType<?> type = TileEntityType.Builder.create(NIHayTileEntity::new, blockNIHay).build(null); I don't see anything wrong with this line except you are not giving it a registry name. 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.
April 1, 20205 yr Author 1 hour ago, Animefan8888 said: I don't see anything wrong with this line except you are not giving it a registry name. Yeah, I think it can be done in a second time. (it doesn't change anything if I do it anyway) I would like to know if this is normal that ITileEntityProvider is seen as deprecated ? What should I use then ? Edited April 1, 20205 yr by Orionss
April 2, 20205 yr Hi There's a working example of TileEntities in this project, it might give you some clues. https://github.com/TheGreyGhost/MinecraftByExample (see mbe20, mbe21) Cheers TGG PS @Deprecated //Forge: Do not use, use BlockState.hasTileEntity/Block.createTileEntity instead public interface ITileEntityProvider { @Nullable TileEntity createNewTileEntity(IBlockReader worldIn); }
April 2, 20205 yr Author 2 hours ago, TheGreyGhost said: Hi There's a working example of TileEntities in this project, it might give you some clues. https://github.com/TheGreyGhost/MinecraftByExample (see mbe20, mbe21) Cheers TGG PS @Deprecated //Forge: Do not use, use BlockState.hasTileEntity/Block.createTileEntity instead public interface ITileEntityProvider { @Nullable TileEntity createNewTileEntity(IBlockReader worldIn); } Hello and thank you for your answer. I'm afraid that the Block class doesn't have an overridable createTileEntity function neither a hasTileEntity function as shown in your examples : EDIT : ok, I was mispelling it. But it doesn't solve my problem with datafixers for now. I'm looking depper in your examples right now. /** * User: The Grey Ghost * Date: 11/01/2015 * * BlockTileEntityData is a ordinary solid cube with an associated TileEntity * For background information on block see here http://greyminecraftcoder.blogspot.com.au/2014/12/blocks-18.html */ public class BlockTileEntityData extends Block { public BlockTileEntityData() { super(Block.Properties.create(Material.ROCK) ); } private final int TIMER_COUNTDOWN_TICKS = 20 * 10; // duration of the countdown, in ticks = 10 seconds @Override public boolean hasTileEntity(BlockState state) { return true; } // Called when the block is placed or loaded client side to get the tile entity for the block // Should return a new instance of the tile entity for the block @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) {return new TileEntityData();} // Called just after the player places a block. Start the tileEntity's timer @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { super.onBlockPlacedBy(worldIn, pos, state, placer, stack); TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityData) { // prevent a crash if not the right type, or is null TileEntityData tileEntityData = (TileEntityData)tileentity; tileEntityData.setTicksLeftTillDisappear(TIMER_COUNTDOWN_TICKS); } } // render using a BakedModel // not required because the default (super method) is MODEL @Override public BlockRenderType getRenderType(BlockState iBlockState) { return BlockRenderType.MODEL; } } Without ITileEntityProvider implementation, there is not these functions. I'm using forge 1.15.2 31.1.0 It's not the only problem I encounter : there is a lot of "func_id_x_" functions in the API, and I don't have the setters for Block properties. Even in the last implemented TileEntityBlocks, as the lectern, I see a use of the ITileEntityProvider, and in the net.minecraft.block code, it's not marked as deprecated. EDIT 2 : I can see that the TileEntityType.Builder.create().build() function is marked as @NotNull EDIT 3 : I solved the problem by adding the library Gradle: com.mojang:datafixerupper:2.0.24 to my classpath, IntelliJ didn't ask me until I decomposed the assignation in : TileEntityType.Builder<NIHayTileEntity> builder = TileEntityType.Builder.create(NIHayTileEntity::new, blockNIHay); tileEntityNIHayBlock = builder.build(null); Edited April 2, 20205 yr by Orionss
April 2, 20205 yr Hi Glad you resolved it. I haven't see that problem before. BTW I'd recommend that you move from "recommended" to "latest". There are very many old mappings in recommended that are all fixed in "latest", it makes the vanilla code much easier to understand. It won't stop modders from using your code with "recommended". When using IDEA you'll probably need to manually exclude the older library from the project, otherwise every time you search for a method it will give two results- one from the old library and one from the newer. I think this is because of the Forge gradle code but I haven't figured out exactly why. -TGG
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.