Everything posted by Luis_ST
-
[1.16.5] ItemStack Tag
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
-
[1.16.5] ItemStack Tag
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) [?:?] {}
-
[1.16] Modifying water freezing?
you have to overwrite the method IceBlock#turnIntoWater
-
[1.16.5] Help with custom Overlay
i just work thanks
-
[1.16.1] Help with custom villager professions
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
-
[1.16] Modifying water freezing?
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
-
[1.16.5] Within an event, summon a random item.
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);
-
[1.16.5] Help with custom Overlay
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(); } } }
-
[1.16.5] Help with custom Overlay
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(); } } }
-
[1.16.4]How to Let the sword display normally
you have to change the parent in your model (item/generated --> item/handheld)
-
[1.15.2] Override vanilla block and/or properties
you can use the normal one
-
[1.16.1] Help with custom villager professions
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));
-
[1.15.2] Override vanilla block and/or properties
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.
-
[1.16.5] Help with custom Arrow Rendering
thanks it work
-
[1.16.5] Help with custom Arrow Rendering
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
-
[1.16.1] how to get the player perspective?
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
-
how to make flower show up normally
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()); }
-
Getting ServerWorld from World (for getting block drops)
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
-
Getting ServerWorld from World (for getting block drops)
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
-
Getting ServerWorld from World (for getting block drops)
show the log and i think i can help you
-
[1.16.5] Help with Furnace Container/Recipe
thank you very much it works
-
[1.16.5] Help with Furnace Container/Recipe
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
-
[1.16.5] Help with Furnace Container/Recipe
is the correct one the other constructor from the AbstractFurnaceContainer class?
-
[1.16.5] Help with Furnace Container/Recipe
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
-
[1.16.5] Help with Furnace Container/Recipe
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?
IPS spam blocked by CleanTalk.