Jump to content

Cron3x

Members
  • Posts

    10
  • Joined

  • Last visited

Everything posted by Cron3x

  1. Moin, what is your general goal you want to achive? Anyway https://github.com/discord-jda/JDA contains everything you have to do, just search for gradle and follow the steps
  2. Hello there, At the moment i allways create a private static final ResourceLocation HUD_TEXTURE_ATLAS = new ResourceLocation(Mod.MODID, "textures/gui/hud.png"); I do this in every Hud class. Now to my question, Should I create a different class wich loads all texture altlases at once and make them public? For my understanding my current method would always load the same file over and over, wich would be against the general idea of putting everything in on file. So what is the best way of loading Texture Sprites
  3. Thanks, I really didn't think of that. I feel stupid now
  4. For me it does work, are u sure u got the right version of the Mod and forge Server? Here are the versions I tested with: Server: https://files.minecraftforge.net/net/minecraftforge/forge/index_1.18.2.html (I used the one that says latest) Mod: https://www.curseforge.com/minecraft/mc-mods/gravestone-mod/files/3713957
  5. occureHi in my mod I have a method wich tells me if it is day or night: My Problem is that it does not always recognize the right time, I can fix this by manualy setting the time to night or day. Also this doesn't always occur. Does enyone know why? The default Minecraft Method also doesn't work. Thanks for helping
  6. If enyone has the same problem, here is my solution: You have to sync the client and server by overwriting this 4 methods: onDataPacket, the handleUpdateTag, getUpdatePacket, getUpdateTag. I also copied these methods, so credits to https://github.com/Mowmaster/ For me the methods are:
  7. Ok, Thank you. I will try to make it with a container. I thought containers where only needed if you use a GUI.
  8. I don't have a seperate container class, maybe thats the Problem? public class PedestalBlockEntity extends BlockEntity { private final ItemStackHandler inventory = new ItemStackHandler(1); private final LazyOptional<IItemHandler> optional = LazyOptional.of(() -> this.inventory); public PedestalBlockEntity(BlockPos pos, BlockState state) { super(BlockEntityRegister.PEDESTAL.get(), pos, state); } @Override public void load(CompoundTag nbt) { super.load(nbt); this.inventory.deserializeNBT(nbt.getCompound("Inventory")); System.out.println("load: " + nbt.getCompound("Inventory")); } @Override public void saveAdditional(@NotNull CompoundTag nbt) { super.saveAdditional(nbt); nbt.put("Inventory", this.inventory.serializeNBT()); System.out.println("saveAdditional: " + this.inventory.serializeNBT()); } @Override public @NotNull <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap) { return cap == ForgeCapabilities.ITEM_HANDLER ? this.optional.cast() : super.getCapability(cap, null); } @Override public void invalidateCaps() { this.optional.invalidate(); } public ItemStackHandler getInventory() { return inventory; } public ItemStack addItem(ItemStack itemStack, Boolean simulate){ IItemHandler h = optional.orElse(null); ItemStack returner = h.insertItem(0,itemStack.copy(), simulate); if(!simulate) update(); return returner; } public ItemStack getDisplayItem(Boolean simulate) { IItemHandler h = optional.orElse(null); ItemStack returner = h.extractItem(0,1,simulate); if(!simulate) update(); //System.out.println(""+returner); return returner; } public void update() { BlockState state = level.getBlockState(this.worldPosition); this.level.sendBlockUpdated(this.worldPosition, state, state, 3); this.setChanged(); } } Do You want the render class too?
  9. This is in the BlockEntity Class
  10. I want to write a mod with pedestals, I know nothing new but I need them. I wrote a method that gets the first item out of the inventory. If I use it on my use method in the Block Class everything works but if i call the same method from my renderer class it just get air. The code that gets the item: private final ItemStackHandler inventory = new ItemStackHandler(1); private final LazyOptional<IItemHandler> optional = LazyOptional.of(() -> this.inventory); public ItemStack getDisplayItem(Boolean simulate) { IItemHandler h = optional.orElse(null); ItemStack returner = h.extractItem(0,1,simulate); if(!simulate) update(); //System.out.println(""+returner); return returner; } the debug print shows that the returner is air when in rendering and the real item in other classes.
×
×
  • Create New...

Important Information

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