• Recently Browsing

    No registered users viewing this page.

  • Posts

    • Does the issue still happen with a newly made world? If not, then the world must be corrupted. If it does, something is corrupting your worlds. (I suggest checking the drive's health and/or running some scans)
    • 1.8 is not supported on this forum. Please update to a modern version of Minecraft to receive support.
    • I have a problem with passing milk capacity variable to screen class Tile Entity: package com.budrunbun.lavalamp.tileEntities; import com.budrunbun.lavalamp.containers.CheeseGeneratorContainer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.items.ItemStackHandler; import javax.annotation.Nullable; public class CheeseGeneratorTileEntity extends TileEntity implements INamedContainerProvider, ITickableTileEntity { private int milkCapacity = 0; private final ItemStackHandler handler = new ItemStackHandler(3) { @Override protected void onContentsChanged(int slot) { super.onContentsChanged(slot); markDirty(); } }; public CheeseGeneratorTileEntity() { super(ModTileEntities.CHEESE_GENERATOR_TE); } @Override public void read(CompoundNBT compound) { handler.deserializeNBT(compound.getCompound("inv")); super.read(compound); } @Override public CompoundNBT write(CompoundNBT compound) { compound.put("inv", handler.serializeNBT()); return super.write(compound); } @Override public ITextComponent getDisplayName() { return new TranslationTextComponent("cheese_generator"); } @Nullable @Override public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity playerEntity) { return new CheeseGeneratorContainer(windowId, playerInventory, handler, this.milkCapacity); } public ItemStackHandler getHandler() { return handler; } public TileEntity getTileEntity() { return this; } @Override public void tick() { if (this.handler.getStackInSlot(2).getItem() == (Items.MILK_BUCKET) && this.milkCapacity < 8) { this.handler.setStackInSlot(2, new ItemStack(Items.BUCKET)); this.milkCapacity++; this.markDirty(); } } } Container: package com.budrunbun.lavalamp.containers; import com.budrunbun.lavalamp.containers.slots.CheeseGeneratorInputSlot; import com.budrunbun.lavalamp.containers.slots.CheeseGeneratorOutputSlot; import com.budrunbun.lavalamp.tileEntities.CheeseGeneratorTileEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.Slot; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.SlotItemHandler; import net.minecraftforge.items.wrapper.InvWrapper; public class CheeseGeneratorContainer extends Container { private final IItemHandler generatorInventory, playerInventory; private int milkCapacity; public CheeseGeneratorContainer(int windowId, PlayerInventory playerInventory, IItemHandler generatorInventory, int milkCapacity) { super(ModContainers.CHEESE_GENERATOR_CONTAINER, windowId); this.generatorInventory = generatorInventory; this.playerInventory = new InvWrapper(playerInventory); this.milkCapacity = milkCapacity; this.addSlot(new CheeseGeneratorInputSlot(generatorInventory, 0, 51, 29)); this.addSlot(new CheeseGeneratorOutputSlot(generatorInventory, 1, 123, 29, playerInventory.player)); this.addSlot(new CheeseGeneratorInputSlot(generatorInventory, 2, 11, 55)); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { this.addSlot(new SlotItemHandler(this.playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int k = 0; k < 9; ++k) { this.addSlot(new SlotItemHandler(this.playerInventory, k, 8 + k * 18, 142)); } } @Override public boolean canInteractWith(PlayerEntity playerIn) { return true; } public int getMilkCapacity() { return milkCapacity; } @Override public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack stack = slot.getStack(); itemstack = stack.copy(); if (index == 0) { if (!this.mergeItemStack(stack, 1, 37, true)) { return ItemStack.EMPTY; } slot.onSlotChange(stack, itemstack); } else { if (stack.getItem() == Items.MILK_BUCKET) { if (!this.mergeItemStack(stack, 0, 1, false)) { return ItemStack.EMPTY; } } else if (index < 28) { if (!this.mergeItemStack(stack, 28, 37, false)) { return ItemStack.EMPTY; } } else if (index < 37 && !this.mergeItemStack(stack, 1, 28, false)) { return ItemStack.EMPTY; } } if (stack.isEmpty()) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } if (stack.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } slot.onTake(playerIn, stack); } return itemstack; } } Screen: package com.budrunbun.lavalamp.screens; import com.budrunbun.lavalamp.containers.CheeseGeneratorContainer; import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; public class CheeseGeneratorScreen extends ContainerScreen<CheeseGeneratorContainer> { private static final ResourceLocation GUI = new ResourceLocation("lavalamp", "textures/gui/container/cheese_generator.png"); public CheeseGeneratorScreen(CheeseGeneratorContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) { super(screenContainer, inv, titleIn); } public void render(int mouseX, int mouseY, float partialTicks) { this.renderBackground(); super.render(mouseX, mouseY, partialTicks); this.renderHoveredToolTip(mouseX, mouseY); } /** * Draw the foreground layer for the GuiContainer (everything in front of the items) */ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { //this.font.drawString("Cheese Maker", 8.0F, 6.0F, 4210752); this.font.drawString(this.playerInventory.getDisplayName().getFormattedText(), 8.0F, (float) (this.ySize - 96 + 2), 4210752); this.font.drawString(this.container.getMilkCapacity() + "/8" , 8.0F, 6.0F, 4210752); } /** * Draws the background layer of this container (behind the items). */ protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); this.minecraft.getTextureManager().bindTexture(GUI); int i = (this.width - this.xSize) / 2; int j = (this.height - this.ySize) / 2; blit(i, j, 0, 0, this.xSize, this.ySize, 256, 256); } }  
    • Sorry for the bad explanation I am going to explain it  better:I want to make a block like the furnace,that rotates when the player places it.I did the block implementing and it looks cool in the game but its always looking at the same direction(I think north) when I place it. This is the class: package com.xed.basic.blocks; import net.minecraft.block.*; import net.minecraft.block.material.Material; import net.minecraft.item.BlockItemUseContext; import net.minecraft.state.DirectionProperty; import net.minecraft.state.StateContainer; import net.minecraft.util.Direction; import net.minecraftforge.common.ToolType; public class Forge extends Block { public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING; public Forge() { super(AbstractBlock.Properties.create(Material.ROCK) .hardnessAndResistance(3.0f,6.0f) .sound(SoundType.STONE) .harvestLevel(3) .harvestTool(ToolType.PICKAXE) .func_235861_h_() ); this.setDefaultState(this.stateContainer.getBaseState().with(FACING,Direction.NORTH)); } @Override protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder){ builder.add(FACING); } public BlockState getStateForPlacement(BlockItemUseContext context) { return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite()); } } And this is the RegistryHandler: package com.xed.basic.util; import com.xed.basic.Basic; import com.xed.basic.blocks.BlockItemBase; import com.xed.basic.blocks.Forge; import com.xed.basic.blocks.MagnificentDiamondOre; import com.xed.basic.items.CoinsBase; import com.xed.basic.items.DiamondHeart; import com.xed.basic.items.ItemBase; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; public class RegistryHandler { public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Basic.MOD_ID); public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Basic.MOD_ID); public static void init(){ ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus()); } //Items public static final RegistryObject<Item> GOLDEN_COIN = ITEMS.register("golden_coin", CoinsBase::new); public static final RegistryObject<Item> SILVER_COIN = ITEMS.register("silver_coin", CoinsBase::new); public static final RegistryObject<Item> MAGNIFICENT_DIAMOND = ITEMS.register("magnificent_diamond", ItemBase::new); //Advanced Items public static final RegistryObject<DiamondHeart> DIAMOND_HEART = ITEMS.register("diamond_heart", DiamondHeart::new); //Blocks public static final RegistryObject<Block> MAGNIFICENT_DIAMOND_ORE = BLOCKS.register("magnificent_diamond_ore", MagnificentDiamondOre::new); public static final RegistryObject<Forge> FORGE = BLOCKS.register("forge",Forge::new); //Block Items public static final RegistryObject<Item> MAGNIFICENT_DIAMOND_ORE_ITEM = ITEMS.register("magnificent_diamond_ore", () -> new BlockItemBase(MAGNIFICENT_DIAMOND_ORE.get())); public static final RegistryObject<Item> FORGE_ITEM = ITEMS.register("forge", () -> new BlockItemBase(FORGE.get())); } And the .json model: { "parent": "block/cube_all", "textures": { "particle": "basic:/blocks/forge_front", "north": "basic:/blocks/forge_front", "south": "basic:/blocks/forge_side", "east": "basic:/blocks/forge_side", "west": "basic:/blocks/forge_side", "up": "basic:/blocks/forge_top", "down": "basic:/blocks/forge_top" } }  
    • Ah, didn't see it at first since it's very hidden amongst non-highlighted log entries. Hm, something must be causing the server to not process ticks correctly. (The ServerHangWatchdog, as you may have guessed, watches the server for hangs, and kills it after 60s without ticking) I'll try and investiage the issue, if I can reproduce it. Can you please try starting the Forge server again, and have the first connection to it be a vanilla client? Just to test if you can reproduce the issue cleanly.
  • Topics

  • Who's Online (See full list)