-
Posts
1830 -
Joined
-
Last visited
-
Days Won
12
Everything posted by DavidM
-
[1.13.2] Rendering an entity as another entity
DavidM replied to Trooprm32's topic in Modder Support
Try RenderLivingEvent<EntityLivingBase> . -
I am creating a blacklist for mob in my config (cow would be minecraft:cow). My idea is to get the registry name of the mob and check if it is in the blacklist. How would I get the registry name of a mob (from EntityLiving)?
-
Well, there are many approaches. The easiest (probably) would be to create a Map<Recipe, Player> // Pseudocode, adjust the types based on your code , and set the player value to null at the beginning. Whenever a player claims a recipe, set the value of the recipe to that player (use the player's name or something) (make the recipe claimable only if the corresponding value is null, meaning no one had claimed that recipe). When a player tries to craft something, check if that player is the value corresponding to the recipe.
-
This? http://www.minecraftforge.net/forum/topic/22927-player-based-crafting-recipes/
-
1. Aspects like performance, speed and coding style also counts toward the quality of the code. I would strongly suggest you to change your code once you've done testing. 2. Canceling the event is not the solution you wanted. As LexManos stated here: https://github.com/MinecraftForge/MinecraftForge/issues/3780#issuecomment-286099327, the ItemCraftedEvent is designed for stuff like posting achievements. You should not try to edit the craft inside the event handler of this event.
-
1. Ok... That is some wild testing then. 2. AFAIK the ItemCraftedEvent happens after the event is crafted, thus canceling the event will not cancel the craft.
-
1. To be honest, your code is a mess. - Use List#contains. There is no need to iterate through the list. - You are adding the button item every crafting event, which makes no sense. If you insist to look up items based on a list, initialize the array with the desired objects. 2. This is not how the ItemCraftedEvent is meant to be used. Why don’t you just disable the recipe instead?
-
BlockBase and ItemBase are used to register block and items easier, the code is easier to read, than vanilla one - aren't some conventions pointing that the code should be easy to read? Without them I would have to call Block.Properties.create, every time I create new Block. The code is pretty long then, so I created some more simple constructor. 1. No. In fact, the convention in terms of modding is against using BlockBase and ItemBase. They are an anti-pattern. I've linked some posts from others down below explaining why Block/ItemBases should not be used: http://www.minecraftforge.net/forum/topic/68881-onblockactivated-not-being-called/?tab=comments#comment-332831 http://www.minecraftforge.net/forum/topic/68429-ore-variant-textures-not-working-properly/?tab=comments#comment-330456 In conclusion, there is already a BlockBase, it is called Block; you shouldn't be using inheritance just to write less code; extending from bases prevents you from extending from other stuff. 2. Check your log. Are there any errors during registry? If all of your blocks are in the list, then the problem is probably that some blocks failed to register. Try adding debug lines.
-
Has it become more tedious to mod in the latest updates?
DavidM replied to FlufffyDragon's topic in General Discussion
That is controversial. However, the Forge developers worked hard to make the process of modding easier, so you don't need to worry about Minecraft making it hard. Good luck, and most importantly, have fun?. -
Thanks.
-
Has it become more tedious to mod in the latest updates?
DavidM replied to FlufffyDragon's topic in General Discussion
Developers don't update their libraries to make them "more tedious to use". New updates change many things, and due to this, people need to rewrite their mod, thus the complaining. Take the most recent 1.13.2 update for example. Some people complain that it "breaks" everything, making them having to rewrite everything; however, I'd say that the 1.13.2 update made everything a lot easier due to the code cleanup and rewrote. So yeah, do update to the latest version. It is easier to work with than older versions (and older versions aren't supported on this forum). -
In my TileEntity#read, I am trying to do the following: @Override public void read(NBTTagCompound nbt) { super.read(nbt); /*... getting fields from nbt*/ if (this.world.isRemote()) this.updateModel(); // Used by tesr. Must be called after getting fields from nbt is done. this.power = this.world.getRedstonePowerFromNeighbors(this.pos); } As shown in the code, the last two lines all require access to World; however, when TileEntity#read is called as the world initializes, TileEntity#world is null, and therefore the last two lines will encounter a NullPointerException. My idea is that I can somehow schedule the lines that refers to TileEntity#world to be ran later when the world finishes loading. How would I achieve that?
-
SOLVED Need help making custom bone-meal in Minecraft 1.12.2
DavidM replied to ButterAleks's topic in Modder Support
1. Send your code. We can't help you without your code. 2. What do you mean by "didn't work"? "Didn't work" is very vague. There are many things that can cause "didn't work". 3. Most thing don't have a tutorial. Welcome to programming. -
I am trying to make my block detect block updates (whenever an adjacent block is changed/destroyed/created). I've looked at Block#onNeighborChange, but that only fires when an adjacent tile entity changes. How do I detect block updates?
-
1. Stop using BlockBase. 2. Stop using ItemBase. 3. Where did you register your registerBlocks and registerItems method? Are they being called?
-
You are getting data from an URL, which takes time. Since you are currently in the main game thread, the entire game is going to freeze until your code has finished running, or in this case, until the server respond with your data. Creating another thread enables your "requesting from server" code to be ran parallel with the main game thread, which will not freeze the game. In short, you need to create another thread. If you don't know how to do it, you need to learn multithreading in Java. Cadiboo has provided you a link to a tutorial of multithreading in java; there are more on google or youtube.
-
[Solved] [1.13.2] Open GUI in Block#onBlockActivated
DavidM replied to DavidM's topic in Modder Support
Just realized that the method changed in the update. How would I get a Consumer<PacketBuffer> from a PacketBuffer? From a look of the source code, I assume it requires a method that writes to another PacketBuffer, something like PacketBuffer#writeBytes? Fixed. Thanks for all of your help. -
[Solved] [1.13.2] Open GUI in Block#onBlockActivated
DavidM replied to DavidM's topic in Modder Support
Thanks everyone! -
I am trying to make a GUI open when my block is clicked. My current code for Block#onBlockActivated is as such: @Override public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (!world.isRemote() && player instanceof EntityPlayerMP) { TileEntity tileEntity = world.getTileEntity(pos); if (tileEntity instanceof TileEntityMobFarm) { NetworkHooks.openGui((EntityPlayerMP) player, new InteractionObjectMobFarm((TileEntityMobFarm) tileEntity)); } } return true; } I also registered the GUI as such: ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.GUIFACTORY, () -> { return (openContainer) -> { ResourceLocation location = openContainer.getId(); if (location.toString().equals(Reference.MOD_ID + ":mob_farm_gui")) { EntityPlayerSP player = Minecraft.getInstance().player; BlockPos pos = openContainer.getAdditionalData().readBlockPos(); // This line gives the error. TileEntity tileEntity = player.world.getTileEntity(pos); if (tileEntity instanceof TileEntityMobFarm) { return new GuiMobFarm(player.inventory, (TileEntityMobFarm) tileEntity); } } return null; }; }); However, it seems that the openContainer.getAdditionalData PacketBuffer does not contain the BlockPos data of the block that is clicked by the player, as calling the readBlockPos method gives the following error: java.lang.IndexOutOfBoundsException at io.netty.buffer.EmptyByteBuf.readLong(EmptyByteBuf.java:601) at net.minecraft.network.PacketBuffer.readLong(PacketBuffer.java:749) at net.minecraft.network.PacketBuffer.readBlockPos(PacketBuffer.java:135) at cn.davidma.tinymobfarm.common.TinyMobFarm.lambda$null$0(TinyMobFarm.java:59) at net.minecraftforge.fml.network.FMLPlayMessages$OpenContainer.lambda$null$0(FMLPlayMessages.java:193) at java.util.Optional.map(Optional.java:215) at net.minecraftforge.fml.network.FMLPlayMessages$OpenContainer.lambda$null$2(FMLPlayMessages.java:193) at java.util.Optional.ifPresent(Optional.java:159) at net.minecraftforge.fml.network.FMLPlayMessages$OpenContainer.lambda$handle$3(FMLPlayMessages.java:192) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at net.minecraft.client.Minecraft.addScheduledTask(Minecraft.java:1851) at net.minecraft.client.Minecraft.addScheduledTask(Minecraft.java:1864) at net.minecraftforge.fml.network.NetworkEvent$Context.enqueueWork(NetworkEvent.java:176) at net.minecraftforge.fml.network.FMLPlayMessages$OpenContainer.handle(FMLPlayMessages.java:192) at net.minecraftforge.fml.network.simple.IndexedMessageCodec.lambda$tryDecode$3(IndexedMessageCodec.java:114) at java.util.Optional.ifPresent(Optional.java:159) at net.minecraftforge.fml.network.simple.IndexedMessageCodec.tryDecode(IndexedMessageCodec.java:114) at net.minecraftforge.fml.network.simple.IndexedMessageCodec.consume(IndexedMessageCodec.java:147) at net.minecraftforge.fml.network.simple.SimpleChannel.networkEventListener(SimpleChannel.java:64) at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Streams.java:419) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:201) at net.minecraftforge.eventbus.EventBus.post(EventBus.java:257) at net.minecraftforge.fml.network.NetworkInstance.dispatch(NetworkInstance.java:82) at net.minecraftforge.fml.network.NetworkHooks.lambda$onCustomPayload$0(NetworkHooks.java:75) at java.util.Optional.map(Optional.java:215) at net.minecraftforge.fml.network.NetworkHooks.onCustomPayload(NetworkHooks.java:75) at net.minecraft.client.network.NetHandlerPlayClient.handleCustomPayload(NetHandlerPlayClient.java:1619) at net.minecraft.network.play.server.SPacketCustomPayload.processPacket(SPacketCustomPayload.java:50) at net.minecraft.network.play.server.SPacketCustomPayload.processPacket(SPacketCustomPayload.java:11) at net.minecraft.network.PacketThreadUtil.func_210405_a(SourceFile:10) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at net.minecraft.util.Util.runTask(SourceFile:199) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:761) at net.minecraft.client.Minecraft.run(Minecraft.java:358) at net.minecraft.client.main.Main.main(SourceFile:144) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:19) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:35) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) at cpw.mods.modlauncher.Launcher.run(Launcher.java:58) at cpw.mods.modlauncher.Launcher.main(Launcher.java:44) at net.minecraftforge.userdev.UserdevLauncher.main(UserdevLauncher.java:77) How would I get the BlockPos of the block from the OpenContainer inside the lambda? If needed, my code is at: https://github.com/davidmaamoaix/TinyMobFarm/tree/1.13.2
-
The word is "ingot".
-
Thanks.
-
How does one register a GUI handler in 1.13.2?
-
Oops. I'm sorry.