Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to transfer inventory from old Storage Minecart to new one. Fixes #326 #414

Closed
wants to merge 4 commits into from

Conversation

Anuril
Copy link

@Anuril Anuril commented Feb 28, 2016

Fixes the Problem that Items get destroyed when Storage or Hopper Minecarts go through a Portal.

Fix for Storage Minecarts where portals emptied the contents when they went through.
Removed empty Lines
Fixed the issue of destroyed Items for Hopper Minecarts
Vehicle newVehicle = target.getWorld().spawn(target, event.getVehicle().getClass());

// Gets inventory from old Cart
if (event.getVehicle() instanceof StorageMinecart || event.getVehicle() instanceof HopperMinecart) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be vehicle instanceof InventoryHolder for maximum compatibility.

Thanks to @dumptruckman - Line 91 Should be vehicle instanceof InventoryHolder for maximum compatibility.
@dumptruckman dumptruckman changed the title Fix to transfer inventory from old Storage Minecart to new one. Fix to transfer inventory from old Storage Minecart to new one. Fixes #326 Mar 10, 2016
@nicegamer7
Copy link
Member

nicegamer7 commented Oct 14, 2020

I don't like this solution because it has one major oversight. The Vehicle class provided by Bukkit extends Entity. That means that a Vehicle has more than just inventory that has to be worried about. For example, with this solution (and without it) regardless of what health the Vehicle had before entering a portal, it will always emerge at full health on the other side.

Here is my proposed solution:
Rather than deleting and spawning a new Vehicle, simply teleport it. This has an added benefit, since all Vehicles are Entities, we can change MV Portals to support teleporting all Entities, rather than just Vehicles.

@nicegamer7 nicegamer7 closed this Nov 25, 2020
@nicegamer7 nicegamer7 deleted the branch Multiverse:master November 25, 2020 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants