Commit Graph

2345 Commits

Author SHA1 Message Date
Wesley Wolfe
cfa5490a58 Clarify exception message for bad hanging location. Fixes BUKKIT-4824
This change adds the location and a more specific message to the
IllegalArgumentException that gets thrown when a hanging entity is being
spawned in a location that it cannot survive.
2013-10-05 13:21:15 -05:00
Wesley Wolfe
90e8aa008a Initialize hostname on handshake. Fixes BUKKIT-4793
This restores a lost CraftBukkit diff that initializes the hostname
field used during login events.
2013-09-20 09:13:48 -05:00
feildmaster
dcb9d6a5ef Update CraftBukkit to 1.6.4 2013-09-19 20:01:02 -05:00
feildmaster
7ad5d6098d Fix villager death sound 2013-09-10 21:55:42 -05:00
feildmaster
ac73522ecf Add missing villager sounds. Addresses BUKKIT-4756 2013-09-10 21:30:36 -05:00
EvilSeph
6d700c3320 Use correct spawn reason for Zombie reinforcements. Fixes BUKKIT-4744 2013-09-10 22:24:00 -04:00
EvilSeph
b8feaf059c Remove unnecessary error logging. Fixes BUKKIT-4406 2013-09-10 22:23:59 -04:00
Phillip Schichtel
ffcd0f4502 Provide a tab completion handler for JLine. Adds BUKKIT-4168 2013-09-10 20:57:31 -05:00
FrozenBrain
5f65cd9a1c Add support for custom Hopper inventories. Fixes BUKKIT-4722
Opening a hopper inventory created by Server.createInventory will
currently have no effect as proper handling code is missing in
CraftEntityHuman for hopper inventories that aren't associated with a tile
entity or minecart. Initialization logic for hoppers is also missing from
CraftContainer, which is necessary for the opening of custom hopper
inventories.

This commit fixes the two aforementioned by adding proper handling to
CraftHumanEntity for opening inventories not associated with a tile
entity, and by adding initialization logic for hoppers to CraftContainer.
2013-09-10 20:51:35 -05:00
feildmaster
600e1524a9 Update and add new sound mappings. Fixes BUKKIT-4756 2013-09-10 20:24:34 -05:00
Brokkonaut
5f43109c0e Correct location of fire from lightning strikes. Fixes BUKKIT-4707
Previously fires spawned by lightning strikes were in the wrong locations.
This introduced the possibility of having blocks replaced when they should
not be.

EntityLightning now uses the correct locations as defined to spawn the
fires when needed.
2013-09-10 20:53:48 -04:00
feildmaster
8ae8957d15 Properly set persistence flag for bred animals. Fixes BUKKIT-4751 2013-09-10 19:42:08 -05:00
Nate Mortensen
c62375f95e Check that a vehicle is a Vehicle before casting. Fixes BUKKIT-4749
When an entity is being moved as the passenger of an entity from one
entity to another, a VehicleExitEvent is fired, but it is assumed that the
current entity is a Vehicle. However, entities can be passengers of more than
just Vehicles, which causes a ClassCastException to be thrown.

This commit fixes the issue by checking that the current entity's vehicle's
bukkitEntity is an instance of Vehicle before casting it to Vehicle.
2013-09-09 22:07:27 -05:00
Wesley Wolfe
5c861fe864 Fix improperly initialized usernames 2013-09-02 16:51:14 -05:00
T00thpick1
cd593fb1ee Set current recipe to null when a recipe isn't found. Fixes BUKKIT-2311
This commit restores the diff from 84dbc21aa71b96fd1d2ea40d624b536309118cde
that has since been lost.
2013-08-28 08:14:01 -06:00
Roger Baumgartner
2e7f66787d Return correct hasLineOfSight value for players. Fixes BUKKIT-4634
Prior to this change when a plugin called Player.hasLineOfSite() the
method would always return false because EntityHuman does not extend
EntityInsentient. This commit changes that by explicitly checking for
line of sight between two entities and returning that value.
2013-08-26 08:43:51 -06:00
T00thpick1
6482b6f0bd Fire FoodLevelChangeEvent when eating cake. Fixes BUKKIT-2242 2013-08-15 11:59:47 -06:00
T00thpick1
3fb4ccb62c Add BlockCake for diff visibility. 2013-08-15 11:59:46 -06:00
Wesley Wolfe
f481c9ee07 Make ItemFactoryTest.java platform agnostic. Fixes BUKKIT-4695
Maven paths that include spaces (and possible other characters) get
improperly translated when using a file handle from a URL. This changes
the unit test to open a stream directly from the URL, providing proper
file resolution on multiple platforms.
2013-08-14 02:37:24 -05:00
T00thpick1
ea39ca187b Return instance of CraftInventoryBeacon for Beacons. Fixes BUKKIT-4521 2013-08-07 13:42:23 -06:00
Wesley Wolfe
92f111cfed Fix missed diff for chat packets. Fixes BUKKIT-4666
This commit removes chat wrapping. It is no longer needed, as clients
properly render lines with line breaks.

This commit also changes an outgoing chat message to use the vanilla
behavior for indicating a client cannot chat with commands-only setting.
2013-08-07 04:05:56 -05:00
riking
0506b709fe Wrap plugin.getDefaultWorldGenerator in try-catch. Fixes BUKKIT-4116
If a plugin generates an exception when returning a world generator, the
server will crash. This change adds a try-catch block to keep the server
from crashing on plugin defined world generators.
2013-08-07 01:01:12 -05:00
Wesley Wolfe
71a6a56572 Fix javac workaround in ItemStackTest 2013-08-06 20:09:42 -05:00
Wesley Wolfe
9ba5c79c30 Add BukkitObjectIOStream tests on top of ItemMeta tests 2013-08-06 20:00:29 -05:00
Wesley Wolfe
066fcfe79f Validate title for custom inventories. Fixes BUKKIT-4616, BUKKIT-4663
Custom inventories currently do not validate the titles provided. Null values
cause NPEs when writing packets. Values longer than 32 characters
disconnect clients.

This change throws and IllegalArgumentException for null titles or titles
longer than 32 characters.
2013-08-06 17:11:30 -05:00
T00thpick1
5e8dd7d57d Use correct spawn reason for Villagers Breeding. Fixes BUKKIT-4113 2013-08-06 13:03:14 -06:00
T00thpick1
485e9ad93f Add PathfinderGoalMakeLove for diff visibility 2013-08-06 13:03:13 -06:00
T00thpick1
4aeb3ff63d Call unleash event for non-sitting animals. Fixes BUKKIT-4658
The unleash event is only called for animals that are sitting - ones that
receive no movement vector. This adds the missing event call for
non-sitting animals.
2013-08-06 00:38:44 -05:00
Jonatan Noponen
6d0d33b9d2 Fix off by 1 error for spawn protection. Fixes BUKKIT-4154 2013-08-03 18:23:38 -04:00
Kai Dederichs
e7539378fa Fix mistranslation in isPlayerCreated() for IronGolems. Fixes BUKKIT-4543 2013-08-03 18:23:37 -04:00
Wesley Wolfe
da5d494b36 Update players when coming into view of vehicle. Fixes BUKKIT-4628
When only considering trackers from player perspective, attach entity
packet could be sent before a packet for a respective vehicle is in view
and will, in turn, be ignored.

This adds another notification when the vehicle comes into view to cover
all cases.
2013-08-03 17:03:49 -05:00
T00thpick1
54672a75f6 Implement Leash API. Adds BUKKIT-4459, BUKKIT-4583 2013-08-03 15:03:41 -05:00
T00thpick1
f7ca953ff1 Add EntityLeash and ItemLeash for diff visibility 2013-08-03 14:48:40 -05:00
Wesley Wolfe
8a7c582d54 Ignore null sound by contract. Fixes BUKKIT-4641 2013-08-02 20:05:22 -05:00
Wesley Wolfe
93cfe3961f Indicate help is a command. Fixes BUKKIT-4642 2013-08-02 20:03:50 -05:00
EvilSeph
720a8d706a Revert to 1.5 despawning behaviour for Ocelots and Wolves. Fixes BUKKIT-4449 2013-08-02 19:21:35 -04:00
EvilSeph
a466e0aa6c Add timeout for Panic goal. Fixes BUKKIT-4531 2013-08-02 19:20:26 -04:00
EvilSeph
ab36dbb6a9 Add PathfinderGoalPanic for diff visibility. 2013-08-02 19:20:25 -04:00
h31ix
f959530f6b Add raw sound string playSound method. Adds BUKKIT-2443
A method has been added to Player which allows the server to send a sound string to the client. Assuming the client has the specified sound, it will be played. This is needed by the implementation of the /playsound command.
2013-08-02 00:13:20 -05:00
Wesley Wolfe
c8b09db844 Restore diff missed in 4176258a836062b22ac46919aefa5cc36fae78f2 2013-08-01 12:12:40 -05:00
Wesley Wolfe
69d3362335 Revert "Correct vehicle movement issues." Fixes BUKKIT-4565
This reverts commit 3d906d134417cfeefe7f71b916fee4d105e7650f.

Conflicts:
	src/main/java/net/minecraft/server/EntityTrackerEntry.java
2013-07-29 13:04:23 -05:00
Wesley Wolfe
b2be908fbb Fix NBT token for attribute names. Addresses BUKKIT-4483 2013-07-28 14:52:25 -05:00
Wesley Wolfe
1e7f2ebebd Store item attributes. Addresses BUKKIT-4523 2013-07-27 18:00:01 -05:00
T00thpick1
b6fec0467f Restore CraftBukkit diff in ItemDye. Fixes BUKKIT-4493
Change ItemDye to pass the EntityHuman for StructureGrowEvent again.
2013-07-25 18:27:00 -05:00
Wesley Wolfe
5bfd599e9f Store owning Horse in horse inventory. Fixes BUKKIT-4586 2013-07-25 18:04:09 -05:00
Wesley Wolfe
0a9758ae54 Fix CraftBukkit diffs 2013-07-23 22:07:42 -05:00
Wesley Wolfe
e88cea8402 Check interactable items before event. Fixes BUKKIT-4576
Items that cause entities to change state, including tags, chest, and
leashes, do not update the client properly following the firing of
PlayerInteractEntityEvent. This change makes the item checks occur
before the event fires, to concur with the client's assumptions.
2013-07-23 21:52:31 -05:00
T00thpick1
1192f2a53a Add API to control scaled health. Adds BUKKIT-4590
This commit implements the ability to set the scale of hearts that the
client renders.  When the Packet44UpdateAttributes packet is sent, the
max health attribute is replaced with a scaled version, to preserve the
scaled health illusion clientside.

In order to accurately display the scaled health for players, a true
health is stored within CraftPlayer, and the datawatcher now stores the
scaled health. The getHealth() method for players still returns their
true health.

Changed setHealth() within EntityLiving to appropriately handle health
for instances of EntityPlayer. Inlined a call to
setHealth(getMaxHealth()) within the EntityLiving constructor to work
around CraftEntity instantiation.

Additionally fixes the health values sent when eating food within
FoodMetaData and ItemFood, which previously sent the unscaled health;
this commit alters them to send the properly scaled health.

Additionally fixes BUKKIT-4535, BUKKIT-4536, and BUKKIT-4127
2013-07-23 21:52:17 -05:00
Jim Bilbrey
4ad3cdd4b5 Use ambient setting of potion effects. Fixes BUKKIT-4357 and BUKKIT-3653
This changes livingEntity.addPotionEffect(PotionEffect, boolean) to
construct the MobEffect using the constructor that includes the ambient
setting as supplied by the PotionEffect

This also changes livingEntity.getActivePotionEffects() to construct the
PotionEffects using the ambient setting supplied by the MobEffects.
2013-07-13 20:28:16 -04:00
Nate Mortensen
cebc247b78 Correctly fire VehicleExitEvent. Fixes BUKKIT-3761
This change makes it so that EntityHuman#setPassengerOf(Entity) invokes
its parent method when leaving vehicles so that VehicleExitEvent is fired
for players leaving vehicles.

This change also fixes BUKKIT-2110, making it so VehicleExitEvent
correctly handles cancellation. The implementation of VehicleExitEvent
completely ignored the cancellation state of the event, making it so that
cancelling the event had no effect.  Cancelling a VehicleExitEvent now
causes the entity to remain inside of the vehicle, with no visual stutter.
2013-07-13 13:29:32 -06:00
EvilSeph
67f15266da Return inGround when checking Arrow's OnGround state. Fixes BUKKIT-4439 2013-07-10 20:27:03 -04:00
EvilSeph
a31158bd0b Clear attributes on death; mistranslation issue. 2013-07-10 20:02:18 -04:00
h31ix
f9d58bf481 Implement Horse API. Adds BUKKIT-4424
API has been added to interface with Horses and to modify their inventories. Horse entities will now be recognized with the type EntityType.HORSE, and will no longer be UNKNOWN.

HorseJumpEvent, EntityDamageEvent, and EntityTameEvent are all correctly fired for horses.

This commit fixes BUKKIT-4393.
2013-07-10 13:45:52 -04:00
h31ix
a192775f0f Add PathfinderGoalTame for diff visibility. 2013-07-10 13:45:43 -04:00
EvilSeph
f665884955 Correctly set level name for 'world' option. Fixes BUKKIT-4474 2013-07-09 21:35:49 -04:00
EvilSeph
9109bd7652 Ocelots -> Ocelittle. Addresses BUKKIT-4449 2013-07-09 21:04:45 -04:00
mbax
f6a0b1e426 Update CraftBukkit to 1.6.2 2013-07-08 19:43:37 -04:00
EvilSeph
2d9a9d8cea Removed extra eat call. Fixes BUKKIT-4462 2013-07-04 19:19:36 -04:00
EvilSeph
c00db5f751 Properly clear attributes on remove and death. Fixes BUKKIT-4416 2013-07-03 00:25:31 -04:00
Wesley Wolfe
adcb293a03 Fix scaling for player health. Fixes BUKKIT-4431 2013-07-02 23:09:43 -05:00
EvilSeph
29fa46a4b2 Fix donkey/mule dupe exploit. 2013-07-02 23:38:44 -04:00
EvilSeph
7b71fc23be Added EntityHorse for diff visibility. 2013-07-02 23:38:44 -04:00
mbax
d213f7588f Update client on cancelled entity naming. Fixes BUKKIT-4396 2013-07-02 21:38:01 -04:00
mbax
774cf2a2ca Update client on cancelled leash. Fixes BUKKIT-4395 2013-07-02 21:06:17 -04:00
mbax
a15096ae1c Send event-defined MOTD/maxplayers. Fixes BUKKIT-4409
Also, revert to previous CraftBukkit functionality
2013-07-02 16:36:57 -04:00
mbax
905f00b070 Fix world preparation status output. Fixes BUKKIT-4407 2013-07-02 16:07:50 -04:00
mbax
65ccff6340 Regrow sheep wool on grass consumption. Resolves BUKKIT-4405 2013-07-02 15:01:57 -04:00
Nate Mortensen
3a9622cbdc Fix Entity persistence. Fixes BUKKIT-4397
Missed diff.
2013-07-02 11:50:37 -06:00
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
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
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
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
mbax
3f637d1724 Add ScoreboardServer from mc-dev for diff visibility 2013-04-04 01:05:03 -05:00
gjmcferrin@gmail.com
5ede9ce5f7 Add missing calls to BlockRedstoneEvent. Adds BUKKIT-3926
This adds calls to BlockRedstoneEvent for the new daylight sensor and
trapped chest blocks. Note that the redstone level for trapped chests
cannot be modified, as it is based on the number of players currently
viewing the chest's inventory.
2013-04-03 02:48:58 -05:00
gjmcferrin@gmail.com
1d6ff3461d Add BlockDaylightDetector from mc-dev for diff visibility 2013-04-03 02:48:47 -05:00
h31ix
743d0fb603 Properly return contents of Inventory. Fixes BUKKIT-3930
When an array of an inventory's contents is requested, we loop through the contents of the NMS inventory's ItemStacks in order to return Bukkit ItemStacks that can be used through the API. However, the NMS ItemStack can, in some cases, be larger than the physical size of the inventory. Using the size of the NMS array as a limit on the loop that follows can result in an ArrayIndexOutOfBoundsException because the Bukkit array's length is the actual size of the inventory, and thus will be smaller.

With this commit we use the smaller of the two arrays' length as the limit in the loop, thus eliminating the possibility that the smaller array will be asked for an index higher than its length.
2013-04-02 16:10:04 -05:00
Travis Watkins
c33908509a Set world on fixed tile entity to avoid NPE. Addresses BUKKIT-3949 2013-04-01 00:06:09 -05:00
Travis Watkins
311f0c86a4 Fix mismatched tile entities for new blocks. Fixes BUKKIT-3949 2013-03-31 19:38:25 -05: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
d3dbb1bb50 Correct slot types for brewing stand. Fixes BUKKIT-3937 2013-03-31 18:41:36 -05:00
Wesley Wolfe
f859d45727 Throw exception for disabled plugin tasks. Fixes BUKKIT-3951
Without this check, any non-null reference to a plugin is considered
'valid' for registering a task in the scheduler. This is obviously
unintentional behavior and has been changed to throw an
IllegalPluginAccessException. It is now consistent with the
SimplePluginManager event registration contract.

This in affect also addresses BUKKIT-3950 for uninitialized plugin
references (ones without a description).
2013-03-31 15:37:17 -05:00
Travis Watkins
af964c8331 Limit hopper to valid directions. Fixes BUKKIT-3940 2013-03-31 13:29:13 -05:00
Travis Watkins
06ebe6b705 Add BlockHopper from mc-dev for diff visibility. 2013-03-31 13:20:30 -05:00
Travis Watkins
a1c38cd8f3 Include anvil result in inventory size. Fixes BUKKIT-3741 2013-03-30 02:51:26 -05:00
Travis Watkins
af7ea28bc7 Only call event when turning pressure plate on. Fixes BUKKIT-3881 2013-03-29 22:48:49 -05:00
Travis Watkins
82e05d435b Special case large chests for hopper events. Fixes BUKKIT-3916
Large chests work in a different fashion as they are a combination of
two other inventories. This causes their getOwner method to always return
null as their is no correct return. To compensate for this for the hopper
events we special case them to use their CraftBukkit counterpart that has
the information we need for the event.
2013-03-29 22:27:07 -05:00
Travis Watkins
ee572114dd Add Beacon block state for hopper events. Fixes BUKKIT-3932 2013-03-29 22:26:27 -05:00
EdGruberman
377be0a79e Call PotionSplashEvent even for no effects. Fixes BUKKIT-3618
When a splash potion has no applicable effects we currently do not call
PotionSplashEvent. This means plugins are unable to make custom
potions with reliable splash handling as they have to relicate the
functionality themselves.

With this commit we simply make the event fire regardless of the effects
on the potion.
2013-03-28 21:14:48 -05:00
gjmcferrin@gmail.com
adbee6049e Call appropriate event for zombies igniting players. Adds BUKKIT-3915 2013-03-28 21:10:42 -05:00
Wesley Wolfe
acd637d48b Properly copy collection references in ItemMeta.clone(). Fixes BUKKIT-3913
When cloning an item, all references are copied to the new item. For
collections, this makes internal changes become visible in both the old and
new items.

In CraftMetaItem, clone was not making copies of the appropriate collections
and has been fixed for non-null values.

In CraftMetaEnchantedBook and CraftMetaPotion, clone was using possible empty
collection references and has been changed to explicitly null-check instead.
2013-03-28 20:01:01 -05:00
Travis Watkins
1a7e5a75ae Correct missed diff on skeletons. Fixes BUKKIT-3912 2013-03-28 19:42:27 -05:00
Andre LeBlanc
08f3df82eb Improve calling of ProjectileHitEvent. Fixes BUKKIT-3872 2013-03-26 07:13:14 -04:00
riking
45d3e2514d Add missing semicolon
I should try to compile before I say "this change is okay".
I should try to compile before I say "this change is okay".
I should try to compile before I say "this change is okay".
I should try to compile before I say "this change is okay".
for i in range(100)
2013-03-25 17:12:22 -07:00
Kristofer Henriksson
3c02fb02a1 Allow plugins to enchant already enchanted items. Fixes BUKKIT-1956
This causes the server to generate PrepareItemEnchantEvent even in the
case that an item is already enchanted or otherwise would normally not
be enchantable.
2013-03-25 15:56:15 -07:00
Black-Hole
02a5d09ddf Call EntityChangeBlockEvent when boats destroy blocks. Fixes BUKKIT-3871 2013-03-25 16:55:48 -04:00
Andre LeBlanc
18d7bc7ca3 Allow fishing success rate to be adjustable. Adds BUKKIT-3837 2013-03-25 14:45:24 -04:00
GJ
96ba65d506 Add methods to check conflicting enchantments. Adds BUKKIT-3830 2013-03-25 10:51:54 -04:00
Travis Watkins
5f089137ee Cleanup comments, formatting, etc 2013-03-25 00:51:36 -05:00
Patrick Seidel
7c40a073d8 Add ability to change player item in hand. Adds BUKKIT-3318 2013-03-24 14:04:27 -04:00
Travis Watkins
b532042973 Don't assume all hoppers are blocks. Fixes BUKKIT-3883 2013-03-24 12:38:57 -05:00
riking
8d3ba07f93 Add check for Thorns damage - Fixes BUKKIT-3505 2013-03-23 19:45:46 -07:00
Carlos Cobo
62c6d223e4 Include ThrownPotion in spawn methods. Adds BUKKIT-2542 2013-03-23 19:05:14 -07:00
EdGruberman
e1b50b0110 Identify outside slot independent of inventory type. Fixes BUKKIT-2768 2013-03-23 16:23:03 -07:00
Dennis Bliefernicht
e61a6bab05 Implement InventoryMoveItemEvent. Adds BUKKIT-3765
This makes droppers, hoppers and hopper minecarts fire an
InventoryMoveItemEvent whenever an item is being moved from or to another
inventory.
2013-03-23 16:12:52 -06:00
me4502
b10474253c Fire VehicleEnterEvent for loaded chunks only. Fixes BUKKIT-3831 2013-03-23 10:58:01 -06:00
James Clarke
3ad423af07 ANSI color codes now reset text attributes. Fixes BUKKIT-3508
The client resets all formatting after a color code is received, but currently the ANSI codes do not, and so the console does not accurately reflect the appearance of the formatted text. Instead, the ANSI color codes are now set to reset all text attributes.
2013-03-23 00:26:22 -04:00
Travis Watkins
444ced306a Cleanup and rework physical interaction events. Fixes BUKKIT-3686
Currently when dealing with physical interactions with pressure plates
and tripwires we immediately block their activation as soon as a single
entity involved has their event cancelled. We also fire events whenever
an entity intersects the block a wooden button is in even if they aren't
actually pressing it. To correct this we move the button interaction to
the correct place and modify all three to only block the activation if
every entity is blocked from using them instead of just one of them.
2013-03-22 17:18:19 -05:00
Xephi
ae19f2c46f Implement Dropper interface. Adds BUKKIT-3750 2013-03-21 22:33:16 -06:00
Xephi
978de7e9da Add BlockDropper for diff visibility 2013-03-21 21:42:47 -06:00
Travis Watkins
6f9e4f8541 Stationary lava is also a LAVA ignition cause. 2013-03-21 16:59:45 -05:00