use of net.minecraftforge.items.wrapper.RecipeWrapper in project createaddition by mrh0.
the class RollingMillTileEntity method process.
private void process() {
RecipeWrapper inventoryIn = new RecipeWrapper(inputInv);
if (lastRecipe == null || !lastRecipe.matches(inventoryIn, level)) {
Optional<RollingRecipe> recipe = find(inventoryIn, level);
if (!recipe.isPresent())
return;
lastRecipe = recipe.get();
}
ItemStack result = lastRecipe.assemble(inventoryIn).copy();
ItemHandlerHelper.insertItemStacked(outputInv, result, false);
ItemStack stackInSlot = inputInv.getStackInSlot(0);
stackInSlot.shrink(1);
inputInv.setStackInSlot(0, stackInSlot);
sendData();
setChanged();
}
use of net.minecraftforge.items.wrapper.RecipeWrapper in project createaddition by mrh0.
the class RollingMillTileEntity method tick.
@Override
public void tick() {
super.tick();
if (getSpeed() == 0)
return;
for (int i = 0; i < outputInv.getSlots(); i++) if (outputInv.getStackInSlot(i).getCount() == outputInv.getSlotLimit(i))
return;
if (timer > 0) {
timer -= getProcessingSpeed();
if (level.isClientSide) {
spawnParticles();
return;
}
if (timer <= 0)
process();
return;
}
if (inputInv.getStackInSlot(0).isEmpty())
return;
RecipeWrapper inventoryIn = new RecipeWrapper(inputInv);
if (lastRecipe == null || !lastRecipe.matches(inventoryIn, level)) {
Optional<RollingRecipe> recipe = find(inventoryIn, level);
if (!recipe.isPresent()) {
timer = 100;
sendData();
} else {
lastRecipe = recipe.get();
timer = getProcessingDuration();
sendData();
}
return;
}
timer = getProcessingDuration();
sendData();
}
use of net.minecraftforge.items.wrapper.RecipeWrapper in project Create by Creators-of-Create.
the class MillstoneTileEntity method canProcess.
private boolean canProcess(ItemStack stack) {
ItemStackHandler tester = new ItemStackHandler(1);
tester.setStackInSlot(0, stack);
RecipeWrapper inventoryIn = new RecipeWrapper(tester);
if (lastRecipe != null && lastRecipe.matches(inventoryIn, level))
return true;
return AllRecipeTypes.MILLING.find(inventoryIn, level).isPresent();
}
use of net.minecraftforge.items.wrapper.RecipeWrapper in project createaddition by mrh0.
the class RollingMillTileEntity method canProcess.
private boolean canProcess(ItemStack stack) {
ItemStackHandler tester = new ItemStackHandler(1);
tester.setStackInSlot(0, stack);
RecipeWrapper inventoryIn = new RecipeWrapper(tester);
if (lastRecipe != null && lastRecipe.matches(inventoryIn, level))
return true;
return find(inventoryIn, level).isPresent();
}
use of net.minecraftforge.items.wrapper.RecipeWrapper in project Create by Creators-of-Create.
the class MillstoneTileEntity method tick.
@Override
public void tick() {
super.tick();
if (getSpeed() == 0)
return;
for (int i = 0; i < outputInv.getSlots(); i++) if (outputInv.getStackInSlot(i).getCount() == outputInv.getSlotLimit(i))
return;
if (timer > 0) {
timer -= getProcessingSpeed();
if (level.isClientSide) {
spawnParticles();
return;
}
if (timer <= 0)
process();
return;
}
if (inputInv.getStackInSlot(0).isEmpty())
return;
RecipeWrapper inventoryIn = new RecipeWrapper(inputInv);
if (lastRecipe == null || !lastRecipe.matches(inventoryIn, level)) {
Optional<MillingRecipe> recipe = AllRecipeTypes.MILLING.find(inventoryIn, level);
if (!recipe.isPresent()) {
timer = 100;
sendData();
} else {
lastRecipe = recipe.get();
timer = lastRecipe.getProcessingDuration();
sendData();
}
return;
}
timer = lastRecipe.getProcessingDuration();
sendData();
}
Aggregations