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.

Luis_ST

Members
  • Joined

  • Last visited

Everything posted by Luis_ST

  1. i know but why is the tag null it can't be null because it will set before attacking the last entity so i don't understand why the tag is Empty do I have to save the tag
  2. i just hava a custom item which is called damage star This item has a tag ("damage") if the player has the item in their inventory and the player attacks an entity. Couter damage is increased by 1. If the player attacks, the damage the player deal plus the value of the tag. this is the star item: public class DamageStar extends Star { public DamageStar() { super(new Item.Properties().group(Cave.MISC), StarType.DAMAGE); } @Override public void starTick(ItemStack stack, World world, PlayerEntity player) { // custom method in Star } @Override public void onCreated(ItemStack stack, World worldIn, PlayerEntity playerIn) { Cave.LOGGER.debug("creat tag"); stack.getOrCreateChildTag(this.getTag()).putDouble(this.getTag(), 0); } } and this the event i use to calc the tag: @SubscribeEvent public static void LivingDamage(LivingDamageEvent event) { Entity target = event.getEntity(); Entity entity = event.getSource().getTrueSource(); float amount = event.getAmount(); float newAmount = 0.0f; if (entity instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) entity; if (PlayerManager.getItem(player, ModItems.DAMAGE_STAR.get()).getItem() != ItemStack.EMPTY.getItem()) { ItemStack stack = PlayerManager.getItem(player, ModItems.DAMAGE_STAR.get()); if (stack.getItem() instanceof DamageStar) { DamageStar star = (DamageStar) stack.getItem(); //gets the TagName from the Enum StarType final String tag = star.getTag(); if (!stack.hasTag()) { stack.getOrCreateChildTag(tag); Cave.LOGGER.debug("creat tag"); } CompoundNBT nbt = stack.getChildTag(tag); Cave.LOGGER.debug("getDouble: " + nbt.getDouble(tag)); newAmount += nbt.getDouble(tag); nbt.putDouble(tag, nbt.getDouble(tag) + 1); stack.setTag(nbt); Cave.LOGGER.debug("getDouble: " + nbt.getDouble(tag)); } } event.setAmount(newAmount == 0.0f ? amount : newAmount); } } but now my problem i got an error but i dont knwo why: java.lang.NullPointerException: Cannot invoke "net.minecraft.nbt.CompoundNBT.getDouble(String)" because "nbt" is null at net.luis.cave.events.entity.living.OnLivingDamageEvent.LivingDamage(OnLivingDamageEvent.java:72) ~[main/:?] {re:classloading} at net.minecraftforge.eventbus.ASMEventHandler_20_OnLivingDamageEvent_LivingDamage_LivingDamageEvent.invoke(.dynamic) ~[?:?] {} at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.common.ForgeHooks.onLivingDamage(ForgeHooks.java:349) ~[forge:?] {re:classloading} at net.minecraft.entity.LivingEntity.damageEntity(LivingEntity.java:1578) ~[forge:?] {re:classloading} at net.minecraft.entity.LivingEntity.attackEntityFrom(LivingEntity.java:1043) ~[forge:?] {re:classloading} at net.minecraft.entity.passive.IronGolemEntity.attackEntityFrom(IronGolemEntity.java:210) ~[forge:?] {re:classloading} at net.minecraft.entity.player.PlayerEntity.attackTargetEntityWithCurrentItem(PlayerEntity.java:1167) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.entity.player.ServerPlayerEntity.attackTargetEntityWithCurrentItem(ServerPlayerEntity.java:1399) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.network.play.ServerPlayNetHandler.processUseEntity(ServerPlayNetHandler.java:1255) ~[forge:?] {re:classloading} at net.minecraft.network.play.client.CUseEntityPacket.processPacket(CUseEntityPacket.java:89) ~[forge:?] {re:classloading} at net.minecraft.network.play.client.CUseEntityPacket.processPacket(CUseEntityPacket.java:15) ~[forge:?] {re:classloading} at net.minecraft.network.PacketThreadUtil.lambda$checkThreadAndEnqueue$0(PacketThreadUtil.java:19) ~[forge:?] {re:classloading} at net.minecraft.util.concurrent.TickDelayedTask.run(TickDelayedTask.java:20) ~[forge:?] {re:classloading} at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:139) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) ~[forge:?] {re:classloading} at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:758) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:159) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:109) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.driveOneInternal(MinecraftServer.java:741) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.driveOne(MinecraftServer.java:735) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.ThreadTaskExecutor.drainTasks(ThreadTaskExecutor.java:97) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.runScheduledTasks(MinecraftServer.java:720) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:667) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.lambda$startServer$0(MinecraftServer.java:233) ~[forge:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Thread.java:832) [?:?] {}
  3. you have to overwrite the method IceBlock#turnIntoWater
  4. i just work thanks
  5. i just fixed this i use the RegistryEvent and i think i had read something on github that villager pois are bugged in this version
  6. you can overwrite the ice block and add your chance you then have to register the block with the minecraft id Another way would be with the BlockEvent NeighborNotifyEvent, but I'm not sure when this event is triggered exactly (i don't know if it is triggered when the ice is converted into water). If you want to try that, first use the debbuger to determine whether the event is triggered
  7. do you want to spawn a random item so every time when the event is fired a new Item? use Item#getItemById and spawn the item as below or choose a random item from a range of items (I mean, for example, if Random#nextInt == 10 spawn a diamond (everytime)) than use this with your item (replace null with your item): ItemEntity itemEntity = new ItemEntity(world, player.getPosX(), player.getPosY(), player.getPosZ(), null); world.addEntity(itemEntity);
  8. now i use this but it dosent work: @SubscribeEvent(priority = EventPriority.HIGHEST) @SuppressWarnings({ "resource", "static-access" }) public static void RenderSpyglassOverlay(RenderGameOverlayEvent.Pre event) { ElementType type = event.getType(); if (type != ElementType.BOSSHEALTH) { return; } switch (type) { case HEALTH: event.setCanceled(true); case FOOD: event.setCanceled(true); case ARMOR: event.setCanceled(true); case EXPERIENCE: event.setCanceled(true); default: } PlayerEntity player = Minecraft.getInstance().player; GameSettings settings = Minecraft.getInstance().gameSettings; int posX = event.getWindow().getScaledWidth(); int posY = event.getWindow().getScaledHeight(); if (player.getActiveItemStack().getItem() == ModItems.SPYGLASS.get()) { if (settings.getPointOfView()== PointOfView.FIRST_PERSON) { RenderSystem.disableDepthTest(); RenderSystem.depthMask(false); RenderSystem.enableBlend(); RenderSystem.blendFunc(770, 771); Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("cave:textures/misc/spyglass_scope.png")); Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), 0, 0, 0, 0, posX, posY, 480, 270); RenderSystem.depthMask(true); RenderSystem.enableDepthTest(); } } }
  9. I have a custom overlay, it works fine, but the xp bar and health and hunger are above the overlay so how to change that or is there a way to disable the rendering of xp bar hunger and health? this is the code of my event: @SubscribeEvent(priority = EventPriority.HIGHEST) @SuppressWarnings({ "resource", "static-access" }) public static void RenderSpyglassOverlay(RenderGameOverlayEvent event) { if (event.getType() != ElementType.BOSSHEALTH) { return; } PlayerEntity player = Minecraft.getInstance().player; GameSettings settings = Minecraft.getInstance().gameSettings; int posX = event.getWindow().getScaledWidth(); int posY = event.getWindow().getScaledHeight(); if (player.getActiveItemStack().getItem() == ModItems.SPYGLASS.get()) { if (settings.getPointOfView()== PointOfView.FIRST_PERSON) { RenderSystem.disableDepthTest(); RenderSystem.depthMask(false); RenderSystem.enableBlend(); RenderSystem.blendFunc(770, 771); Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("cave:textures/misc/spyglass_scope.png")); Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), 0, 0, 0, 0, posX, posY, 480, 270); RenderSystem.depthMask(true); RenderSystem.enableDepthTest(); } } }
  10. you have to change the parent in your model (item/generated --> item/handheld)
  11. i just have custom villager professions and point of interest but the villager will not use them but i dont know why poi: public static final DeferredRegister<PointOfInterestType> POI_TYPE = DeferredRegister.create(ForgeRegistries.POI_TYPES, Cave.Mod_Id); public static final RegistryObject<PointOfInterestType> LUMBERJACK = POI_TYPE.register("lumberjack", () -> new PointOfInterestType("lumberjack", VillagerUtil.getAllStates(Blocks.CRAFTING_TABLE), 1, 1)); public static final RegistryObject<PointOfInterestType> MOB_HUNTER = POI_TYPE.register("mob_hunter", () -> new PointOfInterestType("mob_hunter", VillagerUtil.getAllStates(Blocks.ANVIL), 1, 1)); public static final RegistryObject<PointOfInterestType> MINER = POI_TYPE.register("miner", () -> new PointOfInterestType("miner", VillagerUtil.getAllStates(ModBlocks.SMELTING_FURNACE.get()), 1, 1)); public static final RegistryObject<PointOfInterestType> ENCHANTER = POI_TYPE.register("enchanter", () -> new PointOfInterestType("enchanter", VillagerUtil.getAllStates(Blocks.ENCHANTING_TABLE), 1, 1)); public static final RegistryObject<PointOfInterestType> BEEKEEPER = POI_TYPE.register("beekeeper", () -> new PointOfInterestType("beekeeper", VillagerUtil.getAllStates(ModBlocks.BEE_TABLE.get()), 1, 1)); public static final RegistryObject<PointOfInterestType> NETHER_TRADER = POI_TYPE.register("nether_trader", () -> new PointOfInterestType("nether_trader", VillagerUtil.getAllStates(Blocks.field_235400_nj_), 1, 1)); public static final RegistryObject<PointOfInterestType> END_TRADER = POI_TYPE.register("end_trader", () -> new PointOfInterestType("end_trader", VillagerUtil.getAllStates(Blocks.ENDER_CHEST), 1, 1)); and the professions : public static final DeferredRegister<VillagerProfession> PROFESSIONS = DeferredRegister.create(ForgeRegistries.PROFESSIONS, Cave.Mod_Id); public static final RegistryObject<VillagerProfession> LUMBERJACK = PROFESSIONS.register("lumberjack", () -> new VillagerProfession("lumberjack", ModPointOfInterestTypes.LUMBERJACK.get(), ImmutableSet.of(), ImmutableSet.of(), null)); public static final RegistryObject<VillagerProfession> MOB_HUNTER = PROFESSIONS.register("mob_hunter", () -> new VillagerProfession("mob_hunter", ModPointOfInterestTypes.MOB_HUNTER.get(), ImmutableSet.of(), ImmutableSet.of(), null)); public static final RegistryObject<VillagerProfession> MINER = PROFESSIONS.register("miner", () -> new VillagerProfession("miner", ModPointOfInterestTypes.MINER.get(), ImmutableSet.of(), ImmutableSet.of(), null)); public static final RegistryObject<VillagerProfession> ENCHANTER = PROFESSIONS.register("enchanter", () -> new VillagerProfession("enchanter", ModPointOfInterestTypes.ENCHANTER.get(), ImmutableSet.of(), ImmutableSet.of(), null)); public static final RegistryObject<VillagerProfession> BEEKEEPER = PROFESSIONS.register("beekeeper", () -> new VillagerProfession("beekeeper", ModPointOfInterestTypes.BEEKEEPER.get(), ImmutableSet.of(), ImmutableSet.of(), null)); public static final RegistryObject<VillagerProfession> NETHER_TRADER = PROFESSIONS.register("nether_trader", () -> new VillagerProfession("nether_trader", ModPointOfInterestTypes.NETHER_TRADER.get(), ImmutableSet.of(), ImmutableSet.of(), null)); public static final RegistryObject<VillagerProfession> END_TRADER = PROFESSIONS.register("end_trader", () -> new VillagerProfession("end_trader", ModPointOfInterestTypes.END_TRADER.get(), ImmutableSet.of(), ImmutableSet.of(), null));
  12. first my code example is from 1.16 but I think it works also in 1.15.2. your code looks okay, unfortunately I can't tell you where the error is. but i have an idea where the mistake is, can you show your mod class constructor.
  13. i creat a new Arrow (called jade arrow) but when i creat the arrow there is no arrow (no hitbox or something else) my classes which i have: arrow class (entity): https://github.com/Luis-st/Forge-1.16.5-36.0.1-mdk/blob/main/forge-1.16.5-36.0.1-mdk/src/main/java/net/luis/cave/common/entities/JadeArrow.java arrow class (item): https://github.com/Luis-st/Forge-1.16.5-36.0.1-mdk/blob/main/forge-1.16.5-36.0.1-mdk/src/main/java/net/luis/cave/common/item/entity/JadeArrowItem.java arrow render class: https://github.com/Luis-st/Forge-1.16.5-36.0.1-mdk/blob/main/forge-1.16.5-36.0.1-mdk/src/main/java/net/luis/cave/client/render/entity/JadeArrowRender.java arrow registration: https://github.com/Luis-st/Forge-1.16.5-36.0.1-mdk/blob/main/forge-1.16.5-36.0.1-mdk/src/main/java/net/luis/cave/init/ModEntityType.java i think something is missing but i dont now what
  14. I'm currently writing a mod for 1.16.1 and I need the player perspective. I know that in version 1.16.5 there is a method GameSettings#getPointOfView but how do I get the perspective in version 1.16.1
  15. first you have to add to your block properties notSolid (that you can't look into the ground) and second you have to do something like this (in your mod class): private void doClientStuff(FMLClientSetupEvent event) { RenderTypeLookup.setRenderLayer(yourBlock, RenderType.getCutout()); }
  16. why do you do this? you check if the world is not remot so you can use: getDrops(world.getBlockState(pos), (ServerWorld) world, pos, tileEntity);); because you check if the world is a ServerWorld so you dont need the server (if you want to use your code check if the server is not null) otherwise your code is okay, a bit messy in my opinion but okay
  17. can you post the coplet code here / creat a github repos because a text file is not the best way to look in your code
  18. show the log and i think i can help you
  19. thank you very much it works
  20. okay i change the constructor but now i have a costructor with: public SmeltingContainer(int id, PlayerInventory playerInventory, IInventory inventory, IIntArray array) { super(ModContainer.SMELTING_CONTAINER.get(), ModRecipeType.SMELTING_RECIPE, RecipeBookCategory.FURNACE, id, playerInventory, inventory, array); } but now i cant register my container type because my constructor contains worng things (IInventory and the IIntArray) so what i have to set there/ did i get this things from the PacketBuffer which i need in the constructor
  21. is the correct one the other constructor from the AbstractFurnaceContainer class?
  22. okay thanks unfortunately i still have two problems: 1. when I put items in the slots, close the gui and open it again, the items disappear 2. I added a custom recipe. I can transfer the item into the slot using shift, which means that the recipe works but the smelting process does not start
  23. i hope these are my last two questions on this topic. So first of all a question about the custom IRecipeType do I have to register this? And secondly how do I tell the recipe book to show my recipes?

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.