Luis_ST
Members-
Posts
5704 -
Joined
-
Last visited
-
Days Won
72
Everything posted by Luis_ST
-
[1.16.4] RenderRegistry#registerEntityRenderingHandler not working
Luis_ST replied to Mahdi1224's topic in Modder Support
the constructor of your Renderer contains two elemetnts a EntityRendererManager and a float the IRenderFactory needs only the EntityRendererManager In addition, the Factory cannot do anything with the float and gives you the error that's exactly what @diesieben07 meant by -
where and when do I have to use this in the container class or when I interact with the block i fixed it (it was a question about the error log) i don't understand what i have to set there, i tried a lot but every time i get an error
-
I have a NullPointerException but I don’t know where
Luis_ST replied to TokiiWalkie's topic in Modder Support
use onBlockActivated instead of onBlockClicked -
I have a NullPointerException but I don’t know where
Luis_ST replied to TokiiWalkie's topic in Modder Support
store the facing in a field and add it to setDefaultState beacuse you add it to stateContainer but you never set the base facing so minecraft dont know how to set the block this is the last mistake that it could be and that I find in your code i try to create your block in my mod and see if it works -
what do I have to change so that it works like a double chest inventory? which class did you mean? like this? (this doesent work -> "Cannot make a static reference to the non-static method getInventory() from the type Container") public static class Provider implements ICapabilityProvider { @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { return cap == CAPABILITY ? LazyOptional.of(ModEnderChestContainer::getInventory) : LazyOptional.empty(); } }
-
then like this: NetworkHooks.openGui(serverPlayer, new SimpleNamedContainerProvider((id, inventory, playerIn) -> { return new ModEnderChestContainer(id, inventory); }, ModEnderChestContainer.getContainerName()), pos); This checks whether the player's Enderchest inventory is already in use, as the player may add the mod later. If this is the case, the existing inventory will be dropped and the new one will be opened with the next click. i dont get a constructor so this is my complet class: package net.luis.cave.init; import java.util.concurrent.Callable; import net.luis.cave.api.capability.IModItemHandler; import net.minecraft.item.ItemStack; import net.minecraft.nbt.INBT; import net.minecraft.util.Direction; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability.IStorage; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.NonNullSupplier; public class ModCapability { @CapabilityInject(IModItemHandler.class) public static Capability<IModItemHandler> CAPABILITY = null; public ModCapability() { CapabilityManager.INSTANCE.register(IModItemHandler.class, new Storage(), new Factory()); } public static class Storage implements IStorage<IModItemHandler> { @Override public INBT writeNBT(Capability<IModItemHandler> capability, IModItemHandler instance, Direction side) { return null; } @Override public void readNBT(Capability<IModItemHandler> capability, IModItemHandler instance, Direction side, INBT nbt) { } } public static class Factory implements Callable<IModItemHandler> { @Override public IModItemHandler call() throws Exception { return null; } } public static class Provider implements ICapabilityProvider { @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { return cap == CAPABILITY ? LazyOptional.of(() -> null) : LazyOptional.empty(); } } } what do I have to replace null with
-
I have a NullPointerException but I don’t know where
Luis_ST replied to TokiiWalkie's topic in Modder Support
you will set the default state and inside you will get the default state? use: this.setDefaultState(this.stateContainer.getBaseState().with(PLATFORM_NUMBER, 0)); I think that's your mistake but I'm not sure because I don't know if it's line 28 -
I already have that, but how do I open the container in my event? what do I have to hand over to the method at "null"? @SubscribeEvent public static void PlayerInteract(PlayerInteractEvent.RightClickBlock event) { PlayerEntity player = event.getPlayer(); BlockPos pos = event.getPos(); World world = event.getWorld(); BlockState state = world.getBlockState(pos); EnderChestInventory enderChestInventory = player.getInventoryEnderChest(); if (state.getBlock() == Blocks.ENDER_CHEST) { if (!enderChestInventory.isEmpty()) { InventoryHelper.dropInventoryItems(world, pos, enderChestInventory); } else { if (player instanceof ServerPlayerEntity) { event.setCanceled(true); ServerPlayerEntity serverPlayer = (ServerPlayerEntity) player; NetworkHooks.openGui(serverPlayer, null, pos); } } } } you say I should use a constructor, what must be in the constructor and what should the method "getCapability" return
-
do i only have to implement Named ContainerProvider because i currently extends Chest Container / Container and i think thats wrong so like this: public static class Provider implements ICapabilityProvider { @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { return null; } }
-
so i have to use IItemHandler to get and open the gui inside there: NetworkHooks.openGui(serverPlayer, /*here*/, pos); and: public class ModCapability { @CapabilityInject(IModItemHandler.class) public static Capability<IModItemHandler> CAPABILITY = null; public ModCapability() { CapabilityManager.INSTANCE.register(IModItemHandler.class, new Storage(), new Factory()); } public static class Storage implements IStorage<IModItemHandler> { @Override public INBT writeNBT(Capability<IModItemHandler> capability, IModItemHandler instance, Direction side) { return null; } @Override public void readNBT(Capability<IModItemHandler> capability, IModItemHandler instance, Direction side, INBT nbt) { } } public static class Factory implements Callable<IModItemHandler> { @Override public IModItemHandler call() throws Exception { return null; } } public static class Provider implements ICapabilityProvider { private final LazyOptional<IModItemHandler> lazyOptional = LazyOptional.of(CAPABILITY::getDefaultInstance); @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { return cap == CAPABILITY ? lazyOptional.cast() : LazyOptional.empty(); } } }
-
so i just have to open the container / inventory and forge saves the gui from automatically? ? and where i have to put the container/inventory into the capability because when i use the AttachCapabilitiesEvent i got an NullPointerException: event: @SubscribeEvent public static void AttachCapabilities(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof PlayerEntity && !(event.getObject() instanceof FakePlayer)) { event.addCapability(new ResourceLocation("cave:extended_enderchest_gui"), new ModCapability.Provider()); } } and error log: [10:38:50] [Server thread/ERROR] [ne.mi.ev.EventBus/EVENTBUS]: Exception caught during firing event: null Index: 1 Listeners: 0: NORMAL 1: ASM: class net.luis.cave.events.capability.OnAttachCapabilitiesEvent AttachCapabilities(Lnet/minecraftforge/event/AttachCapabilitiesEvent;)V java.lang.NullPointerException at java.base/java.util.Objects.requireNonNull(Objects.java:208) at net.luis.cave.init.ModCapability$Provider.<init>(ModCapability.java:59) at net.luis.cave.events.capability.OnAttachCapabilitiesEvent.AttachCapabilities(OnAttachCapabilitiesEvent.java:21) at net.minecraftforge.eventbus.ASMEventHandler_16_OnAttachCapabilitiesEvent_AttachCapabilities_AttachCapabilitiesEvent.invoke(.dynamic) at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:579) at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:573) at net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:48) at net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:44) at net.minecraft.entity.Entity.<init>(Entity.java:221) at net.minecraft.entity.LivingEntity.<init>(LivingEntity.java:207) at net.minecraft.entity.player.PlayerEntity.<init>(PlayerEntity.java:160) at net.minecraft.entity.player.ServerPlayerEntity.<init>(ServerPlayerEntity.java:182) at net.minecraft.server.management.PlayerList.createPlayerForUser(PlayerList.java:419) at net.minecraft.network.login.ServerLoginNetHandler.tryAcceptPlayer(ServerLoginNetHandler.java:122) at net.minecraft.network.login.ServerLoginNetHandler.tick(ServerLoginNetHandler.java:66) at net.minecraft.network.NetworkManager.tick(NetworkManager.java:244) at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:151) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:898) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:820) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:84) at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:663) at net.minecraft.server.MinecraftServer.lambda$startServer$0(MinecraftServer.java:233) at java.base/java.lang.Thread.run(Thread.java:832) [10:38:50] [Server thread/FATAL] [ne.mi.co.ForgeMod/]: Preparing crash report with UUID 3dbca5d1-2854-4053-a647-dfa6633d91c6 [10:38:50] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception net.minecraft.crash.ReportedException: Ticking memory connection at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:154) ~[forge:?] {re:classloading} at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:898) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:820) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:84) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:663) ~[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) [?:?] {} Caused by: java.lang.NullPointerException at java.util.Objects.requireNonNull(Objects.java:208) ~[?:?] {} at net.luis.cave.init.ModCapability$Provider.<init>(ModCapability.java:59) ~[main/:?] {re:classloading} at net.luis.cave.events.capability.OnAttachCapabilitiesEvent.AttachCapabilities(OnAttachCapabilitiesEvent.java:21) ~[main/:?] {re:classloading} at net.minecraftforge.eventbus.ASMEventHandler_16_OnAttachCapabilitiesEvent_AttachCapabilities_AttachCapabilitiesEvent.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.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:579) ~[forge:?] {re:classloading} at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:573) ~[forge:?] {re:classloading} at net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:48) ~[forge:?] {re:classloading} at net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:44) ~[forge:?] {re:classloading} at net.minecraft.entity.Entity.<init>(Entity.java:221) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.entity.LivingEntity.<init>(LivingEntity.java:207) ~[forge:?] {re:classloading} at net.minecraft.entity.player.PlayerEntity.<init>(PlayerEntity.java:160) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.entity.player.ServerPlayerEntity.<init>(ServerPlayerEntity.java:182) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.management.PlayerList.createPlayerForUser(PlayerList.java:419) ~[forge:?] {re:classloading} at net.minecraft.network.login.ServerLoginNetHandler.tryAcceptPlayer(ServerLoginNetHandler.java:122) ~[forge:?] {re:classloading} at net.minecraft.network.login.ServerLoginNetHandler.tick(ServerLoginNetHandler.java:66) ~[forge:?] {re:classloading} at net.minecraft.network.NetworkManager.tick(NetworkManager.java:244) ~[forge:?] {re:classloading} at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:151) ~[forge:?] {re:classloading} ... 6 more
-
Sorry I forgot i translate it into english okay thanks, if I don't want to overwrite the block (ender chest). can I open the gui with the PlayerInteractEvent#RightClickBlock (using NetworkHooks) the container and when closing save them in the capability? do i have to creat a container with screen or an inventory because the ender chest use an inventory
-
[1.15.2] Override vanilla block and/or properties
Luis_ST replied to Asleep365's topic in Modder Support
I think yes, but I have no idea how you do it exactly. what you can try is to creat a ore generate and use vanilla dirt as a filler block Edit: what is also possible is to create a dirt block that extends the vanilla dirt (does not overwrite). which has your desired properties, and then generate them in the world instead of vanilla dirt -
i think the only way to get an Entity by id is Entity#getEntityId beacuse there is no methode inside the EntityType class which returns an id
-
There are two possibilities way 1 (difficult): create your own IItemTier and overwrite all tools with your new properties and register them with the vanilla name and the vanilla id way 2 (easy): use events to change the properties: - PlayerEvent#HarvestCheck -> harvestLevel - PlayerEvent#BreakSpeed -> breakSpeed - LivingDamageEvent -> damage of tools - LivingEntityUseItemEvent -> durablity
- 1 reply
-
- 1
-
Another question how to add the extendsEnderChestGui (Generic9x3 ChestContainer) to the Capability (with this two methode \/ ) do I have to synchronize the gui between the server and the client and if so how do I do it since I looked at a few mods on github that use SimpleChannel and an interface is there another way to do this? @Override public INBT writeNBT(Capability<IModItemHandler> capability, IModItemHandler instance, Direction side) { CompoundNBT nbt = new CompoundNBT(); return nbt; } @Override public void readNBT(Capability<IModItemHandler> capability, IModItemHandler instance, Direction side, INBT nbt) { }
-
do I have to register the capability or will it be registered automatically when I add it to the player
-
this is now my complet class is this corect: @CapabilityInject(IModItemHandler.class) public static Capability<IModItemHandler> ITEM_HANDLER_CAPABILITY = null; public ModCapability() { CapabilityManager.INSTANCE.register(IModItemHandler.class, new Storage(), new Factory()); } private static class Storage implements IStorage<IModItemHandler> { @Override public INBT writeNBT(Capability<IModItemHandler> capability, IModItemHandler instance, Direction side) { return null; } @Override public void readNBT(Capability<IModItemHandler> capability, IModItemHandler instance, Direction side, INBT nbt) { } } private static class Factory implements Callable<IModItemHandler> { @Override public IModItemHandler call() throws Exception { return null; } }
-
do i need the factory? and what's wrong with the factory? public ModCapability() { CapabilityManager.INSTANCE.register(IModItemHandler.class, new Storage(), new Factory()); } private static class Storage implements IStorage<IModItemHandler> { @Override public INBT writeNBT(Capability<IModItemHandler> capability, IModItemHandler instance, Direction side) { return null; } @Override public void readNBT(Capability<IModItemHandler> capability, IModItemHandler instance, Direction side, INBT nbt) { } } private static class Factory implements Callable<IModItemHandler> { @Override public IModItemHandler call() throws Exception { // what is here wrong? return new IModItemHandler(); } }
-
i just read this, and i created this but i'm not sure if this is correct: public class ModCapability { public ModCapability() { CapabilityManager.INSTANCE.register(IModItemHandler.class, new Storage(), null); } private static class Storage implements IStorage<IModItemHandler> { @Override public INBT writeNBT(Capability<IModItemHandler> capability, IModItemHandler instance, Direction side) { return null; } @Override public void readNBT(Capability<IModItemHandler> capability, IModItemHandler instance, Direction side, INBT nbt) { } } }
-
I created the classes as described above. how do I create or register the capability?
-
Now i have my custom Interfacce and a class which extends ItemStackHandler and implements my interface now i have to create a new capability like forge doc: @CapabilityInject(MyInterface.class) public static Capability<MyInterface> ITEM_HANDLER_CAPABILITY = null; but should the class in which i created the capability extends / implements another class
-
do I have to overwrite any method? using the AttachCapabilitiesEvent?
-
I want to overwrite the vanilla ender chest container that the enderchest uses the double chest container. I looked in the enderchest class vanilla uses PlayerEntity#getInventoryEnderChest to open the gui so my question how to creat my own enderchest gui with 54 slots? I know that I have to create my own capability. do I have to create a completely new one or can I use IItemHandler in my TileEntity? because in the forge doc to capabilities it says that I can use persisting capabilities. if I can use an existing capability, is this capability unique for each player? (this is the first time that i use capabilities so i have no experience with them).
-
i think the only way is to overwrite the vanilla piston block, because vanilla use the PistonBlockStructureHelper where the push limit is set (not in a field so there are no getter and setter)