Java 类net.minecraft.world.ILockableContainer 实例源码
项目:DecompiledMinecraft
文件:InventoryLargeChest.java
public InventoryLargeChest(String nameIn, ILockableContainer upperChestIn, ILockableContainer lowerChestIn)
{
this.name = nameIn;
if (upperChestIn == null)
{
upperChestIn = lowerChestIn;
}
if (lowerChestIn == null)
{
lowerChestIn = upperChestIn;
}
this.upperChest = upperChestIn;
this.lowerChest = lowerChestIn;
if (upperChestIn.isLocked())
{
lowerChestIn.setLockCode(upperChestIn.getLockCode());
}
else if (lowerChestIn.isLocked())
{
upperChestIn.setLockCode(lowerChestIn.getLockCode());
}
}
项目:DecompiledMinecraft
文件:InventoryLargeChest.java
public InventoryLargeChest(String nameIn, ILockableContainer upperChestIn, ILockableContainer lowerChestIn)
{
this.name = nameIn;
if (upperChestIn == null)
{
upperChestIn = lowerChestIn;
}
if (lowerChestIn == null)
{
lowerChestIn = upperChestIn;
}
this.upperChest = upperChestIn;
this.lowerChest = lowerChestIn;
if (upperChestIn.isLocked())
{
lowerChestIn.setLockCode(upperChestIn.getLockCode());
}
else if (lowerChestIn.isLocked())
{
upperChestIn.setLockCode(lowerChestIn.getLockCode());
}
}
项目:BaseClient
文件:BlockChest.java
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
EnumFacing side, float hitX, float hitY, float hitZ) {
if (worldIn.isRemote) {
return true;
} else {
ILockableContainer ilockablecontainer = this.getLockableContainer(worldIn, pos);
if (ilockablecontainer != null) {
playerIn.displayGUIChest(ilockablecontainer);
if (this.chestType == 0) {
playerIn.triggerAchievement(StatList.field_181723_aa);
} else if (this.chestType == 1) {
playerIn.triggerAchievement(StatList.field_181737_U);
}
}
return true;
}
}
项目:BaseClient
文件:InventoryLargeChest.java
public InventoryLargeChest(String nameIn, ILockableContainer upperChestIn, ILockableContainer lowerChestIn)
{
this.name = nameIn;
if (upperChestIn == null)
{
upperChestIn = lowerChestIn;
}
if (lowerChestIn == null)
{
lowerChestIn = upperChestIn;
}
this.upperChest = upperChestIn;
this.lowerChest = lowerChestIn;
if (upperChestIn.isLocked())
{
lowerChestIn.setLockCode(upperChestIn.getLockCode());
}
else if (lowerChestIn.isLocked())
{
upperChestIn.setLockCode(lowerChestIn.getLockCode());
}
}
项目:BaseClient
文件:InventoryLargeChest.java
public InventoryLargeChest(String nameIn, ILockableContainer upperChestIn, ILockableContainer lowerChestIn)
{
this.name = nameIn;
if (upperChestIn == null)
{
upperChestIn = lowerChestIn;
}
if (lowerChestIn == null)
{
lowerChestIn = upperChestIn;
}
this.upperChest = upperChestIn;
this.lowerChest = lowerChestIn;
if (upperChestIn.isLocked())
{
lowerChestIn.setLockCode(upperChestIn.getLockCode());
}
else if (lowerChestIn.isLocked())
{
upperChestIn.setLockCode(lowerChestIn.getLockCode());
}
}
项目:Backmemed
文件:InventoryLargeChest.java
public InventoryLargeChest(String nameIn, ILockableContainer upperChestIn, ILockableContainer lowerChestIn)
{
this.name = nameIn;
if (upperChestIn == null)
{
upperChestIn = lowerChestIn;
}
if (lowerChestIn == null)
{
lowerChestIn = upperChestIn;
}
this.upperChest = upperChestIn;
this.lowerChest = lowerChestIn;
if (upperChestIn.isLocked())
{
lowerChestIn.setLockCode(upperChestIn.getLockCode());
}
else if (lowerChestIn.isLocked())
{
upperChestIn.setLockCode(lowerChestIn.getLockCode());
}
}
项目:CustomWorldGen
文件:InventoryLargeChest.java
public InventoryLargeChest(String nameIn, ILockableContainer upperChestIn, ILockableContainer lowerChestIn)
{
this.name = nameIn;
if (upperChestIn == null)
{
upperChestIn = lowerChestIn;
}
if (lowerChestIn == null)
{
lowerChestIn = upperChestIn;
}
this.upperChest = upperChestIn;
this.lowerChest = lowerChestIn;
if (upperChestIn.isLocked())
{
lowerChestIn.setLockCode(upperChestIn.getLockCode());
}
else if (lowerChestIn.isLocked())
{
upperChestIn.setLockCode(lowerChestIn.getLockCode());
}
}
项目:CrystalMod
文件:ItemUtil.java
public static IInventory getInventory(IInventory inv) {
if (inv instanceof TileEntityChest) {
TileEntityChest chest = (TileEntityChest) inv;
TileEntityChest neighbour = null;
if (chest.adjacentChestXNeg != null) {
neighbour = chest.adjacentChestXNeg;
} else if (chest.adjacentChestXPos != null) {
neighbour = chest.adjacentChestXPos;
} else if (chest.adjacentChestZNeg != null) {
neighbour = chest.adjacentChestZNeg;
} else if (chest.adjacentChestZPos != null) {
neighbour = chest.adjacentChestZPos;
}
if (neighbour != null) {
return new InventoryLargeChest("", (ILockableContainer)inv, (ILockableContainer)neighbour);
}
return inv;
}
return inv;
}
项目:ExpandedRailsMod
文件:InventoryLargeChest.java
public InventoryLargeChest(String nameIn, ILockableContainer upperChestIn, ILockableContainer lowerChestIn)
{
this.name = nameIn;
if (upperChestIn == null)
{
upperChestIn = lowerChestIn;
}
if (lowerChestIn == null)
{
lowerChestIn = upperChestIn;
}
this.upperChest = upperChestIn;
this.lowerChest = lowerChestIn;
if (upperChestIn.isLocked())
{
lowerChestIn.setLockCode(upperChestIn.getLockCode());
}
else if (lowerChestIn.isLocked())
{
upperChestIn.setLockCode(lowerChestIn.getLockCode());
}
}
项目:DecompiledMinecraft
文件:EntityPlayerMP.java
/**
* Displays the GUI for interacting with a chest inventory. Args: chestInventory
*/
public void displayGUIChest(IInventory chestInventory)
{
if (this.openContainer != this.inventoryContainer)
{
this.closeScreen();
}
if (chestInventory instanceof ILockableContainer)
{
ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;
if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
{
this.playerNetServerHandler.sendPacket(new S02PacketChat(new ChatComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
this.playerNetServerHandler.sendPacket(new S29PacketSoundEffect("random.door_close", this.posX, this.posY, this.posZ, 1.0F, 1.0F));
return;
}
}
this.getNextWindowId();
if (chestInventory instanceof IInteractionObject)
{
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
}
else
{
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
}
this.openContainer.windowId = this.currentWindowId;
this.openContainer.onCraftGuiOpened(this);
}
项目:DecompiledMinecraft
文件:BlockChest.java
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
ILockableContainer ilockablecontainer = this.getLockableContainer(worldIn, pos);
if (ilockablecontainer != null)
{
playerIn.displayGUIChest(ilockablecontainer);
if (this.chestType == 0)
{
playerIn.triggerAchievement(StatList.field_181723_aa);
}
else if (this.chestType == 1)
{
playerIn.triggerAchievement(StatList.field_181737_U);
}
}
return true;
}
}
项目:DecompiledMinecraft
文件:EntityPlayerMP.java
/**
* Displays the GUI for interacting with a chest inventory. Args: chestInventory
*/
public void displayGUIChest(IInventory chestInventory)
{
if (this.openContainer != this.inventoryContainer)
{
this.closeScreen();
}
if (chestInventory instanceof ILockableContainer)
{
ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;
if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
{
this.playerNetServerHandler.sendPacket(new S02PacketChat(new ChatComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
this.playerNetServerHandler.sendPacket(new S29PacketSoundEffect("random.door_close", this.posX, this.posY, this.posZ, 1.0F, 1.0F));
return;
}
}
this.getNextWindowId();
if (chestInventory instanceof IInteractionObject)
{
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
}
else
{
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
}
this.openContainer.windowId = this.currentWindowId;
this.openContainer.onCraftGuiOpened(this);
}
项目:DecompiledMinecraft
文件:BlockChest.java
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
ILockableContainer ilockablecontainer = this.getLockableContainer(worldIn, pos);
if (ilockablecontainer != null)
{
playerIn.displayGUIChest(ilockablecontainer);
if (this.chestType == 0)
{
playerIn.triggerAchievement(StatList.field_181723_aa);
}
else if (this.chestType == 1)
{
playerIn.triggerAchievement(StatList.field_181737_U);
}
}
return true;
}
}
项目:BaseClient
文件:EntityPlayerMP.java
/**
* Displays the GUI for interacting with a chest inventory. Args: chestInventory
*/
public void displayGUIChest(IInventory chestInventory)
{
if (this.openContainer != this.inventoryContainer)
{
this.closeScreen();
}
if (chestInventory instanceof ILockableContainer)
{
ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;
if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
{
this.playerNetServerHandler.sendPacket(new S02PacketChat(new ChatComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
this.playerNetServerHandler.sendPacket(new S29PacketSoundEffect("random.door_close", this.posX, this.posY, this.posZ, 1.0F, 1.0F));
return;
}
}
this.getNextWindowId();
if (chestInventory instanceof IInteractionObject)
{
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
}
else
{
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
}
this.openContainer.windowId = this.currentWindowId;
this.openContainer.onCraftGuiOpened(this);
}
项目:BaseClient
文件:EntityPlayerMP.java
/**
* Displays the GUI for interacting with a chest inventory. Args: chestInventory
*/
public void displayGUIChest(IInventory chestInventory)
{
if (this.openContainer != this.inventoryContainer)
{
this.closeScreen();
}
if (chestInventory instanceof ILockableContainer)
{
ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;
if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
{
this.playerNetServerHandler.sendPacket(new S02PacketChat(new ChatComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
this.playerNetServerHandler.sendPacket(new S29PacketSoundEffect("random.door_close", this.posX, this.posY, this.posZ, 1.0F, 1.0F));
return;
}
}
this.getNextWindowId();
if (chestInventory instanceof IInteractionObject)
{
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
}
else
{
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
}
this.openContainer.windowId = this.currentWindowId;
this.openContainer.onCraftGuiOpened(this);
}
项目:BaseClient
文件:BlockChest.java
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
ILockableContainer ilockablecontainer = this.getLockableContainer(worldIn, pos);
if (ilockablecontainer != null)
{
playerIn.displayGUIChest(ilockablecontainer);
if (this.chestType == 0)
{
playerIn.triggerAchievement(StatList.field_181723_aa);
}
else if (this.chestType == 1)
{
playerIn.triggerAchievement(StatList.field_181737_U);
}
}
return true;
}
}
项目:Backmemed
文件:BlockChest.java
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
if (worldIn.isRemote)
{
return true;
}
else
{
ILockableContainer ilockablecontainer = this.getLockableContainer(worldIn, pos);
if (ilockablecontainer != null)
{
playerIn.displayGUIChest(ilockablecontainer);
if (this.chestType == BlockChest.Type.BASIC)
{
playerIn.addStat(StatList.CHEST_OPENED);
}
else if (this.chestType == BlockChest.Type.TRAP)
{
playerIn.addStat(StatList.TRAPPED_CHEST_TRIGGERED);
}
}
return true;
}
}
项目:CustomWorldGen
文件:BlockChest.java
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
ILockableContainer ilockablecontainer = this.getLockableContainer(worldIn, pos);
if (ilockablecontainer != null)
{
playerIn.displayGUIChest(ilockablecontainer);
if (this.chestType == BlockChest.Type.BASIC)
{
playerIn.addStat(StatList.CHEST_OPENED);
}
else if (this.chestType == BlockChest.Type.TRAP)
{
playerIn.addStat(StatList.TRAPPED_CHEST_TRIGGERED);
}
}
return true;
}
}
项目:Toms-Mod
文件:LimitableChest.java
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (worldIn.isRemote) {
return true;
} else {
ILockableContainer ilockablecontainer = this.getLockableContainer(worldIn, pos);
if (ilockablecontainer != null) {
playerIn.openGui(CoreInit.modInstance, GuiIDs.limitableChest.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
}
return true;
}
}
项目:Toms-Mod
文件:LimitableChest.java
public ILockableContainer getLockableContainer(World worldIn, BlockPos pos) {
TileEntity tileentity = worldIn.getTileEntity(pos);
if (!(tileentity instanceof TileEntityLimitableChest)) {
return null;
} else {
ILockableContainer ilockablecontainer = (TileEntityLimitableChest) tileentity;
if (this.isBlocked(worldIn, pos)) {
return null;
} else {
return ilockablecontainer;
}
}
}
项目:Skree
文件:GoldRushListener.java
@Listener
public void onChestOpen(InteractInventoryEvent.Open event, @Root Player player) {
Optional<GoldRushInstance> optInst = manager.getApplicableZone(player);
if (!optInst.isPresent()) {
return;
}
GoldRushInstance inst = optInst.get();
Inventory inventory = event.getTargetInventory();
if (!inst.isLocked() && inventory instanceof ContainerChest) {
IInventory chestInv = ((ContainerChest) inventory).getLowerChestInventory();
if (chestInv instanceof ILockableContainer) {
LockCode newLockCode = new LockCode(UUID.randomUUID().toString());
tileEntityClaimMap.put(newLockCode.getLock(), player);
((ILockableContainer) chestInv).setLockCode(newLockCode);
BigDecimal risk = Optional.ofNullable(
inst.cofferRisk.get(player.getUniqueId())
).orElse(BigDecimal.ZERO);
Collection<org.spongepowered.api.item.inventory.ItemStack> queue = CofferValueMap.inst().satisfy(risk.toBigInteger());
Iterator<org.spongepowered.api.item.inventory.ItemStack> it = queue.iterator();
for (int i = 0; i < chestInv.getSizeInventory(); ++i) {
if (it.hasNext()) {
chestInv.setInventorySlotContents(i, tf(it.next()));
continue;
}
chestInv.setInventorySlotContents(i, ItemStack.EMPTY);
}
}
}
}
项目:ExpandedRailsMod
文件:BlockChest.java
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
ILockableContainer ilockablecontainer = this.getLockableContainer(worldIn, pos);
if (ilockablecontainer != null)
{
playerIn.displayGUIChest(ilockablecontainer);
if (this.chestType == BlockChest.Type.BASIC)
{
playerIn.addStat(StatList.CHEST_OPENED);
}
else if (this.chestType == BlockChest.Type.TRAP)
{
playerIn.addStat(StatList.TRAPPED_CHEST_TRIGGERED);
}
}
return true;
}
}
项目:PowerAdvantageAPI
文件:InventoryWrapper.java
/**
* Gets whether this is a locked container
* @return true if the wrapped inventory is an instance of ILockableContainer and is locked
*/
public boolean isLocked(){
if(inventory instanceof ILockableContainer){
return ((ILockableContainer)inventory).isLocked();
}
return false;
}
项目:DecompiledMinecraft
文件:ItemInWorldManager.java
/**
* Activate the clicked on block, otherwise use the held item.
*/
public boolean activateBlockOrUseItem(EntityPlayer player, World worldIn, ItemStack stack, BlockPos pos, EnumFacing side, float offsetX, float offsetY, float offsetZ)
{
if (this.gameType == WorldSettings.GameType.SPECTATOR)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof ILockableContainer)
{
Block block = worldIn.getBlockState(pos).getBlock();
ILockableContainer ilockablecontainer = (ILockableContainer)tileentity;
if (ilockablecontainer instanceof TileEntityChest && block instanceof BlockChest)
{
ilockablecontainer = ((BlockChest)block).getLockableContainer(worldIn, pos);
}
if (ilockablecontainer != null)
{
player.displayGUIChest(ilockablecontainer);
return true;
}
}
else if (tileentity instanceof IInventory)
{
player.displayGUIChest((IInventory)tileentity);
return true;
}
return false;
}
else
{
if (!player.isSneaking() || player.getHeldItem() == null)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock().onBlockActivated(worldIn, pos, iblockstate, player, side, offsetX, offsetY, offsetZ))
{
return true;
}
}
if (stack == null)
{
return false;
}
else if (this.isCreative())
{
int j = stack.getMetadata();
int i = stack.stackSize;
boolean flag = stack.onItemUse(player, worldIn, pos, side, offsetX, offsetY, offsetZ);
stack.setItemDamage(j);
stack.stackSize = i;
return flag;
}
else
{
return stack.onItemUse(player, worldIn, pos, side, offsetX, offsetY, offsetZ);
}
}
}
项目:DecompiledMinecraft
文件:ItemInWorldManager.java
/**
* Activate the clicked on block, otherwise use the held item.
*/
public boolean activateBlockOrUseItem(EntityPlayer player, World worldIn, ItemStack stack, BlockPos pos, EnumFacing side, float offsetX, float offsetY, float offsetZ)
{
if (this.gameType == WorldSettings.GameType.SPECTATOR)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof ILockableContainer)
{
Block block = worldIn.getBlockState(pos).getBlock();
ILockableContainer ilockablecontainer = (ILockableContainer)tileentity;
if (ilockablecontainer instanceof TileEntityChest && block instanceof BlockChest)
{
ilockablecontainer = ((BlockChest)block).getLockableContainer(worldIn, pos);
}
if (ilockablecontainer != null)
{
player.displayGUIChest(ilockablecontainer);
return true;
}
}
else if (tileentity instanceof IInventory)
{
player.displayGUIChest((IInventory)tileentity);
return true;
}
return false;
}
else
{
if (!player.isSneaking() || player.getHeldItem() == null)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock().onBlockActivated(worldIn, pos, iblockstate, player, side, offsetX, offsetY, offsetZ))
{
return true;
}
}
if (stack == null)
{
return false;
}
else if (this.isCreative())
{
int j = stack.getMetadata();
int i = stack.stackSize;
boolean flag = stack.onItemUse(player, worldIn, pos, side, offsetX, offsetY, offsetZ);
stack.setItemDamage(j);
stack.stackSize = i;
return flag;
}
else
{
return stack.onItemUse(player, worldIn, pos, side, offsetX, offsetY, offsetZ);
}
}
}
项目:BaseClient
文件:ItemInWorldManager.java
/**
* Activate the clicked on block, otherwise use the held item.
*/
public boolean activateBlockOrUseItem(EntityPlayer player, World worldIn, ItemStack stack, BlockPos pos, EnumFacing side, float offsetX, float offsetY, float offsetZ)
{
if (this.gameType == WorldSettings.GameType.SPECTATOR)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof ILockableContainer)
{
Block block = worldIn.getBlockState(pos).getBlock();
ILockableContainer ilockablecontainer = (ILockableContainer)tileentity;
if (ilockablecontainer instanceof TileEntityChest && block instanceof BlockChest)
{
ilockablecontainer = ((BlockChest)block).getLockableContainer(worldIn, pos);
}
if (ilockablecontainer != null)
{
player.displayGUIChest(ilockablecontainer);
return true;
}
}
else if (tileentity instanceof IInventory)
{
player.displayGUIChest((IInventory)tileentity);
return true;
}
return false;
}
else
{
if (!player.isSneaking() || player.getHeldItem() == null)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock().onBlockActivated(worldIn, pos, iblockstate, player, side, offsetX, offsetY, offsetZ))
{
return true;
}
}
if (stack == null)
{
return false;
}
else if (this.isCreative())
{
int j = stack.getMetadata();
int i = stack.stackSize;
boolean flag = stack.onItemUse(player, worldIn, pos, side, offsetX, offsetY, offsetZ);
stack.setItemDamage(j);
stack.stackSize = i;
return flag;
}
else
{
return stack.onItemUse(player, worldIn, pos, side, offsetX, offsetY, offsetZ);
}
}
}
项目:BaseClient
文件:ItemInWorldManager.java
/**
* Activate the clicked on block, otherwise use the held item.
*/
public boolean activateBlockOrUseItem(EntityPlayer player, World worldIn, ItemStack stack, BlockPos pos, EnumFacing side, float offsetX, float offsetY, float offsetZ)
{
if (this.gameType == WorldSettings.GameType.SPECTATOR)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof ILockableContainer)
{
Block block = worldIn.getBlockState(pos).getBlock();
ILockableContainer ilockablecontainer = (ILockableContainer)tileentity;
if (ilockablecontainer instanceof TileEntityChest && block instanceof BlockChest)
{
ilockablecontainer = ((BlockChest)block).getLockableContainer(worldIn, pos);
}
if (ilockablecontainer != null)
{
player.displayGUIChest(ilockablecontainer);
return true;
}
}
else if (tileentity instanceof IInventory)
{
player.displayGUIChest((IInventory)tileentity);
return true;
}
return false;
}
else
{
if (!player.isSneaking() || player.getHeldItem() == null)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock().onBlockActivated(worldIn, pos, iblockstate, player, side, offsetX, offsetY, offsetZ))
{
return true;
}
}
if (stack == null)
{
return false;
}
else if (this.isCreative())
{
int j = stack.getMetadata();
int i = stack.stackSize;
boolean flag = stack.onItemUse(player, worldIn, pos, side, offsetX, offsetY, offsetZ);
stack.setItemDamage(j);
stack.stackSize = i;
return flag;
}
else
{
return stack.onItemUse(player, worldIn, pos, side, offsetX, offsetY, offsetZ);
}
}
}
项目:Zombe-Modpack
文件:EntityPlayerMP.java
/**
* Displays the GUI for interacting with a chest inventory.
*/
public void displayGUIChest(IInventory chestInventory)
{
if (chestInventory instanceof ILootContainer && ((ILootContainer)chestInventory).getLootTable() != null && this.isSpectator())
{
this.addChatComponentMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)), true);
}
else
{
if (this.openContainer != this.inventoryContainer)
{
this.closeScreen();
}
if (chestInventory instanceof ILockableContainer)
{
ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;
if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
{
this.connection.sendPacket(new SPacketChat(new TextComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
this.connection.sendPacket(new SPacketSoundEffect(SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.posX, this.posY, this.posZ, 1.0F, 1.0F));
return;
}
}
this.getNextWindowId();
if (chestInventory instanceof IInteractionObject)
{
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
}
else
{
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
}
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
}
}
项目:Backmemed
文件:EntityPlayerMP.java
/**
* Displays the GUI for interacting with a chest inventory.
*/
public void displayGUIChest(IInventory chestInventory)
{
if (chestInventory instanceof ILootContainer && ((ILootContainer)chestInventory).getLootTable() != null && this.isSpectator())
{
this.addChatComponentMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)), true);
}
else
{
if (this.openContainer != this.inventoryContainer)
{
this.closeScreen();
}
if (chestInventory instanceof ILockableContainer)
{
ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;
if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
{
this.connection.sendPacket(new SPacketChat(new TextComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
this.connection.sendPacket(new SPacketSoundEffect(SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.posX, this.posY, this.posZ, 1.0F, 1.0F));
return;
}
}
this.getNextWindowId();
if (chestInventory instanceof IInteractionObject)
{
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
}
else
{
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
}
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
}
}
项目:Backmemed
文件:BlockChest.java
@Nullable
public ILockableContainer getLockableContainer(World worldIn, BlockPos pos)
{
return this.getContainer(worldIn, pos, false);
}
项目:Backmemed
文件:PlayerInteractionManager.java
public EnumActionResult processRightClickBlock(EntityPlayer player, World worldIn, ItemStack stack, EnumHand hand, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ)
{
if (this.gameType == GameType.SPECTATOR)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof ILockableContainer)
{
Block block1 = worldIn.getBlockState(pos).getBlock();
ILockableContainer ilockablecontainer = (ILockableContainer)tileentity;
if (ilockablecontainer instanceof TileEntityChest && block1 instanceof BlockChest)
{
ilockablecontainer = ((BlockChest)block1).getLockableContainer(worldIn, pos);
}
if (ilockablecontainer != null)
{
player.displayGUIChest(ilockablecontainer);
return EnumActionResult.SUCCESS;
}
}
else if (tileentity instanceof IInventory)
{
player.displayGUIChest((IInventory)tileentity);
return EnumActionResult.SUCCESS;
}
return EnumActionResult.PASS;
}
else
{
if (!player.isSneaking() || player.getHeldItemMainhand().func_190926_b() && player.getHeldItemOffhand().func_190926_b())
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock().onBlockActivated(worldIn, pos, iblockstate, player, hand, facing, hitX, hitY, hitZ))
{
return EnumActionResult.SUCCESS;
}
}
if (stack.func_190926_b())
{
return EnumActionResult.PASS;
}
else if (player.getCooldownTracker().hasCooldown(stack.getItem()))
{
return EnumActionResult.PASS;
}
else
{
if (stack.getItem() instanceof ItemBlock && !player.canUseCommandBlock())
{
Block block = ((ItemBlock)stack.getItem()).getBlock();
if (block instanceof BlockCommandBlock || block instanceof BlockStructure)
{
return EnumActionResult.FAIL;
}
}
if (this.isCreative())
{
int j = stack.getMetadata();
int i = stack.func_190916_E();
EnumActionResult enumactionresult = stack.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
stack.setItemDamage(j);
stack.func_190920_e(i);
return enumactionresult;
}
else
{
return stack.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
}
}
}
}
项目:CustomWorldGen
文件:EntityPlayerMP.java
/**
* Displays the GUI for interacting with a chest inventory.
*/
public void displayGUIChest(IInventory chestInventory)
{
if (chestInventory instanceof ILootContainer && ((ILootContainer)chestInventory).getLootTable() != null && this.isSpectator())
{
this.addChatMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)));
}
else
{
if (this.openContainer != this.inventoryContainer)
{
this.closeScreen();
}
if (chestInventory instanceof ILockableContainer)
{
ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;
if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
{
this.connection.sendPacket(new SPacketChat(new TextComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
this.connection.sendPacket(new SPacketSoundEffect(SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.posX, this.posY, this.posZ, 1.0F, 1.0F));
return;
}
}
this.getNextWindowId();
if (chestInventory instanceof IInteractionObject)
{
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
}
else
{
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
}
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
}
}
项目:CustomWorldGen
文件:BlockChest.java
@Nullable
public ILockableContainer getLockableContainer(World worldIn, BlockPos pos)
{
return this.getContainer(worldIn, pos, false);
}
项目:ToroChess
文件:CheckerBoardGenerator.java
public ILockableContainer getWhiteChest() {
setCursor(WHITE_PODIUM);
y++;
return getChestAtCursor();
}
项目:ToroChess
文件:CheckerBoardGenerator.java
private ILockableContainer getChestAtCursor() {
return ((BlockChest) world.getBlockState(cursorCoords()).getBlock()).getLockableContainer(world, cursorCoords());
}
项目:ToroChess
文件:CheckerBoardGenerator.java
public ILockableContainer getBlackChest() {
setCursor(BLACK_PODIUM);
y++;
return getChestAtCursor();
}
项目:DrawersBits
文件:TileBitController.java
@Override
public ILockableContainer getLockableContainer() {
return null;
}
项目:ExpandedRailsMod
文件:EntityPlayerMP.java
/**
* Displays the GUI for interacting with a chest inventory.
*/
public void displayGUIChest(IInventory chestInventory)
{
if (chestInventory instanceof ILootContainer && ((ILootContainer)chestInventory).getLootTable() != null && this.isSpectator())
{
this.addChatMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)));
}
else
{
if (this.openContainer != this.inventoryContainer)
{
this.closeScreen();
}
if (chestInventory instanceof ILockableContainer)
{
ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;
if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
{
this.connection.sendPacket(new SPacketChat(new TextComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
this.connection.sendPacket(new SPacketSoundEffect(SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.posX, this.posY, this.posZ, 1.0F, 1.0F));
return;
}
}
this.getNextWindowId();
if (chestInventory instanceof IInteractionObject)
{
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
}
else
{
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
}
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
}
}
项目:ExpandedRailsMod
文件:BlockChest.java
@Nullable
public ILockableContainer getLockableContainer(World worldIn, BlockPos pos)
{
return this.getContainer(worldIn, pos, false);
}
项目:PowerAdvantageAPI
文件:TileEntityConveyor.java
protected static boolean isLocked(Object o){
return o instanceof ILockableContainer && ((ILockableContainer)o).isLocked();
}