use of com.mraof.minestuck.entity.item.EntityGrist in project Minestuck by mraof.
the class TileEntityCrockerMachine method processContents.
@Override
public void processContents() {
switch(getMachineType()) {
case GRIST_WIDGET:
if (!world.isRemote) {
ItemStack item = AlchemyRecipeHandler.getDecodedItem(inv.get(0));
GristSet gristSet = GristRegistry.getGristConversion(item);
if (item.getCount() != 1)
gristSet.scaleGrist(item.getCount());
gristSet.scaleGrist(0.9F);
if (item.isItemDamaged()) {
float multiplier = 1 - item.getItem().getDamage(item) / ((float) item.getMaxDamage());
for (GristAmount amount : gristSet.getArray()) {
gristSet.setGrist(amount.getType(), (int) (amount.getAmount() * multiplier));
}
}
for (Entry<GristType, Integer> entry : gristSet.getMap().entrySet()) {
int grist = entry.getValue();
while (true) {
if (grist == 0)
break;
GristAmount gristAmount = new GristAmount(entry.getKey(), grist <= 3 ? grist : (world.rand.nextInt(grist) + 1));
EntityGrist entity = new EntityGrist(world, this.pos.getX() + 0.5, /* this.width - this.width / 2 */
this.pos.getY() + 1, this.pos.getZ() + 0.5, /* this.width - this.width / 2 */
gristAmount);
entity.motionX /= 2;
entity.motionY /= 2;
entity.motionZ /= 2;
world.spawnEntity(entity);
// Create grist entity of gristAmount
grist -= gristAmount.getAmount();
}
}
}
this.decrStackSize(0, 1);
break;
}
}
use of com.mraof.minestuck.entity.item.EntityGrist in project Minestuck by mraof.
the class EntityUnderling method onDeathUpdate.
@Override
protected void onDeathUpdate() {
super.onDeathUpdate();
if (this.deathTime == 20 && !this.world.isRemote) {
GristSet grist = this.getGristSpoils();
if (fromSpawner)
grist.scaleGrist(0.5F);
if (!dropCandy) {
for (GristAmount gristType : grist.getArray()) this.world.spawnEntity(new EntityGrist(world, randX(), this.posY, randZ(), gristType));
} else {
for (GristAmount gristType : grist.getArray()) {
int candy = (gristType.getAmount() + 2) / 4;
int gristAmount = gristType.getAmount() - candy * 2;
if (candy > 0)
this.world.spawnEntity(new EntityItem(world, randX(), this.posY, randZ(), new ItemStack(MinestuckItems.candy, candy, gristType.getType().getId() + 1)));
if (gristAmount > 0)
this.world.spawnEntity(new EntityGrist(world, randX(), this.posY, randZ(), new GristAmount(gristType.getType(), gristAmount)));
}
}
if (this.rand.nextInt(4) == 0)
this.world.spawnEntity(new EntityVitalityGel(world, randX(), this.posY, randZ(), this.getVitalityGel()));
}
}
Aggregations