Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Cyanki

Members
  • Joined

  • Last visited

  1. I want to make a weapon that have custom attack animation so I decide to use BEWLR but it wont work for some reason: the " System.out.println("Show your code");" in class BEWLR wont print Item name ExoSickle Registration: Item class: BEWLR?
  2. https://github.com/Tanki-Crystal/git
  3. [01:20:59] [Render thread/FATAL]: Error executing task on Client java.lang.NullPointerException: Cannot invoke "net.minecraft.nbt.CompoundTag.getCompound(String)" because "compound" is null at org.Tanki.extraspicy.common.Electrolysis.ElectrolysisEntity.load(ElectrolysisEntity.java:49) ~[%2381!:?] at net.minecraftforge.common.extensions.IForgeBlockEntity.handleUpdateTag(IForgeBlockEntity.java:88) ~[forge-1.18-38.0.17_mapped_official_1.18-recomp.jar%2376%2382!:?] at org.Tanki.extraspicy.common.Electrolysis.ElectrolysisEntity.handleUpdateTag(ElectrolysisEntity.java:71) ~[%2381!:?] at org.Tanki.extraspicy.common.Electrolysis.ElectrolysisEntity.onDataPacket(ElectrolysisEntity.java:62) ~[%2381!:?] at net.minecraft.client.multiplayer.ClientPacketListener.lambda$handleBlockEntityData$4(ClientPacketListener.java:999) ~[forge-1.18-38.0.17_mapped_official_1.18-recomp.jar%2377!:?] at java.util.Optional.ifPresent(Optional.java:178) ~[?:?] at net.minecraft.client.multiplayer.ClientPacketListener.handleBlockEntityData(ClientPacketListener.java:998) ~[forge-1.18-38.0.17_mapped_official_1.18-recomp.jar%2377!:?] at net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket.handle(ClientboundBlockEntityDataPacket.java:46) ~[forge-1.18-38.0.17_mapped_official_1.18-recomp.jar%2377!:?] at net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket.handle(ClientboundBlockEntityDataPacket.java:13) ~[forge-1.18-38.0.17_mapped_official_1.18-recomp.jar%2377!:?] at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$0(PacketUtils.java:21) ~[forge-1.18-38.0.17_mapped_official_1.18-recomp.jar%2377!:?] at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:139) ~[forge-1.18-38.0.17_mapped_official_1.18-recomp.jar%2377!:?] at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:22) ~[forge-1.18-38.0.17_mapped_official_1.18-recomp.jar%2377!:?] at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:112) ~[forge-1.18-38.0.17_mapped_official_1.18-recomp.jar%2377!:?] at net.minecraft.util.thread.BlockableEventLoop.runAllTasks(BlockableEventLoop.java:100) ~[forge-1.18-38.0.17_mapped_official_1.18-recomp.jar%2377!:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1009) ~[forge-1.18-38.0.17_mapped_official_1.18-recomp.jar%2377!:?] at net.minecraft.client.Minecraft.run(Minecraft.java:660) ~[forge-1.18-38.0.17_mapped_official_1.18-recomp.jar%2377!:?] at net.minecraft.client.main.Main.main(Main.java:205) ~[forge-1.18-38.0.17_mapped_official_1.18-recomp.jar%2377!:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] at net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler.lambda$launchService$0(ForgeClientUserdevLaunchHandler.java:38) ~[fmlloader-1.18-38.0.17.jar%230!:?] at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.0.24.jar%2310!:?] at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.0.24.jar%2310!:?] at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.0.24.jar%2310!:?] at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.0.24.jar%2310!:?] at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.0.24.jar%2310!:?] at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.0.24.jar%2310!:?] at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.0.24.jar%2310!:?] at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:90) [bootstraplauncher-0.1.17.jar:?] Just see this in debug
  4. public class ElectrolysisEntity extends BlockEntity { int Debug = 0; public ElectrolysisEntity(BlockPos p_153215_, BlockState p_153216_) { super(Registration.BlockEntity_electrolysis.get(),p_153215_,p_153216_); } public void prependItem(Player player) { Debug += 1; setChanged(); } public void appendItem(ItemStack stack) { Debug -= 1; setChanged(); } @Override public void load(CompoundTag compound) { final CompoundTag inventory = compound.getCompound("Inventory"); Debug = inventory.getInt("Int"); super.load(compound); } @Override public void saveAdditional(CompoundTag compound) { final var inventory = new CompoundTag(); inventory.putInt("Int", Debug); compound.put("Inventory", inventory); } @Override public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { handleUpdateTag(pkt.getTag()); } @Override public Packet<ClientGamePacketListener> getUpdatePacket() { return ClientboundBlockEntityDataPacket.create(this); } @Override public void handleUpdateTag(CompoundTag tag) { super.handleUpdateTag(tag); load(tag); } }
  5. but it still not working
  6. I remove the junk code you talk about but I still dont understand the load method thing you mean something like this??? Any example?
  7. So I make a Block,when player use it int Debug in BlockEntity add one and print it with System.out.println(entity.Debug); For some reason the BlockEntity print 1 while BlockEntityRenderer print 0 Registration: @Mod(ExtraSpicy.MOD_ID) public class ExtraSpicy { // Directly reference a log4j logger. public static final String MOD_ID = "extraspicy"; private static final Logger LOGGER = LogManager.getLogger(); public ExtraSpicy() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::AttributeRegister); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::ModelRegister); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::LayerRegister); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::RenderRegister); Registration.register(); MinecraftForge.EVENT_BUS.register(this); } //Register Model Layer Render here!!! public void AttributeRegister(EntityAttributeCreationEvent event){ event.put(Registration.Entity_exoft.get(), ExoFT.createMobAttributes().build()); } public void ModelRegister(ModelRegistryEvent event) { ForgeModelBakery.addSpecialModel(new ResourceLocation(ExtraSpicy.MOD_ID,"effect/sphere")); ForgeModelBakery.addSpecialModel(new ResourceLocation(ExtraSpicy.MOD_ID,"effect/invsphere")); } public void LayerRegister(EntityRenderersEvent.RegisterLayerDefinitions event){ event.registerLayerDefinition(ExoTridentModel.LAYER_LOCATION,ExoTridentModel::createBodyLayer); event.registerLayerDefinition(ExoFTModel.LAYER_LOCATION,ExoFTModel::createBodyLayer); } public void RenderRegister(EntityRenderersEvent.RegisterRenderers event) { event.registerBlockEntityRenderer(Registration.BlockEntity_electrolysis.get(), ElectrolysisRender::new); EntityRenderers.register(Registration.Entity_exotrident.get(), ExoTridentRender::new); EntityRenderers.register(Registration.Entity_exoft.get(), ExoFTRender::new); } } public class Registration { public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, ExtraSpicy.MOD_ID); public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ExtraSpicy.MOD_ID); public static final DeferredRegister<EntityType<?>> ENTITY = DeferredRegister.create(ForgeRegistries.ENTITIES, ExtraSpicy.MOD_ID); public static final DeferredRegister<BlockEntityType<?>> Block_ENTITY = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, ExtraSpicy.MOD_ID); public static void register(){ IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); BLOCKS.register(modEventBus); ITEMS.register(modEventBus); ENTITY.register(modEventBus); Block_ENTITY.register(modEventBus); } //Register Item Entity Tab here!!! public static final CreativeModeTab TAB = new CreativeModeTab(ExtraSpicy.MOD_ID) { @Nonnull @Override public ItemStack makeIcon() { return new ItemStack(Item_exocore.get()); } }; public static RegistryObject<Block> Block_electrolysis = BLOCKS.register("electrolysis",() -> new Electrolysis(BlockBehaviour.Properties.copy(Blocks.QUARTZ_BLOCK).noOcclusion().dynamicShape())); public static RegistryObject<Item> Item_coke = ITEMS.register("coke",() -> new Item(new Item.Properties().tab(TAB))); public static RegistryObject<Item> Item_quartzcoke = ITEMS.register("quartzcoke",() -> new Item(new Item.Properties().tab(TAB))); public static RegistryObject<Item> Item_silicon = ITEMS.register("silicon",() -> new Item(new Item.Properties().tab(TAB))); public static RegistryObject<Item> Item_exocoreshell = ITEMS.register("exo_core_shell",() -> new Item(new Item.Properties().tab(TAB))); public static RegistryObject<Item> Item_exocore = ITEMS.register("exo_core",() -> new Item(new Item.Properties().tab(TAB))); public static RegistryObject<Item> Item_exotrident = ITEMS.register("exo_trident", () -> new ExoTrident()); public static RegistryObject<Item> Item_block_electrolysis = ITEMS.register("electrolysis",() -> new BlockItem(Block_electrolysis.get(), new Item.Properties().tab(TAB))); public static final RegistryObject<BlockEntityType<ElectrolysisEntity>> BlockEntity_electrolysis = Block_ENTITY.register("electrolysis",() -> BlockEntityType.Builder.of(ElectrolysisEntity::new, Registration.Block_electrolysis.get()).build(null)); public static RegistryObject<EntityType<ExoTridentEntity>> Entity_exotrident = ENTITY.register("exo_trident_entity",() -> EntityType.Builder.<ExoTridentEntity>of(ExoTridentEntity::new, MobCategory.MISC).sized(0.5F, 0.5F).clientTrackingRange(4).updateInterval(20).build(new ResourceLocation(ExtraSpicy.MOD_ID, "exo_trident_entity").toString())); public static RegistryObject<EntityType<ExoFT>> Entity_exoft = ENTITY.register("exo_ft",() -> EntityType.Builder.<ExoFT>of(ExoFT::new, MobCategory.MISC).sized(0.5F, 0.5F).fireImmune().build(new ResourceLocation(ExtraSpicy.MOD_ID, "exo_ft").toString())); } Block: public class Electrolysis extends AbstractGlassBlock implements EntityBlock { protected static final VoxelShape SHAPE = Shapes.or(Block.box(1.0D, 0.0D, 1.0D, 14.0D, 13.0D, 14.0D)); public Electrolysis(Properties properties){ super(properties); } @Override public BlockEntity newBlockEntity(BlockPos pos, BlockState state){ return new ElectrolysisEntity(pos,state); } @Override public RenderShape getRenderShape(BlockState state){ return RenderShape.ENTITYBLOCK_ANIMATED; } public VoxelShape getShape(BlockState p_50952_, BlockGetter p_50953_, BlockPos p_50954_, CollisionContext p_50955_) { return SHAPE; } @Override public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult result) { if (!level.isClientSide && level.getBlockEntity(pos) instanceof ElectrolysisEntity) { if (!player.isCrouching()) { if(player.getItemInHand(hand).getItem() == Items.AIR){ //Take item out ((ElectrolysisEntity) level.getBlockEntity(pos)).prependItem(player); }else{ //Put item in ((ElectrolysisEntity) level.getBlockEntity(pos)).appendItem(player.getItemInHand(hand)); } } } return InteractionResult.SUCCESS; } } BlockEntity: public class ElectrolysisEntity extends BlockEntity { int Debug = 0; public ElectrolysisEntity(BlockPos p_153215_, BlockState p_153216_) { super(Registration.BlockEntity_electrolysis.get(),p_153215_,p_153216_); } public void prependItem(Player player) { Debug += 1; requestModelDataUpdate(); setChanged(); load(getTileData()); if (this.level != null) { this.level.setBlockAndUpdate(this.worldPosition, getBlockState()); } } public void appendItem(ItemStack stack) { Debug -= 1; requestModelDataUpdate(); setChanged(); getTileData(); if (this.level != null) { this.level.setBlockAndUpdate(this.worldPosition, getBlockState()); } } @Override public void load(CompoundTag compound) { System.out.println("------------------------------------------------------------------"); final CompoundTag inventory = compound.getCompound("Inventory"); Debug = inventory.getInt("Int"); } @Override public void saveAdditional(CompoundTag compound) { System.out.println("////////////////////////////////////////////////////////////////"); final var inventory = new CompoundTag(); inventory.putInt("Int", Debug); compound.put("Inventory", inventory); } @Override public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { handleUpdateTag(pkt.getTag()); } @Override public Packet<ClientGamePacketListener> getUpdatePacket() { return ClientboundBlockEntityDataPacket.create(this); } @Override public CompoundTag getUpdateTag() { return serializeNBT(); } @Override public void handleUpdateTag(CompoundTag tag) { super.handleUpdateTag(tag); load(tag); } } BlockEntityRenderer: public class ElectrolysisRender implements BlockEntityRenderer<ElectrolysisEntity> { private final BlockEntityRendererProvider.Context context; public ElectrolysisRender(BlockEntityRendererProvider.Context context){ this.context = context; } @Override public void render(ElectrolysisEntity entity, float partialTicks, PoseStack matrixStack, MultiBufferSource buffer, int combinedOverlay, int packedLight) { final BlockRenderDispatcher dispatcher = this.context.getBlockRenderDispatcher(); final ItemRenderer itemRender = Minecraft.getInstance().getItemRenderer(); matrixStack.pushPose(); matrixStack.scale(0.5F,0.5F,0.5F); matrixStack.translate(0.7F,1.5F,1F); matrixStack.mulPose(Vector3f.XN.rotationDegrees(180F)); itemRender.renderStatic(Minecraft.getInstance().player,Items.GLASS_BOTTLE.getDefaultInstance(), ItemTransforms.TransformType.FIXED,false,matrixStack,buffer,Minecraft.getInstance().level,combinedOverlay,packedLight,packedLight); matrixStack.popPose(); matrixStack.pushPose(); matrixStack.scale(0.5F,0.5F,0.5F); matrixStack.translate(1.3F,1.5F,1F); matrixStack.mulPose(Vector3f.XN.rotationDegrees(180F)); itemRender.renderStatic(Minecraft.getInstance().player,Items.GLASS_BOTTLE.getDefaultInstance(), ItemTransforms.TransformType.FIXED,false,matrixStack,buffer,Minecraft.getInstance().level,combinedOverlay,packedLight,packedLight); matrixStack.popPose(); matrixStack.pushPose(); matrixStack.scale(0.8F,0.8F,0.8F); matrixStack.translate(0.1F,0,0.1F); dispatcher.renderSingleBlock(Blocks.GLASS.defaultBlockState(),matrixStack,buffer,combinedOverlay,packedLight, EmptyModelData.INSTANCE); matrixStack.popPose(); System.out.println(entity.Debug); matrixStack.pushPose(); matrixStack.scale(0.75F,0.6F,0.75F); matrixStack.translate(0.15F,0,0.15F); dispatcher.renderSingleBlock(Blocks.ICE.defaultBlockState(),matrixStack,buffer,combinedOverlay,packedLight, EmptyModelData.INSTANCE); matrixStack.popPose(); } }
  8. Im trying to make a trident I already register the entity but it still said it failed to create model

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.