Jump to content

Jar36

Members
  • Posts

    7
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Jar36's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I added a tile entity with a container GUI in my mod But when i clicked the block ,it printed a lot of stacktrace but not make crash this is the stacktrace [21:45:45] [Server thread/FATAL] [minecraft/ThreadTaskExecutor]: Error executing task on Server java.lang.UnsupportedOperationException: Unable to construct this menu by type at net.minecraft.inventory.container.Container.getType(Container.java:56) ~[forge:?] {re:classloading} at net.minecraftforge.fml.network.NetworkHooks.openGui(NetworkHooks.java:227) ~[forge:?] {re:classloading} at net.minecraftforge.fml.network.NetworkHooks.openGui(NetworkHooks.java:192) ~[forge:?] {re:classloading} at com.lucaiyu.touhoucraft.blocks.DonateBox.onBlockActivated(DonateBox.java:46) ~[?:?] {re:classloading} at net.minecraft.block.AbstractBlock$AbstractBlockState.onBlockActivated(AbstractBlock.java:732) ~[forge:?] {re:classloading} at net.minecraft.server.management.PlayerInteractionManager.func_219441_a(PlayerInteractionManager.java:347) ~[forge:?] {re:classloading} at net.minecraft.network.play.ServerPlayNetHandler.processTryUseItemOnBlock(ServerPlayNetHandler.java:986) ~[forge:?] {re:classloading} at net.minecraft.network.play.client.CPlayerTryUseItemOnBlockPacket.processPacket(CPlayerTryUseItemOnBlockPacket.java:45) ~[forge:?] {re:classloading} at net.minecraft.network.play.client.CPlayerTryUseItemOnBlockPacket.processPacket(CPlayerTryUseItemOnBlockPacket.java:12) ~[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:759) ~[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:742) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.driveOne(MinecraftServer.java:736) ~[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:721) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:668) ~[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:748) [?:1.8.0_312] {} This is the block package com.lucaiyu.touhoucraft.blocks; import com.lucaiyu.touhoucraft.blocks.tileentities.DonateBoxGuiTileEntity; import com.lucaiyu.touhoucraft.blocks.tileentities.TileEntityRegistry; import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.network.PacketBuffer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.common.ToolType; import net.minecraftforge.fml.network.NetworkHooks; import javax.annotation.Nullable; public class DonateBox extends Block { public DonateBox() { super(AbstractBlock.Properties.create(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(1.0F, 1.0F).harvestTool(ToolType.AXE)); } @Override public boolean hasTileEntity(BlockState state){ return true; } @Nullable @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return TileEntityRegistry.donate_box_gui_tile_entity.get().create(); } @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { if (!worldIn.isRemote){ TileEntity tileEntity = worldIn.getTileEntity(pos); if (tileEntity instanceof DonateBoxGuiTileEntity){ NetworkHooks.openGui((ServerPlayerEntity) player,(DonateBoxGuiTileEntity)tileEntity, pos); } } return ActionResultType.SUCCESS; } } This is the tile entity package com.lucaiyu.touhoucraft.blocks.tileentities; import com.lucaiyu.touhoucraft.TouHouCraft; import com.lucaiyu.touhoucraft.containers.DonateBoxContainer; import net.minecraft.block.BlockState; 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.nbt.CompoundNBT; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; import javax.annotation.Nullable; public class DonateBoxGuiTileEntity extends TileEntity implements ITickableTileEntity, INamedContainerProvider { private static final int SLOTS = 1; private static int power = 0; @Override public void read(BlockState state, CompoundNBT nbt) { power = nbt.getInt("power"); super.read(state, nbt); } @Override public CompoundNBT write(CompoundNBT compound) { compound.putInt("power", power); return super.write(compound); } public DonateBoxGuiTileEntity(TileEntityType<?> tileEntityTypeIn) { super(tileEntityTypeIn); } public DonateBoxGuiTileEntity(){ this(TileEntityRegistry.donate_box_gui_tile_entity.get()); } @Override public void tick() { // todo } @Override public ITextComponent getDisplayName() { return new TranslationTextComponent("container." + TouHouCraft.MOD_ID + ".donate_box"); } @Nullable @Override public Container createMenu(int id, PlayerInventory playerInventory, PlayerEntity playerEntity) { return new DonateBoxContainer(id, playerInventory, this); } } This is the container package com.lucaiyu.touhoucraft.containers; import com.lucaiyu.touhoucraft.blocks.BlockRegistry; import com.lucaiyu.touhoucraft.blocks.tileentities.DonateBoxGuiTileEntity; 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.network.PacketBuffer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.IWorldPosCallable; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.SlotItemHandler; import java.util.Objects; public class DonateBoxContainer extends Container { public final DonateBoxGuiTileEntity tileentity; private final IWorldPosCallable ableToInteract; private final LazyOptional<IItemHandler> UP; public DonateBoxContainer(final int id, final PlayerInventory playerInventory, final DonateBoxGuiTileEntity entity){ super(null, id); this.tileentity = entity; this.ableToInteract = IWorldPosCallable.of(tileentity.getWorld(), tileentity.getPos()); this.UP = tileentity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP); this.UP.ifPresent((s)->{ this.addSlot(new SlotItemHandler(s, 0, 80, 32)); }); for (int i = 0;i < 8; i++) { this.addSlot(new Slot(playerInventory,i,i*18+8,152)); this.addSlot(new Slot(playerInventory,i+9,i*18+8,94)); this.addSlot(new Slot(playerInventory,i+18,i*18+8,112)); this.addSlot(new Slot(playerInventory,i+27,i*18+8,130)); } } public DonateBoxContainer(final int id, final PlayerInventory playerInventory, final PacketBuffer data) { this(id, playerInventory,getTileEntity(playerInventory, data)); } public static DonateBoxGuiTileEntity getTileEntity(PlayerInventory playerInventory, PacketBuffer data){ Objects.requireNonNull(playerInventory, "player inventory couldn't be null!"); Objects.requireNonNull(data, "Packet buffer counldn't be null!"); BlockPos blockPos = data.readBlockPos(); TileEntity tileEntity = playerInventory.player.world.getTileEntity(blockPos); if(tileEntity instanceof DonateBoxGuiTileEntity){ return ((DonateBoxGuiTileEntity) tileEntity); } throw new IllegalStateException("Invalid tile entity!"); } @Override public boolean canInteractWith(PlayerEntity playerIn) { return isWithinUsableDistance(ableToInteract, playerIn, BlockRegistry.donate_box.get()); } @Override public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { return ItemStack.EMPTY; } } And this is the GUI package com.lucaiyu.touhoucraft.client.gui; import com.lucaiyu.touhoucraft.TouHouCraft; import com.lucaiyu.touhoucraft.containers.DonateBoxContainer; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; 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; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class DonateBoxGui extends ContainerScreen<DonateBoxContainer> { private static final ResourceLocation DONATE_BOX_GUI = new ResourceLocation(TouHouCraft.MOD_ID,"textures/gui/donate_box_gui.png"); public DonateBoxGui(DonateBoxContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) { super(screenContainer, inv, titleIn); this.guiLeft = 0; this.guiTop = 0; this.xSize = 176; this.ySize = 176; } @Override public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { this.drawGuiContainerBackgroundLayer(matrixStack,partialTicks,mouseX,mouseY); super.render(matrixStack, mouseX, mouseY, partialTicks); this.renderHoveredTooltip(matrixStack, mouseX, mouseY); } @Override protected void drawGuiContainerForegroundLayer(MatrixStack matrixStack, int x, int y) { this.font.func_243248_b(matrixStack, this.playerInventory.getDisplayName(), (float) this.playerInventoryTitleX, (float) this.playerInventoryTitleY, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(MatrixStack matrixStack, float partialTicks, int mouseX, int mouseY) { RenderSystem.color4f(1.0F,1.0F,1.0F,1.0F); this.minecraft.textureManager.bindTexture(DONATE_BOX_GUI); int x = (this.width-this.xSize)/2; int y = (this.height - this.ySize)/2; this.blit(matrixStack, x, y, 0, 0, this.xSize, this.ySize); } } The registry had no problem Please help me This is the repo of my project https://www.github.com/lucaiyu/TouhouCraft
  2. Minecraft version:1.16.5 Forge version:32.6.34 MCP mapping version:20201028-1.16.3-snapshot I tried to add an entity to my game,compile is succsseful,but when i enter "/summon touhoucraft:power_point ~ ~ ~" It returned "Unable to summon entity" this is the entity code and model& render code package com.lucaiyu.touhoucraft.entities; import net.minecraft.entity.EntityType; import net.minecraft.entity.MobEntity; import net.minecraft.world.World; public class PowerPoint extends MobEntity { public PowerPoint(World worldIn){ this(null, worldIn); } public PowerPoint(EntityType<? extends MobEntity> type, World worldIn) { super(type, worldIn); } } package com.lucaiyu.touhoucraft.entities.model; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import net.minecraft.client.renderer.entity.model.EntityModel; import net.minecraft.client.renderer.model.ModelRenderer; import com.lucaiyu.touhoucraft.entities.PowerPoint; public class PowerPointModel extends EntityModel<PowerPoint> { private final ModelRenderer bb_main; public PowerPointModel() { textureWidth = 64; textureHeight = 64; bb_main = new ModelRenderer(this); bb_main.setRotationPoint(0.0F, 24.0F, 0.0F); bb_main.setTextureOffset(0, 0).addBox(-5.0F, -0.5F, -5.0F, 10.0F, 1.0F, 10.0F, 0.0F, false); } @Override public void setRotationAngles(PowerPoint entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch){ } @Override public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){ bb_main.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); } public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { modelRenderer.rotateAngleX = x; modelRenderer.rotateAngleY = y; modelRenderer.rotateAngleZ = z; } } package com.lucaiyu.touhoucraft.entities.render; import com.lucaiyu.touhoucraft.TouHouCraft; import com.lucaiyu.touhoucraft.entities.PowerPoint; import com.lucaiyu.touhoucraft.entities.model.PowerPointModel; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.entity.MobRenderer; import net.minecraft.util.ResourceLocation; public class PowerPointRender extends MobRenderer<PowerPoint, PowerPointModel> { private static final ResourceLocation POWER_POINT_TEXTURE = new ResourceLocation(TouHouCraft.MOD_ID, "texture/entity/power_point.png"); public PowerPointRender(EntityRendererManager renderManagerIn) { super(renderManagerIn, new PowerPointModel(), 0.8F); } public PowerPointRender(EntityRendererManager renderManagerIn, PowerPointModel entityModelIn, float shadowSizeIn) { super(renderManagerIn, entityModelIn, shadowSizeIn); } @Override public ResourceLocation getEntityTexture(PowerPoint entity) { return POWER_POINT_TEXTURE; } } This is the registry and client event package com.lucaiyu.touhoucraft.entities; import com.lucaiyu.touhoucraft.TouHouCraft; import net.minecraft.entity.EntityClassification; import net.minecraft.entity.EntityType; import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; public class EntityRegistry { public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, TouHouCraft.MOD_ID); public static RegistryObject<EntityType<PowerPoint>> power_point = ENTITIES.register("power_point", ()->EntityType.Builder.<PowerPoint>create(PowerPoint::new, EntityClassification.MISC) .size(1.0F, 1.0F).build("power_point")); } package com.lucaiyu.touhoucraft.events; import com.lucaiyu.touhoucraft.entities.EntityRegistry; import com.lucaiyu.touhoucraft.entities.render.PowerPointRender; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public class ClientEvent { @SubscribeEvent public static void onClientSetupEvent(FMLClientSetupEvent event){ event.enqueueWork(()->{ Minecraft mc = Minecraft.getInstance(); EntityRendererManager manager = mc.getRenderManager(); manager.register(EntityRegistry.power_point.get(), new PowerPointRender(manager)); }); } } And this is the main class package com.lucaiyu.touhoucraft; import com.lucaiyu.touhoucraft.blocks.BlockRegistry; import com.lucaiyu.touhoucraft.entities.EntityRegistry; import com.lucaiyu.touhoucraft.items.ItemRegistry; import com.lucaiyu.touhoucraft.world.gen.OreGeneration; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @Mod("touhoucraft") public class TouHouCraft{ public static String MOD_ID = "touhoucraft"; public TouHouCraft() { ItemRegistry.ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); BlockRegistry.BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus()); MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGH, OreGeneration::generateOres); EntityRegistry.ENTITIES.register(FMLJavaModLoadingContext.get().getModEventBus()); } }
  3. I don't think 1.18 is a LTS version I think Forge and should support the older and classic version such as 1.12.2 and 1.16.5 You don't make 1.16 a LTS version and disable the discussion of it in the forum
  4. Something wrong The texture still not loaded [21:14:33] [Worker-Main-6/WARN] [minecraft/ModelBakery]: Exception loading blockstate definition: 'touhoucraft:blockstates/shrine_torii_title.json' missing model for variant: 'touhoucraft:shrine_torii_title#char=1' [21:14:33] [Worker-Main-6/WARN] [minecraft/ModelBakery]: Exception loading blockstate definition: 'touhoucraft:blockstates/shrine_torii_title.json' missing model for variant: 'touhoucraft:shrine_torii_title#char=0' [21:14:33] [Worker-Main-6/WARN] [minecraft/ModelBakery]: Exception loading blockstate definition: 'touhoucraft:blockstates/shrine_torii_title.json' in resourcepack: 'Mod Resources': Missing model, expected to find a string [21:14:34] [Worker-Main-6/WARN] [minecraft/ModelBakery]: Unable to load model: 'touhoucraft:block/shrine_torii_title_model' referenced from: touhoucraft:shrine_torii_title#inventory: java.io.FileNotFoundException: touhoucraft:models/block/shrine_torii_title_model.json [21:14:36] [Worker-Main-6/WARN] [minecraft/ModelBakery]: Unable to resolve texture reference: #missingno in touhoucraft:item/shrine_torii_title This is the blockstate code { "variants": { "": { "char=0": { "model": "touhoucraft:block/shrine_torii_title_model_0" }, "char=1": { "model": "touhoucraft:block/shrine_torii_title_model_1" } } } } Blockstate in my code is int format and includes 0 and 1 I think something wrong in the resource pack
  5. Ok thanks I will try to do this
  6. Minecraft version:1.16.5(STABLE) Forge version:36.2.34 IDE:Intellij 2022.3 Project REPO : https://www.github.com/lucaiyu/TouhouCraft I tried to add a block with 2 blocks but the texture not render at all. This is the block code package com.lucaiyu.touhoucraft.blocks; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.state.IntegerProperty; import net.minecraft.state.StateContainer; public class ShrineToriiTitle extends Block { private static IntegerProperty STATE = IntegerProperty.create("char", 0, 1); public ShrineToriiTitle() { super(Properties.of(Material.STONE).sound(SoundType.STONE).strength(5.0F,5.0F)); this.registerDefaultState(this.stateDefinition.any().setValue(STATE, 0)); } @Override protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder) { builder.add(STATE); } } This is the block registry package com.lucaiyu.touhoucraft.blocks; import com.lucaiyu.touhoucraft.TouHouCraft; import net.minecraft.block.Block; import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; public class BlockRegistry { public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, TouHouCraft.MOD_ID); public static RegistryObject<Block> touhou_crystal_ore = BLOCKS.register("touhou_crystal_ore", () -> { return new TouhouCrystalOre(); }); public static RegistryObject<Block> magic_ore = BLOCKS.register("magic_ore",()->{ return new MagicOre(); }); public static RegistryObject<Block> shrine_torii_title = BLOCKS.register("shrine_torii_title",()->{ return new ShrineToriiTitle(); }); public static RegistryObject<Block> touhou_crystal_ore_in_nether = BLOCKS.register("touhou_crystal_ore_in_nether",()->{ return new TouhouCrystalOreInNether(); }); public static RegistryObject<Block> magic_ore_in_nether = BLOCKS.register("magic_ore_in_nether",()->{ return new MagicOreInNether(); }); } This is the main class package com.lucaiyu.touhoucraft; import com.lucaiyu.touhoucraft.blocks.BlockRegistry; import com.lucaiyu.touhoucraft.items.ItemRegistry; import com.lucaiyu.touhoucraft.world.gen.OreGeneration; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @Mod("touhoucraft") public class TouHouCraft{ public static String MOD_ID = "touhoucraft"; public TouHouCraft() { ItemRegistry.ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); BlockRegistry.BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus()); MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGH, OreGeneration::generateOres); } } this is the texture pack blockstates { "variants": { "": { "char=0": { "model": "shrine_torii_title_model_0" }, "char=1": { "model": "shrine_torii_title_model_1" } } } } These are { "parent": "minecraft:block/cube_column", "textures": { "end": "touhoucraft:block/blank", "side": "touhoucraft:block/char0" } } /*these are two files*/ { "parent": "minecraft:block/cube_column", "textures": { "end": "touhoucraft:block/blank", "side": "touhoucraft:block/char1" } }
×
×
  • Create New...

Important Information

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