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.

Draco18s

Members
  • Joined

  • Last visited

Everything posted by Draco18s

  1. Getting the recipe result while looping through the crafting list is very easy, as the IRecipe interface includes getRecipeOutput() . So that'll let you narrow in on the right recipe quickly. From there, you just need to convert it to the proper recipe class (there are several) and get the inputs. Do note that (most!) tools are of type ShapedOreRecipe and they're made up of lists of items in each slot, rather than a single item (I had to write a recipe comparison function last night that would take in an arbitrary recipe and find recipe with the same pattern, but using a different material: i.e. given the recipe for a wooden axe, find the recipe for the golden axe; that was fun).
  2. Hmm. That sounds pretty reasonable, actually.
  3. Should just be able to call super.insertItem() at that point, no?
  4. So something occurred to me recently. ItemHandlers need to be exposed for both input and output. In order to prevent an item from being inserted into an "output" slot, setting up a custom ItemHandler class to always return the item inserted into it seems to make sense. Expose for extraction, forbid insertion, seems reasonable. However. Now that means that a machine itself can't put items into its own output slot (other than by using setStackInSlot() which requires that it calculate the stack size manually). There's got to be a better way than this...what am I missing?
  5. While I know I can do this with Eclipse, I prefer not to for very large classes like Block because the list is very very large and often I'm already looking at the method I want to override.
  6. You can't compare strings this way. Well you can but its not going to work. http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java
  7. Open up the Block class. Ctrl-F "onBlockActivated" Copy-paste
  8. This is how I handled getting the property with the name "age", along with its max and current value: Iterator<IProperty<?>> props = state.getPropertyNames().iterator(); while(props.hasNext()) { IProperty<?> p = props.next(); //lower case just to insure we're matching if(p instanceof PropertyInteger && p.getName().toLowerCase().equals("age")) { PropertyInteger ageProp = (PropertyInteger)p; //do whatever: int maxAge = (Integer) ageProp.getAllowedValues().toArray()[ageProp.getAllowedValues().size()-1]; int currAge = state.getValue(ageProp); } } And if there are any improvements, I would be interested.
  9. Your method signature is wrong.
  10. Please don't check against the air block. Many mods use "technical" blocks for various things (usually lighting), but which should be treated like air. I'd suggest checking the block's material against Material.AIR
  11. EntityAIAttackMelee isn't an "attack you when you attack it" it's the "I bump into you and deal damage" behavior. You might also want to look at what makes EntityAIZombieAttack different.
  12. Let me just go look at vanilla code for a second. Oh look at that. EntityAIZombieAttack extends EntityAIAttackMelee
  13. Ahh. IBlockState blockstate = world.getBlockState(pos); Don't do this. You want event.getState() (getBlockState? I am not sure on the exact name). That will give you the block that decayed.
  14. scheduled ticks are, by definition, not random. You can use a random interval, but they are distinct from random update ticks, which are given to a fixed number of blocks in each chunk at random. Yes: Use @Override on every method that you are overriding. If Eclipse says "not valid, suggest remove" then you should fix the signature. Eclipse can't suggest an alternate signature, its too complex of an operation.
  15. There are random update ticks. Look at BlockCrops. Line 28, specifically.
  16. For random ticks, you didn't specify that your block should receive random ticks). For right-clicking, you have the wrong method signature (@Override would tell you this). You want public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
  17. You can simplify this: BlockPos pos0 = new BlockPos(pos.getX(), (pos.getY()+1) , pos.getZ()); BlockPos pos0 = pos.up(); That said, what isn't working correctly?
  18. IBlockState#getValue(BlockDirectional.FACING)
  19. Containers are instanced once and then it just renders AFAIK. Have you tried making the changes, then closing and re-opening the GUI?
  20. Always post the crash report.
  21. No, you do not need a spawn egg for spawners to work.
  22. Null check, yes. Also sendUpdate is a void, so you don't return anything.
  23. My first guess is that worldObj is null (which can happen).

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.