Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.lycoon.lemnoslife.gui;
- import com.lycoon.lemnoslife.ExtendedEntityPropTuto;
- import com.lycoon.lemnoslife.Main;
- import com.lycoon.lemnoslife.assets.ItemCoca;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.player.InventoryPlayer;
- import net.minecraft.inventory.Container;
- import net.minecraft.inventory.IInventory;
- import net.minecraft.inventory.Slot;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.ChatComponentText;
- import net.minecraft.util.ChatStyle;
- import net.minecraft.util.EnumChatFormatting;
- public class ContainerShop extends Container {
- public static ChatStyle rouge = new ChatStyle().setColor(EnumChatFormatting.RED);
- public static ChatStyle vert = new ChatStyle().setColor(EnumChatFormatting.GREEN);
- public ContainerShop(IInventory playerInv) {
- for (int x = 0; x < 9; x++) {
- this.addSlotToContainer(new Slot(playerInv, x, 145 + 21 * x + 5, 8));
- }
- this.putStackInSlot(0, new ItemStack(Main.itemPhone));
- this.putStackInSlot(1, new ItemStack(Main.itemGPS));
- }
- @Override
- public boolean canInteractWith(EntityPlayer player) {
- return true;
- }
- /*
- * Clic gauche: key = 0
- * Clic droit: key = 1
- * Clic molette: key = 2
- */
- public ItemStack slotClick(int slotID, int key, int par3, EntityPlayer player)
- {
- ItemStack itemstack = null;
- ExtendedEntityPropTuto extProp = ExtendedEntityPropTuto.get(player);
- InventoryPlayer inventoryplayer = player.inventory;
- if(slotID == 0){
- if(extProp.getSoldeLiquide() >= 500){
- extProp.setSoldeLiquide(extProp.getSoldeLiquide() - 500); //Retrait du montant depuis l'arg
- inventoryplayer.addItemStackToInventory(new ItemStack(Main.itemPhone)); //Ajout de l'item dans l'inventaire
- player.addChatMessage(new ChatComponentText("[Magasin] Vous avez acheté un portable pour 500€.").setChatStyle(vert));
- }
- else{
- player.addChatMessage(new ChatComponentText("[Magasin] Vous n'avez pas assez d'argent.").setChatStyle(rouge));
- }
- }
- else if(slotID == 1){
- if(extProp.getSoldeLiquide() >= 2000){
- extProp.setSoldeLiquide(extProp.getSoldeLiquide() - 2000);
- inventoryplayer.addItemStackToInventory(new ItemStack(Main.itemGPS));
- player.addChatMessage(new ChatComponentText("[Magasin] Vous avez acheté un GPS pour 2000€.").setChatStyle(vert));
- }
- else{
- player.addChatMessage(new ChatComponentText("[Magasin] Vous n'avez pas assez d'argent.").setChatStyle(rouge));
- }
- }
- return itemstack;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement