443 Commits

Author SHA1 Message Date
Dylan K. Taylor
ffe89f5e1b fixed Anvils item/block different logic handling, close #1910 2018-02-16 11:07:50 +00:00
Dylan K. Taylor
88a05845c2 Item: Removed protected block field, items should now override getBlock() 2018-02-16 11:06:29 +00:00
Dylan K. Taylor
2cabdca3f7 ItemFactory: Allow block-items to be overridden
Currently an ItemBlock is created for every Block requested, but this will need to change in the future (for Anvils because they have stupid bitshifts on the meta instead of a nice bitmask). This allows registering items in the ItemFactory with IDs lower than 256 and having them recognized.
2018-02-16 11:03:04 +00:00
Dylan K. Taylor
be1ddb9f5b Item: Added API method getVanillaName()
This allows retrieving the name of an item without the custom name being plastered over the top. This will also allow weird things to have special functions for their names.
2018-02-16 10:57:02 +00:00
Dylan K. Taylor
3b632c2870 ItemFactory::fromString(): throw an exception on failure to parse meta value 2018-02-16 09:45:38 +00:00
Dylan K. Taylor
4c583ec8ab ItemFactory: Throw exception on failure to parse string as an item in fromString()
closes #1487
2018-02-15 17:56:55 +00:00
Dylan K. Taylor
af2435f199 Removed redundant checks from ItemFactory::init() and BlockFactory::init()
These are never called accidentally, or at least it's highly unlikely to do so. It might be reasonable to throw exceptions for this, but for the meantime they are redundant - extra indentation for no good reason.

This also removes the $force parameter from BlockFactory::init().
2018-02-15 17:42:03 +00:00
Dylan K. Taylor
456987e212 ItemFactory: Don't initialize creative items in init()
Wanting initialized item factory does not require initializing the creative inventory. This is often useless and unwanted extra baggage (when this is used on threads for example).
2018-02-15 17:09:38 +00:00
Dylan K. Taylor
8e6ec04abc Item: Replace a usage of hardcoded resource path with \pocketmine\RESOURCE_PATH 2018-02-15 12:24:57 +00:00
Dylan K. Taylor
42a7b7fa36 More NBT updates
This library is going to be completely different before I'm done here >.>
2018-02-15 12:11:36 +00:00
Dylan K. Taylor
9abfd54cc1 Updated with ListTag changes from PocketMine-NBT 2018-02-13 16:50:49 +00:00
Dylan K. Taylor
ffbb44673f Enchantment: fix mistake in Protection translation key 2018-02-07 10:15:31 +00:00
Dylan K. Taylor
de0741f727 Item: remove unused imports 2018-01-26 17:12:00 -05:00
Dylan K. Taylor
6c8a1a5b80 Item: Remove redundant Level parameter from onActivate()
there are three other sources this could be gotten from, an arbitrary level doesn't make sense.
2018-01-25 10:15:36 +00:00
Dylan K. Taylor
3842ee15cf Item: Removed now-obsolete Cake class
>> As of 1.2, cake has a max stack size of 64, making this class redundant as its only purpose was to declare a stack size of 1.
2018-01-25 10:09:09 +00:00
Dylan K. Taylor
0df2064802
Implement armor damage protection enchantments (#1839) 2018-01-24 10:13:24 +00:00
Dylan K. Taylor
1e67360048 SpawnEgg: Remove redundant isSurvival() check 2018-01-18 17:04:25 +00:00
Dylan K. Taylor
9551e5b8e5 Durable: Allow subclasses to override behaviour when the item breaks 2018-01-18 14:37:22 +00:00
Dylan K. Taylor
c7f15a556d Durable: Don't allow damage to exceed max damage 2018-01-18 14:34:50 +00:00
Dylan K. Taylor
efca9f0450 Item: Moved getMaxDurability() to Durable class only, and make it abstract
It's only now used in the Durable class, so it does not make sense to keep it in Item anymore. This is a leftover from the days where Durable did not exist.
2018-01-18 14:16:30 +00:00
Dylan K. Taylor
8d7c65585c
Enchantment: Implement Silk Touch (#1912) 2018-01-14 13:37:27 +00:00
Dylan K. Taylor
94feecd44b Enchantment: Implemented Unbreaking 2018-01-13 19:34:45 +00:00
Dylan K. Taylor
98b36fd73e Enchantment: Implemented Efficiency
This is only needed server-side for block-break animation times.
2018-01-11 20:13:57 +00:00
Dylan K. Taylor
07c7048433 Enchantment: Converted item type bitflags to hex 2018-01-11 20:09:42 +00:00
Dylan K. Taylor
f09cf92197 Enchantment: Updated item type flags 2018-01-11 20:08:50 +00:00
Dylan K. Taylor
a6c1e02847 Enchantment: Register Respiration enchantment
First working enchantment on master. Hooray for 3 years late.

This works out of the box (the code checking for this enchantment already exists in Human->doAirSupplyTick()).
2018-01-11 18:32:22 +00:00
Dylan K. Taylor
b04cee12ea Item: Added API method getEnchantmentLevel() 2018-01-11 18:22:29 +00:00
Dylan K. Taylor
90fc649441 Fixed bad PhpDoc leftovers from NBT streams refactor 2018-01-04 20:32:06 +00:00
Dylan K. Taylor
5f48433c95 Bucket: Added sounds for bucket fill/empty 2018-01-03 14:27:41 +00:00
Dylan K. Taylor
33352638a9 Bucket: Fixed appearing empty when picking up still liquids
Buckets already affected by this bug will still appear empty until used. After that they'll work fine.
2018-01-03 14:22:53 +00:00
Dylan K. Taylor
db52501462 Bucket: Fixed stack size handling for empty buckets
GOD this code is horrible
close #1472
2018-01-03 14:12:04 +00:00
Dylan K. Taylor
965c19375f NBT: Split up concerns of endianness and varint NBT into their own classes, separate stream handling from NBT class
The remaining methods, constants and fields in the NBT class now pertain to generic NBT functionality (except for the matchList()/matchTree() methods, but that's a job for another time). All NBT I/O specific logic has now been moved to NBTStream and its descendents.
2017-12-30 14:55:45 +00:00
Dylan K. Taylor
1edf69892a Fixed chorus fruit teleporting players into the void in superflat worlds 2017-12-24 16:27:58 +00:00
Dylan K. Taylor
3bbdc5ab5b Implemented chorus fruit 2017-12-23 15:11:48 +00:00
Dylan K. Taylor
082e3404c3 Potion: Implement potion effects 2017-12-23 15:07:39 +00:00
Dylan K. Taylor
6e1df36188
Consumables refactor (#1796)
* Removed broken EntityEatEvents - these don't fit the pattern since they only apply to Human entities anyway. PlayerItemConsumeEvent and PlayerInteractEvent can be used for cancellation purposes, and plugins can do custom stuff without mess.

* Restrict item consuming to Living entities only

* Added FoodSource->requiresHunger()

* Only items implementing the Consumable interface can now be consumed.

* The effects from consuming items are now generic-ized by way of the Living->consume() function. This is overridden in Human to allow applying food and hunger.

* Fixed the hardcoded mess for buckets
2017-12-23 13:03:41 +00:00
Dylan K. Taylor
375243860e Potion: Restrict item stack size to 1 2017-12-21 15:02:56 +00:00
Dylan K. Taylor
a842a5319f Enchantment: Create constant name once, and reuse it
this is more readable and more maintainable.
2017-12-21 13:11:31 +00:00
Dylan K. Taylor
c2b0f6af22 Enchantment: Simplify getEnchantment() with null coalesce
This is made possible by 0e538ee51dc543e97994899bbf7a73f288fb33a6.
2017-12-21 13:02:24 +00:00
Dylan K. Taylor
6490d99ac2 Enchantment: Added a TODO (calculating XP min/max level cost bounds) 2017-12-21 12:55:55 +00:00
Dylan K. Taylor
e0b063ac85 Enchantment: Added max level property 2017-12-21 12:49:34 +00:00
Dylan K. Taylor
12ac2f4ac7 Enchantment: Fixed rarity constant values to match vanilla
Rarity is used for "weighting" enchantments on enchantment tables and such. Therefore higher numbers mean the enchantment is more common. This changes the rarity values to match vanilla.
2017-12-21 12:48:35 +00:00
Dylan K. Taylor
cc1951c7ba Enchantment: Remove activation type stuff
This isn't and won't be used anywhere.
2017-12-21 12:48:14 +00:00
Dylan K. Taylor
0e538ee51d
Enchantment: Split up enchantment type data and enchantment instance data (#1825)
* Enchantment: Split enchantment type data from instance data
This commit splits enchantments into (effectively) enchantment TYPES vs enchantment INSTANCES.

When applying an enchantment to an item, it only needs to know 2 things:
1. the enchantment ID (identifier) which is used to identify the TYPE
2. the enchantment LEVEL which is used to modify the enchantment's power IN THIS INSTANCE.

Therefore, the LEVEL is not an immutable property. However, all other properties of the currently-named "Enchantment" class are immutable type properties.
Currently, when applying an enchantment to an item, a copy of the enchantment object is created from the registry, and returned. This copies all of the properties contained by the type, which is obviously sub optimal.
2017-12-21 12:40:33 +00:00
Dylan K. Taylor
4f8e4f0522
Add EOF newlines where missing (bulk) (#1836)
This should solve issues with people making GitHub PRs and having the web editor messing things up. GitHub Web Editor sucks :(
2017-12-20 11:56:36 +00:00
Dylan K. Taylor
914e4c9a72 Enchantment: Fix formatting issue 2017-12-16 13:04:25 +00:00
Dylan K. Taylor
24387d1efe Enchantment: Add some PhpDoc for fields 2017-12-16 10:01:42 +00:00
Dylan K. Taylor
4bd4d42b82 Fixed raw porkchop being inedible 2017-12-14 09:09:47 +00:00
Dylan K. Taylor
0004e7429f Added some documentation on harvest level properties 2017-12-12 16:55:00 +00:00
Dylan K. Taylor
e2e6b7516a Removed WoodenTool classes
These were only needed for their fuel properties, which are the same for all tools of the wooden tier anyway.
2017-12-12 13:55:38 +00:00