111 lines
3.3 KiB
Java
111 lines
3.3 KiB
Java
package net.minecraft.world;
|
|
|
|
import net.minecraft.world.entity.player.Player;
|
|
import net.minecraft.world.item.ItemStack;
|
|
|
|
public class CompoundContainer implements Container {
|
|
private final Container container1;
|
|
private final Container container2;
|
|
|
|
public CompoundContainer(Container ajb1, Container ajb2) {
|
|
if (ajb1 == null) {
|
|
ajb1 = ajb2;
|
|
}
|
|
if (ajb2 == null) {
|
|
ajb2 = ajb1;
|
|
}
|
|
this.container1 = ajb1;
|
|
this.container2 = ajb2;
|
|
}
|
|
|
|
@Override
|
|
public int getContainerSize() {
|
|
return this.container1.getContainerSize() + this.container2.getContainerSize();
|
|
}
|
|
|
|
@Override
|
|
public boolean isEmpty() {
|
|
return this.container1.isEmpty() && this.container2.isEmpty();
|
|
}
|
|
|
|
public boolean contains(final Container ajb) {
|
|
return this.container1 == ajb || this.container2 == ajb;
|
|
}
|
|
|
|
@Override
|
|
public ItemStack getItem(final int integer) {
|
|
if (integer >= this.container1.getContainerSize()) {
|
|
return this.container2.getItem(integer - this.container1.getContainerSize());
|
|
}
|
|
return this.container1.getItem(integer);
|
|
}
|
|
|
|
@Override
|
|
public ItemStack removeItem(final int integer1, final int integer2) {
|
|
if (integer1 >= this.container1.getContainerSize()) {
|
|
return this.container2.removeItem(integer1 - this.container1.getContainerSize(), integer2);
|
|
}
|
|
return this.container1.removeItem(integer1, integer2);
|
|
}
|
|
|
|
@Override
|
|
public ItemStack removeItemNoUpdate(final int integer) {
|
|
if (integer >= this.container1.getContainerSize()) {
|
|
return this.container2.removeItemNoUpdate(integer - this.container1.getContainerSize());
|
|
}
|
|
return this.container1.removeItemNoUpdate(integer);
|
|
}
|
|
|
|
@Override
|
|
public void setItem(final int integer, final ItemStack bek) {
|
|
if (integer >= this.container1.getContainerSize()) {
|
|
this.container2.setItem(integer - this.container1.getContainerSize(), bek);
|
|
}
|
|
else {
|
|
this.container1.setItem(integer, bek);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public int getMaxStackSize() {
|
|
return this.container1.getMaxStackSize();
|
|
}
|
|
|
|
@Override
|
|
public void setChanged() {
|
|
this.container1.setChanged();
|
|
this.container2.setChanged();
|
|
}
|
|
|
|
@Override
|
|
public boolean stillValid(final Player ayg) {
|
|
return this.container1.stillValid(ayg) && this.container2.stillValid(ayg);
|
|
}
|
|
|
|
@Override
|
|
public void startOpen(final Player ayg) {
|
|
this.container1.startOpen(ayg);
|
|
this.container2.startOpen(ayg);
|
|
}
|
|
|
|
@Override
|
|
public void stopOpen(final Player ayg) {
|
|
this.container1.stopOpen(ayg);
|
|
this.container2.stopOpen(ayg);
|
|
}
|
|
|
|
@Override
|
|
public boolean canPlaceItem(final int integer, final ItemStack bek) {
|
|
if (integer >= this.container1.getContainerSize()) {
|
|
return this.container2.canPlaceItem(integer - this.container1.getContainerSize(), bek);
|
|
}
|
|
return this.container1.canPlaceItem(integer, bek);
|
|
}
|
|
|
|
@Override
|
|
public void clearContent() {
|
|
this.container1.clearContent();
|
|
this.container2.clearContent();
|
|
}
|
|
}
|