Search in sources :

Example 1 with GraderTileEntity

use of net.silentchaos512.gear.block.grader.GraderTileEntity in project Silent-Gear by SilentChaos512.

the class GraderTileEntity method tick.

public static void tick(Level level, BlockPos pos, BlockState state, GraderTileEntity blockEntity) {
    // Don't waste time if there is no input or no free output slots
    ItemStack input = blockEntity.getInputStack();
    if (input.isEmpty())
        return;
    int outputSlot = blockEntity.getFreeOutputSlot();
    if (outputSlot < 0)
        return;
    ItemStack catalyst = blockEntity.getCatalystStack();
    int catalystTier = getCatalystTier(catalyst);
    if (catalystTier < 1)
        return;
    MaterialInstance material = MaterialInstance.from(input);
    if (material != null && material.getGrade() != MaterialGrade.getMax()) {
        if (blockEntity.progress < BASE_ANALYZE_TIME) {
            ++blockEntity.progress;
        }
        if (blockEntity.progress >= BASE_ANALYZE_TIME && !level.isClientSide) {
            blockEntity.progress = 0;
            catalyst.shrink(1);
            blockEntity.tryGradeItem(input, catalystTier, material);
        }
    } else {
        blockEntity.progress = 0;
    }
// if (requireClientSync) {
// BlockState state = world.getBlockState(pos);
// world.notifyBlockUpdate(pos, state, state, 3);
// requireClientSync = false;
// }
}
Also used : ItemStack(net.minecraft.world.item.ItemStack) MaterialInstance(net.silentchaos512.gear.gear.material.MaterialInstance) IMaterialInstance(net.silentchaos512.gear.api.material.IMaterialInstance)

Aggregations

ItemStack (net.minecraft.world.item.ItemStack)1 IMaterialInstance (net.silentchaos512.gear.api.material.IMaterialInstance)1 MaterialInstance (net.silentchaos512.gear.gear.material.MaterialInstance)1