52 Commits

Author SHA1 Message Date
md_5
e2f5ea34e9
Update to Minecraft 1.17 2021-06-11 15:00:00 +10:00
md_5
90d6905b15
Repackage NMS 2021-03-16 09:00:00 +11:00
md_5
9a9c2234a4
SPIGOT-6087: Revert "SPIGOT-6086: Twisting vines growing at top of world crashes server"
This reverts commit fad5fb9e8cfc2a2c6883e59203b604f4c0ecf421.
2020-08-18 20:44:06 +10:00
md_5
fad5fb9e8c
SPIGOT-6086: Twisting vines growing at top of world crashes server 2020-08-18 17:50:13 +10:00
md_5
9c9fb593f5
Update to Minecraft 1.16.2 2020-08-12 07:00:00 +10:00
md_5
6b20d04c71
SPIGOT-5826: Don't store chunk in block states 2020-06-26 09:34:25 +10:00
md_5
6515ea4957 SPIGOT-5537: Bee nests generated by growing trees near flower have no bees 2020-01-28 09:48:28 +11:00
md_5
e3df3d5cda Add Override annotations where appropriate 2019-04-28 11:38:01 +10:00
md_5
5fea790398 Apply import ordering rules to CraftBukkit classes 2019-04-23 14:56:58 +10:00
md_5
48c4c5ca81 Begin implementation of CheckStyle style checking 2019-04-23 14:00:30 +10:00
md_5
dff66dfccd Reduce copying of positions from block states 2018-12-22 11:32:11 +11:00
md_5
fc1024944e Make CraftBlockState use BlockPosition 2018-12-22 10:29:53 +11:00
md_5
5184216f27 SPIGOT-4447: Clear error for people trying to set an item as a block 2018-10-27 08:21:49 +11:00
md_5
e7ced970d2 Catch plugins setting null Material or BlockData to blocks 2018-10-13 09:43:05 +11:00
md_5
66b62a63b5 Fix bad old API call in CraftBlockState 2018-07-20 10:32:17 +10:00
md_5
3791cf947e SPIGOT-4037: Improve legacy BlockState.setData 2018-07-18 09:53:50 +10:00
md_5
421c1728c8 Update to Minecraft 1.13-pre7 2018-07-15 10:00:00 +10:00
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
ac405c3cd4 Fix some blockstate consistency issues. 2017-04-15 18:01:44 +10:00
md_5
c25ddf063a Update to Minecraft 1.11 2016-11-17 12:41:03 +11:00
md_5
88123f0569 SPIGOT-2286: Don't store CraftBlockState light level 2016-05-16 16:37:22 +10:00
md_5
5c23262f15 Update physics on attached block when setting data of attachable blocks 2016-04-09 12:57:19 +10:00
md_5
aa008dff0f Update to Minecraft 1.9 2016-03-01 09:32:45 +11:00
Thinkofdeath
61ef214f91 Implement BlockStateMeta which allows creating and editting 1.8's blockEntityTag 2015-03-24 16:02:47 +00:00
Thinkofdeath
b58808d54d Fix tree related crashes due to lazy BlockState updating 2014-12-02 11:51:49 +00:00
Thinkofdeath
24557bc2b3 Update to Minecraft 1.8
For more information please see http://www.spigotmc.org/
2014-11-28 17:16:30 +11:00
bloodshot
576758bc55 Refactored BlockPlaceEvent and BlockChangeDelegate. Adds BUKKIT-5558
23 classes have been removed as they are no longer needed using the new
capture logic. This should help quite a bit with future MC updates.

BlockPlaceEvent Refactor

Before calling Item.interactWith, a recording flag is turned on for
setTypeAndData to capture a blockstate for each block that attempts to be set.
When a block place event is cancelled, the recorded blockstate, stack
size, and metadata will revert back to the captured state. If the event is
not cancelled, a notification will be sent to clients and block physics
will be updated.

BlockChangeDelegate Refactor

Now that we have the ability to capture blockstates through world, there
is no need to modify world gen classes with BlockChangeDelegate. Instead
we will simply capture blocks during world generation in order to "replay"
all of the captured blockstates to send back to delegates.
StructureGrowDelegate and BlockSapling.TreeGenerator have also been
removed as part of this change. BlockSapling and BlockMushroom will
capture blockstates the same as block placement and revert back any grow
events if needed.
2014-04-23 21:25:55 -06:00
Travis Watkins
71a475f076 Don't update physics when block place is cancelled. Fixes BUKKIT-3939
When a block placement happens we currently update physics on the
attempted placement and update again if the placement is cancelled.
To correct the first one we simply set the block without applying
physics. To correct the second we have to add a new method to
BlockState that lets us update without applying physics and use
this method method when putting the block back.
2013-03-31 19:18:42 -05:00
Travis Watkins
5f089137ee Cleanup comments, formatting, etc 2013-03-25 00:51:36 -05:00
Travis Watkins
846a22304c Provide a faster way to get a location. Adds BUKKIT-3120
Currently when a plugin wants to get the location of something it calls
getLocation() which returns a new Location object. In some scenarios this
can cause enough object creation/destruction churn to be a significant
overhead. For this cases we add a method that updates a provided Location
object so there is no object creation done. This allows well written code
to work on several locations with only a single Location object getting
created.

Providing a more efficient way to set a location was also looked at but
the current solution is the fastest we can provide. You are not required
to create a new Location object every time you want to set something's
location so, with proper design, you can set locations with only a single
Location object being created.
2012-12-07 21:15:05 -06:00
Wesley Wolfe
e2b1514daf Bulk pending cleanup. 2012-09-09 23:19:28 -05:00
rmichela
1394926e53 [Bleeding] Implement Metadata framework for Entities, Blocks, and Worlds 2012-02-29 19:21:25 +01:00
Feildmaster
7792156fb2 [Bleeding] Added BlockGrowEvent. Addresses BUKKIT-104 2012-02-22 21:46:45 -05:00
Erik Broes
a4ce846d07 Fix formatting. 2012-01-15 10:54:57 +01:00
Nathan Adams
366d310186 Added .equals and .hashcode to CraftBlockState 2012-01-14 17:47:15 +00:00
Nathan Adams
61edd36378 Made BlockStates inform playes upon update 2011-11-24 18:48:23 +00:00
Erik Broes
cc9ccc8976 Removed some old deprecated code and clean up javadocs + warnings 2011-07-17 18:14:45 +02:00
Erik Broes
a98c7ba2c7 Massive renaming update in nms. If you bypassed Bukkit, you will likely break.
Also minimized all the nms diffs and generic cleanups all around.
2011-06-27 00:47:03 +02:00
Erik Broes
9adc03abab Generic cleanup of the org.bukkit.craftbukkit classes. 2011-06-12 12:51:54 +02:00
Erik Broes
309846d732 Whitespace + general cleanup 2011-05-15 13:41:46 +02:00
Erik Broes
324efa8224 Fix BlockPlace 2011-03-21 00:31:13 +01:00
Dinnerbone
770bb9e3b5 Removed Block.getRawData 2011-03-04 14:20:38 +00:00
Tahg
96435cfc76 refactor Items 2011-02-21 19:57:23 -05:00
Erik Broes
04be2b9b31 Generic cleanup/reformat. 2011-02-02 00:39:08 +01:00
VictorD
3477a86995 Added getBlockReplacedState to BlockPlaceEvent, in case one wants to see what type of block was there previously. 2011-01-24 23:22:28 +01:00
Dinnerbone
0db8d5d111 Moved block stuff from org.bukkit to org.bukkit.block 2011-01-15 21:36:57 +00:00
Erik Broes
dea72d6623 Global ID -> Id rename 2011-01-15 20:55:59 +01:00
Dinnerbone
e4a31ce206 Implemented BlockState MaterialData 2011-01-15 19:53:33 +00:00
Dinnerbone
2761b59845 Update to Minecraft Server 1.2 2011-01-14 13:31:10 +00:00
Dinnerbone
d374bff8d0 Implemented BlockState.update(boolean), signs should now work, cleaned up some code a little 2011-01-08 01:22:17 +00:00