Commit Graph

2668 Commits

Author SHA1 Message Date
Wesley Wolfe
22adf8a3ce Rework max health values. Fixes BUKKIT-4398 2013-07-02 12:34:40 -05:00
Wesley Wolfe
e79d26d7d7 Fixed NPE in BrewingStand 2013-07-01 22:29:43 -05:00
Nate Mortensen
6c09066e22 Update CraftBukkit to 1.6.1 2013-07-01 12:10:06 -05:00
EvilSeph
f887b76a25 Updated version to 1.5.2-R1.1-SNAPSHOT for development towards next release. 2013-06-14 22:25:24 -04:00
EvilSeph
c945563f9b Updated version to 1.5.2-R1.0 in pom.xml for RB. 2013-06-14 21:54:39 -04:00
Nate Mortensen
5c8498c8b7 Fix cancellation for InventoryDragEvent. Fixes BUKKIT-4332
Cancelling InventoryDragEvent causes the placed items to be lost.  This is
because the cursor is set to the result prior to the event taking place,
so the items are removed from the cursor. When the event is cancelled, the
items removed from the cursor aren't placed in the inventory, and are just
lost.

This change sets the cursor back to the original cursor when the event is
cancelled.
2013-06-13 22:01:50 -05:00
Nate Mortensen
930a9e805c Correct cancellation of InventoryClickEvent. Fixes BUKKIT-4331
Cancelling an InventoryClickEvent for a single click causes the click not
to be processed by the clicked inventory. The server then doesn't
correctly identify their second click as being a double click, causing an
inconsistency between what the Player believes the inventory to be and
what the server believes the inventory to be.

This change forces an updateInventory call whenever an InventoryClickEvent
whose action is NOTHING is cancelled.  Both clicks are considered
PICKUP_ALL, so updating the inventory after the second click fixes any
inconsistencies that could arise between the client and the server.
2013-06-13 22:01:50 -05:00
ST-DDT
93c0d7e6b5 Fix negative damage from Zombies. Fixes BUKKIT-4193
Currently, the method used for calculating the damage of zombies is scaled
to their health, but it uses the default max health rather than the real
max health value. If zombies have more health than the default max health
value, the amount of damage they deal becomes negative.

This is caused by EntityZombie.getMaxHealth() returning a hardcoded value of
20, which is the vanilla max health for zombies. Rather than using this value
when calculating zombie damage, the call is changed to instead use
((CraftLivingEntity) this.bukkitEntity).getMaxHealth(). This uses the true
maximum health of the Entity. "this.maxHealth" could be used instead of the
aforementioned method, however that creates a very unclear diff, and a
confusing change.
2013-06-13 16:53:35 -06:00
Des Herriott
045121d095 Implement PlayerBookEditEvent. Adds BUKKIT-1995 2013-06-10 12:06:37 -06:00
mbax
c55c0db86d Update blaze breathe sound. Fixes BUKKIT-4286 2013-06-05 19:45:24 -05:00
Nate Mortensen
bf4796d39e Fix creative ArrayIndexOutOfBoundsException. Fixes BUKKIT-4305
When a Player drops an ItemStack while in creative mode by placing it outside
of their inventory window, the slot number in the packet is -1. The check
that was added to avoid throwing InventoryCreativeEvent excessively didn't
take this into account, and would cause an ArrayIndexOutOfBoundsException to
be thrown when attempting to get the slot specified by the packet.

This change shorts the invocation of player.defaultContainer.getSlot(
packet107setcreativeslot.b) to only occur if the slot id is within the range
of the Inventory.  This prevents attempting to get the slot from a location
that is actually outside of the Inventory.
2013-06-04 15:58:36 -05:00
riking
991218a339 Improve events for new inventory features. Adds BUKKIT-3859
This commit brings the InventoryClickEvent up to date with the new Minecraft
changes in 1.5.

InventoryDragEvent (thanks to @YLivay for his PR) is added to represent the
new "dragging" or "painting" functionality, where if you hold an itemstack and
click-drag over several slots, the items will be split evenly (left click) or
1 each (right click).

The ClickType enum is used to represent what the client did to trigger the
event.

The InventoryAction enum is reserved for future expansion, but will be used to
indicate the approximate result of the action.

Additionally, handling of creative inventory editing is improved with the new
InventoryCreativeEvent, and handling of numberkey presses is also improved
within InventoryClickEvent and CraftItemEvent.

Also, cancelling a creative click now displays properly on the client.

Adresses BUKKIT-3692, BUKKIT-4035, BUKKIT-3859 (new 1.5 events),
BUKKIT-2659, BUKKIT-3043, BUKKIT-2659, and BUKKIT-2897 (creative click events).
2013-06-03 18:01:08 -06:00
EvilSeph
56dbde3c5b Updated version to 1.5.2-R0.2-SNAPSHOT for development towards next release. 2013-05-03 18:39:32 -04:00
EvilSeph
9b9cd2dc0c Updated version to 1.5.2-R0.1 in pom.xml for BETA. 2013-05-03 17:42:59 -04:00
Travis Watkins
5ed1418bb4 Pass correct block when dispensing empty buckets. Fixes BUKKIT-3668 2013-05-03 06:45:11 -05:00
Travis Watkins
d9eb586568 Correct event handling for dispensing filled buckets. Fixes BUKKIT-4046
We only go through event creation and calling when dispensing filled buckets
if the bucket is able to place its liquid. However, the check for this is
incorrect so the event is not called when a block liquids can destroy is
in front of the dispenser. This commit fixes the check to match the checks
vanilla does when actually using the bucket.
2013-05-03 06:38:44 -05:00
Des Herriott
28fb514a4d Send block updates even when applyPhysics is false. Fixes BUKKIT-3971
The CraftBlock class is setting bit 0x4 of the update flag when bit 0x2
should in fact be set here. Bit 0x2 means "do updates"; bit 0x4 means
"don't do updates if the world is static, even when bit 0x2 is set".
2013-05-02 16:42:47 -06:00
Travis Watkins
4e7ad05111 Fix typo/logic error in previous commit 2013-05-02 13:06:21 -05:00
Travis Watkins
25ca3f41af Fix animal spawning ignoring limits. Fixes BUKKIT-4180
Minecraft 1.5.2 changed mob spawning by ignoring persistent mobs from the
mob count. In CraftBukkit all mobs that previously used a separate hard
coded persistence system were ported to instead use this one. This causes
all animals to be persistent by default and thus never be counted. To
correct this issue we consider if the mob would be considered persistent
in the hard coded system as well when deciding if a mob should count.
2013-05-02 12:24:31 -05:00
Travis Watkins
401a6809be Improve InventoryCloseEvent handling. Fixes BUKKIT-3286
Currently there are several cases where a player will have their inventory
screen closed client side but we will not call an event. To correct this
we call the event when the server is the cause of the inventory closing
instead of just when the client is the cause. We also ensure the server is
closing the inventory reliably so we get the events. Additionally this
commit also calls the event when a player disconnects which will handle
kicks, quits, and server shutdown.
2013-05-02 06:28:51 -05:00
Score_Under
75641a607e Move world generator warning to CraftBukkit. Fixes BUKKIT-2565 2013-04-30 17:09:04 -07:00
Travis Watkins
f08081c77d Always process movement for vehicles and passengers. Fixes BUKKIT-4142
As an optimization we don't do any movement processing on entities that
have not moved. However, players in minecarts trigger this condition when
the minecart is moving on its own. This causes issues with things that rely
on player collision like tripwires. To correct this and any future related
issues we always handle movement for passengers and their vehicles even
if one of the two hasn't moved since they are linked.
2013-04-30 01:21:04 -05:00
Travis Watkins
2715e43305 Revert "Add delay to hopper even if it doesn't do anything."
This reverts commit f5388e8f94e2cbab76c2255fd872c289e83100a0.
2013-04-27 10:42:25 -05:00
Travis Watkins
3bbfb41798 Fix things using wall time running too fast. Fixes BUKKIT-4155
When converting things in Minecraft to use wall time instead of ticks I
realized we'd run into integer division rounding issues and could have
updates that end up counting as zero ticks. To compensate for this the
code ensures we always process at least one tick. However, every time we
end up with zero ticks the next time we have an extra tick due to rounding
the other way with the leftovers. This means we are going far too fast and
should not have this at least one tick logic at all.

On top of this some potions rely on the number of ticks they run and not
just the amount of time they last and so potions were put back to running
with ticks entirely.
2013-04-27 10:42:25 -05:00
Travis Watkins
799779e4b1 Update CraftBukkit to Minecraft 1.5.2 2013-04-27 10:42:19 -05:00
Wesley Wolfe
83c3aa188b Rework EntityExplodeEvent. Fixes BUKKIT-4140. Adds BUKKIT-4141 2013-04-24 03:03:38 -05:00
Travis Watkins
708b0e6ae1 Don't do physics updates in world generation. Fixes BUKKIT-3747 2013-04-16 07:09:32 -05:00
Mike Primm
40e6308718 Validate chunk data array lengths. Fixes BUKKIT-4093
If a chunk has somehow managed to save with arrays that are not 4096
entries long when reading them again we will get exceptions. Checking the
array length and resizing if needed is cheap so we should do this to help
avoid crashing servers due to this error.
2013-04-15 22:50:20 -05:00
Travis Watkins
928e4d9bbb When moving a misplaced chunk move tile entities too. Fixes BUKKIT-4092
When a chunk is being loaded the server checks to ensure the chunk's idea
of where it is located matches where it was located in the region file. If
these two values do not match the chunk's idea of its position is updated
and the chunk is reloaded. In vanilla minecraft this loading involves the
chunk's tile entities as well. With the change to loading player chunks
asynchronously we split loading tile entities to a separate step that takes
place after this check. Because of this tile entities are loaded with
invalid locations that result in trying to fetch block data from negative
or too large positions in the chunk's internal block storage arrays.

Because loading the tile entities is not thread safe we cannot return to
vanilla behavior here. Instead when we detect a misplaced chunk we just
edit the NBT data for the chunk to relocate the tile entities. This results
in them moving correctly with the chunk without having to actually load
them first.
2013-04-15 22:49:54 -05:00
GJ
0ab14dbaad Make Slimes fire EntityTarget events. Fixes BUKKIT-1408 2013-04-15 20:03:22 -07:00
EvilSeph
e62614a71e Updated version to 1.5.1-R0.3-SNAPSHOT for development towards next release. 2013-04-13 02:58:41 -04:00
EvilSeph
3dfdd0fe41 Updated version to 1.5.1-R0.2 in pom.xml for BETA. 2013-04-13 02:47:51 -04:00
Travis Watkins
c3cf8a435b Don't apply fall damage when cancelled. Fixes BUKKIT-4065 2013-04-13 01:03:08 -05:00
Travis Watkins
8590492680 Add delay to hopper even if it doesn't do anything. Fixes BUKKIT-4061
If a hopper is unable to perform any action during a tick it attempts to do
so every tick from then on. Once it is able to do so it then sets a delay
before attempting to do something again. To avoid excessive CPU usage for
hoppers sitting idle we now apply this delay regardless of the success of
the action.
2013-04-13 00:36:35 -05:00
riking
5cc4fbd712 Perform anvil calculations when using 1.5 drop feature.
When using the new feature in 1.5 to drop the item in any highlighted slot,
the anvil result slot does not apply the full anvil calculation that picking
up the item does, including the experience calculation.
2013-04-13 00:31:20 -05:00
Travis Watkins
1c18834b7d Use wall time instead of ticks for several things. Fixes BUKKIT-4059
Currently furnace smelting and the item pickup delay timer use wall time
(aka actual time passed) to emulate a constant tick rate so run at the
same speed regardless of the server's actual tick rate. There are several
other places this makes sense so this commit converts them.

The item despawn timer is converted so now always takes 5 minutes. Users
know this 5 minute number well so keeping this constant helps to avoid
confusion. This also helps alleviate lag because if a large number of item
drops is the reason your server is running slowly having them stay around
longer just means your server is slow longer.

Potion brewing and the zombie villager conversion timer are now constant.
These match the furnace criteria of being useful for hiding lag and not
having a detrimental effect on gameplay.

Potion effects are now also using wall time. The client is told about effect
times in ticks and displays this information to the user as minutes and
seconds assuming a solid 20 ticks per second. The server does have
code for updating the client with the current time remaining to help
avoid skew due to differing tick rates but making this a constant makes
sense due to this display.
2013-04-13 00:31:08 -05:00
Travis Watkins
94f43d8c36 Add MobEffect from mc-dev for diff visibility 2013-04-13 00:30:56 -05:00
Travis Watkins
a2d9f33ca3 Various minor performance improvements
Add a check to avoid doing movement work if an entity doesn't move. This
usually will not ever happen in the current server but is useful when it
does and will be more useful in the future.

Only process mob on mob (non-player) collisions every other tick. Players
tend to pack a lot of mobs into a small space (sheep farm, mob grinder, etc)
so they do a lot of work processing collisions. To help alleviate some of
this we only run these calculations every other tick. This has no visible
effect on the client but can be a huge win on the server depending on
circumstances.

Use generic entity inWater checking for squids. Squids have their own logic
currently for determining if they are in water. This check is almost
identical to the generic entity checking which is run anyway. To avoid
doing duplicate work we just remove the squid version. This does not
have any noticeable effect on gameplay since the checks are so similar.

Use HashSet for tile entities instead of ArrayList. Using an ArrayList for
storing tile entities in a world means we have very expensive inserts and
removes that aren't at the end of the array due to the array copy this
causes. This is most noticeable during chunk unload when a large number of
tile entities are removed from the world at once. Using a HashSet here uses
a little more memory but is O(1) for all operations so removes this
bottleneck.
2013-04-13 00:30:43 -05:00
Travis Watkins
159d614a3a Correct vehicle movement issues. Fixes BUKKIT-2993, BUKKIT-4056
When a player comes into range of an entity in a vehicle they will often be
sent the spawn packet for the rider before receiving one for the vehicle.
This causes the attachment packet to fail client side because it attempts
to attach the rider to a vehicle that doesn't exist on the client. To
correct this we account for both possible orderings and send the
attachment packet appropriately.

Vanilla also sends an new attach packet every 60 ticks even if the vehicle
has not changed. As this packet is a toggle this resulting in players
teleporting around randomly. Since we handle attachments properly now we
simply revert this section to use the 1.4 logic.
2013-04-13 00:30:30 -05:00
Travis Watkins
ce5b97ea83 Fetch tile entities from chunks instead of world. Fixes BUKKIT-4055
When looking up tile entities for a chunk to send to a player we currently
loop through every tile entity in the world checking if it is within the
bounds of the relevant chunk. Instead of doing this we can just use the
tile entities list stored in the chunk to avoid this costly searching.

As a further optimization, we also modify the generic range-based lookup
to use chunks as well. For most lookups this will give a smaller search
pool which will result in faster lookups.

Thanks to @mikeprimm for the idea and most of the implementation.
2013-04-13 00:30:16 -05:00
Travis Watkins
70a778f475 Boats can only die once.
In certain scenarios a boat can be killed multiple ways in a single tick.
Due to improper guards this can cause the death code to run multiple times
creating item drops. To correct this we insert the appropriate death check.
2013-04-13 00:29:49 -05:00
Wesley Wolfe
7939572c33 Check connection status before setting scoreboard. Fixes BUKKIT-4064
Two connection status checks were added to setting a scoreboard for a
player. The first checks to see if a player has logged in yet, which
implicates the ability to receive packets. The second checks to affirm
that the CraftPlayer reference is still to a logged in player; setting
it while not logged in would maintain a stale player reference in the
scoreboard manager.
2013-04-12 21:31:24 -05:00
Wesley Wolfe
3e0d8331be Change perspective of team checking. Fixes BUKKIT-4044
The method's return value was being incorrectly calculated from the
perspective of this.canHurt(that), where it's actually used from the
this.canBeHurtBy(that) perspective.
2013-04-11 23:22:41 -05:00
Wesley Wolfe
ac593849ae Use correct method for getting player's team. Fixes BUKKIT-4050
The method getTeam gets the team from name of, as opposed to getting the
team a player belongs to.

This also addresses BUKKIT-4002 and partially BUKKIT-4044
2013-04-11 23:03:37 -05:00
feildmaster
77d1524b3d Refactor EntityDamageEvents. Adds BUKKIT-1944 & BUKKIT-3684 2013-04-10 21:33:33 -05:00
Wesley Wolfe
535a85a5b0 Make auxiliary worlds use the main scoreboard. Addresses BUKKIT-3984
When a world is created using our API, it does not use secondary world
server and will maintain a reference to its own scoreboard. In vanilla,
this is not an issue as there is only ever one world.

Similarly to maps, an overwrite to the scoreboard reference has been
added for when another world has been created.

This should also address BUKKIT-3982 and BUKKIT-3985
2013-04-04 23:35:16 -05:00
Travis Watkins
2a5e90fb8b Handle large chests correctly for hopper events. Fixes BUKKIT-3979
In commit 7710efc5f9 we corrected the handling of large chests as the
destination for hoppers moving items but did not apply the same fix for
large chests being the source or for droppers. This commit updates these
to have the same fix.
2013-04-04 12:59:47 -05:00
Wesley Wolfe
055c13461d We compile for 1.5 2013-04-04 01:22:50 -05:00
mbax
d95a4705cb Implement Scoreboard API. Adds BUKKIT-3776
This implementation facilitates the correspondence of the Bukkit Scoreboard
API to the internal minecraft implementation.

When the first scoreboard is loaded, the scoreboard manager will be created.
It uses the newly added WeakCollection for handling plugin scoreboard
references to update the respective objectives. When a scoreboard contains no
more active references, it should be garbage collected.

An active reference can be held by a still registered objective, team, and
transitively a score for a still registered objective. An internal reference
will also be kept if a player's specific scoreboard has been set, and will
remain persistent until that player logs out.

A player's specific scoreboard becomes the scoreboard used when determining
team structure for the player's attacking damage and the player's vision.
2013-04-04 01:13:21 -05:00
Wesley Wolfe
5634d9f701 Add a WeakCollection utility class.
This class is designed to be an invisible layer between a normal collection,
and one that silently loses entries because they are only weakly referencable.
Some operations have additional overhead to be semantically correct, but it
maintains the equals contract for all entries, as opposed to identity.

It does not support the equals or hash code method as it cannot easily have
the transitive and commutative properties.
2013-04-04 01:05:47 -05:00