use of com.dreammaster.modcustomdrops.CustomDrops.CustomDrop.Drop in project NewHorizonsCoreMod by GTNewHorizons.
the class CustomDropsFactory method createDrop.
public Drop createDrop(String pItemName, String pIdentifier, String pNBTTag, int pAmount, boolean pDropRnd, int pChance, int pLimitedDropCount) {
Drop drop = new Drop();
drop.mAmount = pAmount;
drop.mChance = pChance;
drop.mDropID = pIdentifier;
drop.mIsRandomAmount = pDropRnd;
drop.mItemName = pItemName;
drop.mLimitedDropCount = pLimitedDropCount;
drop.mTag = pNBTTag;
return drop;
}
use of com.dreammaster.modcustomdrops.CustomDrops.CustomDrop.Drop in project NewHorizonsCoreMod by GTNewHorizons.
the class CustomDropsHandler method HandleCustomDrops.
/*
* @SubscribeEvent public void
* LivingDeathEvent(net.minecraftforge.event.entity.living.LivingDeathEvent
* pEvent) { try { EntityLivingBase tEntity = pEvent.entityLiving; UUID
* tUUID = null; EntityPlayer tEP = null;
*
* if (pEvent.source.getEntity() != null) { if (pEvent.source.getEntity()
* instanceof EntityPlayer) { tEP = (EntityPlayer)pEvent.source.getEntity();
* tUUID = tEP.getUniqueID(); if (_mDeathDebugPlayers.contains(tUUID))
* PlayerChatHelper.SendInfo(tEP, String.format("Killed entity: [%s]",
* tEntity.getClass().getName())); } }
*
* if (tEP == null) // Not doing anything, only players are valid return; if
* (tEP instanceof net.minecraftforge.common.util.FakePlayer) // Nope, no
* fakeplayers return;
*
* CustomDrop tCustomDrop = _mCustomDrops.FindDropEntry(tEntity); if
* (tCustomDrop == null) return; // no custom drop defined for this mob,
* skipping
*
* HandleCustomDrops(tCustomDrop, tEntity, tEP); } catch (Exception e) {
* e.printStackTrace(); } }
*/
private void HandleCustomDrops(CustomDrop tCustomDrop, EntityLivingBase tEntity, EntityPlayer tEP, ArrayList<EntityItem> pDropList) {
try {
if (_mPersistedDB == null) {
_mPersistedDB = new PersistedDataBase(DimensionManager.getCurrentSaveRootDirectory(), "CustomDrops.dat", Refstrings.COLLECTIONID);
}
for (Drop dr : tCustomDrop.getDrops()) {
String tDropID = dr.getIdentifier();
String tUserID = tEP.getUniqueID().toString();
String tFinalDropID = String.format("%s.%s", tUserID, tDropID);
int tFinalAmount = dr.getAmount();
if (MainRegistry.Rnd.nextInt(100) > dr.getChance())
continue;
// Is this drop limited?
if (dr.getLimitedDropCount() > 0) {
// if it is, check if player already got this item. If so,
// skip this drop
int tDropCount = _mPersistedDB.getValueAsInt(tFinalDropID, 0);
if (tDropCount >= dr.getLimitedDropCount())
continue;
else {
// Player will get the drop this time, increase his
// counter
_mPersistedDB.setValue(tFinalDropID, ++tDropCount);
}
}
if (dr.getIsRandomAmount())
tFinalAmount = 1 + MainRegistry.Rnd.nextInt(dr.getAmount() - 1);
ItemStack tDropStack = ItemDescriptor.fromString(dr.getItemName()).getItemStackwNBT(tFinalAmount, dr.mTag);
if (tDropStack == null)
_mLogger.error(String.format("CustomDrop ID %s failed to drop"));
else {
EntityItem tDropEntity = new EntityItem(tEntity.worldObj, tEntity.posX, tEntity.posY, tEntity.posZ, tDropStack);
pDropList.add(tDropEntity);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.dreammaster.modcustomdrops.CustomDrops.CustomDrop.Drop in project NewHorizonsCoreMod by GTNewHorizons.
the class CustomDropsHandler method VerifyConfig.
private boolean VerifyConfig(CustomDrops pDropListToCheck) {
boolean tSuccess = true;
for (CustomDrop X : pDropListToCheck.getCustomDrops()) {
for (Drop Y : X.getDrops()) {
if (ItemDescriptor.fromString(Y.getItemName()) == null) {
_mLogger.error(String.format("In ItemDropID: [%s], can't find item [%s]", Y.getIdentifier(), Y.getItemName()));
tSuccess = false;
}
if (Y.mTag != null && !Y.mTag.isEmpty()) {
try {
NBTTagCompound tNBT = (NBTTagCompound) JsonToNBT.func_150315_a(Y.mTag);
if (tNBT == null)
tSuccess = false;
} catch (Exception e) {
_mLogger.error(String.format("In ItemDropID: [%s], NBTTag is invalid", Y.getIdentifier()));
tSuccess = false;
}
}
}
}
return tSuccess;
}
use of com.dreammaster.modcustomdrops.CustomDrops.CustomDrop.Drop in project NewHorizonsCoreMod by GTNewHorizons.
the class CustomDropsHandler method InitSampleConfig.
public void InitSampleConfig() {
Drop pigDiamondLimitedDrop = _mCfF.createDrop("minecraft:diamond", "sample_Pig_DiamondDrop", "{Lore: [\"Oh, shiny!\"]}", 1, false, 100, 5);
Drop pigCakeUnlimitedDrop = _mCfF.createDrop("minecraft:cake", "sample_Pig_CakeDrop", 1, false, 100, 0);
Drop pigRandomCharcoalDrop = _mCfF.createDrop("minecraft:coal:1", "sample_Pig_CharcoalDrop", 5, true, 100, 0);
CustomDrop pigDrop = _mCfF.createCustomDropEntry("eu.usrv.dummyEntity.ImbaSampleDragon");
pigDrop.getDrops().add(pigDiamondLimitedDrop);
pigDrop.getDrops().add(pigCakeUnlimitedDrop);
pigDrop.getDrops().add(pigRandomCharcoalDrop);
_mCustomDrops = new CustomDrops();
_mCustomDrops.getCustomDrops().add(pigDrop);
}
Aggregations