Register for your free account! | Forgot your password?

Go Back   elitepvpers > Other Online Games > Minecraft
You last visited: Today at 07:34

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Java] crafted items amount

Discussion on [Java] crafted items amount within the Minecraft forum part of the Other Online Games category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Oct 2013
Posts: 4
Received Thanks: 2
[Java] crafted items amount

Hallo epvp,

und zwar geht es um ein bukkit problem. Ich habe schon in diversen anderen Foren gefragt leider konnte mir da keiner so wirklich helfen, deswegenn hoffe ich um eine Hilfe hier

Ich möchte gerne, wenn jemand etwas Crafted die Anzahl der gecrafteten gegenstände in einer Variable gespeichert haben. Ich habe es schon mit

Code:
 onCraftItemEvent(CraftItemEvent ev)
int iAmount = ev.getInventory().getResult().getAmount();
versucht, aber das gibt mir nur aus wie viele Gegenstände es sind wenn ich nur Materialen für einen Craftvorgang reinlege. D.h. auch wenn ich jeweils 4 Holzbretter untereinander gelegt habe ist iAmount = 4 weil nach einem Craftvorgang 4 Sticks entstehen. (Für meine vorhaben sollte iAmount = 16 sein weil genug Mats da sind für 16 Sticks)

Ich hoffe ihr versteht was ich meine und könnt mir helfen MfG
ananus is offline  
Old 10/03/2013, 18:55   #2
Moderator


 
elite*gold: 558
Join Date: Feb 2010
Posts: 6,544
Received Thanks: 1,424
Minecraft unterstützt beim Craften nur ein Item pro Slot. Es ist also nicht vorgesehen, dass mehr als eine Portion gleichzeitigt hergestellt wird.

Um dein Problem zu lösen musst du dir das Rezept und den Inhalt des Craftingsfelds holen und selber ausrechnen wieviele Portionen damit hergestellt werden können.
ComputerBaer is offline  
Thanks
1 User
Old 10/03/2013, 20:51   #3
 
elite*gold: 0
Join Date: Oct 2013
Posts: 4
Received Thanks: 2
D.h. bei einem CraftItemEvent überprüfen ob auf das Item shift+klick gemacht wurde und dann die Anzahl der Items im craftingfeld mit dem recipe abgleichen?
ananus is offline  
Old 10/03/2013, 22:14   #4
Moderator


 
elite*gold: 558
Join Date: Feb 2010
Posts: 6,544
Received Thanks: 1,424
Bei Shift+Klick stellt er solange Items her, bis die Zutaten nicht mehr ausreichen um weiter zu machen.
Er müsste ungefähr so vorgehen: Item herstellen -> immernoch selbes Rezept? -> Item herstellen -> immernoch sel...

Ob das Event jetzt jedesmal neu aufgerufen wird weiß ich nicht, aber ich würde erstmal davon ausgehen. (Wenn du willst kann ich das testen, oder du machst es einfach selber)
ComputerBaer is offline  
Thanks
1 User
Old 10/04/2013, 13:33   #5
 
elite*gold: 0
Join Date: Oct 2013
Posts: 4
Received Thanks: 2
Ok, danke für die Antwort. Wenn wir beide vom selben reden (CraftItemEvent) dann ruft er dies nur einmal auf. Daher bin ich auch etwas ratlos wie ich das ganze angehen soll. Ich werde einfach mal versuchen die 9 Craftingfelder mit dem Rezept abzugleichen. Ansonsten sind weiter Lösungsvorschläge erwünscht
ananus is offline  
Old 10/04/2013, 14:32   #6
Moderator


 
elite*gold: 558
Join Date: Feb 2010
Posts: 6,544
Received Thanks: 1,424
Ich habe es jetzt auch mal ausprobiert und es scheint wirklich nicht so einfach zu sein.

Dann habe ich einfach mal Google geschäftigt und dabei diese beiden Threads mit verschiedenen Lösungen gefunden:



Ich hoffe das hilft dir weiter, auf den ersten Blick scheinen die gut zu funktionieren.

Oder du versuchst meine Idee mit dem Rezept, da gibt es aber noch eine Schwachstelle. Du müsstest auch beachten das das Inventar voll sein kann und nur einige oder garkeine Items hergestellt wurden.
ComputerBaer is offline  
Thanks
1 User
Old 10/04/2013, 18:47   #7
 
elite*gold: 0
Join Date: Oct 2013
Posts: 4
Received Thanks: 2
Also, ich habe jetzt eine eigene Funktion fürs Berechnen der gecrafteten Items geschrieben. Vielen Dank an ComputerBaer's Idee und Links als Gedankenstütze.

Die fertige Funktion sieht jetzt so aus:
PHP Code:
public int CountCraftedItems(CraftItemEvent cie){
    
int iMaxCrafts=64;
    
int iAmount=0;
    for (
ItemStack isStack cie.getInventory().getMatrix()){
        if (
isStack == null) continue;
        if (
isStack.getAmount() < 1) continue;
        if (
isStack.getAmount() < iMaxCraftsiMaxCrafts isStack.getAmount();
    }
if (
cie.getClick().isShiftClick()){
    
iAmount=iMaxCrafts*cie.getCurrentItem().getAmount();
    
int MaxInventoryPlace GetMaxInventoryPlaceForItem(cie,iAmount);
    if (
iAmount>MaxInventoryPlaceiAmount MaxInventoryPlace;
}
else
{
    
iAmount cie.getCurrentItem().getAmount();
}
return 
iAmount;
}
public 
int GetMaxInventoryPlaceForItem(CraftItemEvent cie_countint ItemAmount){
    
int MaxPlace 0;
    
int MaxStackSize cie_count.getCurrentItem().getMaxStackSize();
    
PlayerInventory piPlayerInventory cie_count.getWhoClicked().getInventory();
    for (
ItemStack isStack piPlayerInventory){
        if (
isStack == null){
            
MaxPlace MaxPlace+MaxStackSize;
            continue;
        }
        if (
isStack.getType()!=cie_count.getCurrentItem().getType()) continue;    
        if (
isStack.getType() == cie_count.getCurrentItem().getType()) MaxPlace MaxPlace+MaxStackSize-isStack.getAmount();
    }
    return 
MaxPlace;

Einfach an die Funktion "CountCraftedItems" das CarftItemEvent übergeben und der Rückgabewert wird die Anzahl der gecrafteten Items sein

€dit: Klammer zu viel entfernt
ananus is offline  
Thanks
2 Users
Old 10/04/2013, 19:53   #8
Moderator


 
elite*gold: 558
Join Date: Feb 2010
Posts: 6,544
Received Thanks: 1,424
Ich habe es nur kurz ausprobiert und es hat gut funktioniert. Vielen Danke für den Quellcode, wer weiß wann ich den mal brauchen werde.

Du hast am Ende noch eine "}" zuviel (Vermutlich die von der Klasse).
ComputerBaer is offline  
Reply


Similar Threads Similar Threads
[Selling] STEAM/ORIGIN/UPLAY accounts WITH HUGE AMOUNT OF GAMES ( new games + items) low prices
06/12/2013 - Steam Trading - 0 Replies
ORIGIN/STEAM/UPLAY accounts with full info/FARCRY 3/FIFA 2013/BF3/ac3/MW2012/Simcity3/SKYRIM LEGENDARY EDITION/DARKSIDERS 2/SLEEPING DOGS AND MORE! DIDN't put the price because you can make your own offers, also accepting very low prices, just add skype/ym and talk there! ACCEPTING PAYPAL ALSO ACCEPTING other game gifts traded on my main account on steam!
conquer9 patch 5632 pirate fixed new amount , new skills , new items , new effects
08/24/2012 - CO2 PServer Archive - 7 Replies
Welcome to all members and visitors Conquer 9 patch 5632 priate 100 % all has been fixed
[TUT] Unlimited Cash Skill Amount and Pet Skill Amount Hack
12/15/2011 - Grand Chase Hacks, Bots, Cheats & Exploits - 33 Replies
This Hack allows you to use potion as much as you like in one dungeon run,, Requirement : 1. Cheat Engine lastest version 2. Windows 7 64bit (not tested with other 64bit OS) 3. grandchase.exe How to use : Unlimited Potion Amount Hack : Exact Value, Bytes, uncheck the Fast Scan
Crafted pickit?
04/25/2010 - Diablo 2 - 8 Replies
Hi Leute, Hat jemand eine gute crafted pickit config? Oder was noch besser wär: Wie macht man das, damit der Bot einfach nur Crafted und nichts wegschmeißt? Amus am besten. Edit: Benutzt der bot denn die Juwelen, die er eigentlich aufheben sollte, oder benutzt er zum craften crapjewels? MFG & Danke im voraus.
Crafted Amu
07/24/2008 - Diablo 2 - 6 Replies
Moin, ich wollte mal fragen ob hier jemand für meinen Pala ein crafted Pala Amu mit +2 pala und Stats Str/Dex/life tauschen würde. Entweder ihr schreibt mir hier eine Pm oder schreibt mich ingame an. Accname: baggerb2



All times are GMT +2. The time now is 07:34.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.