MCPcopy Create free account
hub / github.com/GregTech6/gregtech6 / onItemExpireEvent

Method onItemExpireEvent

src/main/java/gregapi/GT_API_Proxy.java:1439–1479  ·  view source on GitHub ↗
(ItemExpireEvent aEvent)

Source from the content-addressed store, hash-verified

1437 */
1438
1439 @SubscribeEvent(priority = EventPriority.HIGHEST)
1440 public void onItemExpireEvent(ItemExpireEvent aEvent) {
1441 if (aEvent.entity.worldObj.isRemote) return;
1442 ItemStack aStack = aEvent.entityItem.getEntityItem();
1443 int aX = UT.Code.roundDown(aEvent.entity.posX), aY = UT.Code.roundDown(aEvent.entity.posY), aZ = UT.Code.roundDown(aEvent.entity.posZ);
1444 if (ST.valid(aStack)) {
1445 if (ST.item_(aStack) instanceof MultiTileEntityItemInternal) {
1446 long tExtraLife = ((MultiTileEntityItemInternal)ST.item_(aStack)).onDespawn(aEvent.entityItem, aStack);
1447 if (aStack.stackSize <= 0) {
1448 aEvent.extraLife = 0;
1449 aEvent.entityItem.setDead();
1450 aEvent.setCanceled(T);
1451 return;
1452 }
1453 aEvent.entityItem.setEntityItemStack(aStack);
1454 if (tExtraLife > 0) {
1455 aEvent.extraLife = UT.Code.bindInt(aEvent.extraLife + tExtraLife);
1456 aEvent.setCanceled(T);
1457 return;
1458 }
1459 }
1460 MultiTileEntityRegistry tRegistry = MultiTileEntityRegistry.getRegistry("gt.multitileentity");
1461 if (tRegistry != null) {
1462 OreDictItemData tData = OM.anydata(aStack);
1463 if (tData != null) {
1464 if (tData.mPrefix == OP.rockGt || tData.mPrefix == OP.oreRaw) for (byte[] tOff : CUBE_3) if (WD.irrelevant(aEvent.entity.worldObj, aX+tOff[0], aY+tOff[1], aZ+tOff[2]) && tRegistry.mBlock.placeBlock(aEvent.entity.worldObj, aX+tOff[0], aY+tOff[1], aZ+tOff[2], SIDE_TOP, (short)32074, ST.save(NBT_VALUE, aStack), T, F)) {aStack.stackSize = 0; aEvent.extraLife = 0; aEvent.entityItem.setDead(); aEvent.setCanceled(T); return;}
1465 if (tData.mPrefix == OP.ingot ) for (byte[] tOff : CUBE_3) if (WD.irrelevant(aEvent.entity.worldObj, aX+tOff[0], aY+tOff[1], aZ+tOff[2]) && tRegistry.mBlock.placeBlock(aEvent.entity.worldObj, aX+tOff[0], aY+tOff[1], aZ+tOff[2], SIDE_TOP, (short)32084, ST.save(NBT_VALUE, aStack), T, F)) {aStack.stackSize = 0; aEvent.extraLife = 0; aEvent.entityItem.setDead(); aEvent.setCanceled(T); return;}
1466 if (tData.mPrefix == OP.plate ) for (byte[] tOff : CUBE_3) if (WD.irrelevant(aEvent.entity.worldObj, aX+tOff[0], aY+tOff[1], aZ+tOff[2]) && tRegistry.mBlock.placeBlock(aEvent.entity.worldObj, aX+tOff[0], aY+tOff[1], aZ+tOff[2], SIDE_TOP, (short)32085, ST.save(NBT_VALUE, aStack), T, F)) {aStack.stackSize = 0; aEvent.extraLife = 0; aEvent.entityItem.setDead(); aEvent.setCanceled(T); return;}
1467 if (tData.mPrefix == OP.plateGem ) for (byte[] tOff : CUBE_3) if (WD.irrelevant(aEvent.entity.worldObj, aX+tOff[0], aY+tOff[1], aZ+tOff[2]) && tRegistry.mBlock.placeBlock(aEvent.entity.worldObj, aX+tOff[0], aY+tOff[1], aZ+tOff[2], SIDE_TOP, (short)32086, ST.save(NBT_VALUE, aStack), T, F)) {aStack.stackSize = 0; aEvent.extraLife = 0; aEvent.entityItem.setDead(); aEvent.setCanceled(T); return;}
1468 if (tData.mPrefix == OP.scrapGt ) for (byte[] tOff : CUBE_3) if (WD.irrelevant(aEvent.entity.worldObj, aX+tOff[0], aY+tOff[1], aZ+tOff[2]) && tRegistry.mBlock.placeBlock(aEvent.entity.worldObj, aX+tOff[0], aY+tOff[1], aZ+tOff[2], SIDE_TOP, (short)32103, ST.save(NBT_VALUE, aStack), T, F)) {aStack.stackSize = 0; aEvent.extraLife = 0; aEvent.entityItem.setDead(); aEvent.setCanceled(T); return;}
1469 }
1470 }
1471 GarbageGT.trash(aStack);
1472 aStack.stackSize = 0;
1473 aEvent.extraLife = 0;
1474 aEvent.entityItem.setEntityItemStack(aStack);
1475 aEvent.entityItem.setDead();
1476 aEvent.setCanceled(T);
1477 return;
1478 }
1479 }
1480
1481 @SubscribeEvent(priority = EventPriority.LOWEST)
1482 public void onCheckSpawnEvent(LivingSpawnEvent.CheckSpawn aEvent) {

Callers

nothing calls this directly

Calls 12

validMethod · 0.95
item_Method · 0.95
getRegistryMethod · 0.95
anydataMethod · 0.95
irrelevantMethod · 0.95
saveMethod · 0.95
trashMethod · 0.95
roundDownMethod · 0.80
setDeadMethod · 0.80
bindIntMethod · 0.80
onDespawnMethod · 0.65
placeBlockMethod · 0.65

Tested by

no test coverage detected