Jump to content

ElTotisPro50

Members
  • Posts

    266
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by ElTotisPro50

  1. Ok i created a new VOID world, put a teleporter without anything in it and teleported 500 blocks away, an that crashed my game with the exact same error, what the hell /*Synchronization to the client*/ @Nullable @Override public Packet<ClientGamePacketListener> getUpdatePacket() { return ClientboundBlockEntityDataPacket.create(this); } @Override public CompoundTag getUpdateTag() { return this.saveWithoutMetadata(); } @Override public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { super.onDataPacket(net, pkt); }
  2. If im correct, here (in the tick method): "ItemStack stack0 = ((TeleporterBlockEntity) level.getBlockEntity(pPos)).itemHandler.getStackInSlot(0);" The weird thing is that minecraft only crashes sometimes and when it wants, for example if i have 2 teleports 500 blocks away from each and i use one of them minecraft crashes, or when i tp too far away, but that only crashes the game sometimes, is VERY WEIRD BTW in the crash report the error is in line 219, this is line 219: ItemStack stack0 = ((TeleporterBlockEntity) level.getBlockEntity(pPos)).itemHandler.getStackInSlot(0); Crash report: https://pastebin.com/s2KqP6yX Block entity Class: public class TeleporterBlockEntity extends BlockEntity implements MenuProvider { private final ContainerData data; public final ItemStackHandler itemHandler = new ItemStackHandler(Constants.TELEPORTER_TOTALSLOTS) { @Override protected void onContentsChanged(int slot) { setChanged(); }; }; @Override public void setChanged() { super.setChanged(); } private LazyOptional<IItemHandler> lazyItemHandler = LazyOptional.empty(); public TeleporterBlockEntity(BlockPos pos, BlockState state) { super(ModBlockEntities.TELEPORTER_BLOCKENTITY.get(), pos, state); } @Override public AbstractContainerMenu createMenu(int id, Inventory inv, Player player) { return new TeleporterMenu(id, inv, this, this.data); } @Override public Component getDisplayName() { return new TextComponent(""); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @javax.annotation.Nullable Direction side) { if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return lazyItemHandler.cast(); } return super.getCapability(cap, side); } @Override public void onLoad() { super.onLoad(); lazyItemHandler = LazyOptional.of(() -> itemHandler); ModMessages.sendToClients(new PacketSyncTeleporterPosToClient(posX,posY,posZ,dimName,worldPosition)); } @Override public void invalidateCaps() { super.invalidateCaps(); lazyItemHandler.invalidate(); } @Override protected void saveAdditional(@NotNull CompoundTag tag) { tag.put("inventory", itemHandler.serializeNBT()); super.saveAdditional(tag); } @Override public void load(CompoundTag tag) { super.load(tag); itemHandler.deserializeNBT(tag.getCompound("inventory")); } public void drops() { SimpleContainer inventory = new SimpleContainer(itemHandler.getSlots()); for (int i = 0; i < itemHandler.getSlots(); i++) { inventory.setItem(i, itemHandler.getStackInSlot(i)); } Containers.dropContents(this.level, this.worldPosition, inventory); } public boolean hasCrystal() { return this.getItemFromSlot(0).getItem() == ModItems.TELEPORTCRYSTAL.get(); } public void setItemToSlot(int slot, ItemStack stack) { stack.setCount(1); this.itemHandler.setStackInSlot(slot, stack); } public ItemStack getItemFromSlot(int slot) { return this.itemHandler.getStackInSlot(slot); } public static void tick(Level level, BlockPos pPos, BlockState pState, TeleporterBlockEntity blockEntity) { level.getEntitiesOfClass(Player.class, new AABB(pPos.getX(), pPos.getY(), pPos.getZ(), pPos.getX() + 1, pPos.getY() + 1, pPos.getZ() + 1)).forEach(entity -> { if(!(entity instanceof Player)) return; if(!entity.isShiftKeyDown() || !entity.isCrouching()) return; if(level.getBlockEntity(pPos) != null && level.getBlockEntity(pPos) instanceof TeleporterBlockEntity) { ItemStack stack = ((TeleporterBlockEntity) level.getBlockEntity(pPos)).itemHandler.getStackInSlot(0); CompoundTag tag = stack.getTag(); if(tag == null) return; entity.playSound(SoundEvents.ENDERMAN_TELEPORT, 1, 1); if(!level.isClientSide) { String dim = TotisPlayerUtils.getDimension(stack); ResourceKey<Level> currentDim = level.dimension(); ServerLevel serverWorld = ((ServerLevel)level).getServer().getLevel(currentDim); ServerPlayer player = (ServerPlayer)entity; ResourceKey<Level> storedKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(dim)); ServerLevel storedWorld = ((ServerLevel)level).getServer().getLevel(storedKey); if(serverWorld == storedWorld) { player.teleportTo(tag.getInt("x")+0.5,tag.getInt("y")+1,tag.getInt("z")+0.5); } else { player.teleportTo(storedWorld, tag.getInt("x")+0.5,tag.getInt("y")+1,tag.getInt("z")+0.5, player.getRespawnAngle(), player.getRespawnAngle()); } } entity.playSound(SoundEvents.ENDERMAN_TELEPORT, 1, 1); } }); } /*Synchronization to the client*/ @Nullable @Override public Packet<ClientGamePacketListener> getUpdatePacket() { return ClientboundBlockEntityDataPacket.create(this); } @Override public CompoundTag getUpdateTag() { CompoundTag tag = saveWithoutMetadata(); load(tag); return tag; } @Override public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { super.onDataPacket(net, pkt); load(pkt.getTag()); } @Override public void handleUpdateTag(CompoundTag tag) { super.handleUpdateTag(tag); } }
  3. the chunk loading problem is solved but i realized that this is not necessary, actually is useless // I had to add this if lol if(!level.isClientSide) { ChunkPos chunkPos = new ChunkPos(pPos); ResourceKey<Level> currentDimension = level.dimension(); ServerLevel serverLevel = (ServerLevel)level.getServer().getLevel(currentDimension); ForgeChunkManager.forceChunk(serverLevel, Constants.MOD_ID, pPos, chunkPos.x,chunkPos.z,true,true); } but actually as you said, forcing the chunks is not helping me, im back to problem 1 Caused by: java.lang.NullPointerException: Cannot read field "itemHandler" because the return value of "net.minecraft.world.level.Level.getBlockEntity(net.minecraft.core.BlockPos)" is null what can i do
  4. Why i need this: My block entity is a teleporter, you put an item with coordinates inside the gui and when you shift above the block it teleports you, the problem is that if both block entities are too far away one from another is crashes the game java.lang.NullPointerException: Cannot read field "itemHandler" because the return value of "net.minecraft.world.level.Level.getBlockEntity(net.minecraft.core.BlockPos)" is null im pretty shure it needs the chunk loaded because it teleports me instantly and it doesnt have time to load the things of the block entity My point is that in the tick method, im trying to force the chunk just like the player's spawnpoint does, but is throwing me this error: Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.server.MinecraftServer.getLevel(net.minecraft.resources.ResourceKey)" because the return value of "net.minecraft.world.level.Level.getServer()" is null public static void tick(Level level, BlockPos pPos, BlockState pState, TeleportBlockEntity blockEntity) { ChunkPos chunkPos = new ChunkPos(pPos); ResourceKey<Level> currentDimension = level.dimension(); ServerLevel serverLevel = level.getServer().getLevel(currentDimension); ForgeChunkManager.forceChunk(serverLevel, Constants.MOD_ID, pPos, chunkPos.x,chunkPos.z,true,true); }
  5. cause i want to learn how to do it the minecraft way (events are from forge so minecraft had to do it different) i only found "UsedTotemTrigger" but it is another thing
  6. thats all i want, to know how can i copy the totem functionality to a custom totem without events (not the animation)
  7. That is an integer(1) because im only using 1 ContainerData Im not very good to explain myself so i tried to put almost all the code (not the smartest idea) and it didnt result well Basically, i had to use a ContainerData to get the integer value (private int slot0Price = 0;), so for example if i press a created button and get/set the integer value, it will work, but if i right click the block and try to do the same it wont work @Override public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player player, InteractionHand pHand, BlockHitResult pHit) { ItemStack stack = player.getItemInHand(pHand); VendingMachineBlockEntity entity = (VendingMachineBlockEntity) pLevel.getBlockEntity(pPos); if(!pLevel.isClientSide) { player.sendmessage(entity.getSlot0Price(), blahblah); } return super.use(pState, pLevel, pPos, player, pHand, pHit); } With "it wont work" i mean that when i change the integer with the screen (button and editbox) it sets the value to anything i want or gets it, but as i said it doesnt do it directly from the block entity
  8. So, if you want to access to a int variable from the screen you have to use ContainerData cause the server and client things, from the screen, i can get that value, but i cant from the block entity when the variable is created there (i need to get the value from the block entity too so when i right click the block, it gives me the price /* The block itself */ @Override public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player player, InteractionHand pHand, BlockHitResult pHit) { ItemStack stack = player.getItemInHand(pHand); VendingMachineBlockEntity entity = (VendingMachineBlockEntity) pLevel.getBlockEntity(pPos); if(!pLevel.isClientSide) { if(!player.isShiftKeyDown()) { if(entity instanceof VendingMachineBlockEntity) NetworkHooks.openGui(((ServerPlayer)player), (VendingMachineBlockEntity) entity, pPos); else throw new IllegalStateException("The Container provider is missing!"); } else { player.sendMessage(new TextComponent("" + entity.getSlot0Price()), player.getUUID()); } } return super.use(pState, pLevel, pPos, player, pHand, pHit); } In this case, the value is the price from the slot 0 public class VendingMachineBlockEntity extends BlockEntity implements MenuProvider { private int slot0Price = 0; private final ContainerData data; private final ItemStackHandler itemHandler = new ItemStackHandler(Constants.VENDINGMACHINE_TOTALSLOTS) { @Override protected void onContentsChanged(int slot) { setChanged(); }; }; private LazyOptional<IItemHandler> lazyItemHandler = LazyOptional.empty(); public VendingMachineBlockEntity(BlockPos pos, BlockState state) { super(ModBlockEntities.VENDINGMACHINE_BLOCKENTITY.get(), pos, state); this.data = new ContainerData() { @Override public int get(int index) { switch(index) { case 0: return VendingMachineBlockEntity.this.slot0Price; default: return 0; } } @Override public void set(int index, int value) { switch(index) { case 0: VendingMachineBlockEntity.this.slot0Price = value; break; }; } @Override public int getCount() { return Constants.VENDINGMACHINE_CONTAINERDATASIZE; } }; } @Override public AbstractContainerMenu createMenu(int id, Inventory inv, Player player) { return new VendingMachineMenu(id, inv, this, this.data); } @Override public Component getDisplayName() { return new TextComponent(""); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @javax.annotation.Nullable Direction side) { if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return lazyItemHandler.cast(); } return super.getCapability(cap, side); } @Override public void onLoad() { super.onLoad(); lazyItemHandler = LazyOptional.of(() -> itemHandler); } @Override public void invalidateCaps() { super.invalidateCaps(); lazyItemHandler.invalidate(); } @Override protected void saveAdditional(@NotNull CompoundTag tag) { tag.put("inventory", itemHandler.serializeNBT()); tag.putInt("Slot0Price", slot0Price); super.saveAdditional(tag); } @Override public void load(CompoundTag nbt) { super.load(nbt); itemHandler.deserializeNBT(nbt.getCompound("inventory")); slot0Price = nbt.getInt("Slot0Price"); } public void drops() { SimpleContainer inventory = new SimpleContainer(itemHandler.getSlots()); for (int i = 0; i < itemHandler.getSlots(); i++) { inventory.setItem(i, itemHandler.getStackInSlot(i)); } Containers.dropContents(this.level, this.worldPosition, inventory); } /*Synchronization to the client*/ @Nullable @Override public Packet<ClientGamePacketListener> getUpdatePacket() { return ClientboundBlockEntityDataPacket.create(this); } @Override public CompoundTag getUpdateTag() { return this.saveWithoutMetadata(); } @Override public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { super.onDataPacket(net, pkt); load(pkt.getTag()); } @Override public void handleUpdateTag(CompoundTag tag) { super.handleUpdateTag(tag); } public int getSlot0Price() { return data.get(0); //this is not getting me the value //return slot0Price; //neither this } } public class VendingMachineMenu extends AbstractContainerMenu { public final VendingMachineBlockEntity blockEntity; private final Level level; private final ContainerData data; // Client constructor public VendingMachineMenu(int pContainerId, Inventory inv, FriendlyByteBuf extraData) { this(pContainerId, inv, inv.player.level.getBlockEntity(extraData.readBlockPos()), new SimpleContainerData(Constants.VENDINGMACHINE_CONTAINERDATASIZE)); } // Server constructor public VendingMachineMenu(int pContainerId, Inventory inv, BlockEntity entity, ContainerData data) { super(ModMenuTypes.VENDINGMACHINE_MENU.get(), pContainerId); checkContainerSize(inv, Constants.VENDINGMACHINE_TOTALSLOTS); blockEntity = ((VendingMachineBlockEntity) entity); this.level = inv.player.level; this.data = data; addPlayerInventory(inv); addPlayerHotbar(inv); this.blockEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(handler -> { //The third and fourth numbers are the position of the slots // (this.addSlot(new SlotItemHandler(handler, 0, THIRD, FOURTH));) //in an editing program, put your mouse above one of the slots at the top left part //(the mouse goes starting from the lightest grey pixel) this.addSlot(new SlotItemHandler(handler, 0, 62, 0)); this.addSlot(new SlotItemHandler(handler, 1, 80, 0)); this.addSlot(new SlotItemHandler(handler, 2, 98, 0)); this.addSlot(new SlotItemHandler(handler, 3, 62, 18)); this.addSlot(new SlotItemHandler(handler, 4, 80, 18)); this.addSlot(new SlotItemHandler(handler, 5, 98, 18)); this.addSlot(new SlotItemHandler(handler, 6, 62, 36)); this.addSlot(new SlotItemHandler(handler, 7, 80, 36)); this.addSlot(new SlotItemHandler(handler, 8, 98, 36)); this.addSlot(new SlotItemHandler(handler, 9, 62, 54)); this.addSlot(new SlotItemHandler(handler, 10, 80, 54)); this.addSlot(new SlotItemHandler(handler, 11, 98, 54)); this.addSlot(new SlotItemHandler(handler, 12, 62, 72)); this.addSlot(new SlotItemHandler(handler, 13, 80, 72)); this.addSlot(new SlotItemHandler(handler, 14, 98, 72)); //for(int i = 0; i < 5; i++) { // downwards //for(int l = 0; l < 3; l++) { // rightwards //this.addSlot(new SlotItemHandler(handler, l + i * 3 + 3, 62 + l * 18, 0 + i * 18)); //} //} }); addDataSlots(data); } private static final int HOTBAR_SLOT_COUNT = 9; private static final int PLAYER_INVENTORY_ROW_COUNT = 3; private static final int PLAYER_INVENTORY_COLUMN_COUNT = 9; private static final int PLAYER_INVENTORY_SLOT_COUNT = PLAYER_INVENTORY_COLUMN_COUNT * PLAYER_INVENTORY_ROW_COUNT; private static final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT; private static final int VANILLA_FIRST_SLOT_INDEX = 0; private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT; // THIS YOU HAVE TO DEFINE! private static final int TE_INVENTORY_SLOT_COUNT = Constants.VENDINGMACHINE_TOTALSLOTS - 1; // must be the number of slots you have! @Override public ItemStack quickMoveStack(Player playerIn, int index) { Slot sourceSlot = slots.get(index); if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM ItemStack sourceStack = sourceSlot.getItem(); ItemStack copyOfSourceStack = sourceStack.copy(); // Check if the slot clicked is one of the vanilla container slots if (index < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) { // This is a vanilla container slot so merge the stack into the tile inventory if (!moveItemStackTo(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT, false)) { return ItemStack.EMPTY; // EMPTY_ITEM } } else if (index < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) { // This is a TE slot so merge the stack into the players inventory if (!moveItemStackTo(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) { return ItemStack.EMPTY; } } else { System.out.println("Invalid slotIndex:" + index); return ItemStack.EMPTY; } // If stack size == 0 (the entire stack was moved) set slot contents to null if (sourceStack.getCount() == 0) { sourceSlot.set(ItemStack.EMPTY); } else { sourceSlot.setChanged(); } sourceSlot.onTake(playerIn, sourceStack); return copyOfSourceStack; } @Override public boolean stillValid(Player pPlayer) { return stillValid(ContainerLevelAccess.create(level, blockEntity.getBlockPos()), pPlayer, ModBlocks.VENDING_MACHINE.get()); } private final void addPlayerInventory(Inventory playerInventory) { for (int i = 0; i < 3; ++i) { for (int l = 0; l < 9; ++l) { this.addSlot(new Slot(playerInventory, l + i * 9 + 9, 8 + l * 18, 102 + i * 18)); //default: 122 } } } private final void addPlayerHotbar(Inventory playerInventory) { for (int i = 0; i < 9; ++i) { this.addSlot(new Slot(playerInventory, i, 8 + i * 18, 160)); //default: 180 } } public int getPriceFromSlot(int slot) { return data.get(slot); } public void setSlot0Price(int price) { data.set(0, price); } } public class VendingMachineScreen extends AbstractContainerScreen<VendingMachineMenu> { public static final String UP_ARROW = "\u2191"; public static final String DOWN_ARROW = "\u2193"; public static final String LEFT_ARROW = "\u2190"; public static final String RIGHT_ARROW = "\u2192"; public static final ResourceLocation TEXTURE = new ResourceLocation(Constants.MOD_ID, "textures/gui/vendingmachine_gui.png"); private final Player player; private Button button; public EditBox box; public VendingMachineScreen(VendingMachineMenu menu, Inventory inv, Component component) { super(menu, inv, component); this.player = inv.player; inventoryLabelY = -1000; } @Override protected void init() { super.init(); this.minecraft.keyboardHandler.setSendRepeatsToGui(true); this.box = new EditBox(font, leftPos + 122, topPos + 15, 76, 15, TextComponent.EMPTY); this.box.setCanLoseFocus(false); this.box.setTextColor(-1); this.box.setTextColorUneditable(-1); this.box.setBordered(true); this.box.setMaxLength(50); //this.box.setSuggestion("Introduce a 4 characters password"); this.box.setValue(""); this.addWidget(this.box); this.setInitialFocus(this.box); this.button = addRenderableWidget(new Button(leftPos + 128, topPos + 60, 66, 20, new TextComponent("Set price"), thebutton -> { // slot;price String slot = TotisJavaUtils.removeSymbol(TotisJavaUtils.removeSpaces(TotisJavaUtils.separateBySymbol(this.box.getValue(), ";", 0)), "."); String price = TotisJavaUtils.removeSymbol(TotisJavaUtils.removeSpaces(TotisJavaUtils.separateBySymbol(this.box.getValue(), ";", 1)), "."); if (slot == null || price == null || this.box.getValue().equalsIgnoreCase("") || this.box.getValue().length() < 1) return; if(menu.blockEntity.getItemFromSlot(Integer.parseInt(slot)).is(Items.AIR) || menu.blockEntity.getItemFromSlot(Integer.parseInt(slot)).sameItem(ItemStack.EMPTY)) { player.sendMessage(new TextComponent(ChatFormatting.RED + "That slot does not have an item"), player.getUUID()); return; } this.menu.setSlot0Price(Integer.parseInt(price)); this.menu.blockEntity.getSlot0Price(); player.sendMessage(new TextComponent(this.menu.getPriceFromSlot(0) + " is the price"), player.getUUID()); player.sendMessage(new TextComponent(ChatFormatting.BLUE + "The item from slot " + slot + " now has a price of $" + price), player.getUUID()); player.closeContainer(); })); } @Override public void resize(Minecraft pMinecraft, int pWidth, int pHeight) { super.resize(pMinecraft, pWidth, pHeight); String s = this.box.getValue(); this.box.setValue(s); } @Override public void removed() { super.removed(); this.minecraft.keyboardHandler.setSendRepeatsToGui(false); } public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) { if (pKeyCode == 256) { this.minecraft.player.closeContainer(); } return !this.box.keyPressed(pKeyCode, pScanCode, pModifiers) && !this.box.canConsumeInput() ? super.keyPressed(pKeyCode, pScanCode, pModifiers) : true; } @Override protected void renderLabels(PoseStack p_97808_, int p_97809_, int p_97810_) { super.renderLabels(p_97808_, p_97809_, p_97810_); } @Override protected void renderBg(PoseStack stack, float partialTick, int mouseX, int mouseY) { RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShaderTexture(0, TEXTURE); //int x = (width - imageWidth) / 2; //int y = (height - imageHeight) / 2; int x = this.leftPos; int y = this.topPos; this.blit(stack, x, y - 20, 0, 0, imageWidth + 30, imageHeight + 36); } @Override public void render(PoseStack pPoseStack, int mouseX, int mouseY, float delta) { renderBackground(pPoseStack); super.render(pPoseStack, mouseX, mouseY, delta); this.renderFg(pPoseStack, mouseX, mouseY, delta); renderTooltip(pPoseStack, mouseX, mouseY); } public void renderFg(PoseStack pPoseStack, int pMouseX, int pMouseY, float pPartialTick) { this.box.render(pPoseStack, pMouseX, pMouseY, pPartialTick); } } )
  9. I forgot i wrote that, but that is a porting from 1.18 to 1.19, i want what Luis_ST said: the discord bot I cant find a discord server for forge and less, a bot that translates methods, fields and classes
  10. yeah i know about that, thats why i said that i cant use that page, only translates between fabric and forge
  11. (this is an example), i found a mod that has code that could help me, but oh no the mod is made for minecraft 1.12/1.16, etc (versions lower that 1.18 that is where im now) For example in 1.16.5 there is a class named "Tessellator" with double L, and now they changed the name(i found a class named the same but with one L, but it doesnt have all the methods so i think they changed the class's name), so i want some kind of program, bot, page, anything that translates METHODS, FIELDS AND CLASSES from 2 different versions I found a page that does kind of that because it translates from fabric to forge or viceversa (https://linkie.shedaniel.me/mappings), but as i said i want to translate from 2 different versions both from forge I found out that there is a discord bot that does that, but i cant find it, but i could use another method to achieve what i want to
  12. It works now, thanks /*Synchronization to the client*/ @Nullable @Override public Packet<ClientGamePacketListener> getUpdatePacket() { return ClientboundBlockEntityDataPacket.create(this); } @Override public CompoundTag getUpdateTag() { return this.saveWithoutMetadata(); } @Override public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { super.onDataPacket(net, pkt); load(pkt.getTag()); } @Override public void handleUpdateTag(CompoundTag tag) { super.handleUpdateTag(tag); }
  13. not working /*Synchronization to the client*/ @Nullable @Override public Packet<ClientGamePacketListener> getUpdatePacket() { return ClientboundBlockEntityDataPacket.create(this); } @Override public CompoundTag getUpdateTag() { CompoundTag tag = super.getUpdateTag(); return tag; } @Override public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { super.onDataPacket(net, pkt); } @Override public void handleUpdateTag(CompoundTag tag) { super.handleUpdateTag(tag); } A dude asked for something about fluids in his GUI, and he also needed to sync it to the client, "used the 4 same methods like me"
  14. So i have my block entity, that renders the item that the container has in the slot, but when i leave the world the item rendering doesnt show up, i have to "update" the block by opening the menu, and it is not very nice because every time you would have to update the block. I want that the rendering never disappears private void registerRenderers(final EntityRenderersEvent.RegisterRenderers event) { event.registerBlockEntityRenderer(ModBlockEntities.MYBLOCK_BLOCKENTITY.get(), MyBlockEntityRender::new); } public class MyBlockEntityRender implements BlockEntityRenderer<MyBlockBlockEntity> { private final BlockEntityRendererProvider.Context context; private final Minecraft mc = Minecraft.getInstance(); public MyBlockEntityRender(BlockEntityRendererProvider.Context context) { this.context = context; } @Override public void render(MyBlockBlockEntity blockEntity, float partialTicks, PoseStack stack,MultiBufferSource buffer, int combinedLightIn,int combinedOverlayIn) { final LocalPlayer player = mc.player; final ItemRenderer itemRenderer = mc.getItemRenderer(); if (blockEntity.getItemSlot0().getItem().equals(Items.AIR) || blockEntity.getItemSlot0().getItem().equals(ItemStack.EMPTY)) return; renderItem(blockEntity.getItemSlot0(), new double[]{0,1,0}, Vector3f.XP.rotationDegrees(0), 0.5f, stack,buffer, combinedLightIn, OverlayTexture.NO_OVERLAY); } public void renderItem(ItemStack item, double[] translation, Quaternion rotation, float scale, PoseStack stack, MultiBufferSource buffer, int combinedLightIn, int combinedOverlayIn) { final LocalPlayer player = mc.player; final ItemRenderer itemRenderer = mc.getItemRenderer(); stack.pushPose(); stack.translate(translation[0],translation[1],translation[2]); stack.mulPose(rotation); stack.scale(scale,scale,scale); itemRenderer.renderStatic(player, item, ItemTransforms.TransformType.FIXED, false, stack,buffer, mc.level, combinedLightIn,combinedOverlayIn, 0); stack.popPose(); } } I dont think is necessary to show all the other clases, both of this are the ones that controls the rendering
  15. So, i want that i can hurt my entity, but at the same time is like it doesnt have any collisions(like a ghost that i can't trespass it) The method "isPushable" is not working when im returning false and im overriding it, so for fixing that(make that i cant push it when i hit my entity) i did this: @Override public void knockback(double p_147241_, double p_147242_, double p_147243_) { super.knockback(0,0,0); } And the only thing remaining as i said, make that i can't pass through my entity I thought that the method "canBeCollidedWith" could work but that doesnt let me hurt my entity, so i need another method to do it
  16. well there isn't enough information to learn how to to this well, so i have to wait until someone that knows a bit of this theme helps me, thank you anyway
  17. Thank you it helped me, how do i change the post's title to "solved"
  18. First, i know i have to use RenderPlayerEvent.Post for changing player stuff like size, rotation of player body parts, etc. And .Pre for capes, elytras, etc Knowing that, i tried 2 things, rotate the player's arm and change the player's size(only visual but still) but non of them works @EventBusSubscriber public class PlayerRenderingEvent { @SubscribeEvent public void playerRendering(RenderPlayerEvent.Post event) { //This one PoseStack pose = new PoseStack(); pose.pushPose(); pose.scale(2, 2, 2); pose.popPose(); //Or this one event.getRenderer().getModel().leftArm.xRot = (float) Math.toRadians(120); } }
  19. I would like to understand how to translate classes or methods from lower versions, for example, in 1.19.2 i cant find the method .pushMatrix(), .popMatrix(), translatef(), etc (from the class GLStateManager) First: what are the new names of those methods and Second: is there a website or something that translates classes/methods from different forge versions?
  20. @Luis_STi opened the class which is in package net.minecraft.client.particle; and i cant see anything about setParticleSpeed, even if i CONTROL+F to search in all class there is no word called speed create instance of my particle?, i would instance Particle ABSTRACT class Particle particle = new Particle() { @Override public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) { } @Override public IParticleRenderType getRenderType() { return null; } };
  21. @Alpvaxsorry for @ing you but i cant quote your answer(i think the page is bugged), where do i get the setParticeSpeed, and what constructor do you mean?
  22. and for the x,y,z speed? as i told you tha particle stays with me it doesnt shoot where im looking
  23. 1 didnt work so i multiplied it by 100,appart of that the particles stay in the same place (btw getEyeHeight or getHeight makes that the particles doesnt spawn i dont know if i have to add or substract something to eyeheight but it doesnt matter so im using getPosY() + 1.5) world.addParticles(particles, player.getPosX(), player.getPosY() + 1.3, player.getPosZ(), player.getLookVec().x * 100, player.getLookVec().y * 100, player.getLookVec().z * 100);
×
×
  • Create New...

Important Information

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