Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

MonkeyKnight

Members
  • Posts

    28
  • Joined

  • Last visited

Everything posted by MonkeyKnight

  1. I am having an issue running a server with my mod. I know that I am reaching across sides somewhere in my Mod, but could not find where this error is occurring in my mod. The crash report that I have attached below mentioned that it involved the LocalPlayer. However, when I searched my mod for LocalPlayer, I only found one case in the event that I have attached below. Can you find where I errored? Crash Report: ---- Minecraft Crash Report ---- // I bet Cylons wouldn't have this problem. Time: 1/17/22, 8:10 PM Description: Mod loading error has occurred java.lang.Exception: Mod Loading has failed at net.minecraftforge.logging.CrashReportExtender.dumpModLoadingCrashReport(CrashReportExtender.java:69) ~[forge-1.18-38.0.17_mapped_official_1.18-recomp.jar%2376%2382!:?] {re:classloading} at net.minecraftforge.server.loading.ServerModLoader.load(ServerModLoader.java:53) ~[forge-1.18-38.0.17_mapped_official_1.18-recomp.jar%2376%2382!:?] {re:classloading} at net.minecraft.server.Main.main(Main.java:104) ~[forge-1.18-38.0.17_mapped_official_1.18-recomp.jar%2377!:?] {re:classloading} at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {} at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {} at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {} at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {} at net.minecraftforge.fml.loading.targets.ForgeServerUserdevLaunchHandler.lambda$launchService$0(ForgeServerUserdevLaunchHandler.java:16) ~[fmlloader-1.18-38.0.17.jar%230!:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.0.24.jar%2310!:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.0.24.jar%2310!:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.0.24.jar%2310!:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.0.24.jar%2310!:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.0.24.jar%2310!:?] {} at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.0.24.jar%2310!:?] {} at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.0.24.jar%2310!:?] {} at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:90) [bootstraplauncher-0.1.17.jar:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: main Stacktrace: at net.minecraftforge.fml.loading.RuntimeDistCleaner.processClassWithFlags(RuntimeDistCleaner.java:71) ~[fmlloader-1.18-38.0.17.jar%230!:1.0] {} -- MOD examplemod -- Details: Mod File: main Failure message: Example Mod (examplemod) has failed to load correctly java.lang.RuntimeException: Attempted to load class net/minecraft/client/player/LocalPlayer for invalid dist DEDICATED_SERVER Mod Version: 3.0 Mod Issue URL: NOT PROVIDED Exception message: java.lang.RuntimeException: Attempted to load class net/minecraft/client/player/LocalPlayer for invalid dist DEDICATED_SERVER Stacktrace: at net.minecraftforge.fml.loading.RuntimeDistCleaner.processClassWithFlags(RuntimeDistCleaner.java:71) ~[fmlloader-1.18-38.0.17.jar:1.0] {} at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:88) ~[modlauncher-9.0.7.jar:?] {} at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:120) ~[modlauncher-9.0.7.jar:?] {} at cpw.mods.modlauncher.TransformingClassLoader.maybeTransformClassBytes(TransformingClassLoader.java:50) ~[modlauncher-9.0.7.jar:?] {} at cpw.mods.cl.ModuleClassLoader.readerToClass(ModuleClassLoader.java:110) ~[securejarhandler-0.9.54.jar:?] {} at cpw.mods.cl.ModuleClassLoader.lambda$findClass$16(ModuleClassLoader.java:213) ~[securejarhandler-0.9.54.jar:?] {} at cpw.mods.cl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:223) ~[securejarhandler-0.9.54.jar:?] {} at cpw.mods.cl.ModuleClassLoader.findClass(ModuleClassLoader.java:213) ~[securejarhandler-0.9.54.jar:?] {} at cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:130) ~[securejarhandler-0.9.54.jar:?] {} at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?] {} at java.lang.Class.forName0(Native Method) ~[?:?] {} at java.lang.Class.forName(Class.java:467) ~[?:?] {} at net.minecraftforge.fml.javafmlmod.AutomaticEventSubscriber.lambda$inject$6(AutomaticEventSubscriber.java:75) ~[javafmllanguage-1.18-38.0.17.jar%2378!:?] {} at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?] {} at net.minecraftforge.fml.javafmlmod.AutomaticEventSubscriber.inject(AutomaticEventSubscriber.java:62) ~[javafmllanguage-1.18-38.0.17.jar%2378!:?] {} at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:91) ~[javafmllanguage-1.18-38.0.17.jar%2378!:?] {} at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:120) ~[fmlcore-1.18-38.0.17.jar%2380!:?] {} at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) ~[?:?] {} at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796) ~[?:?] {} at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?] {} at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[?:?] {} at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[?:?] {} at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[?:?] {} at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[?:?] {} -- System Details -- Details: Minecraft Version: 1.18 Minecraft Version ID: 1.18 Operating System: Windows 10 (amd64) version 10.0 Java Version: 17.0.1, Eclipse Adoptium Java VM Version: OpenJDK 64-Bit Server VM (mixed mode, sharing), Eclipse Adoptium Memory: 320780752 bytes (305 MiB) / 1127219200 bytes (1075 MiB) up to 2122317824 bytes (2024 MiB) CPUs: 4 Processor Vendor: GenuineIntel Processor Name: Intel(R) Core(TM) i3-7020U CPU @ 2.30GHz Identifier: Intel64 Family 6 Model 142 Stepping 9 Microarchitecture: Amber Lake Frequency (GHz): 2.30 Number of physical packages: 1 Number of physical CPUs: 2 Number of logical CPUs: 4 Graphics card #0 name: Intel(R) HD Graphics 620 Graphics card #0 vendor: Intel Corporation (0x8086) Graphics card #0 VRAM (MB): 1024.00 Graphics card #0 deviceId: 0x5921 Graphics card #0 versionInfo: DriverVersion=27.20.100.9664 Memory slot #0 capacity (MB): 8192.00 Memory slot #0 clockSpeed (GHz): 2.67 Memory slot #0 type: DDR4 Virtual memory max (MB): 16427.04 Virtual memory used (MB): 10800.33 Swap memory total (MB): 8334.11 Swap memory used (MB): 434.15 JVM Flags: 1 total; -XX:+ShowCodeDetailsInExceptionMessages ModLauncher: 9.0.24+9.0.24+main.7be9f01d ModLauncher launch target: forgeserveruserdev ModLauncher naming: mcp ModLauncher services: mixin PLUGINSERVICE eventbus PLUGINSERVICE object_holder_definalize PLUGINSERVICE runtime_enum_extender PLUGINSERVICE capability_token_subclass PLUGINSERVICE accesstransformer PLUGINSERVICE runtimedistcleaner PLUGINSERVICE mixin TRANSFORMATIONSERVICE fml TRANSFORMATIONSERVICE FML Language Providers: minecraft@1.0 javafml@null Mod List: forge-1.18-38.0.17_mapped_official_1.18-recomp.jar|Minecraft |minecraft |1.18 |COMMON_SET|Manifest: a1:d4:5e:04:4f:d3:d6:e0:7b:37:97:cf:77:b0:de:ad:4a:47:ce:8c:96:49:5f:0a:cf:8c:ae:b2:6d:4b:8a:3f main |Example Mod |examplemod |3.0 |ERROR |Manifest: NOSIGNATURE |Forge |forge |38.0.17 |COMMON_SET|Manifest: NOSIGNATURE Crash Report UUID: a2d945ef-ef76-4bb1-ac09-f2b263e52519 FML: 38.0 Forge: net.minecraftforge:38.0.17 Mod Event with LocalPlayer: @SubscribeEvent public static void renderGameOverlay(RenderGameOverlayEvent.Post event) { if(!(Thread.currentThread().getThreadGroup() == SidedThreadGroups.SERVER)) { Minecraft mc = Minecraft.getInstance(); LocalPlayer player = mc.player; if (mc.gameMode.canHurtPlayer() && event.getType() == RenderGameOverlayEvent.ElementType.ALL) { ModRender renderer = new ModRender(Minecraft.getInstance()); renderer.renderToolbars(Minecraft.getInstance(), player); } } }
  2. Oh, Thanks. So it would look like this? public class CapabilitiesRegisterEvent { @SubscribeEvent public void registerCaps(RegisterCapabilitiesEvent event) { event.register(IExample.class); } }
  3. I have coded a capability which keeps track of several properties of the Player. All my code is error free, except when I try and register the capability with the CapabilityManager. I have looked in the forge docs but cannot find any examples of this. My entire class is this: public class CapabilityExample { public static Capability<IExample> EXAMPLE_CAPABILITY = CapabilityManager.get(new CapabilityToken<>() {}); public static void register() { CapabilityManager.INSTANCE.register(IExample.class); } } I am getting an error message that reads, "The method register(Class<IExample>) is undefined for the type CapabilityManager. I have looked into the Capability manager and do not see another way to do this. Is there a new method for registering for 1.18?
  4. I checked my code and my mod id was lowercase. There must have been an error when I copy and pasted it. I fixed my issue. The setup was not being called for some reason so I tweaked my code a bit and it now works. Thanks you for your help.
  5. I have been trying to generate an ore for my mod and have created a new feature and registered it. However, whenever I join a world, it immediately crashes. I cannot find anything useful in the crash report and am stumped. Can you find where I made a mistake? Main Mod Class: package com.monkey.ExampleMod; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biomes; import net.minecraft.world.gen.GenerationStage.Decoration; import net.minecraftforge.common.BiomeManager.BiomeType; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.world.BiomeLoadingEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.monkey.ExampleMod.capabilities.Examples; import com.monkey.ExampleMod.capabilities.ExamplesProvider; import com.monkey.ExampleMod.capabilities.ExamplesStorage; import com.monkey.ExampleMod.capabilities.IExamples; import com.monkey.ExampleMod.capabilities.IVersions; import com.monkey.ExampleMod.capabilities.Versions; import com.monkey.ExampleMod.capabilities.VersionsProvider; import com.monkey.ExampleMod.capabilities.VersionsStorage; import com.monkey.ExampleMod.events.ExampleStats; import com.monkey.ExampleMod.init.BlockInit; import com.monkey.ExampleMod.init.EffectsInit; import com.monkey.ExampleMod.init.FeaturesInit; import com.monkey.ExampleMod.init.ItemInit; import com.monkey.ExampleMod.init.SoundInit; import com.monkey.ExampleMod.init.TileEntityInit; @Mod("ExampleMod") @Mod.EventBusSubscriber(modid = ExampleMod.MOD_ID, bus = Bus.FORGE) public class ExampleMod { public static final Logger LOGGER = LogManager.getLogger(); public static final String MOD_ID = "ExampleMod"; public static final ItemGroup ExampleMod_GROUP = new ExampleModGroup("ExampleModtab"); public ExampleMod() { IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); BlockInit.BLOCKS.register(bus); ItemInit.ITEMS.register(bus); EffectsInit.EFFECTS.register(bus); SoundInit.SOUNDS.register(bus); TileEntityInit.TILE_ENTITY.register(bus); MinecraftForge.EVENT_BUS.register(this); FMLJavaModLoadingContext.get().getModEventBus().addListener(ExampleMod::onCommonSetup); } @SubscribeEvent public static void onCommonSetup(FMLCommonSetupEvent event) { CapabilityManager.INSTANCE.register(IExample.class, new ExampleStorage(), Examples::new); CapabilityManager.INSTANCE.register(IExampleTwo.class, new ExampleTwoStorage(), ExampleTwo::new); RenderTypeLookup.setRenderLayer(BlockInit.FLASK_GLASS.get(), RenderType.translucent()); } @SubscribeEvent public void onBiomeLoading(final BiomeLoadingEvent biome) { if(!(biome.getCategory() == Biome.Category.NETHER || biome.getCategory() == Biome.Category.THEEND)) { System.out.println("!"); biome.getGeneration().getFeatures(Decoration.UNDERGROUND_ORES) .add(() -> FeaturesInit.ORE_SULFUR_CONFIG); } } @SubscribeEvent public static void onAttachCapabilities(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof PlayerEntity) { event.addCapability(new ResourceLocation(ExampleMod.MOD_ID, "examples"), new ExamplesProvider()); event.addCapability(new ResourceLocation(ExampleMod.MOD_ID, "versions"), new VersionsProvider()); } } public static class ExampleModGroup extends ItemGroup { public ExampleModGroup(String label) { super(label); } @Override public ItemStack makeIcon() { return ItemInit.EXAMPLE_ICON.get().getDefaultInstance(); } } } Feature Class: package com.monkey.Example.init; import com.monkey.Example.Example; import net.minecraft.util.ResourceLocation; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.WorldGenRegistries; import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.IFeatureConfig; import net.minecraft.world.gen.feature.OreFeatureConfig; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; @Mod.EventBusSubscriber(modid = Example.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class FeaturesInit { public static ConfiguredFeature<?, ?> ORE_SULFUR_CONFIG; @SubscribeEvent public void setup(FMLCommonSetupEvent event) { ORE_SULFUR_CONFIG = register("ore_sulfur", Feature.ORE.configured( new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, BlockInit.SULFUR_ORE.get().defaultBlockState(), 9)).range(64).squared().count(20)); } private static <FC extends IFeatureConfig> ConfiguredFeature<FC, ?> register(String key, ConfiguredFeature<FC, ?> configuredFeature) { return Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation(Example.MOD_ID, key), configuredFeature); } }
  6. I have an error that says The Container 'Project and External Dependencies' references non existing library 'C:\Users\benba\.gradle\caches\modules-2\files-2.1\com.mojang\patchy\1.1\aef610b34a1be37fa851825f12372b78424d8903\patchy-1.1.jar'. This error is new and only occurred after I did gradlew build to get the jar file for my project for the first time. Now it is not allowing me to build my new code until I fix the error. I went to the folder and noticed that there was only a patchy-1.2.3 and a patchy-2.1.6 jar file. I tried going into properties but cannot change anything in the Project and External Dependencies. I also tried executing gradlew genEclipseRuns --refresh-dependencies to no effect. Do you have any idea how to fix this error?
  7. Thanks. I checked the logs and solved my problem. I am not sure if multipart would help for this block but I will definingly read more about them and use them in the future! The issue was that I included a space before the age.
  8. EDIT: If anyone is having the same issue as me, the log tells you the exact combinations of the missing blockstates. I have been having issues with writing blockstates JSON files. I have searched the documentation but did not find enough information to narrow down the place that I am wrong. I have coded several items with multiple different blockstates and some of my JOSN files work fine while others never seem to work. I do not notice any major differences between the two and am writing to ask your help in figuring out how to write these files. I have coded a lamp that has the blockstates HorizontalBlock.FACING and BlockStateProperties.AGE_3. My JSON file is below. I have checked it in several JSON validators and have a JSON editor addon added to Eclipse but still cannot see anything wrong. The Inventory icon works fine so it is not an issue with the texture. { "variants": { "facing=north, age=0": { "model": "testmod:block/ceiling_light_off", "y": 180 }, "facing=south, age=0": { "model": "testmod:block/ceiling_light_off", "y": 0 }, "facing=west, age=0": { "model": "testmod:block/ceiling_light_off", "y": 270 }, "facing=east, age=0": { "model": "testmod:block/ceiling_light_off", "y": 90 }, "facing=north, age=1": { "model": "testmod:block/ceiling_light_1", "y": 0 }, "facing=south, age=1": { "model": "testmod:block/ceiling_light_1", "y": 180 }, "facing=west, age=1": { "model": "testmod:block/ceiling_light_1", "y": 270 }, "facing=east, age=1": { "model": "testmod:block/ceiling_light_1", "y": 90 }, "facing=north, age=2": { "model": "testmod:block/ceiling_light_2", "y": 0 }, "facing=south, age=2": { "model": "testmod:block/ceiling_light_2", "y": 180 }, "facing=west, age=2": { "model": "testmod:block/ceiling_light_2", "y": 270 }, "facing=east, age=2": { "model": "testmod:block/ceiling_light_2", "y": 90 }, "facing=north, age=3": { "model": "testmod:block/ceiling_light_3", "y": 0 }, "facing=south, age=3": { "model": "testmod:block/ceiling_light_3", "y": 180 }, "facing=west, age=3": { "model": "testmod:block/ceiling_light_3", "y": 270 }, "facing=east, age=3": { "model": "testmod:block/ceiling_light_3", "y": 90 } } }
  9. Thank you for your help. It ended up being the entity block animated that was making it not work. I did not need it and getting rid of it solved all my issues.
  10. I added override to the methods that I missed but the blockstates are still not working. Here is my new code: import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; import net.minecraft.block.HorizontalBlock; import net.minecraft.block.IWaterLoggable; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; import net.minecraft.item.BlockItemUseContext; import net.minecraft.pathfinding.PathType; import net.minecraft.state.BooleanProperty; import net.minecraft.state.DirectionProperty; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; public class Incubator extends Block implements IWaterLoggable{ private static final VoxelShape AABB = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 13.0D, 16.0D); public static final DirectionProperty FACING = HorizontalBlock.FACING; public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public Incubator(Properties properties) { super(properties); this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, Boolean.FALSE)); } @SuppressWarnings("deprecation") @Override public BlockState updateShape(BlockState state, Direction dir, BlockState oldState, IWorld world, BlockPos pos, BlockPos oldPos) { if (state.hasProperty(WATERLOGGED)) { world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); } return super.updateShape(state, dir, oldState, world, pos, oldPos); } @Override public BlockRenderType getRenderShape(BlockState p_149645_1_) { return BlockRenderType.ENTITYBLOCK_ANIMATED; } @Override public VoxelShape getShape(BlockState p_220053_1_, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) { return AABB; } @Nullable @Override public BlockState getStateForPlacement(BlockItemUseContext context) { Direction direction = context.getNearestLookingDirection().getOpposite(); if (direction.equals(Direction.UP) || direction.equals(Direction.DOWN)) direction = Direction.NORTH; FluidState state = context.getLevel().getFluidState(context.getClickedPos()); return this.defaultBlockState().setValue(FACING, direction).setValue(WATERLOGGED, state.getType() == Fluids.WATER); } @SuppressWarnings("deprecation") @Override public FluidState getFluidState(BlockState state) { return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); } @Override public BlockState rotate(BlockState state, Rotation rotation) { return state.setValue(FACING, rotation.rotate(state.getValue(FACING))); } @Override @SuppressWarnings("deprecation") public BlockState mirror(BlockState state, Mirror mirror) { return state.rotate(mirror.getRotation(state.getValue(FACING))); } @Override protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder) { super.createBlockStateDefinition(builder); builder.add(FACING, WATERLOGGED); } @Override public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType pathType) { return false; } } The block looks normal without blockstates but when I change the blockstates json to rotate the model it does not show the block as thee blockstates are not working. When looking at the block, no blockstates were shown.
  11. I have been trying to create a block that has two blockstates, a basic facing one and a waterlogged one. I have been able to get blockstates to work fine in 1.12, 1.15, and 1.16.4 but when I started coding a new mod in 1.16.5, I have not been able to get the blockstates to work. It does not show up when the block is looked at using f3. My code is below: import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; import net.minecraft.block.HorizontalBlock; import net.minecraft.block.IWaterLoggable; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; import net.minecraft.item.BlockItemUseContext; import net.minecraft.pathfinding.PathType; import net.minecraft.state.BooleanProperty; import net.minecraft.state.DirectionProperty; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; public class Incubator extends Block implements IWaterLoggable{ private static final VoxelShape AABB = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 13.0D, 16.0D); public static final DirectionProperty FACING = HorizontalBlock.FACING; public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;; public Incubator(Properties properties) { super(properties); this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, Boolean.FALSE)); } @SuppressWarnings("deprecation") @Override public BlockState updateShape(BlockState state, Direction dir, BlockState oldState, IWorld world, BlockPos pos, BlockPos oldPos) { if (state.hasProperty(WATERLOGGED)) { world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); } return super.updateShape(state, dir, oldState, world, pos, oldPos); } @Override public BlockRenderType getRenderShape(BlockState p_149645_1_) { return BlockRenderType.ENTITYBLOCK_ANIMATED; } @Override public VoxelShape getShape(BlockState p_220053_1_, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) { return AABB; } @Nullable @Override public BlockState getStateForPlacement(BlockItemUseContext context) { Direction nearestLookingDirection = context.getNearestLookingDirection(); Direction direction = nearestLookingDirection.getOpposite(); if (direction.equals(Direction.UP) || direction.equals(Direction.DOWN)) direction = Direction.NORTH; FluidState state = context.getLevel().getFluidState(context.getClickedPos()); return this.defaultBlockState().setValue(FACING, direction).setValue(WATERLOGGED, state.getType() == Fluids.WATER); } @SuppressWarnings("deprecation") @Override public FluidState getFluidState(BlockState state) { return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); } public BlockState rotate(BlockState state, Rotation rotation) { return state.setValue(FACING, rotation.rotate(state.getValue(FACING))); } @SuppressWarnings("deprecation") public BlockState mirror(BlockState state, Mirror mirror) { return state.rotate(mirror.getRotation(state.getValue(FACING))); } protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder) { builder.add(FACING, WATERLOGGED); } public boolean isPathfindable(BlockState state, IBlockReader reader, BlockPos pos, PathType pathType) { return false; } } Is there an issue with my code? I have ran out of ideas. Maybe I imported a wrong class?
  12. Sure, here are my two classes that I used. The render event: @EventBusSubscriber(modid = Epidemics.MOD_ID, bus = Bus.FORGE) public class GuiRenderEvents { @SubscribeEvent public static void renderGameOverlay(RenderGameOverlayEvent.Post event) { if (event.getType() == RenderGameOverlayEvent.ElementType.ALL) { System.out.println(1); RenderTest render = new RenderTest(Minecraft.getInstance()); render.renderTestPumpkin(Minecraft.getInstance()); } } } The renderer: public class RenderTest extends IngameGui{ public static final ResourceLocation NEW_PUMPKIN_LOCATION = new ResourceLocation(Epidemics.MOD_ID + ":textures/gui/pumpkinblurtest.png"); private int screenWidth; private int screenHeight; public RenderTest(Minecraft minecraft) { super(minecraft); screenWidth = minecraft.getWindow().getGuiScaledWidth(); screenHeight = minecraft.getWindow().getGuiScaledHeight(); } public void renderTestPumpkin(Minecraft minecraft) { RenderSystem.disableDepthTest(); RenderSystem.enableBlend(); RenderSystem.depthMask(false); RenderSystem.defaultBlendFunc(); RenderSystem.blendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.disableAlphaTest(); minecraft.getTextureManager().bind(NEW_PUMPKIN_LOCATION); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuilder(); bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX); bufferbuilder.vertex(0.0D, (double)screenHeight, -90.0D).uv(0.0F, 1.0F).endVertex(); bufferbuilder.vertex((double)screenWidth, (double)screenHeight, -90.0D).uv(1.0F, 1.0F).endVertex(); bufferbuilder.vertex((double)screenWidth, 0.0D, -90.0D).uv(1.0F, 0.0F).endVertex(); bufferbuilder.vertex(0.0D, 0.0D, -90.0D).uv(0.0F, 0.0F).endVertex(); tessellator.end(); RenderSystem.depthMask(true); RenderSystem.enableDepthTest(); RenderSystem.enableAlphaTest(); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); } }
  13. I have another update! I changed my render event code to this: @EventBusSubscriber(modid = Epidemics.MOD_ID, bus = Bus.FORGE) public class GuiRenderEvents { @SubscribeEvent public static void renderGameOverlay(RenderGameOverlayEvent.Post event) { if (event.getType() == RenderGameOverlayEvent.ElementType.HOTBAR) { System.out.println(1); RenderTest render = new RenderTest(Minecraft.getInstance()); render.renderTestPumpkin(Minecraft.getInstance()); } } } public class RenderTest extends IngameGui{ private int screenWidth; private int screenHeight; public RenderTest(Minecraft minecraft) { super(minecraft); screenWidth = minecraft.getWindow().getGuiScaledWidth(); screenHeight = minecraft.getWindow().getGuiScaledHeight(); /* renderTest(minecraft); */ } public void renderTestPumpkin(Minecraft minecraft) { RenderSystem.disableDepthTest(); RenderSystem.depthMask(false); RenderSystem.defaultBlendFunc(); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.disableAlphaTest(); minecraft.getTextureManager().bind(PUMPKIN_BLUR_LOCATION); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuilder(); bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX); bufferbuilder.vertex(0.0D, (double)screenHeight, -90.0D).uv(0.0F, 1.0F).endVertex(); bufferbuilder.vertex((double)screenWidth, (double)screenHeight, -90.0D).uv(1.0F, 1.0F).endVertex(); bufferbuilder.vertex((double)screenWidth, 0.0D, -90.0D).uv(1.0F, 0.0F).endVertex(); bufferbuilder.vertex(0.0D, 0.0D, -90.0D).uv(0.0F, 0.0F).endVertex(); tessellator.end(); RenderSystem.depthMask(true); RenderSystem.enableDepthTest(); RenderSystem.enableAlphaTest(); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); } } Now it is showing up n the game, just as a black screen though. Do you know what is causing the black screen?
  14. I have a quick update. I have narrowed down the issue to the renderGameOverlay.post event. I changed the code of the renderTest constructor to just trigger the vanilla renderPumpkin() method and there still was no pumpkin face shown. public RenderTest(Minecraft minecraft) { super(minecraft); renderPumpkin(); /* screenWidth = minecraft.getWindow().getGuiScaledWidth(); screenHeight = minecraft.getWindow().getGuiScaledHeight(); renderTest(minecraft); */ } Do you have any suggestions on what I should change in my render event?
  15. The only further suggestion I would have is to check Minecraft's code for the fire aspect enchantment. You may find what you are looking for there.
  16. I know this might be stupid but for deferedRegisters, that error normally goes away when you put .get() at the end. Something like this: if (event.getSource().equals(ItemInit.EMBERCLEAVE.get())) I have only coded blocks and potions in 1.16 so I am a little rusty on items but this might work.
  17. I have coded a little test to experiment with rendering fullscreen overlays for my mod in Minecraft. As it is my first time delving into this kind of rendering, I started off simple, basically copying the renderPumpkin() method but I am having issues. My goal is to render textures that will show up on a player's screen in certain situations. For this test, I just went with the standard pumpkinblur. I used a RenderGameOverlayEvent.Post to trigger the rendering of the pumpkin. Here is my event code: @EventBusSubscriber(modid = Epidemics.MOD_ID, bus = Bus.FORGE) public class GuiRenderEvents { @SubscribeEvent public static void renderGameOverlay(RenderGameOverlayEvent.Post event) { if (event.getType() == RenderGameOverlayEvent.ElementType.HOTBAR) { //System.out.println("Event Triggered"); new RenderTest(Minecraft.getInstance()); } } } I then created a class that extends InGameGUI to render the pumpkin. It almost directly copies the renderPumpkin() method in InGameGUI. import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.IngameGui; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; public class RenderTest extends IngameGui{ public RenderTest(Minecraft minecraft) { super(minecraft); renderTest(minecraft); } private void renderTest(Minecraft minecraft) { RenderSystem.disableDepthTest(); RenderSystem.depthMask(false); RenderSystem.defaultBlendFunc(); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.disableAlphaTest(); minecraft.getTextureManager().bind(PUMPKIN_BLUR_LOCATION); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuilder(); bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX); bufferbuilder.vertex(0.0D, (double)this.screenHeight, -90.0D).uv(0.0F, 1.0F).endVertex(); bufferbuilder.vertex((double)this.screenWidth, (double)this.screenHeight, -90.0D).uv(1.0F, 1.0F).endVertex(); bufferbuilder.vertex((double)this.screenWidth, 0.0D, -90.0D).uv(1.0F, 0.0F).endVertex(); bufferbuilder.vertex(0.0D, 0.0D, -90.0D).uv(0.0F, 0.0F).endVertex(); tessellator.end(); RenderSystem.depthMask(true); RenderSystem.enableDepthTest(); RenderSystem.enableAlphaTest(); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); } } The renderTest() method is being triggered but I do not see anything on my screen. Can you spot where I might have forgotten something?
  18. I have solved the issue as I called the wrong method in the ReadNBT class. Here is my final updated code. @Override public INBT writeNBT(Capability<IDiseases> capability, IDiseases instance, Direction side) { CompoundNBT tag = new CompoundNBT(); tag.putInt("diseases", instance.getDiseases()); tag.putInt("diseasesTime", instance.getDiseasesTime()); return tag; } @Override public void readNBT(Capability<IDiseases> capability, IDiseases instance, Direction side, INBT nbt) { CompoundNBT tag = (CompoundNBT) nbt; instance.setDiseases(tag.getInt("diseases")); instance.setDiseasesTime(tag.getInt("diseasesTime")); }
  19. I have done some further testing and have noticed something quite strange. I have changed my readNBT method to read from the INBT. @Override public INBT writeNBT(Capability<IDiseases> capability, IDiseases instance, Direction side) { CompoundNBT tag = new CompoundNBT(); tag.putInt("diseases", instance.getDiseases()); tag.putInt("diseasesTime", instance.getDiseasesTime()); return tag; } @Override public void readNBT(Capability<IDiseases> capability, IDiseases instance, Direction side, INBT nbt) { CompoundNBT tag = (CompoundNBT) nbt; instance.setDiseases(tag.getInt("diseases")); instance.setDiseases(tag.getInt("diseasesTime")); } The interesting thing that I noticed when testing after making the change is that the Serialize method is called twice when leaving a world an the reserialize method is called once when rejoining. My Capacity stores two ints called diseases and diseaseTime. However, when I exit and reload a world, the diseaseTime value becomes the dseases value. Here is the printout from my test where a world with a diseases value of 1 and a diseaseTime value of 2331 is exited and reentered. // After leaving and entering the world, as the world is loaded the Capacity is deserialized once. [18:57:51] [Netty Server IO #3/DEBUG] [ne.mi.fm.ne.FMLHandshakeHandler/FMLHANDSHAKE]: Received client indexed reply 1 of type net.minecraftforge.fml.network.FMLHandshakeMessages$C2SAcknowledge [18:57:51] [Netty Server IO #3/DEBUG] [ne.mi.fm.ne.FMLHandshakeHandler/FMLHANDSHAKE]: Received acknowledgement from client [18:57:51] [Server thread/DEBUG] [ne.mi.fm.ne.FMLHandshakeHandler/FMLHANDSHAKE]: Handshake complete! [18:57:51] [Netty Local Client IO #1/INFO] [ne.mi.fm.ne.NetworkHooks/]: Connected to a modded server. [18:57:51] [Server thread/INFO] [ne.mi.co.AdvancementLoadFix/]: Using new advancement loading for net.minecraft.advancements.PlayerAdvancements@5772ea3a [18:57:51] [Server thread/INFO] [STDOUT/]: [com.monkey.epidemics.capabilities.DiseasesProvider:deserializeNBT:32]: deserialize diseases [18:57:51] [Server thread/INFO] [minecraft/PlayerList]: Dev[local:E:0daae43a] logged in with entity id 733 at (-170.35850493023133, 71.0, 129.3425231398343) [18:57:51] [Server thread/INFO] [minecraft/MinecraftServer]: Dev joined the game //When the world is rejoined the diseaseTime int becomes the disease int, breaking my code [18:57:52] [Server thread/INFO] [STDOUT/]: [com.monkey.epidemics.events.DiseaseStartEvents:onPlayerTick:26]: 2331 [18:57:52] [Server thread/INFO] [STDOUT/]: [com.monkey.epidemics.events.DiseaseStartEvents:onPlayerTick:26]: 2331 [18:57:52] [Server thread/INFO] [STDOUT/]: [com.monkey.epidemics.events.DiseaseStartEvents:onPlayerTick:26]: 2331 [18:57:52] [Server thread/INFO] [STDOUT/]: [com.monkey.epidemics.events.DiseaseStartEvents:onPlayerTick:26]: 2331 [18:57:52] [Server thread/INFO] [STDOUT/]: [com.monkey.epidemics.events.DiseaseStartEvents:onPlayerTick:26]: 2331 [18:57:52] [Server thread/INFO] [minecraft/IntegratedServer]: Saving and pausing game... //When the game saves and exits the world, the Capability is Serialized twice [18:57:52] [Server thread/INFO] [STDOUT/]: [com.monkey.epidemics.capabilities.DiseasesProvider:serializeNBT:26]: serialize diseases [18:57:52] [Server thread/INFO] [STDOUT/]: [com.monkey.epidemics.capabilities.DiseasesProvider:serializeNBT:26]: serialize diseases [18:57:52] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'ServerLevel[New World]'/minecraft:overworld [18:57:53] [Render thread/INFO] [minecraft/AdvancementList]: Loaded 0 advancements [18:57:53] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'ServerLevel[New World]'/minecraft:the_nether [18:57:53] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'ServerLevel[New World]'/minecraft:the_end Is SerializeNBT being called twice causing this error? Is this duplication caused by some kind of server client thing? If that is the case is there some way I should make it server only?
  20. I am not too familiar with the eclipse debugger, (The last time I modded was on 1.7.10 using Intellij). I know that my getCapability() method is working, but after adding print statements to the serializeNBT and deserializeNBT, I did not see any printouts so I do not believe they have been invoked. @Override public INBT serializeNBT() { System.out.println("serialize diseases"); return DISEASES_CAPABILITY.getStorage().writeNBT(DISEASES_CAPABILITY, this.instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null); } @Override public void deserializeNBT(INBT nbt) { System.out.println("deserialize diseases"); DISEASES_CAPABILITY.getStorage().readNBT(DISEASES_CAPABILITY, this.instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null, nbt); } I am 99% sure they are doing the right thing because it is nearly the same as what I have found in the Minecraft forge code and seen on this forum. I am not sure that I am checking to see if the data is present. Is there some code that I am missing? Not sure if this helps but here is my Read and Write NBT code: public class DiseasesStorage implements IStorage<IDiseases>{ @Override public INBT writeNBT(Capability<IDiseases> capability, IDiseases instance, Direction side) { CompoundNBT tag = new CompoundNBT(); tag.putInt("diseases", instance.getDiseases()); tag.putInt("diseasesTime", instance.getDiseasesTime()); return tag; } @Override public void readNBT(Capability<IDiseases> capability, IDiseases instance, Direction side, INBT nbt) { CompoundNBT tag = new CompoundNBT(); instance.setDiseases(tag.getInt("diseases")); instance.setDiseases(tag.getInt("diseasesTime")); } }
  21. I have used this class in other classes without any issues and have not found anything else wrong with the class. Am I supposed to call serializeNBT and deserializeNBT from somewhere else when the player is leaving?
  22. I have already added a ICapabilitySerializable. It still does not save any data. I am not getting any errors in my Capability as it works as intended each time, except that it resets after leaving and reentering the world. Is there something wrong with my class? public class DiseasesProvider implements ICapabilitySerializable<INBT> { @CapabilityInject(IDiseases.class) public static final Capability<IDiseases> DISEASES_CAPABILITY = null; private LazyOptional<IDiseases> instance = LazyOptional.of(DISEASES_CAPABILITY::getDefaultInstance); @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { return cap == DISEASES_CAPABILITY ? instance.cast() : LazyOptional.empty(); } @Override public INBT serializeNBT() { return DISEASES_CAPABILITY.getStorage().writeNBT(DISEASES_CAPABILITY, this.instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null); } @Override public void deserializeNBT(INBT nbt) { DISEASES_CAPABILITY.getStorage().readNBT(DISEASES_CAPABILITY, this.instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null, nbt); } } Here is my AttachCapabilitiesEvent: @SubscribeEvent public static void onAttachCapabilities(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof PlayerEntity) { event.addCapability(new ResourceLocation(Epidemics.MOD_ID, "diseases"), new DiseasesProvider()); } }
  23. For saving the Capability, I have looked at the documentation and some forum posts as well but still cannot figure out what classes to use. I want my capability to reset upon player death so I never used the playerClone event. All I am trying to do is to save and load my capability when changing dimensions and leaving and rejoining a world. Other than that though, my Capability works like a charm!
  24. Thanks, now it works perfectly. To anyone else who may have the same problem as me in the future, I changed the event to this: @EventBusSubscriber(modid = Epidemics.MOD_ID, bus = Bus.FORGE) public class DiseaseStartEvents { @SubscribeEvent public static void onPlayerTick(PlayerTickEvent event) { if(event.side == LogicalSide.SERVER && event.phase == Phase.START) { Random rand = new Random(); int i = rand.nextInt(800); System.out.println(DiseaseStats.getSickness(event.player)); if(i == 2 && DiseaseStats.getSickness(event.player) == 0) { ITextComponent m = new StringTextComponent("You have fallen ill..."); event.player.sendMessage(m, event.player.getGameProfile().getId()); DiseaseStats.setSickness(1, event.player); } } } }
×
×
  • Create New...

Important Information

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