Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

StefanDeSterke

Members
  • Joined

  • Last visited

Everything posted by StefanDeSterke

  1. Woops I didn't see that it was in that class. But nonetheless, I don't really know where to override the AI of an entity.
  2. The code for when endermen get angry is here in the EndermanEntity class: /** * Checks to see if this enderman should be attacking this player */ private boolean shouldAttackPlayer(PlayerEntity player) { ItemStack itemstack = player.inventory.armorInventory.get(3); if (itemstack.isEnderMask(player, this)) { return false; } else { Vector3d vector3d = player.getLook(1.0F).normalize(); Vector3d vector3d1 = new Vector3d(this.getPosX() - player.getPosX(), this.getPosYEye() - player.getPosYEye(), this.getPosZ() - player.getPosZ()); double d0 = vector3d1.length(); vector3d1 = vector3d1.normalize(); double d1 = vector3d.dotProduct(vector3d1); return d1 > 1.0D - 0.025D / d0 ? player.canEntityBeSeen(this) : false; } } This method is not called in the enderman's AI tasks, but in it's tick method. public void tick() { if (this.enderman.getAttackTarget() == null) { super.func_234054_a_((LivingEntity)null); } if (this.player != null) { if (--this.aggroTime <= 0) { this.nearestTarget = this.player; this.player = null; super.startExecuting(); } } else { if (this.nearestTarget != null && !this.enderman.isPassenger()) { if (this.enderman.shouldAttackPlayer((PlayerEntity)this.nearestTarget)) { //It's called here if (this.nearestTarget.getDistanceSq(this.enderman) < 16.0D) { this.enderman.teleportRandomly(); } this.teleportTime = 0; } else if (this.nearestTarget.getDistanceSq(this.enderman) > 256.0D && this.teleportTime++ >= 30 && this.enderman.teleportToEntity(this.nearestTarget)) { this.teleportTime = 0; } } super.tick(); } } The only problem is, I don't know how to override a vanilla minecraft class.
  3. Done that, but still couldn't find any event that matches what I'm looking for :(. I also looked into the enderman entity class itself, and it seems that 'itemstack.isEnderMask(PlayerEntity, EndermanEntity)' controls wether an item is considered a mask from endermen. Any way I can override this and add my enchantment?
  4. Hi, so I've just added an enchantment to my mod that is supposed to not anger endermen when you put an helmet on with that enchantment. I was wondering if there was a sort of EntityAggravatedEvent of some sort, that I can cancel when an enderman gets angry at a player with that enchantment. Thanks!
  5. We can't help you unless you post the crash log.
  6. I'm sorry, but I've been sitting here for 2 hours now, squeezing my eyes together and looking at Minecraft's source code, but I generally don't know what they are doing. This is mostly due to the fact that the code is obfuscated, and there is generally not really a way to know what 'func_230364_a_' means, or 'int p_230364_3_'. One of the ways to do this, is to have some context around it, and seeing what the other methods around that one do. But they are obfuscated too, leading me only into darkness. Now my question is, is there some deobfuscated form of Minecraft's source code at wich I can look at, and know what they are doing? Thanks.
  7. Hi! My problem is that I don't know how to add custom structures, and I couldn't find any good tutorial that's up to date to 1.15 or 1.16. I know you have to do stuff with Features, but I don't really know where to start. If anyone could link me to an up to date tutorial or could explain what I need to do that would be great. Thanks!
  8. You should check out the forge documentation. https://mcforge.readthedocs.io/en/1.14.x/
  9. Hi! So I coded a block with harvest level 3 and tooltype pickaxe, but for some reason it still drops its loot table when I mine it with a tool that has harvest level 2 (for example an iron pickaxe). It even ignores the tooltype, because if you mine it with for instance a diamond shovel it still drops. I only want it to drop when mined with a diamond pickaxe or a netherite pickaxe. Here's my code: @SubscribeEvent public static void registerBlocks(RegistryEvent.Register<Block> event) { event.getRegistry().registerAll( new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(6f, 2000f).harvestTool(ToolType.PICKAXE).harvestLevel(3)).setRegistryName(location("blaststone_ore")) ); } If someone has a solution to this, that would be greatly appreciated. Thanks!
  10. Nevermind I already found a previous post that worked.
  11. I want to create a mod that implements a new type of rails, but how do I remove the collision for the rails? Vanilla Minecraft rails have disabled collisions so you can walk through them, but my rails currently have a collision just like one layer of snow on the ground does. I have checked the AbstractRailBlock and RailBlock classes of Forge but I couldn't find anything. Overriding the method getCollisionBoundingBoxFromPool and returning null doesn't work either because it doesn't exist anymore. Does anyone have an idea of how to do this?
  12. Yay, works! Thank you all so much for the help
  13. Idk, but where would I initialize the field then and with what?
  14. Ok, so am I just stupid (I think I am :\ ) or doesn't this initialize the field? @SubscribeEvent public static void FMLClientSetupEvent(FMLClientSetupEvent event) { ScreenManager.registerFactory(ContainerList.furnace, StoneFurnaceGUI::new); }
  15. I did pass the correct Container Type, right?
  16. Oh, my bad. I've given it a very wrong name. It's a class that implements INamedContainerProvider. If you want to see it, here it is: package mod.sds.terrariamod.inamedcontainerproviders; import mod.sds.terrariamod.containers.ContainerFurnace; 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.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.World; public class Furnace implements INamedContainerProvider { private BlockPos pos; private World world; public Furnace(BlockPos pos, World world) { this.pos = pos; this.world = world; } @Override public Container createMenu(int windowId, PlayerInventory inv, PlayerEntity player) { return new ContainerFurnace(windowId, inv, this.world, this.pos); } @Override public ITextComponent getDisplayName() { return new StringTextComponent("Furnace Container"); } }
  17. Here's the code: @Override public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { if(!worldIn.isRemote) { NetworkHooks.openGui((ServerPlayerEntity) player, new Furnace(pos, worldIn), buf -> buf.writeBlockPos(pos)); return true; } return false; }
  18. Nope, still getting the same error. Registry class: @Mod.EventBusSubscriber(modid = TerrariaMod.modid, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public static class ClientRegistryEvents { @SubscribeEvent public static void FMLClientSetupEvent(FMLClientSetupEvent event){ ScreenManager.registerFactory(ContainerList.furnace, StoneFurnaceGUI::new); } }
  19. What do I have to put as second argument in ScreenManager.registerFactory? It's asking me to put an IScreenFactory in there.
  20. Ok thank you, but now I'm getting this error when I'm opening the Furnace: java.lang.UnsupportedOperationException: Unable to construct this menu by type I think it has to do with the container type registration not being correct, so here's the code for that: @SubscribeEvent public static void onContainerRegistry(final RegistryEvent.Register<ContainerType<?>> event) { event.getRegistry().registerAll( IForgeContainerType.create((windowId, inv, data) -> { BlockPos pos = data.readBlockPos(); return new ContainerFurnace(windowId, inv, TerrariaMod.proxy.getClientWorld(), pos); }).setRegistryName("container_furnace") ); }
  21. I want to create an empty container when you open the block (Like a crafting table). When you close out of the inventory, then all the items that are in the slots of the furnace will pop back into your inventory,
  22. Ok, but since I don't have a tileentity class, where would I implement INamedContainerProvider? (I don't have one because I don't need to store inv data to the block)

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.