use of net.minecraft.entity.player.InventoryPlayer in project minecolonies by Minecolonies.
the class WindowHutBuilder method pullResourcesFromHut.
/**
* Retrieve resources from the building to display in GUI.
*/
private void pullResourcesFromHut() {
final AbstractBuildingView newView = builder.getColony().getBuilding(builder.getID());
if (newView instanceof BuildingBuilderView) {
final BuildingBuilderView updatedView = (BuildingBuilderView) newView;
final InventoryPlayer inventory = this.mc.player.inventory;
final boolean isCreative = this.mc.player.capabilities.isCreativeMode;
resources.clear();
resources.addAll(updatedView.getResources().values());
for (final BuildingBuilderResource resource : resources) {
final int amountToSet;
if (isCreative) {
amountToSet = resource.getAmount();
} else {
amountToSet = InventoryUtils.getItemCountInItemHandler(new InvWrapper(inventory), stack -> !ItemStackUtils.isEmpty(stack) && stack.isItemEqual(resource.getItemStack()));
}
resource.setPlayerAmount(amountToSet);
}
resources.sort(new BuildingBuilderResource.ResourceComparator());
}
}
use of net.minecraft.entity.player.InventoryPlayer in project Tale-of-Kingdoms by Ivasik78.
the class GuiHunter method actionPerformed.
@Override
protected void actionPerformed(GuiButton button) {
switch(button.id) {
case 1:
this.player.addChatMessage(!HunterHandler.INSTANCE.getHunter() ? new ChatComponentTranslation("gui.guildMaster.killMobs") : new ChatComponentTranslation("gui.guildMaster.discarded"));
this.player.addChatMessage(new ChatComponentTranslation("gui.guildMaster.await"));
this.initGui();
break;
case 2:
if (1500 <= playerProvider.getGoldTotal()) {
EntityLiving entityLiving = (EntityLiving) UltimateHelper.INSTANCE.getEntity("Hired", world);
entityLiving.setLocationAndAngles(this.player.posX, this.player.posY, this.player.posZ, 0.0F, 0.0F);
this.world.spawnEntityInWorld(entityLiving);
playerProvider.decreaseGold(1500);
} else {
this.goldchecker = true;
}
break;
case 3:
this.mc.displayGuiScreen(null);
this.goldchecker = false;
break;
case 4:
InventoryPlayer inventoryPlayer = this.player.inventory;
boolean entity = false;
if (inventoryPlayer.hasItem(Item.getItemFromBlock(Blocks.log))) {
for (ItemStack stack : inventoryPlayer.mainInventory) {
if (stack != null && stack.getItem() == Item.getItemFromBlock(Blocks.log)) {
if (stack.stackSize == stack.getMaxStackSize() && !entity) {
inventoryPlayer.setItemStack(null);
entity = true;
}
}
}
}
if (!entity) {
if (!this.world.isRemote) {
this.player.addChatMessage(new ChatComponentTranslation("gui.guildMaster.needMore"));
}
} else if (!this.world.isRemote) {
this.player.addChatMessage(new ChatComponentTranslation("gui.guildMaster.fixed"));
}
break;
case 5:
IntStream.range(0, this.world.loadedEntityList.size()).mapToObj(var7 -> (Entity) this.world.loadedEntityList.get(var7)).filter(entity1 -> entity1 instanceof EntityHired).map(entity1 -> (EntityHired) entity1).forEach(var9 -> {
var9.setDead();
playerProvider.addGold(1000);
});
break;
}
}
use of net.minecraft.entity.player.InventoryPlayer in project Binnie by ForestryMC.
the class ControlSlot method getHelpTooltip.
@Override
public void getHelpTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) {
final InventorySlot slot = this.getInventorySlot();
if (slot != null) {
tooltip.add(slot.getName());
if (tooltipFlag.isAdvanced()) {
Collection<EnumFacing> inputSides = slot.getInputSides();
if (inputSides.size() > 0) {
tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.side.insert", MachineSide.asString(inputSides)));
}
Collection<EnumFacing> outputSides = slot.getOutputSides();
if (outputSides.size() > 0) {
tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.side.extract", MachineSide.asString(outputSides)));
}
if (slot.isReadOnly()) {
tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.slot.pickup.only"));
}
}
} else if (this.slot.inventory instanceof WindowInventory) {
if (tooltipFlag.isAdvanced()) {
final SlotValidator s = ((WindowInventory) this.slot.inventory).getValidator(this.slot.getSlotIndex());
tooltip.add("Accepts: " + ((s == null) ? "Any Item" : s.getTooltip()));
}
} else if (this.slot.inventory instanceof InventoryPlayer) {
if (tooltipFlag.isAdvanced()) {
tooltip.add(I18N.localise(ModId.CORE, "gui.slot.player.inventory"));
}
}
}
use of net.minecraft.entity.player.InventoryPlayer in project Binnie by ForestryMC.
the class WindowGenesis method receiveGuiNBTOnServer.
@Override
public void receiveGuiNBTOnServer(final EntityPlayer player, final String name, final NBTTagCompound nbt) {
super.receiveGuiNBTOnServer(player, name, nbt);
if (name.equals(ACTION_GENESIS)) {
ItemStack stack = new ItemStack(nbt);
InventoryPlayer inventoryPlayer = player.inventory;
ItemStack playerStack = inventoryPlayer.getItemStack();
if (stack.isEmpty()) {
return;
}
if (playerStack.isEmpty()) {
inventoryPlayer.setItemStack(stack);
} else if (playerStack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(playerStack, stack)) {
final int fit = stack.getMaxStackSize() - (stack.getCount() + playerStack.getCount());
if (fit >= 0) {
stack.grow(playerStack.getCount());
inventoryPlayer.setItemStack(stack);
}
}
player.openContainer.detectAndSendChanges();
if (player instanceof EntityPlayerMP) {
((EntityPlayerMP) player).updateHeldItem();
}
}
}
use of net.minecraft.entity.player.InventoryPlayer in project Binnie by ForestryMC.
the class GuiCraftGUI method drawScreen.
@Override
public void drawScreen(final int mouseX, final int mouseY, final float partialTicks) {
this.window.setMousePosition(mouseX - this.window.getPosition().xPos(), mouseY - this.window.getPosition().yPos());
this.drawDefaultBackground();
GlStateManager.disableRescaleNormal();
RenderHelper.disableStandardItemLighting();
GlStateManager.disableLighting();
GlStateManager.disableDepth();
this.zLevel = 10.0f;
// GuiScreen.itemRender.zLevel = this.zLevel;
this.window.render(this.width, this.height);
GlStateManager.pushMatrix();
GlStateManager.enableRescaleNormal();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f);
final InventoryPlayer playerInventory = this.mc.player.inventory;
this.draggedItem = playerInventory.getItemStack();
if (!this.draggedItem.isEmpty()) {
GlStateManager.translate(0, 0, 200);
RenderUtil.drawItem(new Point(mouseX - 8, mouseY - 8), this.draggedItem, false);
}
RenderHelper.enableGUIStandardItemLighting();
GlStateManager.disableRescaleNormal();
GlStateManager.popMatrix();
GlStateManager.disableLighting();
GlStateManager.disableDepth();
if (draggedItem.isEmpty()) {
ITooltipFlag tooltipFlag = this.mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL;
final MinecraftTooltip tooltip = new MinecraftTooltip();
boolean helpMode = this.isHelpMode();
if (helpMode || this.showBasicHelpTooltips()) {
tooltip.setType(Tooltip.Type.HELP);
ITooltipFlag helpTooltipFlag = helpMode ? ITooltipFlag.TooltipFlags.ADVANCED : tooltipFlag;
if (!this.window.getHelpTooltip(tooltip, helpTooltipFlag)) {
// fallback if there is no help tooltip
this.window.getTooltip(tooltip, tooltipFlag);
}
} else {
tooltip.setType(Tooltip.Type.STANDARD);
this.window.getTooltip(tooltip, tooltipFlag);
}
if (tooltip.exists()) {
this.renderTooltip(new Point(mouseX, mouseY), tooltip);
}
}
this.zLevel = 0.0f;
GlStateManager.enableLighting();
GlStateManager.enableDepth();
}
Aggregations