-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Offline Player Support
- Loading branch information
Showing
9 changed files
with
194 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package us.potatoboy.invview; | ||
|
||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.entity.player.PlayerInventory; | ||
import net.minecraft.inventory.EnderChestInventory; | ||
import net.minecraft.item.ItemConvertible; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.Items; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.collection.DefaultedList; | ||
|
||
public class CombinedInv extends PlayerInventory { | ||
private PlayerInventory inventory; | ||
|
||
public CombinedInv(ServerPlayerEntity player) { | ||
super(player); | ||
inventory = player.inventory; | ||
inventory.setStack(42, new ItemStack(Items.RED_STAINED_GLASS_PANE)); | ||
} | ||
|
||
@Override | ||
public int size() { | ||
return 45; | ||
} | ||
|
||
@Override | ||
public void onClose(PlayerEntity player) { | ||
InvView.SavePlayerData((ServerPlayerEntity) super.player); | ||
} | ||
|
||
@Override | ||
public ItemStack getStack(int slot) { | ||
return inventory.getStack(slot); | ||
} | ||
|
||
@Override | ||
public void setStack(int slot, ItemStack stack) { | ||
if (slot > 40) return; | ||
inventory.setStack(slot, stack); | ||
} | ||
|
||
@Override | ||
public void markDirty() { | ||
inventory.markDirty(); | ||
} | ||
|
||
@Override | ||
public ItemStack removeStack(int slot, int amount) { | ||
return inventory.removeStack(slot, amount); | ||
} | ||
} |
131 changes: 0 additions & 131 deletions
131
src/main/java/us/potatoboy/invview/CombinedInventory.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package us.potatoboy.invview; | ||
|
||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.inventory.EnderChestInventory; | ||
import net.minecraft.inventory.SimpleInventory; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.ListTag; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
|
||
public class EnderChestSavable extends EnderChestInventory { | ||
private ServerPlayerEntity target; | ||
private EnderChestInventory enderChestInventory; | ||
|
||
public EnderChestSavable(ServerPlayerEntity target) { | ||
super(); | ||
this.target = target; | ||
this.enderChestInventory = target.getEnderChestInventory(); | ||
} | ||
|
||
@Override | ||
public void onClose(PlayerEntity player) { | ||
InvView.SavePlayerData(target); | ||
} | ||
|
||
@Override | ||
public void readTags(ListTag tags) { | ||
enderChestInventory.readTags(tags); | ||
} | ||
|
||
@Override | ||
public ItemStack getStack(int slot) { | ||
return enderChestInventory.getStack(slot); | ||
} | ||
|
||
@Override | ||
public ItemStack removeStack(int slot, int amount) { | ||
return enderChestInventory.removeStack(slot, amount); | ||
} | ||
|
||
@Override | ||
public void setStack(int slot, ItemStack stack) { | ||
enderChestInventory.setStack(slot, stack); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.