Commit graph

624 Commits

Autor SHA1 Nachricht Datum
Lukas Hennig
19507baf8b Improvements to BlockStates
* Actually capture all the data of TileEntities. This is done by creating a copy of the TileEntity. The methods of BlockState which currently directly access the TileEntity reference will modify the data of that TileEntity-snapshot instead.
* With the call to BlockState.update, the captured TileEntity data gets applied to the current TileEntity in the world.
* Methods which trigger block specific actions will use the current TileEntity from the world.
* CraftBlockState does not hand out the wrapped or the snapshot TileEntity directly. Instead, it provides an applyTo method to copy the data to a given TileEntity and a method to directly get a copy of the TileEntity NBT data represented by the BlockState. CraftMetaBlockState was updated to make use of that.
* Added #getSnapshotInventory() to bukkit which allows modifiying the captured inventory snapshots of containers.
* Tried to clarify which methods only work if the BlockState is placed, which methods require the block in the world to still be of the same type (methods which trigger actions), and that .getInventory() directly modifies the inventory of the block in the world if the BlockState is placed and becomes invalid if the block type is changed.

Backwards compatibility

* If the BlockState acts as InventoryHolder, getInventory() will still return the inventory directly backed by the TileEntity in the world (like before), and not the snapshot inventory. This compromise should reduce the potential of these changes to break existing plugins, or craftbukkit's own use of BlockState.
* The snapshot's inventory can be accessed by a new method getSnapshotInventory()
* In case the BlockState is not placed (if it was retrieved from the MetaBlockState of an item), the getInventory() method will however return the snapshot inventory. So that when the BlockState gets applied back to the item, the inventory changes are properly included.
* With the changes to CraftMetaBlockState it is no longer required to call the update method before passing a modified BlockState to the CraftMetaBlockState. For backwards compatibility the update method will simply return true for a non-placed BlockState, without actually doing anything.

Impact on plugins
* Restoring blocks now actually works as expected, properly restoring the TileEntity data, reglardless if the block changed its type in the meantime.
* Plugins are now consistently required to call the update method in order to apply changes to blocks. Though, regarding the Javadoc they should have been required to do so anyways.
* New feature: Plugins can take and modify inventory snapshots.
* Breaking change: If a plugin gets the BlockState of a block in the world, modifies the inventory returned by .getInventory(), and then tries to use the same BlockState to apply the TileEntity data to an ItemStack block meta, the ItemStack will use the snapshot inventory, disregarding the changes made to the inventory returned by .getInventory(). This is the compromise of .getInventory() returning the inventory directly backed by the TileEntity in the world.

Other fixes related to BlockState:
* TileEntityContainer#getLocation() will run into a NPE if the TileEntity is non-placed (ex. when getting the BlockState from a CraftMetaBlockState).
* Beacon.getEntitiesInRange() would previously throw a NPE if called for a non-placed BlockState. It was changed to now require to be placed and use the current TileEntity in the world. If the TileEntity in the world is no longer a beacon, it will return an empty list.
* EndGateway now supports setting and getting the exit location even for non-placed EndGateways (inside BlockStateMeta) by using / returning a location with world being null.
2017-08-05 14:37:19 +10:00
md_5
63029f4ff3 SPIGOT-3492: Ensure player functionality uses their specific scoreboard 2017-08-05 09:15:52 +10:00
md_5
2a927e8638 Update to Minecraft 1.12.1 2017-08-03 23:00:00 +10:00
md_5
57c323aad1 SPIGOT-3486: Missing check in redstone placement 2017-08-03 08:31:29 +10:00
md_5
2cfb85dae2 SPIGOT-3487: Llama doesn't drop chest 2017-08-03 08:21:05 +10:00
md_5
86aa17fae1 SPIGOT-3482: ProjectileHitEvent for shulker bullet and llama spit 2017-08-02 18:05:28 +10:00
md_5
2c5c611d0c SPIGOT-3456: Expand calling of ServerCommandEvent
Existing usage preserved by checking sender.
2017-07-28 18:10:38 +10:00
md_5
d00c0574cd SPIGOT-3403: Add an EntityPickupItemEvent 2017-07-28 17:47:59 +10:00
md_5
5c4864398d SPIGOT-3463: Spurious item drops from event 2017-07-28 17:23:39 +10:00
md_5
b1b9ab0df9 SPIGOT-3461: Standardise plugin load timing 2017-07-26 13:20:29 +10:00
md_5
4670a84bd9 SPIGOT-3432: Add playNote support for new sounds 2017-07-24 17:44:44 +10:00
md_5
f078eed54b SPIGOT-3440: Non player entities should not make new portals 2017-07-22 16:40:10 +10:00
md_5
5a12442f22 SPIGOT-3433: Improve AreaEffectCloud#getSource 2017-07-22 09:51:22 +10:00
md_5
49c2537fe2 Fix memory leak in PlayerList 2017-07-17 09:55:47 +10:00
md_5
e03b1a556d SPIGOT-3417: Event for shearing snowman 2017-07-15 09:53:22 +10:00
md_5
50b75cd65d SPIGOT-3407: Set damager for evoker fangs 2017-07-08 22:40:54 +10:00
md_5
0481ae963a SPIGOT-3382: Ensure players can pickup stuff 2017-06-26 11:21:38 +10:00
md_5
9de5cb59a0 SPIGOT-3377: Fix subspace bubble advancement 2017-06-26 10:16:54 +10:00
md_5
d7cd7275f2 SPIGOT-3379: Generalise canPickupItems to other entities. 2017-06-26 08:34:52 +10:00
md_5
de76085596 SPIGOT-3376: Fix nested functions 2017-06-26 08:27:25 +10:00
md_5
258575110f SPIGOT-3373: Fix /execute in gameloop functions 2017-06-25 09:46:19 +10:00
md_5
753a8e700d SPIGOT-3324: Improve tameable damage handling 2017-06-24 10:01:46 +10:00
md_5
763827668e SPIGOT-3368: Allow anvil level cost to be overwritten by properties 2017-06-23 20:35:17 +10:00
md_5
5e2a23055e SPIGOT-3364: Correct EntityResurrectEvent 2017-06-23 12:47:29 +10:00
md_5
03f1e37ae2 Fix nether world border center not adjusting 2017-06-18 19:23:33 +10:00
md_5
a7d074c6c0 SPIGOT-3329: Allow per world loot tables 2017-06-15 20:34:19 +10:00
md_5
732911efbc SPIGOT-3337: Use special data value to indicate multiple recipe choices 2017-06-15 07:23:08 +10:00
Jacob Martin
f7d14f184d Fix detection of missing or invalid tile entities for End portals and gateways 2017-06-12 12:41:18 -05:00
md_5
ec47e791bd SPIGOT-3328: EntityTameEvent for Parrots 2017-06-12 07:27:34 +10:00
md_5
202da9777d SPIGOT-3324: Best effort fix for shoulder Parrots + cancelled damage event 2017-06-11 12:20:18 +10:00
md_5
639aa0cf48 SPIGOT-3320: Apply tile entity fixer to more types 2017-06-11 08:32:29 +10:00
md_5
ed8c725d19 SPIGOT-3304: Respect duration from Vanilla /weather 2017-06-09 16:17:08 +10:00
md_5
2c34c38d7a SPIGOT-3303: Warn when attempting to grant non existent recipe 2017-06-09 16:13:35 +10:00
md_5
1b3122eef1 SPIGOT-3302: Armor stands not dropping armor 2017-06-09 15:51:56 +10:00
md_5
bb4ae3b3b8 Update to Minecraft 1.12 2017-06-08 18:00:00 +10:00
chickeneer
fe3ca95c76 Prevent NPE when setting tempt target to null 2017-06-04 08:43:00 +10:00
md_5
10daedccdd Add proper TeleportCause for /teleport 2017-06-04 08:39:36 +10:00
md_5
9a032b246b SPIGOT-3290: /teleport command overrides player rotation 2017-06-04 08:34:52 +10:00
md_5
701b06494d SPIGOT-3286: Call BlockFormEvent for Concrete Powder -> Concrete 2017-06-03 17:39:03 +10:00
md_5
e13d119686 Update to Minecraft 1.12-pre6 2017-05-30 21:55:13 +10:00
Scetra
ccc420a957 Add support for preventing block drops in BreakEvent 2017-05-28 17:08:28 +10:00
md_5
c037fe3d44 Add color API for Teams 2017-05-28 11:00:02 +10:00
Pokechu22
44dd60ac27 SPIGOT-3272: Fix duplicate creative inventory
This change properly identifies the creative inventory as one with 5 crafting slots (as that's the default set in ContainerPlayer, and handled properly in other containers), instead of having the same inventory twice (which breaks slot identification).
2017-05-28 10:32:31 +10:00
MiniDigger
274304b8ca SPIGOT-439: Add player locale related APIs. 2017-05-27 19:06:28 +10:00
md_5
a479029a85 Ensure gameLoop function gets selectors applied. 2017-05-26 16:43:56 +10:00
md_5
c7920f4302 SPIGOT-3257: Issue with AdvancementRewards function 2017-05-21 10:28:07 +10:00
md_5
24147056e0 SPIGOT-3258: VehicleBlockCollisionEvent only fires in certain directions 2017-05-21 10:24:47 +10:00
md_5
cda27c992d SPIGOT-3254: Check chunks are loaded before ticking entities as per previous versions. 2017-05-20 11:28:38 +10:00
md_5
1004352990 Update to Minecraft 1.12-pre5 2017-05-19 21:00:13 +10:00
md_5
45102fcf28 Misc advancement / recipe reload fixes including SPIGOT-3240 2017-05-16 21:22:07 +10:00